Merge pull request #2692 from SillyTavern/qr-popout-hide QR: Add toggle to hide popout button
Signed| @@ -11,6 +11,9 @@ | ||
| 11 | 11 | <label class="flex-container"> |
| 12 | 12 | <input type="checkbox" id="qr--isCombined"><span data-i18n="Combine Quick Replies">Combine Quick Replies</span> |
| 13 | 13 | </label> |
| 14 | + <label class="flex-container"> | |
| 15 | + <input type="checkbox" id="qr--showPopoutButton"><span data-i18n="Show Popout Button">Show Popout Button</span> | |
| 16 | + </label> | |
| 14 | 17 | |
| 15 | 18 | <hr> |
| 16 | 19 | |
| @@ -16,6 +16,7 @@ export class QuickReplySettings { | ||
| 16 | 16 | /**@type {Boolean}*/ isEnabled = false; |
| 17 | 17 | /**@type {Boolean}*/ isCombined = false; |
| 18 | 18 | /**@type {Boolean}*/ isPopout = false; |
| 19 | + /**@type {Boolean}*/ showPopoutButton = true; | |
| 19 | 20 | /**@type {QuickReplyConfig}*/ config; |
| 20 | 21 | /**@type {QuickReplyConfig}*/ _chatConfig; |
| 21 | 22 | get chatConfig() { |
| @@ -79,6 +80,7 @@ export class QuickReplySettings { | ||
| 79 | 80 | isEnabled: this.isEnabled, |
| 80 | 81 | isCombined: this.isCombined, |
| 81 | 82 | isPopout: this.isPopout, |
| 83 | + showPopoutButton: this.showPopoutButton, | |
| 82 | 84 | config: this.config, |
| 83 | 85 | }; |
| 84 | 86 | } |
| @@ -69,17 +69,20 @@ export class ButtonUi { | ||
| 69 | 69 | root.id = 'qr--bar'; |
| 70 | 70 | root.classList.add('flex-container'); |
| 71 | 71 | root.classList.add('flexGap5'); |
| 72 | - const popout = document.createElement('div'); { | |
| 72 | + if (this.settings.showPopoutButton) { | |
| 73 | - popout.id = 'qr--popoutTrigger'; | |
| 73 | + root.classList.add('popoutVisible'); | |
| 74 | 74 | const popout.classList = document.addcreateElement('menu_buttondiv'); { |
| 75 | - popout.classList.add('fa-solid'); | |
| 75 | + popout.id = 'qr--popoutTrigger'; | |
| 76 | 76 | popout.classList.add('fa-window-restoremenu_button'); |
| 77 | - popout.addEventListener('click', ()=>{ | |
| 77 | + popout.classList.add('fa-solid'); | |
| 78 | - this.settings.isPopout = true; | |
| 78 | + popout.classList.add('fa-window-restore'); | |
| 79 | - this.refresh(); | |
| 79 | + popout.addEventListener('click', ()=>{ | |
| 80 | 80 | this.settings.save()isPopout = true; |
| 81 | - }); | |
| 81 | + this.refresh(); | |
| 82 | - root.append(popout); | |
| 82 | + this.settings.save(); | |
| 83 | + }); | |
| 84 | + root.append(popout); | |
| 85 | + } | |
| 83 | 86 | } |
| 84 | 87 | if (this.settings.isCombined) { |
| 85 | 88 | const buttons = document.createElement('div'); { |
| @@ -14,6 +14,7 @@ export class SettingsUi { | ||
| 14 | 14 | |
| 15 | 15 | /**@type {HTMLInputElement}*/ isEnabled; |
| 16 | 16 | /**@type {HTMLInputElement}*/ isCombined; |
| 17 | + /**@type {HTMLInputElement}*/ showPopoutButton; | |
| 17 | 18 | |
| 18 | 19 | /**@type {HTMLElement}*/ globalSetList; |
| 19 | 20 | |
| @@ -79,6 +80,10 @@ export class SettingsUi { | ||
| 79 | 80 | this.isCombined = this.dom.querySelector('#qr--isCombined'); |
| 80 | 81 | this.isCombined.checked = this.settings.isCombined; |
| 81 | 82 | this.isCombined.addEventListener('click', ()=>this.onIsCombined()); |
| 83 | + | |
| 84 | + this.showPopoutButton = this.dom.querySelector('#qr--showPopoutButton'); | |
| 85 | + this.showPopoutButton.checked = this.settings.showPopoutButton; | |
| 86 | + this.showPopoutButton.addEventListener('click', ()=>this.onShowPopoutButton()); | |
| 82 | 87 | } |
| 83 | 88 | |
| 84 | 89 | prepareGlobalSetList() { |
| @@ -235,6 +240,11 @@ export class SettingsUi { | ||
| 235 | 240 | this.settings.save(); |
| 236 | 241 | } |
| 237 | 242 | |
| 243 | + async onShowPopoutButton() { | |
| 244 | + this.settings.showPopoutButton = this.showPopoutButton.checked; | |
| 245 | + this.settings.save(); | |
| 246 | + } | |
| 247 | + | |
| 238 | 248 | async onGlobalSetListSort() { |
| 239 | 249 | this.settings.config.setList = Array.from(this.globalSetList.children).map((it,idx)=>{ |
| 240 | 250 | const set = this.settings.config.setList[Number(it.getAttribute('data-order'))]; |
| @@ -27,7 +27,6 @@ | ||
| 27 | 27 | max-width: 100%; |
| 28 | 28 | overflow-x: auto; |
| 29 | 29 | order: 1; |
| 30 | - padding-right: 2.5em; | |
| 31 | 30 | position: relative; |
| 32 | 31 | } |
| 33 | 32 | #qr--bar > #qr--popoutTrigger { |
| @@ -35,6 +34,9 @@ | ||
| 35 | 34 | right: 0.25em; |
| 36 | 35 | top: 0; |
| 37 | 36 | } |
| 37 | +#qr--bar.popoutVisible { | |
| 38 | + padding-right: 2.5em; | |
| 39 | +} | |
| 38 | 40 | #qr--popout { |
| 39 | 41 | display: flex; |
| 40 | 42 | flex-direction: column; |
| @@ -25,7 +25,6 @@ | ||
| 25 | 25 | max-width: 100%; |
| 26 | 26 | overflow-x: auto; |
| 27 | 27 | order: 1; |
| 28 | - padding-right: 2.5em; | |
| 29 | 28 | position: relative; |
| 30 | 29 | |
| 31 | 30 | >#qr--popoutTrigger { |
| @@ -34,6 +33,9 @@ | ||
| 34 | 33 | top: 0; |
| 35 | 34 | } |
| 36 | 35 | } |
| 36 | +#qr--bar.popoutVisible { | |
| 37 | + padding-right: 2.5em; | |
| 38 | +} | |
| 37 | 39 | |
| 38 | 40 | #qr--popout { |
| 39 | 41 | display: flex; |