| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 100 | private function getElementJS() |
||
| 101 | { |
||
| 102 | $js = null; |
||
| 103 | $id = $this->getAttribute('id'); |
||
| 104 | //timeFormat: 'hh:mm' |
||
| 105 | $js .= "<script> |
||
| 106 | $(function() { |
||
| 107 | var config = { |
||
| 108 | altInput: true, |
||
| 109 | altFormat: '".get_lang('F d, Y')." ".get_lang('at')." H:i', |
||
| 110 | enableTime: true, |
||
| 111 | dateFormat: 'Y-m-d H:i', |
||
| 112 | time_24hr: true, |
||
| 113 | wrap: true |
||
| 114 | }; |
||
| 115 | $('#{$id}').flatpickr(config); |
||
| 116 | |||
| 117 | /* |
||
| 118 | |||
| 119 | var txtDateTime = $('#$id'), |
||
| 120 | inputGroup = txtDateTime.parents('.input-group'), |
||
| 121 | txtDateTimeAlt = $('#{$id}_alt'), |
||
| 122 | txtDateTimeAltText = $('#{$id}_alt_text'); |
||
| 123 | txtDateTime |
||
| 124 | .hide() |
||
| 125 | .datetimepicker({ |
||
| 126 | defaultDate: '".$this->getValue()."', |
||
| 127 | dateFormat: 'yy-mm-dd', |
||
| 128 | timeFormat: 'HH:mm', |
||
| 129 | altField: '#{$id}_alt', |
||
| 130 | altFormat: \"".get_lang('MM dd, yy')."\", |
||
| 131 | altTimeFormat: \"".get_lang('HH:mm')."\", |
||
| 132 | altSeparator: \" ".get_lang(' at')." \", |
||
| 133 | altFieldTimeOnly: false, |
||
| 134 | showOn: 'both', |
||
| 135 | buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."', |
||
| 136 | buttonImageOnly: true, |
||
| 137 | buttonText: '".get_lang('Select date')."', |
||
| 138 | changeMonth: true, |
||
| 139 | changeYear: true |
||
| 140 | }) |
||
| 141 | .on('change', function (e) { |
||
| 142 | txtDateTimeAltText.text(txtDateTimeAlt.val()); |
||
| 143 | }); |
||
| 144 | |||
| 145 | txtDateTimeAltText.on('click', function () { |
||
| 146 | txtDateTime.datepicker('show'); |
||
| 147 | }); |
||
| 148 | |||
| 149 | inputGroup |
||
| 150 | .find('button') |
||
| 151 | .on('click', function (e) { |
||
| 152 | e.preventDefault(); |
||
| 153 | |||
| 154 | $('#$id, #{$id}_alt').val(''); |
||
| 155 | $('#{$id}_alt_text').html(''); |
||
| 156 | }); |
||
| 157 | */ |
||
| 158 | }); |
||
| 159 | </script>"; |
||
| 160 | |||
| 161 | return $js; |
||
| 162 | } |
||
| 164 |