add option for toastr location to themes
| @@ -4453,6 +4453,17 @@ | |||
| 4453 | <input class="neo-range-slider" type="range" id="shadow_width" name="shadow_width" min="0" max="5" step="1"> | 4453 | <input class="neo-range-slider" type="range" id="shadow_width" name="shadow_width" min="0" max="5" step="1"> |
| 4454 | <input class="neo-range-input" type="number" min="0" max="5" step="1" data-for="shadow_width" id="shadow_width_counter"> | 4454 | <input class="neo-range-input" type="number" min="0" max="5" step="1" data-for="shadow_width" id="shadow_width_counter"> |
| 4455 | </div> | 4455 | </div> |
| 4456 | <div class="flex-container alignItemsBaseline"> | ||
| 4457 | <span data-i18n="Notification Location:">Notification Location:</span><br> | ||
| 4458 | <select id="toastr_position" class="widthNatural flex1 margin0"> | ||
| 4459 | <option value="toast-top-left" data-i18n="Top Left">Top Left</option> | ||
| 4460 | <option value="toast-top-center" data-i18n="Top Center">Top Center</option> | ||
| 4461 | <option value="toast-top-right" data-i18n="Top Right">Top Right</option> | ||
| 4462 | <option value="toast-bottom-left" data-i18n="Bottom Left">Bottom Left</option> | ||
| 4463 | <option value="toast-bottom-center" data-i18n="Bottom Center">Bottom Center</option> | ||
| 4464 | <option value="toast-bottom-right" data-i18n="Bottom Right">Bottom Right</option> | ||
| 4465 | </select> | ||
| 4466 | </div> | ||
| 4456 | </div> | 4467 | </div> |
| 4457 | <hr> | 4468 | <hr> |
| 4458 | <div name="themeToggles"> | 4469 | <div name="themeToggles"> |
| @@ -321,7 +321,7 @@ toastr.options.timeOut = 4000; // How long the toast will display without user i | |||
| 321 | toastr.options.extendedTimeOut = 10000; // How long the toast will display after a user hovers over it | 321 | toastr.options.extendedTimeOut = 10000; // How long the toast will display after a user hovers over it |
| 322 | toastr.options.progressBar = true; // Visually indicate how long before a toast expires. | 322 | toastr.options.progressBar = true; // Visually indicate how long before a toast expires. |
| 323 | toastr.options.closeButton = true; // enable a close button | 323 | toastr.options.closeButton = true; // enable a close button |
| 324 | toastr.options.positionClass = 'toast-top-center'; // Where to position the toast container | 324 | //toastr.options.positionClass = power_user.toastr_position; // Where to position the toast container |
| 325 | toastr.options.onHidden = () => { | 325 | toastr.options.onHidden = () => { |
| 326 | // If we have any dialog still open, the last "hidden" toastr will remove the toastr-container. We need to keep it alive inside the dialog though | 326 | // If we have any dialog still open, the last "hidden" toastr will remove the toastr-container. We need to keep it alive inside the dialog though |
| 327 | // so the toasts still show up inside there. | 327 | // so the toasts still show up inside there. |
| @@ -7592,6 +7592,8 @@ export async function getSettings() { | |||
| 7592 | // Apply theme toggles from power user settings | 7592 | // Apply theme toggles from power user settings |
| 7593 | applyPowerUserSettings(); | 7593 | applyPowerUserSettings(); |
| 7594 | 7594 | ||
| 7595 | toastr.options.positionClass = power_user.toastr_position; // Where to position the toast container | ||
| 7596 | |||
| 7595 | // Load character tags | 7597 | // Load character tags |
| 7596 | loadTagsSettings(settings); | 7598 | loadTagsSettings(settings); |
| 7597 | 7599 | ||
| @@ -137,6 +137,7 @@ let power_user = { | |||
| 137 | fast_ui_mode: true, | 137 | fast_ui_mode: true, |
| 138 | avatar_style: avatar_styles.ROUND, | 138 | avatar_style: avatar_styles.ROUND, |
| 139 | chat_display: chat_styles.DEFAULT, | 139 | chat_display: chat_styles.DEFAULT, |
| 140 | toastr_position: 'toast-top-center', | ||
| 140 | chat_width: 50, | 141 | chat_width: 50, |
| 141 | never_resize_avatars: false, | 142 | never_resize_avatars: false, |
| 142 | show_card_avatar_urls: false, | 143 | show_card_avatar_urls: false, |
| @@ -1044,6 +1045,43 @@ function applyChatDisplay() { | |||
| 1044 | } | 1045 | } |
| 1045 | } | 1046 | } |
| 1046 | 1047 | ||
| 1048 | function applyToastrPosition() { | ||
| 1049 | |||
| 1050 | if (!power_user.toastr_position) { | ||
| 1051 | power_user.toastr_position = 'toast-top-center'; | ||
| 1052 | console.warn('applyToastrPosition: missing toastr position, defaulting to top-center'); | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | switch (power_user.toastr_position) { | ||
| 1056 | case 'toast-top-left': { | ||
| 1057 | toastr.options.positionClass = 'toast-top-left'; | ||
| 1058 | break; | ||
| 1059 | } | ||
| 1060 | case 'toast-top-center': { | ||
| 1061 | toastr.options.positionClass = 'toast-top-center'; | ||
| 1062 | break; | ||
| 1063 | } | ||
| 1064 | case 'toast-top-right': { | ||
| 1065 | toastr.options.positionClass = 'toast-top-right'; | ||
| 1066 | break; | ||
| 1067 | } | ||
| 1068 | case 'toast-bottom-left': { | ||
| 1069 | toastr.options.positionClass = 'toast-bottom-left'; | ||
| 1070 | break; | ||
| 1071 | } | ||
| 1072 | case 'toast-bottom-center': { | ||
| 1073 | toastr.options.positionClass = 'toast-bottom-center'; | ||
| 1074 | break; | ||
| 1075 | } | ||
| 1076 | case 'toast-bottom-right': { | ||
| 1077 | toastr.options.positionClass = 'toast-bottom-right'; | ||
| 1078 | break; | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | $('#toastr_position').val(power_user.toastr_position).prop('selected', true); | ||
| 1083 | } | ||
| 1084 | |||
| 1047 | function applyChatWidth(type) { | 1085 | function applyChatWidth(type) { |
| 1048 | if (type === 'forced') { | 1086 | if (type === 'forced') { |
| 1049 | let r = document.documentElement; | 1087 | let r = document.documentElement; |
| @@ -1207,6 +1245,12 @@ function applyTheme(name) { | |||
| 1207 | }, | 1245 | }, |
| 1208 | }, | 1246 | }, |
| 1209 | { | 1247 | { |
| 1248 | key: 'toastr_position', | ||
| 1249 | action: () => { | ||
| 1250 | applyToastrPosition(); | ||
| 1251 | }, | ||
| 1252 | }, | ||
| 1253 | { | ||
| 1210 | key: 'avatar_style', | 1254 | key: 'avatar_style', |
| 1211 | action: () => { | 1255 | action: () => { |
| 1212 | applyAvatarStyle(); | 1256 | applyAvatarStyle(); |
| @@ -1455,6 +1499,7 @@ function getExampleMessagesBehavior() { | |||
| 1455 | return 'normal'; | 1499 | return 'normal'; |
| 1456 | } | 1500 | } |
| 1457 | 1501 | ||
| 1502 | //MARK: loadPowerUser | ||
| 1458 | async function loadPowerUserSettings(settings, data) { | 1503 | async function loadPowerUserSettings(settings, data) { |
| 1459 | const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript)); | 1504 | const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript)); |
| 1460 | // Load from settings.json | 1505 | // Load from settings.json |
| @@ -1603,6 +1648,7 @@ async function loadPowerUserSettings(settings, data) { | |||
| 1603 | $('#enableLabMode').prop('checked', power_user.enableLabMode).trigger('input', { fromInit: true }); | 1648 | $('#enableLabMode').prop('checked', power_user.enableLabMode).trigger('input', { fromInit: true }); |
| 1604 | $(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop('checked', true); | 1649 | $(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop('checked', true); |
| 1605 | $(`#chat_display option[value=${power_user.chat_display}]`).attr('selected', true).trigger('change'); | 1650 | $(`#chat_display option[value=${power_user.chat_display}]`).attr('selected', true).trigger('change'); |
| 1651 | $(`#toastr_position option[value=${power_user.toastr_position}]`).attr('selected', true).trigger('change'); | ||
| 1606 | $('#chat_width_slider').val(power_user.chat_width); | 1652 | $('#chat_width_slider').val(power_user.chat_width); |
| 1607 | $('#token_padding').val(power_user.token_padding); | 1653 | $('#token_padding').val(power_user.token_padding); |
| 1608 | $('#aux_field').val(power_user.aux_field); | 1654 | $('#aux_field').val(power_user.aux_field); |
| @@ -2372,6 +2418,7 @@ function getThemeObject(name) { | |||
| 2372 | waifuMode: power_user.waifuMode, | 2418 | waifuMode: power_user.waifuMode, |
| 2373 | avatar_style: power_user.avatar_style, | 2419 | avatar_style: power_user.avatar_style, |
| 2374 | chat_display: power_user.chat_display, | 2420 | chat_display: power_user.chat_display, |
| 2421 | toastr_position: power_user.toastr_position, | ||
| 2375 | noShadows: power_user.noShadows, | 2422 | noShadows: power_user.noShadows, |
| 2376 | chat_width: power_user.chat_width, | 2423 | chat_width: power_user.chat_width, |
| 2377 | timer_enabled: power_user.timer_enabled, | 2424 | timer_enabled: power_user.timer_enabled, |
| @@ -3323,6 +3370,14 @@ $(document).ready(() => { | |||
| 3323 | saveSettingsDebounced(); | 3370 | saveSettingsDebounced(); |
| 3324 | }); | 3371 | }); |
| 3325 | 3372 | ||
| 3373 | $('#toastr_position').on('change', function () { | ||
| 3374 | console.error('saw toastr position change'); | ||
| 3375 | const value = $(this).find(':selected').val(); | ||
| 3376 | power_user.toastr_position = String(value); | ||
| 3377 | applyToastrPosition(); | ||
| 3378 | saveSettingsDebounced(); | ||
| 3379 | }); | ||
| 3380 | |||
| 3326 | $('#chat_width_slider').on('input', function (e, data) { | 3381 | $('#chat_width_slider').on('input', function (e, data) { |
| 3327 | const applyMode = data?.forced ? 'forced' : 'normal'; | 3382 | const applyMode = data?.forced ? 'forced' : 'normal'; |
| 3328 | power_user.chat_width = Number(e.target.value); | 3383 | power_user.chat_width = Number(e.target.value); |
| @@ -3933,7 +3933,7 @@ grammarly-extension { | |||
| 3933 | 3933 | ||
| 3934 | /* Override toastr default styles */ | 3934 | /* Override toastr default styles */ |
| 3935 | body #toast-container { | 3935 | body #toast-container { |
| 3936 | top: var(--topBarBlockSize); | 3936 | margin-top: var(--topBarBlockSize); |
| 3937 | } | 3937 | } |
| 3938 | 3938 | ||
| 3939 | body #toast-container>div { | 3939 | body #toast-container>div { |