noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_ipopup.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21 
22 /*!\file
23  * \brief create a popup in html above the current layer
24  * the html inside the popup cannot contain any floating elt as div..
25  *
26  */
27 require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
28 require_once NOALYSS_INCLUDE.'/lib/class_html_input.php';
29 
30 class IPopup extends HtmlInput
31 {
32  var $name; /*!< name name and id of the div */
33  function __construct($p_name)
34  {
35  $this->name=$p_name;
36  $this->parameter='';
37  $this->attribute=array();
38  $this->drag=false;
39  $this->blocking=true;
40  }
41  function set_width($p_val)
42  {
43  $js=sprintf('$("%s'.'_border").style.width="%s";',
44  $this->name,$p_val);
45  $this->parameter.=$js;
46 
47  }
48  function set_height($p_val)
49  {
50  $js=sprintf('$("%s'.'_border").style.height="%s";',
51  $this->name,$p_val);
52  $this->parameter.=$js;
53 
54  }
55  /**
56  *@brief set or not a blocking fond
57  *@param $p_block if true if you want to avoid access to background,
58  *accept true or false
59  */
60  function set_block($p_block)
61  {
62  $this->blocking=$p_block;
63  }
64 
65  function set_zindex($p_val)
66  {
67  $js=sprintf('$("%s'.'_border").style.zIndex=%d;',
68  $this->name,$p_val);
69  $js=sprintf('$("%s'.'_content").style.zIndex=%d;',
70  $this->name,$p_val);
71  $this->parameter.=$js;
72  }
73  function set_dragguable($p_value)
74  {
75  $this->drag=$p_value;
76  }
77  /*!\brief set the attribute thanks javascript as the width, the position ...
78  *\param $p_name attribute name
79  *\param $p_val val of the attribute
80  *\note add to the this->attribut, it will be used in input()
81  */
82  function set_attribute($p_name,$p_val)
83  {
84  $this->attribute[]=array($p_name,$p_val);
85  }
86  /*!\brief set the title of a ipopup thanks javascript and php mode
87  *\param title of the IPopup
88  *\return html string with js script
89  */
90  function set_title($p_title)
91  {
92  $this->title=$p_title;
93  $s=sprintf('$("%s_"+"title")="%s"',
94  $this->name,$this->title);
95  return create_script($s);
96  }
97  function input()
98  {
99  $r="";
100  if ($this->blocking)
101  {
102  $r.=sprintf('<div id="%s_fond" class="popup_back">',$this->name);
103  $r.="</div>";
104  }
105  $javascript=sprintf("javascript:hideIPopup('%s')",
106  $this->name);
107 
108 
109  if ( isset($this->title) && trim($this->title) != "" )
110  {
111  $r.=sprintf('<div id="%s_border" id="%s_border" class="popup_border_title">',
112  $this->name,
113  $this->name);
114  $r.=sprintf('<span id="%s_">%s</span>',$this->name,$this->title);
115  }
116  else
117  {
118  $r.=sprintf('<div id ="%s_border" id="%s_border" class="popup_border_notitle">',
119  $this->name,
120  $this->name);
121  }
122  $r.='<div style="position:absolute;top:0px;right:10px;font-weight:normal;font-size:9px;color:black;text-align:right">';
123  $r.=sprintf('<a style="background-color:blue;color:white;text-decoration:none" href="%s">&#10761;</a></div>',
124  $javascript);
125 
126  $r.=sprintf('<div id ="%s_content" id="%s_content" class="inner_box"> %s </div></div>',
127  $this->name,
128  $this->name,
129  $this->value);
130 
131 
132  /* Add properties at the widget */
133  $attr=$this->parameter;
134  for ($i=0;$i< count($this->attribute);$i++)
135  {
136  list($name,$value)=$this->attribute[$i];
137  $tmp1=sprintf("$('%s').%s='%s';",
138  $this->name,
139  $name,
140  $value);
141  $attr.=$tmp1;
142  }
143  $draggable='';
144  if ($this->drag==true)
145  {
146  /* add draggable possibility */
147  $draggable=sprintf(" new Draggable('%s_border',{starteffect:function(){
148  new Effect.Highlight('%s_border',{scroll:window,queue:'end'}); } });"
149  ,$this->name
150  ,$this->name);
151 
152  }
153  $attr=create_script($attr.$draggable);
154  $r.=$attr;
155  return $r;
156  }
157 
158  static function test_me()
159  {
160  require_once NOALYSS_INCLUDE.'/lib/class_iselect.php';
161  $select=new ISelect('a');
162  $select->value=array(array ('value'=>0,'label'=>'Première valeur'),
163  array ('value'=>0,'label'=>'Première valeur'),
164  array ('value'=>0,'label'=>'Première valeur'));
165  for ($e=0;$e<5;$e++)
166  {
167  echo $select->input();
168  if ($e%10 == 0 ) echo '<hr>';
169  }
170  $a=new IPopup('pop1');
171  $a->value="";
172  for ($e=0;$e<500;$e++)
173  {
174  $a->value.="<p>Il etait une fois dans un pays vraiment lointain où même plus loin que ça</p>";
175  }
176  echo $a->input();
177  echo '
178  <input type="button" onclick="hide(\'pop1\');hide(\'pop1_border\')" value="cacher">
179  <input type="button" onclick="showIPopup(\'pop1\')" value="montrer">
180  ';
181  $a=new IPopup('pop2');
182  $a->value='';
183  $a->title="Retrouvez une saucisse";
184  echo $a->input();
185  echo '
186  <input type="button" onclick="hide(\'pop2\');hide(\'pop2_border\')" value="cacher">
187  <input type="button" onclick="showIPopup(\'pop2\')" value="montrer">
188  ';
189 
190  }
191 }
$select
static test_me()
__construct($p_name)
set_dragguable($p_value)
set_attribute($p_name, $p_val)
set the attribute thanks javascript as the width, the position ...
$from_poste name
set_zindex($p_val)
function trim(s)
remove trailing and heading space
Definition: scripts.js:95
set_block($p_block)
set or not a blocking fond
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
set_title($p_title)
set the title of a ipopup thanks javascript and php mode
set_height($p_val)
set_width($p_val)
create_script($p_string)
create the HTML for adding the script tags around of the script