| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 50 |
| 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 |
||
| 158 | public function renderPost(Renderer $renderer) |
||
| 159 | { |
||
| 160 | $coreformsjs = $renderer->basepath('modules/Core/js/core.forms.js'); |
||
|
|
|||
| 161 | $javaScript = <<<JS |
||
| 162 | $(document).ready(function() { |
||
| 163 | |||
| 164 | console.log('attached yk.forms.done to ', \$('form')); |
||
| 165 | |||
| 166 | \$('form').on('yk.forms.done', function(event, data) { |
||
| 167 | //if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {} |
||
| 168 | if (typeof data != 'undefined' && typeof data['data'] != 'undefined') { |
||
| 169 | if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) { |
||
| 170 | $('#job_incomplete').hide(); |
||
| 171 | \$('.wizard-container .finish').removeClass('disabled'); |
||
| 172 | } |
||
| 173 | else { |
||
| 174 | $('#job_incomplete').show(); |
||
| 175 | \$('.wizard-container .finish').addClass('disabled'); |
||
| 176 | } |
||
| 177 | } |
||
| 178 | \$('#job_errormessages').empty(); |
||
| 179 | |||
| 180 | if (typeof data['data']['errorMessage'] != 'undefined') { |
||
| 181 | $('#job_errormessages').append(data['data']['errorMessage']); |
||
| 182 | } |
||
| 183 | console.debug('job-form-inline', event, data); |
||
| 184 | }); |
||
| 185 | \$('.wizard-container').on('wizard:tabShow.jobcontainer', function(e, \$tab, \$nav, index) { |
||
| 186 | var \$link = \$tab.find('a'); |
||
| 187 | var href = \$link.attr('href'); |
||
| 188 | var \$target = \$(href); |
||
| 189 | var \$iframe = \$target.find('iframe'); |
||
| 190 | |||
| 191 | \$iframe.each(function() { this.contentDocument.location.reload(true); }); |
||
| 192 | |||
| 193 | var \$productList = \$target.find('#product-list-wrapper'); |
||
| 194 | if (\$productList.length) { |
||
| 195 | \$productList.html('').load('/' + lang + '/jobs/channel-list?id=' + \$('#general-nameForm-job').val()); |
||
| 196 | } |
||
| 197 | }); |
||
| 198 | |||
| 199 | \$('.wizard-container .finish a').click(function (e) { |
||
| 200 | if (\$(e.currentTarget).parent().hasClass('disabled')) { |
||
| 201 | e.preventDefault(); |
||
| 202 | return false; |
||
| 203 | } |
||
| 204 | }); |
||
| 205 | |||
| 206 | }); |
||
| 207 | JS; |
||
| 208 | |||
| 209 | $renderer->headScript()->appendScript($javaScript); |
||
| 210 | |||
| 211 | return parent::renderPost($renderer); |
||
| 212 | } |
||
| 226 |