From aa9c209e76c6302a0d772277c7c99c948d72edfa Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Mon, 19 Oct 2020 13:08:37 -0400 Subject: [PATCH] Hide stripe load indicator when a redirect response is returned (#5321) Fixes #5055 --- modules/system/assets/js/framework-min.js | 3 ++- modules/system/assets/js/framework.combined-min.js | 3 ++- modules/system/assets/js/framework.js | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/system/assets/js/framework-min.js b/modules/system/assets/js/framework-min.js index a75e43143..3d7146a4c 100644 --- a/modules/system/assets/js/framework-min.js +++ b/modules/system/assets/js/framework-min.js @@ -69,7 +69,8 @@ var fieldElement=$form.find('[name="'+fieldName+'"], [name="'+fieldName+'[]"], [ if(fieldElement.length>0){var _event=jQuery.Event('ajaxInvalidField') $(window).trigger(_event,[fieldElement.get(0),fieldName,fieldMessages,isFirstInvalidField]) if(isFirstInvalidField){if(!_event.isDefaultPrevented())fieldElement.focus() -isFirstInvalidField=false}}})},handleFlashMessage:function(message,type){},handleRedirectResponse:function(url){window.location.assign(url)},handleUpdateResponse:function(data,textStatus,jqXHR){var updatePromise=$.Deferred().done(function(){for(var partial in data){var selector=(options.update[partial])?options.update[partial]:partial +isFirstInvalidField=false}}})},handleFlashMessage:function(message,type){},handleRedirectResponse:function(url){window.location.assign(url) +$el.trigger('ajaxDone')},handleUpdateResponse:function(data,textStatus,jqXHR){var updatePromise=$.Deferred().done(function(){for(var partial in data){var selector=(options.update[partial])?options.update[partial]:partial if($.type(selector)=='string'&&selector.charAt(0)=='@'){$(selector.substring(1)).append(data[partial]).trigger('ajaxUpdate',[context,data,textStatus,jqXHR])} else if($.type(selector)=='string'&&selector.charAt(0)=='^'){$(selector.substring(1)).prepend(data[partial]).trigger('ajaxUpdate',[context,data,textStatus,jqXHR])} else{$(selector).trigger('ajaxBeforeReplace') diff --git a/modules/system/assets/js/framework.combined-min.js b/modules/system/assets/js/framework.combined-min.js index 382a869ec..4aad7c23b 100644 --- a/modules/system/assets/js/framework.combined-min.js +++ b/modules/system/assets/js/framework.combined-min.js @@ -69,7 +69,8 @@ var fieldElement=$form.find('[name="'+fieldName+'"], [name="'+fieldName+'[]"], [ if(fieldElement.length>0){var _event=jQuery.Event('ajaxInvalidField') $(window).trigger(_event,[fieldElement.get(0),fieldName,fieldMessages,isFirstInvalidField]) if(isFirstInvalidField){if(!_event.isDefaultPrevented())fieldElement.focus() -isFirstInvalidField=false}}})},handleFlashMessage:function(message,type){},handleRedirectResponse:function(url){window.location.assign(url)},handleUpdateResponse:function(data,textStatus,jqXHR){var updatePromise=$.Deferred().done(function(){for(var partial in data){var selector=(options.update[partial])?options.update[partial]:partial +isFirstInvalidField=false}}})},handleFlashMessage:function(message,type){},handleRedirectResponse:function(url){window.location.assign(url) +$el.trigger('ajaxDone')},handleUpdateResponse:function(data,textStatus,jqXHR){var updatePromise=$.Deferred().done(function(){for(var partial in data){var selector=(options.update[partial])?options.update[partial]:partial if($.type(selector)=='string'&&selector.charAt(0)=='@'){$(selector.substring(1)).append(data[partial]).trigger('ajaxUpdate',[context,data,textStatus,jqXHR])} else if($.type(selector)=='string'&&selector.charAt(0)=='^'){$(selector.substring(1)).prepend(data[partial]).trigger('ajaxUpdate',[context,data,textStatus,jqXHR])} else{$(selector).trigger('ajaxBeforeReplace') diff --git a/modules/system/assets/js/framework.js b/modules/system/assets/js/framework.js index c97a1554c..afcf8423e 100644 --- a/modules/system/assets/js/framework.js +++ b/modules/system/assets/js/framework.js @@ -288,6 +288,11 @@ if (window.jQuery.request !== undefined) { */ handleRedirectResponse: function(url) { window.location.assign(url) + // Indicate that the AJAX request is finished if we're still on the current page + // so that the loading indicator for redirects that cause a browser to download + // a file instead of leave the page will properly stop. + // @see https://github.com/octobercms/october/issues/5055 + $el.trigger('ajaxDone') }, /* @@ -974,4 +979,4 @@ if (window.jQuery.request !== undefined) { return sanitize(html) }; -}(window); \ No newline at end of file +}(window);