File: /var/www/html/formacion.bdp.com.py-bk/message/amd/build/notification_preference.min.js.map
{"version":3,"file":"notification_preference.min.js","sources":["../src/notification_preference.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Controls the preference for an individual notification type on the\n * message preference page.\n *\n * @module core_message/notification_preference\n * @copyright 2016 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_processor'],\n function($, Ajax, Notification, NotificationProcessor) {\n\n var SELECTORS = {\n PROCESSOR: '[data-processor-name]',\n STATE_INPUTS: '[data-state] input',\n };\n\n /**\n * Constructor for the Preference.\n *\n * @class\n * @param {object} element jQuery object root element of the preference\n * @param {int} userId The current user id\n */\n var NotificationPreference = function(element, userId) {\n this.root = $(element);\n this.userId = userId;\n };\n\n /**\n * Get the unique prefix key that identifies this user preference.\n *\n * @method getPreferenceKey\n * @return {string}\n */\n NotificationPreference.prototype.getPreferenceKey = function() {\n return this.root.attr('data-preference-key');\n };\n\n /**\n * Get the unique key for the logged in preference.\n *\n * @method getLoggedInPreferenceKey\n * @return {string}\n */\n NotificationPreference.prototype.getLoggedInPreferenceKey = function() {\n return this.getPreferenceKey() + '_loggedin';\n };\n\n /**\n * Get the unique key for the logged off preference.\n *\n * @method getLoggedOffPreferenceKey\n * @return {string}\n */\n NotificationPreference.prototype.getLoggedOffPreferenceKey = function() {\n return this.getPreferenceKey() + '_loggedoff';\n };\n\n /**\n * Get the list of Processors available for this preference.\n *\n * @method getProcessors\n * @return {array}\n */\n NotificationPreference.prototype.getProcessors = function() {\n return this.root.find(SELECTORS.PROCESSOR).map(function(index, element) {\n return new NotificationProcessor($(element));\n });\n };\n\n /**\n * Flag the preference as loading.\n *\n * @method startLoading\n */\n NotificationPreference.prototype.startLoading = function() {\n this.root.addClass('loading');\n this.root.find(SELECTORS.STATE_INPUTS).prop('disabled', true);\n };\n\n /**\n * Remove the loading flag for this preference.\n *\n * @method stopLoading\n */\n NotificationPreference.prototype.stopLoading = function() {\n this.root.removeClass('loading');\n this.root.find(SELECTORS.STATE_INPUTS).prop('disabled', false);\n };\n\n /**\n * Check if the preference is loading.\n *\n * @method isLoading\n * @return {Boolean}\n */\n NotificationPreference.prototype.isLoading = function() {\n return this.root.hasClass('loading');\n };\n\n /**\n * Persist the current state of the processors for this preference.\n *\n * @method save\n * @return {object} jQuery promise\n */\n NotificationPreference.prototype.save = function() {\n if (this.isLoading()) {\n return $.Deferred().resolve();\n }\n\n this.startLoading();\n\n var loggedInValue = '';\n var loggedOffValue = '';\n\n this.getProcessors().each(function(index, processor) {\n if (processor.isLoggedInEnabled()) {\n if (loggedInValue === '') {\n loggedInValue = processor.getName();\n } else {\n loggedInValue += ',' + processor.getName();\n }\n }\n\n if (processor.isLoggedOffEnabled()) {\n if (loggedOffValue === '') {\n loggedOffValue = processor.getName();\n } else {\n loggedOffValue += ',' + processor.getName();\n }\n }\n });\n\n if (loggedInValue === '') {\n loggedInValue = 'none';\n }\n\n if (loggedOffValue === '') {\n loggedOffValue = 'none';\n }\n\n var args = {\n userid: this.userId,\n preferences: [\n {\n type: this.getLoggedInPreferenceKey(),\n value: loggedInValue,\n },\n {\n type: this.getLoggedOffPreferenceKey(),\n value: loggedOffValue,\n },\n ],\n };\n\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: args,\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .always(function() {\n this.stopLoading();\n }.bind(this));\n };\n\n return NotificationPreference;\n});\n"],"names":["define","$","Ajax","Notification","NotificationProcessor","SELECTORS","NotificationPreference","element","userId","root","prototype","getPreferenceKey","this","attr","getLoggedInPreferenceKey","getLoggedOffPreferenceKey","getProcessors","find","map","index","startLoading","addClass","prop","stopLoading","removeClass","isLoading","hasClass","save","Deferred","resolve","loggedInValue","loggedOffValue","each","processor","isLoggedInEnabled","getName","isLoggedOffEnabled","request","methodname","args","userid","preferences","type","value","call","fail","exception","always","bind"],"mappings":";;;;;;;;AAuBAA,8CAAO,CAAC,SAAU,YAAa,oBAAqB,wCAC5C,SAASC,EAAGC,KAAMC,aAAcC,2BAEhCC,oBACW,wBADXA,uBAEc,qBAUdC,uBAAyB,SAASC,QAASC,aACtCC,KAAOR,EAAEM,cACTC,OAASA,eASlBF,uBAAuBI,UAAUC,iBAAmB,kBACzCC,KAAKH,KAAKI,KAAK,wBAS1BP,uBAAuBI,UAAUI,yBAA2B,kBACjDF,KAAKD,mBAAqB,aASrCL,uBAAuBI,UAAUK,0BAA4B,kBAClDH,KAAKD,mBAAqB,cASrCL,uBAAuBI,UAAUM,cAAgB,kBACtCJ,KAAKH,KAAKQ,KAAKZ,qBAAqBa,KAAI,SAASC,MAAOZ,gBACpD,IAAIH,sBAAsBH,EAAEM,cAS3CD,uBAAuBI,UAAUU,aAAe,gBACvCX,KAAKY,SAAS,gBACdZ,KAAKQ,KAAKZ,wBAAwBiB,KAAK,YAAY,IAQ5DhB,uBAAuBI,UAAUa,YAAc,gBACtCd,KAAKe,YAAY,gBACjBf,KAAKQ,KAAKZ,wBAAwBiB,KAAK,YAAY,IAS5DhB,uBAAuBI,UAAUe,UAAY,kBAClCb,KAAKH,KAAKiB,SAAS,YAS9BpB,uBAAuBI,UAAUiB,KAAO,cAChCf,KAAKa,mBACExB,EAAE2B,WAAWC,eAGnBT,mBAEDU,cAAgB,GAChBC,eAAiB,QAEhBf,gBAAgBgB,MAAK,SAASb,MAAOc,WAClCA,UAAUC,sBACY,KAAlBJ,c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