Code clean-up
| @@ -7,7 +7,7 @@ import { | ||
| 7 | 7 | power_user, |
| 8 | 8 | context_presets, |
| 9 | 9 | } from './power-user.js'; |
| 10 | 10 | import { regexFromString, resetScrollHeight } from './utils.js'; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @type {any[]} Instruct mode presets. |
| @@ -85,19 +85,9 @@ export async function loadInstructMode(data) { | ||
| 85 | 85 | |
| 86 | 86 | migrateInstructModeSettings(power_user.instruct); |
| 87 | 87 | |
| 88 | - if (power_user.instruct.enabled) { | |
| 88 | + $('#instruct_enabled').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.enabled); | |
| 89 | - $('#instruct_enabled').parent().find('i').addClass('toggleEnabled'); | |
| 89 | + $('#instructSettingsBlock, #InstructSequencesColumn').toggleClass('disabled', !power_user.instruct.enabled); | |
| 90 | - $('#instructSettingsBlock, #InstructSequencesColumn').removeClass('disabled'); | |
| 90 | + $('#instruct_bind_to_context').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.bind_to_context); | |
| 91 | - } else { | |
| 92 | - $('#instruct_enabled').parent().find('i').removeClass('toggleEnabled'); | |
| 93 | - $('#instructSettingsBlock, #InstructSequencesColumn').addClass('disabled'); | |
| 94 | - } | |
| 95 | - | |
| 96 | - if (power_user.instruct.bind_to_context) { | |
| 97 | - $('#instruct_bind_to_context').parent().find('i').addClass('toggleEnabled'); | |
| 98 | - } else { | |
| 99 | - $('#instruct_bind_to_context').parent().find('i').removeClass('toggleEnabled'); | |
| 100 | - } | |
| 101 | 91 | |
| 102 | 92 | controls.forEach(control => { |
| 103 | 93 | const $element = $(`#${control.id}`); |
| @@ -111,11 +101,6 @@ export async function loadInstructMode(data) { | ||
| 111 | 101 | $element.on('input', async function () { |
| 112 | 102 | power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText; |
| 113 | 103 | saveSettingsDebounced(); |
| 114 | - /* | |
| 115 | - if (!control.isCheckbox) { | |
| 116 | - await resetScrollHeight($element); | |
| 117 | - } | |
| 118 | - */ | |
| 119 | 104 | }); |
| 120 | 105 | |
| 121 | 106 | if (control.trigger) { |
| @@ -623,13 +608,12 @@ jQuery(() => { | ||
| 623 | 608 | |
| 624 | 609 | $('#instruct_system_same_as_user').on('input', function () { |
| 625 | 610 | const state = !!$(this).prop('checked'); |
| 626 | 611 | if (state == true) { |
| 627 | 612 | letconst tempHeightForDisabled = $('#instruct_system_sequence').css('height'); |
| 628 | 613 | $('#instruct_system_sequence_block').addClass('disabled'); |
| 629 | 614 | $('#instruct_system_suffix_block').addClass('disabled'); |
| 630 | 615 | $('#instruct_system_sequence').css('height', tempHeightForDisabled); |
| 631 | 616 | $('#instruct_system_suffix').css('height', tempHeightForDisabled); |
| 632 | - | |
| 633 | 617 | $('#instruct_system_sequence').prop('contenteditable', false); |
| 634 | 618 | $('#instruct_system_suffix').prop('contenteditable', false); |
| 635 | 619 | } else { |
| @@ -669,11 +653,7 @@ jQuery(() => { | ||
| 669 | 653 | }); |
| 670 | 654 | |
| 671 | 655 | $('#instruct_bind_to_context').on('change', function () { |
| 672 | - if (power_user.instruct.bind_to_context) { | |
| 656 | + $('#instruct_bind_to_context').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.bind_to_context); | |
| 673 | - $('#instruct_bind_to_context').parent().find('i').addClass('toggleEnabled'); | |
| 674 | - } else { | |
| 675 | - $('#instruct_bind_to_context').parent().find('i').removeClass('toggleEnabled'); | |
| 676 | - } | |
| 677 | 657 | }); |
| 678 | 658 | |
| 679 | 659 | $('#instruct_presets').on('change', function () { |