From 4eb53e63e9940cee26e7b5dd7d0f76be13aa1f6b Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 20 Dec 2018 15:57:20 +0000 Subject: [PATCH] [IMP] website: review customize loading Before this commit, the loading was shown during colorpicker choice or body image choice too, which makes no sense. This commit also make a new loading visual which is less intrusive and flicker less. PR https://github.com/odoo/odoo/pull/29624 task-1904244 --- addons/website/static/src/js/widgets/theme.js | 24 +++++++++++++------ .../static/src/scss/website.edit_mode.scss | 11 --------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index 380a19d936a..5bbb65cee75 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -464,6 +464,9 @@ var ThemeCustomizeDialog = Dialog.extend({ * @private */ _updateStyle: function (enable, disable, reload) { + var $loading = $('', {class: 'fa fa-refresh fa-spin'}); + this.$modal.find('.modal-title').append($loading); + if (reload || config.debug === 'assets') { window.location.href = $.param.querystring('/website/theme_customize_reload', { href: window.location.href, @@ -482,9 +485,11 @@ var ThemeCustomizeDialog = Dialog.extend({ 'get_bundle': true, }, }).then(function (bundles) { + var $allLinks = $(); var defs = _.map(bundles, function (bundleContent, bundleName) { var linkSelector = 'link[href*="' + bundleName + '"]'; var $links = $(linkSelector); + $allLinks = $allLinks.add($links); var $newLinks = $(bundleContent).filter(linkSelector); var linksLoaded = $.Deferred(); @@ -500,12 +505,13 @@ var ThemeCustomizeDialog = Dialog.extend({ window.location.reload(); }); $links.last().after($newLinks); - return linksLoaded.then(function () { - $links.remove(); - }); + return linksLoaded; }); - return $.when.apply($, defs); + return $.when.apply($, defs).always(function () { + $loading.remove(); + $allLinks.remove(); + }); }); }, @@ -522,6 +528,11 @@ var ThemeCustomizeDialog = Dialog.extend({ // Checkout the option that changed var $option = $(ev.currentTarget); + if ($option.is(':disabled')) { + return; + } + this.$inputs.prop('disabled', true); + var $options = $option; var checked = $option.is(':checked'); @@ -552,15 +563,14 @@ var ThemeCustomizeDialog = Dialog.extend({ this._setActive(); // Update the style according to the whole set of options - this.$modal.addClass('o_theme_customize_loading'); self._processChange($options).then(function () { return self._updateStyle( self._getXMLIDs($enable), self._getXMLIDs($disable), $option.data('reload') && window.location.href.match(new RegExp($option.data('reload'))) ); - }).always(function () { - self.$modal.removeClass('o_theme_customize_loading'); + }).then(function () { + self.$inputs.prop('disabled', false); }); }, }); diff --git a/addons/website/static/src/scss/website.edit_mode.scss b/addons/website/static/src/scss/website.edit_mode.scss index 60536b74bed..2d0254beb2b 100644 --- a/addons/website/static/src/scss/website.edit_mode.scss +++ b/addons/website/static/src/scss/website.edit_mode.scss @@ -6,17 +6,6 @@ } .modal.o_theme_customize_modal { - - &.o_theme_customize_loading { - pointer-events: none; - - &::after { - content: ""; - @include o-position-absolute(0, 0, 0, 0); - background-color: rgba(0, 0, 0, 0.2); - } - } - .modal-dialog { @include o-position-absolute(0, 2%); width: 96%;