Code clean-up
| @@ -7,7 +7,7 @@ import { | |||
| 7 | power_user, | 7 | power_user, |
| 8 | context_presets, | 8 | context_presets, |
| 9 | } from './power-user.js'; | 9 | } from './power-user.js'; |
| 10 | import { regexFromString, resetScrollHeight } from './utils.js'; | 10 | import { regexFromString } from './utils.js'; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * @type {any[]} Instruct mode presets. | 13 | * @type {any[]} Instruct mode presets. |
| @@ -85,19 +85,9 @@ export async function loadInstructMode(data) { | |||
| 85 | 85 | ||
| 86 | migrateInstructModeSettings(power_user.instruct); | 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 | controls.forEach(control => { | 92 | controls.forEach(control => { |
| 103 | const $element = $(`#${control.id}`); | 93 | const $element = $(`#${control.id}`); |
| @@ -111,11 +101,6 @@ export async function loadInstructMode(data) { | |||
| 111 | $element.on('input', async function () { | 101 | $element.on('input', async function () { |
| 112 | power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText; | 102 | power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText; |
| 113 | saveSettingsDebounced(); | 103 | saveSettingsDebounced(); |
| 114 | /* | ||
| 115 | if (!control.isCheckbox) { | ||
| 116 | await resetScrollHeight($element); | ||
| 117 | } | ||
| 118 | */ | ||
| 119 | }); | 104 | }); |
| 120 | 105 | ||
| 121 | if (control.trigger) { | 106 | if (control.trigger) { |
| @@ -623,13 +608,12 @@ jQuery(() => { | |||
| 623 | 608 | ||
| 624 | $('#instruct_system_same_as_user').on('input', function () { | 609 | $('#instruct_system_same_as_user').on('input', function () { |
| 625 | const state = !!$(this).prop('checked'); | 610 | const state = !!$(this).prop('checked'); |
| 626 | if (state == true) { | 611 | if (state) { |
| 627 | let tempHeightForDisabled = $('#instruct_system_sequence').css('height'); | 612 | const tempHeightForDisabled = $('#instruct_system_sequence').css('height'); |
| 628 | $('#instruct_system_sequence_block').addClass('disabled'); | 613 | $('#instruct_system_sequence_block').addClass('disabled'); |
| 629 | $('#instruct_system_suffix_block').addClass('disabled'); | 614 | $('#instruct_system_suffix_block').addClass('disabled'); |
| 630 | $('#instruct_system_sequence').css('height', tempHeightForDisabled); | 615 | $('#instruct_system_sequence').css('height', tempHeightForDisabled); |
| 631 | $('#instruct_system_suffix').css('height', tempHeightForDisabled); | 616 | $('#instruct_system_suffix').css('height', tempHeightForDisabled); |
| 632 | |||
| 633 | $('#instruct_system_sequence').prop('contenteditable', false); | 617 | $('#instruct_system_sequence').prop('contenteditable', false); |
| 634 | $('#instruct_system_suffix').prop('contenteditable', false); | 618 | $('#instruct_system_suffix').prop('contenteditable', false); |
| 635 | } else { | 619 | } else { |
| @@ -669,11 +653,7 @@ jQuery(() => { | |||
| 669 | }); | 653 | }); |
| 670 | 654 | ||
| 671 | $('#instruct_bind_to_context').on('change', function () { | 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 | $('#instruct_presets').on('change', function () { | 659 | $('#instruct_presets').on('change', function () { |