You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.5 KiB
1 line
1.5 KiB
2 years ago
|
define(["jquery","core/ajax","core/notification","core_message/notification_processor"],function(a,b,c,d){var e={PROCESSOR:"[data-processor-name]",STATE_INPUTS:"[data-state] input"},f=function(b,c){this.root=a(b),this.userId=c};return f.prototype.getPreferenceKey=function(){return this.root.attr("data-preference-key")},f.prototype.getLoggedInPreferenceKey=function(){return this.getPreferenceKey()+"_loggedin"},f.prototype.getLoggedOffPreferenceKey=function(){return this.getPreferenceKey()+"_loggedoff"},f.prototype.getProcessors=function(){return this.root.find(e.PROCESSOR).map(function(b,c){return new d(a(c))})},f.prototype.startLoading=function(){this.root.addClass("loading"),this.root.find(e.STATE_INPUTS).prop("disabled",!0)},f.prototype.stopLoading=function(){this.root.removeClass("loading"),this.root.find(e.STATE_INPUTS).prop("disabled",!1)},f.prototype.isLoading=function(){return this.root.hasClass("loading")},f.prototype.save=function(){if(this.isLoading())return a.Deferred().resolve();this.startLoading();var d="",e="";this.getProcessors().each(function(a,b){b.isLoggedInEnabled()&&(""===d?d=b.getName():d+=","+b.getName()),b.isLoggedOffEnabled()&&(""===e?e=b.getName():e+=","+b.getName())}),""===d&&(d="none"),""===e&&(e="none");var f={userid:this.userId,preferences:[{type:this.getLoggedInPreferenceKey(),value:d},{type:this.getLoggedOffPreferenceKey(),value:e}]},g={methodname:"core_user_update_user_preferences",args:f};return b.call([g])[0].fail(c.exception).always(function(){this.stopLoading()}.bind(this))},f});
|