| Total Complexity | 5 |
| Complexity/F | 1.67 |
| Lines of Code | 30 |
| Function Count | 3 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /* globals wp */ |
||
| 2 | import $ from 'jquery' |
||
| 3 | |||
| 4 | wp.customize.controlConstructor['flynt-range'] = wp.customize.Control.extend({ |
||
| 5 | ready: function () { |
||
| 6 | const control = this |
||
| 7 | |||
| 8 | this.container.on('change', '.flynt-range', function () { |
||
| 9 | const $el = $(this) |
||
| 10 | const max = parseInt($el.attr('max'), 10) |
||
| 11 | const min = parseInt($el.attr('min'), 10) |
||
| 12 | let value = parseInt($el.val(), 10) |
||
| 13 | |||
| 14 | if (min > value) { |
||
| 15 | value = min |
||
| 16 | } |
||
| 17 | |||
| 18 | if (max < value) { |
||
| 19 | value = max |
||
| 20 | } |
||
| 21 | |||
| 22 | control.setting.set(value) |
||
| 23 | }) |
||
| 24 | |||
| 25 | this.container.on('click', '.flynt-range-reset', function () { |
||
| 26 | const $el = $(this) |
||
| 27 | const value = $el.data('default') |
||
| 28 | control.setting.set(value) |
||
| 29 | }) |
||
| 30 | } |
||
| 31 | }) |
||
| 32 |