common.js
21 lines
| 1 | (function ($) { |
| 2 | |
| 3 | /** |
| 4 | * sweitch |
| 5 | */ |
| 6 | const switchBox = $('.ssp_switch_box'); |
| 7 | switchBox.click(function (e){ |
| 8 | const labelFor = $(this).attr('for'); |
| 9 | const parentField = $(this).closest('.ssp-field'); |
| 10 | setTimeout( function() { |
| 11 | const val = $('#' + labelFor).prop('checked'); |
| 12 | $('input[name="' + labelFor + '"]').val( Number(val) ); |
| 13 | |
| 14 | if (parentField.attr('data-disable') !== undefined) { |
| 15 | parentField.attr('data-disable', Number(val)); |
| 16 | } else if (p.attr('data-active') !== undefined) { |
| 17 | parentField.attr('data-active', Number(val)); |
| 18 | } |
| 19 | }, 10); |
| 20 | }); |
| 21 | })(window.jQuery); |