diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-29 23:18:40 +0300 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-04-21 10:29:33 +0300 |
commit | b3cf312edcefec3fb26bad8637f3a0969504be87 (patch) | |
tree | 43397a079ea2b558e23cef722d6abbca11bc7cfb /apps/theming/js | |
parent | 12ed5c9ff3e9dac25b43a1ad934a97a86037000b (diff) |
Start theming providers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/theming/js')
-rw-r--r-- | apps/theming/js/settings-admin.js | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js index 335492fdae2..7efdab6dda4 100644 --- a/apps/theming/js/settings-admin.js +++ b/apps/theming/js/settings-admin.js @@ -28,9 +28,9 @@ function setThemingValue(setting, value) { startLoading(); $.post( OC.generateUrl('/apps/theming/ajax/updateStylesheet'), {'setting' : setting, 'value' : value} - ).done(function(response) { + ).done(function() { hideUndoButton(setting, value); - preview(setting, value, response.data.serverCssUrl); + preview(setting, value); }).fail(function(response) { OC.msg.finishedSaving('#theming_settings_msg', response.responseJSON); $('#theming_settings_loading').hide(); @@ -39,41 +39,31 @@ function setThemingValue(setting, value) { function preview(setting, value, serverCssUrl) { OC.msg.startAction('#theming_settings_msg', t('theming', 'Loading preview…')); - var stylesheetsLoaded = 1; - var reloadStylesheets = function(cssFile) { - var queryString = '?reload=' + new Date().getTime(); - var url = cssFile + queryString; - var old = $('link[href*="' + cssFile + '"]'); - var stylesheet = $("<link/>", { - rel: "stylesheet", - type: "text/css", - href: url - }); - stylesheet.load(function () { - $(old).remove(); - stylesheetsLoaded--; - if(stylesheetsLoaded === 0) { - $('#theming_settings_loading').hide(); - var response = { status: 'success', data: {message: t('theming', 'Saved')}}; - OC.msg.finishedSaving('#theming_settings_msg', response); - } - }); - stylesheet.appendTo("head"); - }; - - if (serverCssUrl !== undefined) { - stylesheetsLoaded++; - reloadStylesheets(serverCssUrl); - } - reloadStylesheets(OC.generateUrl('/apps/theming/styles')); + // Get all theming themes css links and force reload them + [...document.querySelectorAll('link.theme')] + .forEach(theme => { + // Only edit the clone to not remove applied one + var clone = theme.cloneNode() + var url = new URL(clone.href) + // Set current timestamp as cache buster + url.searchParams.set('v', Date.now()) + clone.href = url.toString() + clone.onload = function() { + theme.remove() + } + document.head.append(clone) + }) if (setting === 'name') { window.document.title = t('core', 'Admin') + " - " + value; } - + + // Finish + $('#theming_settings_loading').hide(); + var response = { status: 'success', data: {message: t('theming', 'Saved')}}; + OC.msg.finishedSaving('#theming_settings_msg', response); hideUndoButton(setting, value); - } function hideUndoButton(setting, value) { |