MDL-72071 message: preserve window scroll opening processor modal.

This commit is contained in:
Paul Holden 2021-07-01 20:37:38 +01:00
parent 206023c15f
commit b95dd8c5db
3 changed files with 5 additions and 4 deletions

View File

@ -1,2 +1,2 @@
define ("core_message/preferences_notifications_list_controller",["jquery","core/ajax","core/notification","core/custom_interaction_events","core_message/notification_preference","core_message/notification_processor_settings","core/modal_factory"],function(a,b,c,d,f,g,h){var i={DISABLE_NOTIFICATIONS:"[data-region=\"disable-notification-container\"] [data-disable-notifications]",DISABLE_NOTIFICATIONS_CONTAINER:"[data-region=\"disable-notification-container\"]",PREFERENCE:"[data-state]",PREFERENCE_ROW:"[data-region=\"preference-row\"]",PREFERENCE_INPUT:"[data-state] input",PROCESSOR_SETTING:"[data-processor-setting]"},j=function(b){this.root=a(b);this.userId=this.root.attr("data-user-id");this.registerEventListeners()};j.prototype.isDisabled=function(){return this.root.hasClass("disabled")};j.prototype.setDisabled=function(){this.root.addClass("disabled");this.root.find(i.PREFERENCE_INPUT).prop("disabled",!0)};j.prototype.setEnabled=function(){this.root.removeClass("disabled");this.root.find(i.PREFERENCE_INPUT).prop("disabled",!1)};j.prototype.toggleDisableAllStatus=function(){var d=a(i.DISABLE_NOTIFICATIONS),e=a(i.DISABLE_NOTIFICATIONS_CONTAINER),f=d.prop("checked");if(e.hasClass("loading")){return a.Deferred().resolve()}e.addClass("loading");var g={methodname:"core_user_update_user_preferences",args:{userid:this.userId,emailstop:f?1:0}};return b.call([g])[0].done(function(){if(f){this.setDisabled()}else{this.setEnabled()}}.bind(this)).always(function(){e.removeClass("loading")}).fail(c.exception)};j.prototype.registerEventListeners=function(){var b=a(i.DISABLE_NOTIFICATIONS);d.define(this.root,[d.events.activate]);this.root.on("change",function(b){if(!this.isDisabled()){var c=a(b.target).closest(i.PREFERENCE),d=a(b.target).closest(i.PREFERENCE_ROW),e=new f(d,this.userId);c.addClass("loading");e.save().always(function(){c.removeClass("loading")})}}.bind(this));var j=h.create({type:g.TYPE});this.root.on(d.events.activate,i.PROCESSOR_SETTING,function(b){var d=a(b.target).closest(i.PROCESSOR_SETTING);b.preventDefault();j.then(function(c){c.setUserId(a(d).attr("data-user-id"));c.setName(a(d).attr("data-name"));c.setContextId(a(d).attr("data-context-id"));c.setElement(d);c.show();b.stopImmediatePropagation()}).fail(c.exception)});d.define(b,[d.events.activate]);b.on(d.events.activate,function(){this.toggleDisableAllStatus()}.bind(this))};return j});
define ("core_message/preferences_notifications_list_controller",["jquery","core/ajax","core/notification","core/custom_interaction_events","core_message/notification_preference","core_message/notification_processor_settings","core/modal_factory"],function(a,b,c,d,f,g,h){var i={DISABLE_NOTIFICATIONS:"[data-region=\"disable-notification-container\"] [data-disable-notifications]",DISABLE_NOTIFICATIONS_CONTAINER:"[data-region=\"disable-notification-container\"]",PREFERENCE:"[data-state]",PREFERENCE_ROW:"[data-region=\"preference-row\"]",PREFERENCE_INPUT:"[data-state] input",PROCESSOR_SETTING:"[data-processor-setting]"},j=function(b){this.root=a(b);this.userId=this.root.attr("data-user-id");this.registerEventListeners()};j.prototype.isDisabled=function(){return this.root.hasClass("disabled")};j.prototype.setDisabled=function(){this.root.addClass("disabled");this.root.find(i.PREFERENCE_INPUT).prop("disabled",!0)};j.prototype.setEnabled=function(){this.root.removeClass("disabled");this.root.find(i.PREFERENCE_INPUT).prop("disabled",!1)};j.prototype.toggleDisableAllStatus=function(){var d=a(i.DISABLE_NOTIFICATIONS),e=a(i.DISABLE_NOTIFICATIONS_CONTAINER),f=d.prop("checked");if(e.hasClass("loading")){return a.Deferred().resolve()}e.addClass("loading");var g={methodname:"core_user_update_user_preferences",args:{userid:this.userId,emailstop:f?1:0}};return b.call([g])[0].done(function(){if(f){this.setDisabled()}else{this.setEnabled()}}.bind(this)).always(function(){e.removeClass("loading")}).fail(c.exception)};j.prototype.registerEventListeners=function(){var b=a(i.DISABLE_NOTIFICATIONS);d.define(this.root,[d.events.activate]);this.root.on("change",function(b){if(!this.isDisabled()){var c=a(b.target).closest(i.PREFERENCE),d=a(b.target).closest(i.PREFERENCE_ROW),e=new f(d,this.userId);c.addClass("loading");e.save().always(function(){c.removeClass("loading")})}}.bind(this));var j=h.create({type:g.TYPE});this.root.on(d.events.activate,i.PROCESSOR_SETTING,function(b,d){var e=a(b.target).closest(i.PROCESSOR_SETTING);d.originalEvent.preventDefault();j.then(function(c){c.setUserId(a(e).attr("data-user-id"));c.setName(a(e).attr("data-name"));c.setContextId(a(e).attr("data-context-id"));c.setElement(e);c.show();b.stopImmediatePropagation()}).fail(c.exception)});d.define(b,[d.events.activate]);b.on(d.events.activate,function(){this.toggleDisableAllStatus()}.bind(this))};return j});
//# sourceMappingURL=preferences_notifications_list_controller.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -160,10 +160,11 @@ define(['jquery',
type: NotificationProcessorSettings.TYPE,
});
this.root.on(CustomEvents.events.activate, SELECTORS.PROCESSOR_SETTING, function(e) {
this.root.on(CustomEvents.events.activate, SELECTORS.PROCESSOR_SETTING, function(e, data) {
var element = $(e.target).closest(SELECTORS.PROCESSOR_SETTING);
e.preventDefault();
data.originalEvent.preventDefault();
eventFormPromise.then(function(modal) {
// Configure modal with element settings.
modal.setUserId($(element).attr('data-user-id'));