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