moodle/message/amd/build/message_preferences.min.js.map
2023-03-09 09:53:19 +08:00

1 line
6.1 KiB
Plaintext

{"version":3,"file":"message_preferences.min.js","sources":["../src/message_preferences.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 message preference page.\n *\n * @module core_message/message_preferences\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 * @class\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"],"names":["define","$","Ajax","Notification","MessageNotificationPreference","CustomEvents","SELECTORS","MessagePreferences","element","root","userId","this","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":";;;;;;;AAsBAA,0CAAO,CAAC,SAAU,YAAa,oBACvB,+CAAgD,mCAChD,SAASC,EAAGC,KAAMC,aAAcC,8BAA+BC,kBAE/DC,qBACY,eADZA,gCAEuB,wCAFvBA,wCAG+B,4CAS/BC,mBAA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