noalyss Version-9
icon_action.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22/**
23 * @file
24 * @brief Utility , library of icon with javascript
25 */
26
27/**
28 * @brief Utility , library of icon with javascript
29 */
31{
32
33 /**
34 * Display a icon with a magnify glass
35 * @param string $id id of element
36 * @param string $p_javascript
37 * @param string $p_style optionnal HTML code
38 * @return type
39 */
40 static function icon_magnifier($id, $p_javascript, $p_style="")
41 {
42 $r="";
43 $r.=sprintf('<span id="%s" class=" smallbutton icon" style="%s" onclick="%s">&#xf50d;</span>',
44 $id, $p_style, $p_javascript);
45 return $r;
46 }
47 /**
48 * Display a icon with a magnify glass
49 * @param string $id id of element
50 * @param string $p_javascript
51 * @param string $p_style optionnal HTML code
52 * @return type
53 */
54 static function button_magnifier($id, $p_javascript, $p_style="")
55 {
56 $r="";
57 $r.=sprintf('<input type="button" id="%s" class=" smallbutton icon" style="%s" onclick="%s" value="&#xf50d;">',
58 $id, $p_style, $p_javascript);
59 return $r;
60 }
61
62 /**
63 *
64 * @param type $id
65 * @param type $p_javascript
66 * @param type $p_style
67 * @return type
68 */
69 static function icon_add($id, $p_javascript, $p_style="")
70 {
71 $r=sprintf('<input class="smallbutton icon" onclick="%s" id="%s" type="button" %s value="&#xe828;">',
72 $p_javascript, $id, $p_style);
73 return $r;
74 }
75
76 /**
77 *
78 * @param string $id
79 * @param string $p_javascript
80 * @param string opt $p_style
81 * @return html string
82 */
83 static function clean_zone($id, $p_javascript, $p_style="")
84 {
85 $r=sprintf('<input class="smallbutton " onclick="%s" id="%s" value="X" %s type="button" style="">',
86 $p_javascript, $id, $p_style
87 );
88 return $r;
89 }
90
91 /**
92 * Display a info in a bubble, text is in message_javascript
93 * @param integer $p_comment
94 * @see message_javascript.php
95 * @return html string
96 */
97 static function infobulle($p_comment)
98 {
99 $r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="showBulle(\''.$p_comment.'\')" onclick="showBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
100 $r.="&#xf086;";
101 $r.='</span>';
102
103 return $r;
104 }
105 /**
106 * Display a info in a bubble, text is given as parameter
107 * @param string $p_comment
108 *
109 * @return html string
110 */
111 static function tips($p_comment)
112 {
113 $p_comment=noalyss_str_replace("'",' ',$p_comment);
114 $r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="displayBulle(\''.$p_comment.'\')" onclick="displayBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
115 $r.="&#xf086;";
116 $r.='</span>';
117
118 return $r;
119 }
120 /**
121 * Display a info in a bubble, text is given as parameter
122 * @param string $p_comment
123 *
124 * @return html string
125 */
126 static function comment($p_comment)
127 {
128 $p_comment=noalyss_str_replace("'",' ',$p_comment);
129 $js=sprintf("displayBulle('%s')",$p_comment);
130
131 $r=sprintf('<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="%s" onclick="%s" onmouseout="hideBulle(0)">',
132 $js,$js);
133 $r.="&#xf0e5;";
134 $r.='</span>';
135
136 return $r;
137 }
138 /**
139 * Display a icon ON
140 * @param string $p_div id of element
141 * @param string $p_javascript
142 * @param string $p_style optionnal HTML code
143 * @return html string
144 */
145 static function iconon($p_id, $p_javascript, $p_style="")
146 {
147 $r=sprintf('<span style="color:green;cursor:pointer" id="%s" class="icon" style="%s" onclick="%s">&#xf205;</span>',
148 $p_id, $p_style, $p_javascript);
149 return $r;
150 }
151
152 /**
153 * Display a icon OFF
154 * @param string $p_div id of element
155 * @param string $p_javascript
156 * @param string $p_style optionnal HTML code
157 * @return html string
158 */
159 static function iconoff($p_id, $p_javascript, $p_style="")
160 {
161 $r=sprintf('<span style="color:red;cursor:pointer" id="%s" class="icon" style="%s" onclick="%s">&#xf204;</span>',
162 $p_id, $p_style, $p_javascript);
163 return $r;
164 }
165
166 /**
167 * Return a html string with an anchor which close the inside popup. (top-right corner)
168 * @param name of the DIV to close
169 */
170 static function close($p_div)
171 {
172 $r='';
173 $r.=sprintf('<A class="icon text-danger" onclick="removeDiv(\'%s\')">&#xe816;</A>',
174 $p_div);
175 return $r;
176 }
177
178 /**
179 * Display a icon for fix or move a div
180 * @param string $p_div id of the div to fix/move
181 * @param string $p_javascript
182 * @return html string
183 */
184 static function draggable($p_div)
185 {
186 $drag=sprintf('<span id="pin_%s" style="" class="icon " onclick="pin(\'%s\')" >'.UNPINDG.'</span>',
187 $p_div, $p_div);
188 return $drag;
189 }
190
191 /**
192 * Display a icon for zooming
193 * @param string $p_div id of the div to zoom
194 * @param string $p_javascript
195 * @return html string
196 */
197 static function zoom($p_div, $p_javascript)
198 {
199 $r=sprintf('<span id="span_%s" class="icon" onclick="%s">
200 &#xf08e;</span>', $p_div, $p_javascript);
201 return $r;
202 }
203
204 /**
205 * Display a warning in a bubble, text is in message_javascript
206 * @param integer $p_comment
207 * @see message_javascript.php
208 * @return html string
209 */
210 static function warnbulle($p_comment)
211 {
212 $r=sprintf('<span tabindex="-1" onmouseover="showBulle(\'%s\')" onclick="showBulle(\'%s\')" onmouseout="hideBulle(0)" style="color:red" class="icon">&#xe80e;</span>',
213 $p_comment, $p_comment);
214
215 return $r;
216 }
217
218 /**
219 * Return a html string with an anchor to hide a div, put it in the right corner
220 * @param $action action action to perform (message)
221 * @param $javascript javascript
222 * @note not protected against html
223 * @see Acc_Ledger::display_search_form
224 */
225 static function hide($action, $javascript)
226 {
227 $r='';
228 $r.='<span id="hide" style="" class="icon text-danger" onclick="'.$javascript.'">'.$action.'</span>';
229 return $r;
230 }
231 /**
232 * Return a html string with an anchor to hide a div, put it in the right corner
233 * @param $action action action to perform (message)
234 * @param $javascript javascript
235 * @note not protected against html
236 * @see Acc_Ledger::display_search_form
237 */
238 static function hide_icon( $p_id,$javascript)
239 {
240 $r='';
241 $r.='<span id="'.$p_id.'" class="icon" onclick="'.$javascript.'">'."&#xe83b;".'</span>';
242 return $r;
243 }
244 /**
245 * Return a html string with an eye
246 * @param type $javascript
247 * @return string
248 */
249 static function show_icon($p_id,$javascript) {
250 $r='';
251 $r.='<span id="'.$p_id.'" class="icon" onclick="'.$javascript.'">&#xe803;</span>';
252 return $r;
253
254 }
255 /**
256 * Display the icon of a trashbin
257 * @param string $p_id DOMid
258 * @param string $p_javascript
259 * @return htmlString
260 */
261 static function trash($p_id,$p_javascript)
262 {
263 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon">&#xe80f;</span>';
264 return $r;
265 }
266 /**
267 * Display the icon to modify a idem
268 * @param type $p_id
269 * @param type $p_javascript
270 * @return string
271 */
272 static function modify($p_id,$p_javascript)
273 {
274 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon" style="margin-left:5px">&#xe80d;</span>';
275
276 return $r;
277 }
278 /**
279 * Display the icon to modify a idem
280 * @param type $p_id
281 * @param type $p_javascript
282 * @return string
283 */
284 static function validate($p_id,$p_javascript)
285 {
286 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon" style="background-color:lightgrey; border:1px solid blue;padding:2px;margin:0px 1px 0px 1px" >&#xe844;</span>';
287
288 return $r;
289 }
290 /**
291 * Display the icon to modify a idem
292 * @param type $p_id
293 * @param type $p_javascript
294 * @return string
295 */
296 static function cancel($p_id,$p_javascript)
297 {
298 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" style="background-color:lightgrey; border:1px solid blue;padding:2px;margin:0px 1px 0px 1px" class="smallicon icon" >&#xe845;</span>';
299
300 return $r;
301 }
302 static function detail($p_id,$p_javascript)
303 {
304 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe803;</span>',
305 $p_id,
306 $p_javascript);
307 return $r;
308 }
309
310 static function detail_anchor($p_id,$url)
311 {
312 $r=sprintf('
313 <A HREF="%s">
314 <span id="%s" class="smallicon icon" style="margin-left:5px">&#xe803;</span></A>',
315 $url
316 ,$p_id);
317
318 return $r;
319 }
320 static function more($p_id,$p_javascript)
321 {
322 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe824;</span>',
323 $p_id,
324 $p_javascript);
325 return $r;
326 }
327 static function less($p_id,$p_javascript)
328 {
329 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe827;</span>',
330 $p_id,
331 $p_javascript);
332 return $r;
333 }
334 /**
335 * When a mouse is over this or if you click on it , it will trigger the javascript
336 * @param domid $p_id
337 * @param string $p_javascript
338 * @return html string
339 */
340 static function menu_click($p_id,$p_javascript)
341 {
342
343 $r=sprintf('<input type="button" id="%s" onclick="%s" class="smallbutton icon" value="&#xf142;" style="font-weigth:bolder">',
344 $p_id,
345 $p_javascript);
346 return $r;
347 }
348 /**
349 * Display the icon of a padlock to lock or unlock element
350 * @param string $p_id DOMid
351 * @param string $p_javascript
352 * @return htmlString
353 */
354 static function lock($p_id,$p_javascript)
355 {
356 $lock_cur="&#xe831;";
357 $lock_next="&#xe832;";
358
359 $r=sprintf( '<span id="%s" is_locked="1" onclick="toggle_lock(\'%s\');%s" class="icon smallicon">%s</span>',
360 $p_id,
361 $p_id,
362 $p_javascript,
363 $lock_cur);
364 return $r;
365 }
366 /**
367 * Display the icon of a trashbin
368 * @param string $p_id DOMid
369 * @param string $p_javascript
370 * @return htmlString
371 */
372 static function unlock($p_id,$p_javascript)
373 {
374
375 $lock_cur="&#xe832;";
376
377 $r=sprintf( '<span id="%s" is_locked="0" onclick="toggle_lock(\'%s\');%s" class="icon smallicon">%s</span>',
378 $p_id,
379 $p_id,
380 $p_javascript,
381 $lock_cur);
382 return $r;
383 }
384 /**
385 * Display the icon of a slider
386 * @param string $p_id DOMid
387 * @param string $p_javascript
388 * @return htmlString
389 */
390 static function slider($p_id,$p_javascript)
391 {
392
393 $lock_cur="&#xf1de;";
394
395 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
396 $p_id,
397 $p_javascript,
398 $lock_cur);
399 return $r;
400 }
401
402 /**
403 * Display a icon ON is $p_value == 1 otherwise OFF
404 * @param string $p_div id of element
405 * @param string $p_javascript
406 * @param string $p_style optionnal HTML code
407 * @param integer 0 or 1 , 0 means OFF and 1 means ON
408 * @return html string
409 */
410 static function icon_onoff($p_id,$p_javascript,$p_style,$p_value)
411 {
412 if ( $p_value == 1 ) { return \Icon_Action::iconon($p_id, $p_javascript,$p_style);}
413 if ( $p_value == 0 ) { return \Icon_Action::iconoff($p_id, $p_javascript,$p_style);}
414 }
415
416 static function checked ($p_id,$p_javascript="",$p_classrange="") {
417 $lock_cur="&#xe741;";
418 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon %s" >%s</span>',
419 $p_id,
420 $p_javascript,
421 $p_classrange,
422 $lock_cur);
423 return $r;
424 }
425 static function unchecked ($p_id,$p_javascript="",$p_classrange="") {
426 $lock_cur="&#xf096";
427
428 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon %s" >%s</span>',
429 $p_id,
430 $p_javascript,
431 $p_classrange,
432 $lock_cur);
433 return $r;
434 }
435 static function checkbox ($p_id,$p_javascript="",$p_value=0,$p_classrange="") {
436 if ( $p_value == 0 ) { return \Icon_Action::checked($p_id, $p_javascript,$p_classrange); }
437 if ( $p_value == 1 ) { return \Icon_Action::unchecked($p_id, $p_javascript,$p_classrange);}
438 }
439 static function full_size($p_div) {
440 $js=sprintf("full_size('%s')",$p_div);
441 $icon="&#xe80a;";
442 $r=sprintf('<span id="size_%s" onclick="%s" class="icon smallicon">%s</span>',
443 $p_div,$js,$icon);
444 return $r;
445 }
446 static function duplicate($p_js) {
447 $r=sprintf('<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
448 uniqid(),$p_js,"&#xf0c5;");
449 return $r;
450 }
451 static function card($p_js) {
452 $r=sprintf('<span id="%s" onclick="%s" class="icon smallbutton">%s</span>',
453 uniqid(),$p_js,"&#xe843;");
454 return $r;
455 }
456 static function option($p_js) {
457 $r=sprintf('<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
458 uniqid(),$p_js,"&#xf142;");
459 return $r;
460 }
461
462 /**
463 * @brief Increase size of input_text (p_domid) with p_domid
464 * @param $p_domid domid of the input "text" element
465 * @param $p_size size of the element
466 * @return string HTML string
467 */
468 static function longer($p_domid,$p_size) {
469 $r=sprintf('<span id="%s_longer" '.
470 ' onclick="enlarge_text(\'%s\',\'%s\') "'.
471 ' class="icon smallicon">%s</span>',
472 $p_domid,$p_domid,$p_size,"&#xf138");
473 return $r;
474 }
475 /**
476 * @brief Increase size of input_text (p_domid) with p_domid
477 * @param $p_domid domid of the input "text" element
478 * @param $p_size size of the element
479 * @return string HTML string
480 */
481 static function show_note($p_domid) {
482 $r='<span id="'.uniqid().'" class="smallicon icon" style="background-color:yellow" onclick="document.getElementById(\''.$p_domid.'\').show()">&#xf0f6;</span>';
483 return $r;
484 }
485
486 /**
487 * @brief hide or display an element, to be used for an accordon
488 * @param $p_id ip of the icon
489 * @param $p_id_to_hide element to hide or show
490 * @return HTML string
491 */
492 static function toggle_hide($p_id,$p_id_to_hide)
493 {
494 $javascript=sprintf("toggleHideShow('%s','%s',true)",$p_id_to_hide,$p_id);
495 $r=sprintf('<i id="%s" onclick="%s" class="smallicon icon icon-down-open-2" style="margin-left:5px"></i>',
496 $p_id,$javascript
497 );
498 return $r;
499 }
500}
span($p_string, $p_extra='')
Definition: ac_common.php:43
for display
$action
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$url
$opd_description style
margin left
Utility , library of icon with javascript.
static slider($p_id, $p_javascript)
Display the icon of a slider.
static unlock($p_id, $p_javascript)
Display the icon of a trashbin.
static menu_click($p_id, $p_javascript)
When a mouse is over this or if you click on it , it will trigger the javascript.
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
static clean_zone($id, $p_javascript, $p_style="")
static more($p_id, $p_javascript)
static draggable($p_div)
Display a icon for fix or move a div.
static hide_icon( $p_id, $javascript)
Return a html string with an anchor to hide a div, put it in the right corner.
static checked($p_id, $p_javascript="", $p_classrange="")
static less($p_id, $p_javascript)
static icon_magnifier($id, $p_javascript, $p_style="")
Display a icon with a magnify glass.
static icon_onoff($p_id, $p_javascript, $p_style, $p_value)
Display a icon ON is $p_value == 1 otherwise OFF.
static zoom($p_div, $p_javascript)
Display a icon for zooming.
static card($p_js)
static hide($action, $javascript)
Return a html string with an anchor to hide a div, put it in the right corner.
static duplicate($p_js)
static icon_add($id, $p_javascript, $p_style="")
static longer($p_domid, $p_size)
Increase size of input_text (p_domid) with p_domid.
static show_icon($p_id, $javascript)
Return a html string with an eye.
static detail_anchor($p_id, $url)
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
static detail($p_id, $p_javascript)
static show_note($p_domid)
Increase size of input_text (p_domid) with p_domid.
static full_size($p_div)
static checkbox($p_id, $p_javascript="", $p_value=0, $p_classrange="")
static validate($p_id, $p_javascript)
Display the icon to modify a idem.
static unchecked($p_id, $p_javascript="", $p_classrange="")
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
static lock($p_id, $p_javascript)
Display the icon of a padlock to lock or unlock element.
static cancel($p_id, $p_javascript)
Display the icon to modify a idem.
static button_magnifier($id, $p_javascript, $p_style="")
Display a icon with a magnify glass.
static option($p_js)
const UNPINDG
Definition: constant.php:348