diff options
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) { |