noalyss Version-9
ipopup.class.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 */
28/*!
29 * \class IPopup
30 * \brief create a popup in html above the current layer
31 * the html inside the popup cannot contain any floating elt as div..
32 *
33 */
34
35require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
36
37class IPopup extends HtmlInput
38{
39 var $name; /*!< name name and id of the div */
40 function __construct($p_name)
41 {
42 $this->name=$p_name;
43 $this->parameter='';
44 $this->attribute=array();
45 $this->drag=false;
46 $this->blocking=true;
47 }
48 function set_width($p_val)
49 {
50 $js=sprintf('$("%s'.'_border").style.width="%s";',
51 $this->name,$p_val);
52 $this->parameter.=$js;
53
54 }
55 function set_height($p_val)
56 {
57 $js=sprintf('$("%s'.'_border").style.height="%s";',
58 $this->name,$p_val);
59 $this->parameter.=$js;
60
61 }
62 /**
63 *@brief set or not a blocking fond
64 *@param $p_block if true if you want to avoid access to background,
65 *accept true or false
66 */
67 function set_block($p_block)
68 {
69 $this->blocking=$p_block;
70 }
71
72 function set_zindex($p_val)
73 {
74 $js=sprintf('$("%s'.'_border").style.zIndex=%d;',
75 $this->name,$p_val);
76 $js=sprintf('$("%s'.'_content").style.zIndex=%d;',
77 $this->name,$p_val);
78 $this->parameter.=$js;
79 }
80 function set_dragguable($p_value)
81 {
82 $this->drag=$p_value;
83 }
84 /*!\brief set the attribute thanks javascript as the width, the position ...
85 *\param $p_name attribute name
86 *\param $p_val val of the attribute
87 *\note add to the this->attribut, it will be used in input()
88 */
89 function set_attribute($p_name,$p_val)
90 {
91 $this->attribute[]=array($p_name,$p_val);
92 }
93 /*!\brief set the title of a ipopup thanks javascript and php mode
94 *\param title of the IPopup
95 *\return html string with js script
96 */
97 function set_title($p_title)
98 {
99 $this->title=$p_title;
100 $s=sprintf('$("%s_"+"title")="%s"',
101 $this->name,$this->title);
102 return create_script($s);
103 }
104 function input()
105 {
106 $r="";
107 if ($this->blocking)
108 {
109 $r.=sprintf('<div id="%s_fond" class="popup_back">',$this->name);
110 $r.="</div>";
111 }
112 $javascript=sprintf("javascript:hideIPopup('%s')",
113 $this->name);
114
115
116 if ( isset($this->title) && trim($this->title) != "" )
117 {
118 $r.=sprintf('<div id="%s_border" id="%s_border" class="popup_border_title">',
119 $this->name,
120 $this->name);
121 $r.=sprintf('<span id="%s_">%s</span>',$this->name,$this->title);
122 }
123 else
124 {
125 $r.=sprintf('<div id ="%s_border" id="%s_border" class="popup_border_notitle">',
126 $this->name,
127 $this->name);
128 }
129 $r.='<div style="position:absolute;top:0px;right:10px;font-weight:normal;font-size:9px;color:black;text-align:right">';
130 $r.=sprintf('<a style="background-color:blue;color:white;text-decoration:none" href="%s">&#10761;</a></div>',
132
133 $r.=sprintf('<div id ="%s_content" id="%s_content" class="inner_box"> %s </div></div>',
134 $this->name,
135 $this->name,
136 $this->value);
137
138
139 /* Add properties at the widget */
140 $attr=$this->parameter;
141 for ($i=0;$i< count($this->attribute);$i++)
142 {
143 list($name,$value)=$this->attribute[$i];
144 $tmp1=sprintf("$('%s').%s='%s';",
145 $this->name,
146 $name,
147 $value);
148 $attr.=$tmp1;
149 }
150 $draggable='';
151 if ($this->drag==true)
152 {
153 /* add draggable possibility */
154 $draggable=sprintf(" new Draggable('%s_border',{starteffect:function(){
155 new Effect.Highlight('%s_border',{scroll:window,queue:'end'}); } });"
156 ,$this->name
157 ,$this->name);
158
159 }
160 $attr=create_script($attr.$draggable);
161 $r.=$attr;
162 return $r;
163 }
164
165 static function test_me()
166 {
167 $select=new ISelect('a');
168 $select->value=array(array ('value'=>0,'label'=>'Première valeur'),
169 array ('value'=>0,'label'=>'Première valeur'),
170 array ('value'=>0,'label'=>'Première valeur'));
171 for ($e=0;$e<5;$e++)
172 {
173 echo $select->input();
174 if ($e%10 == 0 ) echo '<hr>';
175 }
176 $a=new IPopup('pop1');
177 $a->value="";
178 for ($e=0;$e<500;$e++)
179 {
180 $a->value.="<p>Il etait une fois dans un pays vraiment lointain où même plus loin que ça</p>";
181 }
182 echo $a->input();
183 echo '
184 <input type="button" onclick="hide(\'pop1\');hide(\'pop1_border\')" value="cacher">
185 <input type="button" onclick="showIPopup(\'pop1\')" value="montrer">
186 ';
187 $a=new IPopup('pop2');
188 $a->value='';
189 $a->title="Retrouvez une saucisse";
190 echo $a->input();
191 echo '
192 <input type="button" onclick="hide(\'pop2\');hide(\'pop2_border\')" value="cacher">
193 <input type="button" onclick="showIPopup(\'pop2\')" value="montrer">
194 ';
195
196 }
197}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$from_poste name
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
create a popup in html above the current layer the html inside the popup cannot contain any floating ...
set_zindex($p_val)
set_height($p_val)
set_block($p_block)
set or not a blocking fond
set_width($p_val)
set_dragguable($p_value)
__construct($p_name)
static test_me()
set_attribute($p_name, $p_val)
set the attribute thanks javascript as the width, the position ...
set_title($p_title)
set the title of a ipopup thanks javascript and php mode
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
$anc_filter title
create_script($p_string)
create the HTML for adding the script tags around of the script