add option for toastr location to themes

87f547cd87cd940961e71a76cd61ffbcf70a4bdd

RossAscends <124905043+RossAscends@users.noreply.github.com>

4 files changed, +70 -2Showing whitespace changes
public/index.html+11 -0
@@ -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">
public/script.js+3 -1
@@ -321,7 +321,7 @@ toastr.options.timeOut = 4000; // How long the toast will display without user i
321toastr.options.extendedTimeOut = 10000; // How long the toast will display after a user hovers over it321toastr.options.extendedTimeOut = 10000; // How long the toast will display after a user hovers over it
322toastr.options.progressBar = true; // Visually indicate how long before a toast expires.322toastr.options.progressBar = true; // Visually indicate how long before a toast expires.
323toastr.options.closeButton = true; // enable a close button323toastr.options.closeButton = true; // enable a close button
324toastr.options.positionClass = 'toast-top-center'; // Where to position the toast container324//toastr.options.positionClass = power_user.toastr_position; // Where to position the toast container
325toastr.options.onHidden = () => {325toastr.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 though326 // 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 settings7592 // Apply theme toggles from power user settings
7593 applyPowerUserSettings();7593 applyPowerUserSettings();
75947594
7595 toastr.options.positionClass = power_user.toastr_position; // Where to position the toast container
7596
7595 // Load character tags7597 // Load character tags
7596 loadTagsSettings(settings);7598 loadTagsSettings(settings);
75977599
public/scripts/power-user.js+55 -0
@@ -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}
10461047
1048function 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
1047function applyChatWidth(type) {1085function 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}
14571501
1502//MARK: loadPowerUser
1458async function loadPowerUserSettings(settings, data) {1503async 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.json1505 // 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 });
33253372
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);
public/style.css+1 -1
@@ -3933,7 +3933,7 @@ grammarly-extension {
39333933
3934/* Override toastr default styles */3934/* Override toastr default styles */
3935body #toast-container {3935body #toast-container {
3936 top: var(--topBarBlockSize);3936 margin-top: var(--topBarBlockSize);
3937}3937}
39383938
3939body #toast-container>div {3939body #toast-container>div {