MDL-56426 core_message: prevent page jump when viewing notif. settings
This commit is contained in:
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core_message/notification_preference","core_message/notification_processor_settings"],function(a,b,c,d,e,f){var g={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]"},h=function(b){this.root=a(b),this.userId=this.root.attr("data-user-id"),this.registerEventListeners()};return h.prototype.isDisabled=function(){return this.root.hasClass("disabled")},h.prototype.setDisabled=function(){this.root.addClass("disabled"),this.root.find(g.PREFERENCE_INPUT).prop("disabled",!0)},h.prototype.setEnabled=function(){this.root.removeClass("disabled"),this.root.find(g.PREFERENCE_INPUT).prop("disabled",!1)},h.prototype.toggleDisableAllStatus=function(){var d=a(g.DISABLE_NOTIFICATIONS),e=a(g.DISABLE_NOTIFICATIONS_CONTAINER),f=d.prop("checked");if(e.hasClass("loading"))return a.Deferred().resolve();e.addClass("loading");var h={methodname:"core_user_update_user_preferences",args:{userid:this.userId,emailstop:f?1:0}};return b.call([h])[0].done(function(){f?this.setDisabled():this.setEnabled()}.bind(this)).always(function(){e.removeClass("loading")}).fail(c.exception)},h.prototype.registerEventListeners=function(){var b=a(g.DISABLE_NOTIFICATIONS);d.define(this.root,[d.events.activate]),this.root.on("change",function(b){if(!this.isDisabled()){var c=a(b.target).closest(g.PREFERENCE),d=a(b.target).closest(g.PREFERENCE_ROW),f=new e(d,this.userId);c.addClass("loading"),f.save().always(function(){c.removeClass("loading")})}}.bind(this)),this.root.on(d.events.activate,g.PROCESSOR_SETTING,function(b){var c=a(b.target).closest(g.PROCESSOR_SETTING),d=new f(c);d.show()}),d.define(b,[d.events.activate]),b.on(d.events.activate,function(){this.toggleDisableAllStatus()}.bind(this))},h});
|
||||
define(["jquery","core/ajax","core/notification","core/custom_interaction_events","core_message/notification_preference","core_message/notification_processor_settings"],function(a,b,c,d,e,f){var g={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]"},h=function(b){this.root=a(b),this.userId=this.root.attr("data-user-id"),this.registerEventListeners()};return h.prototype.isDisabled=function(){return this.root.hasClass("disabled")},h.prototype.setDisabled=function(){this.root.addClass("disabled"),this.root.find(g.PREFERENCE_INPUT).prop("disabled",!0)},h.prototype.setEnabled=function(){this.root.removeClass("disabled"),this.root.find(g.PREFERENCE_INPUT).prop("disabled",!1)},h.prototype.toggleDisableAllStatus=function(){var d=a(g.DISABLE_NOTIFICATIONS),e=a(g.DISABLE_NOTIFICATIONS_CONTAINER),f=d.prop("checked");if(e.hasClass("loading"))return a.Deferred().resolve();e.addClass("loading");var h={methodname:"core_user_update_user_preferences",args:{userid:this.userId,emailstop:f?1:0}};return b.call([h])[0].done(function(){f?this.setDisabled():this.setEnabled()}.bind(this)).always(function(){e.removeClass("loading")}).fail(c.exception)},h.prototype.registerEventListeners=function(){var b=a(g.DISABLE_NOTIFICATIONS);d.define(this.root,[d.events.activate]),this.root.on("change",function(b){if(!this.isDisabled()){var c=a(b.target).closest(g.PREFERENCE),d=a(b.target).closest(g.PREFERENCE_ROW),f=new e(d,this.userId);c.addClass("loading"),f.save().always(function(){c.removeClass("loading")})}}.bind(this)),this.root.on(d.events.activate,g.PROCESSOR_SETTING,function(b,c){var d=a(b.target).closest(g.PROCESSOR_SETTING),e=new f(d);e.show(),c.originalEvent.preventDefault()}),d.define(b,[d.events.activate]),b.on(d.events.activate,function(){this.toggleDisableAllStatus()}.bind(this))},h});
|
||||
@@ -143,10 +143,11 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
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);
|
||||
var processorSettings = new NotificationProcessorSettings(element);
|
||||
processorSettings.show();
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
|
||||
CustomEvents.define(disabledNotificationsElement, [
|
||||
|
||||
Reference in New Issue
Block a user