noalyss Version-9
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Attributes
Select_Box Class Reference

Display a kind of select. More...

+ Inheritance diagram for Select_Box:
+ Collaboration diagram for Select_Box:

Public Member Functions

 __construct ($p_id, $value)
 
 add_input ($p_label, HtmlInput $p_element)
 
 add_javascript ($label, $javascript, $replace=false)
 
 add_url ($label, $url)
 
 add_value ($label, $value)
 
 get_default_value ()
 
 get_filter ()
 
 get_id ()
 
 get_item ()
 
 get_position ()
 
 input ()
 
 set_default_value ($default_value)
 
 set_filter ($p_filter)
 
 set_id ($id)
 
 set_item ($item)
 
 set_position ($position)
 

Data Fields

 $default_value
 
 $id
 
 $item
 

Protected Member Functions

 compute_position ()
 

Protected Attributes

 $style_box
 
 $value
 

Private Attributes

 $cnt
 
 $filter
 allow a dynamic not case sensitive search More...
 
 $position
 change depending if we are in an absolute block or not More...
 

Detailed Description

Display a kind of select.

<html>
<head>
<script src="prototype.js"></script>
/* The container <div> - needed to position the dropdown content */
.select_box{
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
.select_box {
border:solid 0.5px darkblue;
background:white;
width:455px;
max-width:250px;
padding:3px;
margin:0px;
display:none;
position:absolute;
z-index:10;
}
div.select_box ul {
list-style:none;
padding:2px;
margin:1px;
width:100%;
top:10px;
}
div.select_box ul li {
padding-top:2px;
padding-bottom:2px;
margin:2px;
}
div.select_box a {
text-decoration:none;
color : darkblue;
}
div.select_box a:hover,div.select_box ul li:hover {
background-color : blue;
color:lightgrey;
}
</style>
</head>
<body>
<div>
<p>
Le CSS est important , surtout la position, il faut qu'il soit dans
un élément positionné en absolu.
</p>
<h2>in-absolute</h2>
<p style="float : static">
<?php
require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
$a=new Select_Box("test","position in-absolute click me !");
$a->set_position("in-absolute");
$a->add_url("List (link)","?id=5&".Dossier::get());
$a->add_javascript("Hello (Javascript)","alert('hello')");
$a->add_value("Value = 10 (set value)",10);
$a->add_value("Value = 1 (set value)",1);
$a->add_value("Value = 15 (set value)",15);
echo $a->input();
?>
</p>
<h2>normal and absolute</h2>
<p>
<?php
$a=new Select_Box("test2","position normal click me !");
$a->set_filter(_("recherche"));
$a->set_position("normal");
$a->add_value("Value = 10 (set value)",10);
$a->add_value("Value = 1 (set value)",1);
$a->add_value("Value = 17 (set value)",15);
$a->add_value("Value = 18 (set value)",15);
$a->add_value("Value = 19 (set value)",15);
$a->add_value("Value = 20 (set value)",15);
$a->add_value("Value = 25 (set value)",15);
$a->add_value("Value = 30 (set value)",15);
$a->add_value("Value = 40 (set value)",15);
$a->add_value("Value = 50 (set value)",15);
$a->add_value("Value = 51 (set value)",15);
echo $a->input();
?>
</p>
</div>
</body>
p($p_string)
Definition: ac_common.php:39
for display
$opd_description style
else $card content[$j]['j_montant']
$desc width

Definition at line 30 of file select_box.class.php.

Constructor & Destructor Documentation

◆ __construct()

Select_Box::__construct (   $p_id,
  $value 
)

Reimplemented in Select_Dialog.

Definition at line 48 of file select_box.class.php.

49 {
50 $this->id=$p_id;
51 $this->item=array();
52 $this->value=$value;
53 $this->cnt=0;
54 $this->default_value=-1;
55 $this->style_box="";
56 $this->filter="";
57 $this->position="normal";
58 }

References $p_id, $value, and value.

Member Function Documentation

◆ add_input()

Select_Box::add_input (   $p_label,
HtmlInput  $p_element 
)

Definition at line 224 of file select_box.class.php.

225 {
226 /* $this->item[$this->cnt]['label']=$p_element->label;
227 $this->item[$this->cnt]['value']=$p_element->value;
228 $this->item[$this->cnt]['javascript']=$p_element->javascript;
229 *
230 */
231 $this->item[$this->cnt]['label']=$p_label;
232 $this->item[$this->cnt]['input']=clone $p_element;
233 $this->item[$this->cnt]['type']='input';
234 $this->cnt++;
235 }

References $cnt.

◆ add_javascript()

Select_Box::add_javascript (   $label,
  $javascript,
  $replace = false 
)

Definition at line 199 of file select_box.class.php.

200 {
201 $this->item[$this->cnt]['label']=$label;
202 if ( $replace )
203 {
204 $this->item[$this->cnt]['javascript']=
205 sprintf("$('%s_bt').value='%s \u21E9';",$this->id,noalyss_str_replace("'","",$label)).
206 $javascript.";$('select_box{$this->id}').hide()";
207 } else {
208 $this->item[$this->cnt]['javascript']=$javascript.";$('select_box{$this->id}').hide()";
209 }
210 $this->item[$this->cnt]['type']="javascript";
211 $this->cnt++;
212 }
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553

References $cnt, $label, and noalyss_str_replace().

+ Here is the call graph for this function:

◆ add_url()

Select_Box::add_url (   $label,
  $url 
)

Definition at line 191 of file select_box.class.php.

192 {
193 $this->item[$this->cnt]['label']=$label;
194 $this->item[$this->cnt]['url']=$url;
195 $this->item[$this->cnt]['type']="url";
196 $this->cnt++;
197 }
$url

References $cnt, $label, and $url.

◆ add_value()

Select_Box::add_value (   $label,
  $value 
)

Definition at line 214 of file select_box.class.php.

215 {
216 $this->item[$this->cnt]['label']=$label;
217 $this->item[$this->cnt]['update']=$value;
218 $this->item[$this->cnt]['javascript']=sprintf(" $('%s').value='%s';$('%s_bt').value='%s \u21E9';$('select_box%s').hide()",
219 $this->id, $value, $this->id, $label, $this->id);
220 $this->item[$this->cnt]['type']='value';
221 $this->cnt++;
222 }

References $cnt, $label, and $value.

◆ compute_position()

Select_Box::compute_position ( )
protected

Definition at line 108 of file select_box.class.php.

109 {
110 $list_id=sprintf('%s_list', $this->id);
111 switch ($this->position)
112 {
113 case 'absolute':
114 case "normal":
115 case "in-absolute":
116 // Show when click
117 $javascript=sprintf('
118 $("%s_bt").onclick=function() {
119 displaySelectBox("%s");
120 }
121 ', $this->id, $this->id);
122
123 break;
124
125 default:
126 break;
127 }
128 return $javascript;
129 }

Referenced by input().

◆ get_default_value()

Select_Box::get_default_value ( )

Definition at line 76 of file select_box.class.php.

77 {
79 }

References $default_value.

◆ get_filter()

Select_Box::get_filter ( )

Definition at line 242 of file select_box.class.php.

243 {
244 return $this->filter;
245 }
$filter
allow a dynamic not case sensitive search

References $filter.

◆ get_id()

Select_Box::get_id ( )

Definition at line 60 of file select_box.class.php.

61 {
62 return $this->id;
63 }

References $id.

Referenced by Select_Dialog\input().

◆ get_item()

Select_Box::get_item ( )

Definition at line 71 of file select_box.class.php.

72 {
73 return $this->item;
74 }

References $item.

◆ get_position()

Select_Box::get_position ( )

Definition at line 93 of file select_box.class.php.

94 {
95 return $this->position;
96 }
$position
change depending if we are in an absolute block or not

References $position.

◆ input()

Select_Box::input ( )

Reimplemented in Select_Dialog.

Definition at line 131 of file select_box.class.php.

132 {
133 $list_id=sprintf('%s_list', $this->id);
134
135 // Show when click
136 $javascript=$this->compute_position();
137
138 // display the button
139 printf('<input type="button" class="smallbutton " id="%s_bt" value="%s &#8681;" >',
140 $this->id, $this->value);
141 printf('<input type="hidden" id="%s" name="%s" value="%s">',
142 $this->id, $this->id, $this->default_value);
143 printf('<div class="select_box " id="select_box%s" style="%s">',
144 $this->id, $this->style_box);
145
146 // Show the filter if there is one,
147 if ($this->filter!="")
148 {
149
150 echo HtmlInput::filter_list($list_id);
151 }
152
153 // Print the list of possible options
154 printf('<ul id="%s">', $list_id);
155 for ($i=0; $i<count($this->item); $i++)
156 {
157 if ($this->item[$i]['type']=="url")
158 {
159 printf('<li><a href="%s">%s</a></li>', $this->item[$i]['url'], $this->item[$i]['label']);
160 }
161 else // For javascript
162 if ($this->item[$i]['type']=="javascript")
163 {
164 printf('<li><a href="javascript:void(0)" onclick="%s">%s</a></li>', $this->item[$i]['javascript'],
165 $this->item[$i]['label']);
166 }
167 else if ($this->item[$i]['type']=="value")
168 {
169 printf('<li><a href="javascript:void(0)" onclick="%s">%s</a></li>', $this->item[$i]['javascript'],
170 $this->item[$i]['label']);
171 }
172 else if ($this->item[$i]['type']=="input")
173 {
174 $ok=new IButton("ok");
175 $ok->value=$this->item[$i]['label'];
176 $ok->javascript=$this->item[$i]['input']->javascript;
177 printf('<li> %s %s</li>', $this->item[$i]['input']->input(), $ok->input()
178 );
179 }
180 }
181
182 echo "</ul>";
183 echo "</div>";
184
185 // javascript : onclick on button
186 echo "<script>";
187 echo $javascript;
188 echo "</script>";
189 }
static filter_list($p_list_id)
Display a field for searching an element in a list, the searchable text must be in an element with th...
Html Input.

References $i, compute_position(), HtmlInput\filter_list(), input(), and value.

Referenced by input().

+ Here is the call graph for this function:

◆ set_default_value()

Select_Box::set_default_value (   $default_value)

Definition at line 87 of file select_box.class.php.

88 {
89 $this->default_value=$default_value;
90 return $this;
91 }

References $default_value.

◆ set_filter()

Select_Box::set_filter (   $p_filter)

Definition at line 237 of file select_box.class.php.

238 {
239 $this->filter=$p_filter;
240 }

References $p_filter.

Referenced by Select_Dialog\__construct().

◆ set_id()

Select_Box::set_id (   $id)

Definition at line 65 of file select_box.class.php.

66 {
67 $this->id=$id;
68 return $this;
69 }

References $id.

◆ set_item()

Select_Box::set_item (   $item)

Definition at line 81 of file select_box.class.php.

82 {
83 $this->item=$item;
84 return $this;
85 }

References $item.

◆ set_position()

Select_Box::set_position (   $position)

Definition at line 98 of file select_box.class.php.

99 {
100 if (!in_array($position, array("normal", "in-absolute", "absolute")))
101 {
102 throw new Exception("SB0005", EXC_PARAM_VALUE);
103 }
104 $this->position=$position;
105 return $this;
106 }
const EXC_PARAM_VALUE
Definition: constant.php:343

References $position, and EXC_PARAM_VALUE.

Field Documentation

◆ $cnt

Select_Box::$cnt
private

Definition at line 35 of file select_box.class.php.

Referenced by add_input(), add_javascript(), add_url(), and add_value().

◆ $default_value

Select_Box::$default_value

Definition at line 37 of file select_box.class.php.

Referenced by get_default_value(), and set_default_value().

◆ $filter

Select_Box::$filter
private

allow a dynamic not case sensitive search

Definition at line 36 of file select_box.class.php.

Referenced by get_filter().

◆ $id

Select_Box::$id

Definition at line 33 of file select_box.class.php.

Referenced by get_id(), Select_Dialog\input(), and set_id().

◆ $item

Select_Box::$item

Definition at line 34 of file select_box.class.php.

Referenced by get_item(), and set_item().

◆ $position

Select_Box::$position
private

change depending if we are in an absolute block or not

Definition at line 38 of file select_box.class.php.

Referenced by get_position(), and set_position().

◆ $style_box

Select_Box::$style_box
protected

Definition at line 39 of file select_box.class.php.

◆ $value

Select_Box::$value
protected

Definition at line 40 of file select_box.class.php.

Referenced by __construct(), Select_Dialog\__construct(), and add_value().


The documentation for this class was generated from the following file: