Add a separate button to update current UI theme
This commit is contained in:
parent
9b9026b12e
commit
6774ec3eb9
|
@ -2776,9 +2776,12 @@
|
|||
<div class="flex-container flexnowrap alignitemscenter">
|
||||
<select id="themes" class="margin0">
|
||||
</select>
|
||||
<div id="ui-preset-save-button" title="Save changes to a new theme file" data-i18n="[title]Save changes to a new theme file" class="menu_button margin0">
|
||||
<div id="ui-preset-update-button" title="Update a theme file" data-i18n="[title]Update a theme file" class="menu_button margin0">
|
||||
<i class="fa-solid fa-save"></i>
|
||||
</div>
|
||||
<div id="ui-preset-save-button" title="Save as a new theme" data-i18n="[title]Save as a new theme" class="menu_button margin0">
|
||||
<i class="fa-solid fa-paste"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div name="themeElements" data-newbie-hidden class="flex-container flexFlowColumn flexNoGap">
|
||||
|
|
|
@ -1912,11 +1912,26 @@ function sortEntitiesList(entities) {
|
|||
});
|
||||
}
|
||||
|
||||
async function saveTheme() {
|
||||
const name = await callPopup('Enter a theme preset name:', 'input');
|
||||
/**
|
||||
* Updates the current UI theme file.
|
||||
*/
|
||||
async function updateTheme() {
|
||||
await saveTheme(power_user.theme);
|
||||
toastr.success('Theme saved.');
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
/**
|
||||
* Saves the current theme to the server.
|
||||
* @param {string|undefined} name Theme name. If undefined, a popup will be shown to enter a name.
|
||||
* @returns {Promise<void>} A promise that resolves when the theme is saved.
|
||||
*/
|
||||
async function saveTheme(name = undefined) {
|
||||
if (typeof name !== 'string') {
|
||||
name = await callPopup('Enter a theme preset name:', 'input', power_user.theme);
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const theme = {
|
||||
|
@ -2825,7 +2840,8 @@ $(document).ready(() => {
|
|||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#ui-preset-save-button').on('click', saveTheme);
|
||||
$('#ui-preset-save-button').on('click', () => saveTheme());
|
||||
$('#ui-preset-update-button').on('click', () => updateTheme());
|
||||
$('#movingui-preset-save-button').on('click', saveMovingUI);
|
||||
|
||||
$('#never_resize_avatars').on('input', function () {
|
||||
|
|
Loading…
Reference in New Issue