| Conditions | 6 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | function init_controls(selector) |
||
| 2 | { |
||
| 3 | const form = $(selector); |
||
| 4 | |||
| 5 | if (form.find('tbody').children().length < 2) { |
||
| 6 | form.find('[name="first"], [name="last"], [name="f_compare"]').css('visibility', 'hidden'); |
||
| 7 | return; |
||
| 8 | } |
||
| 9 | |||
| 10 | if (form.find('[name="first"]:checked').length === 0) { |
||
| 11 | form.find('[name="first"]').eq(1).trigger('click'); |
||
| 12 | } |
||
| 13 | |||
| 14 | if (form.find('[name="last"]:checked').length === 0) { |
||
| 15 | form.find('[name="last"]').eq(0).trigger('click'); |
||
| 16 | } |
||
| 17 | |||
| 18 | form.on('change', '[name="first"]', function() { |
||
| 19 | $('[name="f_compare"]').prop('disabled', $(this).val() == $('[name="last"]:checked').val()); |
||
| 20 | }); |
||
| 21 | |||
| 22 | form.on('change', '[name="last"]', function() { |
||
| 23 | $('[name="f_compare"]').prop('disabled', $(this).val() == $('[name="first"]:checked').val()); |
||
| 24 | }); |
||
| 25 | } |