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 / checkboxdetails.php

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

83 lines 2.1 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_CheckboxDetails
3 {
4 public function render( $name, $value, $checked, $label, $details = NULL, $inverse = FALSE )
5 {
6 $myId = 'hc4-input-checkboxdetails-' . HC3_Functions::generateRand(2);
7
8 // $value = $this->helper->getValue( $name, $value );
9
10 // CHECKBOX
11 $checkboxView = '';
12 $checkboxView .= '<label class="hc-block hc-xs-py1 hc-mr2">';
13 // $checkboxView = $this->inputCheckbox->render( $name, $value, $checked, $label );
14
15 $checkboxView .= '<input type="checkbox" class="hc4-input-checkbox" name="hc-' . $name . '" value="' . $value . '"';
16 if( $checked ){
17 $checkboxView .= ' checked="checked"';
18 }
19 $checkboxView .= '>';
20 if( NULL !== $label ){
21 $checkboxView .= $label;
22 }
23 $checkboxView .= '</label>';
24
25 $detailsView = '<div class="hc4-input-checkboxdetails-detail">' . $details . '</div>';
26
27 $out = array();
28 if( ! $inverse ){
29 $out[] = $checkboxView;
30 $out[] = $detailsView;
31 }
32 else {
33 $out[] = $detailsView;
34 $out[] = $checkboxView;
35 }
36
37 $out = join( '', $out );
38 // $out = $this->helper->afterRender( $name, $out );
39
40 ob_start();
41 ?>
42
43 <div id="<?php echo $myId; ?>">
44 <?php echo $out; ?>
45 </div>
46
47 <script>
48 ( function(){
49 var isInverse = <?php echo $inverse ? 'true' : 'false'; ?>;
50
51 function CheckboxDetailsInput( el ){
52 var ii = 0, jj = 0;
53 var togglers = el.getElementsByClassName( 'hc4-input-checkbox' );
54 var details = el.getElementsByClassName( 'hc4-input-checkboxdetails-detail' );
55
56 this.render = function(){
57 for( ii = 0; ii < togglers.length; ii++ ){
58 for( jj = 0; jj < details.length; jj++ ){
59 if( togglers[ii].checked ){
60 details[jj].style.display = isInverse ? 'none' : 'block';
61 }
62 else {
63 details[jj].style.display = isInverse ? 'block' : 'none';
64 }
65 }
66 }
67 };
68
69 for( ii = 0; ii < togglers.length; ii++ ){
70 togglers[ii].addEventListener( 'change', this.render );
71 }
72 };
73
74 var el = new CheckboxDetailsInput( document.getElementById('<?php echo $myId; ?>') );
75 el.render();
76
77 })();
78 </script>
79
80 <?php
81 return ob_get_clean();
82 }
83 }