(button: JQuery, checkbox: JQuery, forcedState?: boolean)
| 74 | } |
| 75 | |
| 76 | private updateButtonDisplay(button: JQuery, checkbox: JQuery, forcedState?: boolean) { |
| 77 | if (forcedState !== undefined) { |
| 78 | checkbox.prop('checked', forcedState); |
| 79 | } |
| 80 | const isChecked = checkbox.is(':checked'); |
| 81 | |
| 82 | // Set the button's state |
| 83 | button.data('state', isChecked ? 'on' : 'off'); |
| 84 | |
| 85 | // Set the button's icon |
| 86 | button |
| 87 | .find('.state-icon') |
| 88 | .removeClass() |
| 89 | .addClass(`state-icon ${settings[button.data('state') as keyof typeof settings].icon}`); |
| 90 | |
| 91 | // Update the button's color |
| 92 | button.toggleClass('active', isChecked); |
| 93 | if (forcedState === undefined) { |
| 94 | this.set(button.data('bind'), isChecked); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | get() { |
| 99 | return {...this.state}; |
no test coverage detected