Current Path : /var/www/ljmtc/cbt/message/amd/build/ |
Current File : /var/www/ljmtc/cbt/message/amd/build/message_preferences.min.js.map |
{"version":3,"sources":["../src/message_preferences.js"],"names":["define","$","Ajax","Notification","MessageNotificationPreference","CustomEvents","SELECTORS","PREFERENCE","PREFERENCES_CONTAINER","CONTACTABLE_PRIVACY_CONTAINER","MessagePreferences","element","root","userId","find","attr","registerEventListeners","prototype","preferencesDisabled","hasClass","saveContactablePrivacySetting","container","value","val","Deferred","resolve","addClass","request","methodname","args","userid","preferences","type","call","fail","exception","always","removeClass","events","activate","on","e","target","name","preferencesContainer","closest","preferenceElement","messagePreference","save","bind"],"mappings":"AAwBAA,OAAM,oCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,mBAAxB,CACC,8CADD,CACiD,gCADjD,CAAD,CAEE,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAgCC,CAAhC,CAA+DC,CAA/D,CAA6E,IAE7EC,CAAAA,CAAS,CAAG,CACZC,UAAU,CAAE,cADA,CAEZC,qBAAqB,CAAE,yCAFX,CAGZC,6BAA6B,CAAE,6CAHnB,CAFiE,CAa7EC,CAAkB,CAAG,SAASC,CAAT,CAAkB,CACvC,KAAKC,IAAL,CAAYX,CAAC,CAACU,CAAD,CAAb,CACA,KAAKE,MAAL,CAAc,KAAKD,IAAL,CAAUE,IAAV,CAAeR,CAAS,CAACE,qBAAzB,EAAgDO,IAAhD,CAAqD,cAArD,CAAd,CAEA,KAAKC,sBAAL,EACH,CAlBgF,CA0BjFN,CAAkB,CAACO,SAAnB,CAA6BC,mBAA7B,CAAmD,UAAW,CAC1D,MAAO,MAAKN,IAAL,CAAUE,IAAV,CAAeR,CAAS,CAACE,qBAAzB,EAAgDW,QAAhD,CAAyD,UAAzD,CACV,CAFD,CAWAT,CAAkB,CAACO,SAAnB,CAA6BG,6BAA7B,CAA6D,UAAW,IAChEC,CAAAA,CAAS,CAAG,KAAKT,IAAL,CAAUE,IAAV,CAAeR,CAAS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AC,CAACwC,CAAC,CAACC,MAAH,CAAD,CAAYG,OAAZ,CAAoBvC,CAAS,CAACC,UAA9B,CAFK,CAGzBwC,CAAiB,CAAG,GAAI3C,CAAAA,CAAJ,CAAkCwC,CAAlC,CAAwD,KAAK/B,MAA7D,CAHK,CAK7BiC,CAAiB,CAACpB,QAAlB,CAA2B,SAA3B,EACAqB,CAAiB,CAACC,IAAlB,GAAyBZ,MAAzB,CAAgC,UAAW,CACvCU,CAAiB,CAACT,WAAlB,CAA8B,SAA9B,CACH,CAFD,CAGH,CACJ,CACJ,CAjBsB,CAiBrBY,IAjBqB,CAiBhB,IAjBgB,CAAvB,CAkBH,CAvBD,CAyBA,MAAOvC,CAAAA,CACV,CApGK,CAAN","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 message preference page.\n *\n * @module core_message/message_preferences\n * @class message_preferences\n * @package message\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',\n 'core_message/message_notification_preference', 'core/custom_interaction_events'],\n function($, Ajax, Notification, MessageNotificationPreference, CustomEvents) {\n\n var SELECTORS = {\n PREFERENCE: '[data-state]',\n PREFERENCES_CONTAINER: '[data-region=\"preferences-container\"]',\n CONTACTABLE_PRIVACY_CONTAINER: '[data-region=\"privacy-setting-container\"]',\n };\n\n /**\n * Constructor for the MessagePreferences.\n *\n * @param {object} element The root element for the message preferences\n */\n var MessagePreferences = function(element) {\n this.root = $(element);\n this.userId = this.root.find(SELECTORS.PREFERENCES_CONTAINER).attr('data-user-id');\n\n this.registerEventListeners();\n };\n\n /**\n * Check if the preferences have been disabled on this page.\n *\n * @method preferencesDisabled\n * @return {bool}\n */\n MessagePreferences.prototype.preferencesDisabled = function() {\n return this.root.find(SELECTORS.PREFERENCES_CONTAINER).hasClass('disabled');\n };\n\n /**\n * Update the contactable privacy user preference in the DOM and\n * send a request to update on the server.\n *\n * @return {Promise}\n * @method saveContactablePrivacySetting\n */\n MessagePreferences.prototype.saveContactablePrivacySetting = function() {\n var container = this.root.find(SELECTORS.CONTACTABLE_PRIVACY_CONTAINER);\n var value = $(\"input[type='radio']:checked\").val();\n\n if (container.hasClass('loading')) {\n return $.Deferred().resolve();\n }\n\n container.addClass('loading');\n\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n userid: this.userId,\n preferences: [\n {\n type: container.attr('data-preference-key'),\n value: value,\n }\n ]\n }\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .always(function() {\n container.removeClass('loading');\n });\n };\n\n /**\n * Create all of the event listeners for the message preferences page.\n *\n * @method registerEventListeners\n */\n MessagePreferences.prototype.registerEventListeners = function() {\n CustomEvents.define(this.root, [\n CustomEvents.events.activate\n ]);\n\n this.root.on('change', function(e) {\n // Add listener for privacy setting radio buttons change.\n if (e.target.name == 'message_blocknoncontacts') {\n this.saveContactablePrivacySetting();\n } else {\n // Add listener for processor preferences.\n if (!this.preferencesDisabled()) {\n var preferencesContainer = $(e.target).closest(SELECTORS.PREFERENCES_CONTAINER);\n var preferenceElement = $(e.target).closest(SELECTORS.PREFERENCE);\n var messagePreference = new MessageNotificationPreference(preferencesContainer, this.userId);\n\n preferenceElement.addClass('loading');\n messagePreference.save().always(function() {\n preferenceElement.removeClass('loading');\n });\n }\n }\n }.bind(this));\n };\n\n return MessagePreferences;\n});\n"],"file":"message_preferences.min.js"}