PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / ui / element / input / multiset.php

multiset.php in ShiftController Employee Shift Scheduling 4.9.85, at hc3/ui/element/input/multiset.php

89 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Ui_Element_Input_MultiSet
3 {
4 public function render( $name, array $labels, array $options, $value = NULL )
5 {
6 $myId = 'hc4-input-multiset-' . HC3_Functions::generateRand(2);
7
8 // $value = $this->helper->getValue( $name, $value );
9
10 $out = array();
11
12 // RADIO SET
13 $out[] = '<div>';
14 foreach( $labels as $k => $label ){
15 $out[] = '<div class="hc-nowrap hc-lg-inline-block hc-lg-mx1">';
16 $checked = ( $value == $k ) ? TRUE : FALSE;
17
18 // RADIO
19 $out[] = '<label class="hc-block hc-xs-py1 hc-mr2">';
20 $out[] = '<input type="radio" class="hc4-input-radio" name="hc-' . $name . '" value="' . $k . '"';
21 if( $checked ){
22 $out[] = ' checked="checked"';
23 }
24 $out[] = '>';
25 if( NULL !== $label ){
26 $out[] = $label;
27 }
28 $out[] = '</label>';
29
30 $out[] = '</div>';
31 }
32 $out[] = '</div>';
33
34 foreach( $options as $k => $v ){
35 $out[] = '<div class="hc4-input-multiset-detail hc4-input-multiset-detail-' . $k . '">';
36 $out[] = $v;
37 $out[] = '</div>';
38 }
39
40 $out = join( '', $out );
41 // $out = $this->helper->afterRender( $name, $out );
42
43 ob_start();
44 ?>
45
46 <div id="<?php echo $myId; ?>">
47 <?php echo $out; ?>
48 </div>
49
50 <script>
51 ( function(){
52
53 function MultiSetInput( el ){
54 var ii = 0, jj = 0;
55 var togglers = el.getElementsByClassName( 'hc4-input-radio' );
56 var details = el.getElementsByClassName( 'hc4-input-multiset-detail' );
57
58 this.render = function(){
59 for( ii = 0; ii < details.length; ii++ ){
60 details[ii].style.display = 'none';
61 }
62
63 for( ii = 0; ii < togglers.length; ii++ ){
64 if( togglers[ii].checked ){
65 var showClass = 'hc4-input-multiset-detail-' + togglers[ii].value;
66 var showDetails = el.getElementsByClassName( showClass );
67 for( jj = 0; jj < showDetails.length; jj++ ){
68 showDetails[jj].style.display = 'block';
69 }
70 }
71 }
72 };
73
74 for( ii = 0; ii < togglers.length; ii++ ){
75 // togglers[ii].addEventListener( 'RadioStateChange', this.render );
76 togglers[ii].addEventListener( 'change', this.render );
77 }
78 };
79
80 var el = new MultiSetInput( document.getElementById('<?php echo $myId; ?>') );
81 el.render();
82
83 })();
84 </script>
85
86 <?php
87 return ob_get_clean();
88 }
89 }