File: /var/www/html/formacion.bdp.com.py-bk/message/amd/build/message_drawer_view_settings.min.js.map
{"version":3,"file":"message_drawer_view_settings.min.js","sources":["../src/message_drawer_view_settings.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 settings page in the message drawer.\n *\n * @module core_message/message_drawer_view_settings\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/notification',\n 'core/str',\n 'core/pubsub',\n 'core/templates',\n 'core_message/message_repository',\n 'core/custom_interaction_events',\n 'core_message/message_drawer_events'\n],\nfunction(\n $,\n Notification,\n Str,\n PubSub,\n Templates,\n Repository,\n CustomEvents,\n MessageDrawerEvents\n) {\n\n var SELECTORS = {\n CHECKBOX: 'input[type=\"checkbox\"]',\n SETTINGS: '[data-region=\"settings\"]',\n PRIVACY_PREFERENCE: '[data-preference=\"blocknoncontacts\"] input[type=\"radio\"]',\n NOTIFICATIONS_PREFERENCE: '[data-preference=\"notifications\"] input[type=\"checkbox\"]',\n ENTER_TO_SEND_PREFERENCE: '[data-preference=\"entertosend\"] input[type=\"checkbox\"]',\n NOTIFICATION_PREFERENCES_CONTAINER: '[data-region=\"notification-preference-container\"]',\n CONTENT_CONTAINER: '[data-region=\"content-container\"]',\n PLACEHOLDER_CONTAINER: '[data-region=\"placeholder-container\"]'\n };\n\n var TEMPLATES = {\n NOTIFICATION_PREFERENCES: 'core_message/message_drawer_view_settings_body_content_notification_preferences'\n };\n\n var NOTIFICATION_PREFERENCES_KEY = 'message_provider_moodle_instantmessage';\n\n /**\n * Select the correct radio button in the DOM for the privacy preference.\n *\n * @param {Object} body The settings body element.\n * @param {Number} value Which radio button should be set\n */\n var setPrivacyPreference = function(body, value) {\n var inputs = body.find(SELECTORS.PRIVACY_PREFERENCE);\n inputs.each(function(index, input) {\n input = $(input);\n if (input.val() == value) {\n input.prop('checked', true);\n } else {\n input.prop('checked', false);\n }\n });\n };\n\n /**\n * Set the \"enter to send\" checkbox to the correct value in the DOM.\n *\n * @param {Object} body The settings body element.\n * @param {Bool} value Whether enter to send is enabled or disabled.\n */\n var setEnterToSend = function(body, value) {\n var checkbox = body.find(SELECTORS.ENTER_TO_SEND_PREFERENCE);\n\n if (value) {\n checkbox.prop('checked', true);\n } else {\n checkbox.prop('checked', false);\n }\n };\n\n /**\n * Send a request to the server to save the given preferences. Also publish\n * a preferences updated event for the rest of the message drawer to\n * subscribe to.\n *\n * @param {Number} loggedInUserId The logged in user id.\n * @param {Array} preferences The preferences to set.\n * @return {Object} jQuery promise\n */\n var savePreferences = function(loggedInUserId, preferences) {\n return Repository.savePreferences(loggedInUserId, preferences)\n .then(function() {\n PubSub.publish(MessageDrawerEvents.PREFERENCES_UPDATED, preferences);\n return;\n })\n .catch(Notification.exception);\n };\n\n /**\n * Create all of the event listeners for the message preferences page.\n *\n * @method registerEventListeners\n * @param {Object} body The settings body element.\n * @param {Number} loggedInUserId The logged in user id.\n */\n var registerEventListeners = function(body, loggedInUserId) {\n var settingsContainer = body.find(SELECTORS.SETTINGS);\n\n CustomEvents.define(settingsContainer, [\n CustomEvents.events.activate\n ]);\n\n settingsContainer.on(CustomEvents.events.activate, SELECTORS.NOTIFICATIONS_PREFERENCE, function(e) {\n var container = $(e.target).closest(SELECTORS.NOTIFICATION_PREFERENCES_CONTAINER);\n var checkboxes = container.find(SELECTORS.CHECKBOX);\n if (!checkboxes.length) {\n return;\n }\n // The preference value is all of the enabled processors, comma separated, so let's\n // see which ones are enabled.\n var values = checkboxes.toArray().reduce(function(carry, checkbox) {\n checkbox = $(checkbox);\n if (checkbox.prop('checked')) {\n carry.push(checkbox.attr('data-name'));\n }\n\n return carry;\n }, []);\n var newValue = values.length ? values.join(',') : 'none';\n var preferences = [\n {\n type: 'message_provider_moodle_instantmessage_loggedoff',\n value: newValue\n },\n {\n type: 'message_provider_moodle_instantmessage_loggedin',\n value: newValue\n }\n ];\n\n savePreferences(loggedInUserId, preferences);\n });\n\n settingsContainer.on('change', SELECTORS.PRIVACY_PREFERENCE, function(e) {\n var newValue = $(e.target).val();\n var preferences = [\n {\n type: 'message_blocknoncontacts',\n value: newValue\n }\n ];\n\n savePreferences(loggedInUserId, preferences);\n });\n\n settingsContainer.on(CustomEvents.events.activate, SELECTORS.ENTER_TO_SEND_PREFERENCE, function(e) {\n var newValue = $(e.target).prop('checked');\n var preferences = [\n {\n type: 'message_entertosend',\n value: newValue\n }\n ];\n\n savePreferences(loggedInUserId, preferences);\n });\n };\n\n /**\n * Initialise the module by loading the user's messaging preferences from the server and\n * rendering them in the settings page.\n *\n * Moodle may have many (or no) message processors enabled to notify the user when they\n * receive messages. We need to dynamically build the settings page based on which processors\n * are configured for the user.\n *\n * @param {Object} body The settings body element.\n * @param {Number} loggedInUserId The logged in user id.\n */\n var init = function(body, loggedInUserId) {\n // Load the message preferences from the server.\n Repository.getUserMessagePreferences(loggedInUserId)\n .then(function(response) {\n // Set the values of the stright forward preferences.\n setPrivacyPreference(body, response.blocknoncontacts);\n setEnterToSend(body, response.entertosend);\n\n // Parse the list of other preferences into a more usable format.\n var notificationProcessors = [];\n if (response.preferences.components.length) {\n response.preferences.components.forEach(function(component) {\n if (component.notifications.length) {\n // Filter down to just the notification processors that work on instant\n // messaging. We don't care about another other ones.\n var notificationPreferences = component.notifications.filter(function(notification) {\n return notification.preferencekey == NOTIFICATION_PREFERENCES_KEY;\n });\n\n if (notificationPreferences.length) {\n // Messaging only has one config at the moment which is for notifications\n // on personal messages.\n var configuration = component.notifications[0];\n notificationProcessors = configuration.processors.map(function(processor) {\n // Consider the the processor enabled if either preference is set. This is\n // for backwards compatibility. Going forward they will be treated as one\n // setting.\n var checked = processor.loggedin.checked || processor.loggedoff.checked;\n return {\n displayname: processor.displayname,\n name: processor.name,\n checked: checked,\n // The admin can force processors to be enabled at a site level so\n // we need to check if this processor has been locked by the admin.\n locked: processor.locked,\n lockedmessage: processor.lockedmessage || null,\n };\n });\n }\n }\n });\n }\n\n var container = body.find(SELECTORS.NOTIFICATION_PREFERENCES_CONTAINER);\n if (notificationProcessors.length) {\n // We have processors (i.e. email, mobile, jabber) to show.\n container.removeClass('hidden');\n // Render the processor options.\n return Templates.render(TEMPLATES.NOTIFICATION_PREFERENCES, {processors: notificationProcessors})\n .then(function(html) {\n container.append(html);\n return html;\n });\n } else {\n return true;\n }\n })\n .then(function() {\n // We're done loading so hide the loading placeholder and show the settings.\n body.find(SELECTORS.CONTENT_CONTAINER).removeClass('hidden');\n body.find(SELECTORS.PLACEHOLDER_CONTAINER).addClass('hidden');\n // Register the event listers for if the user wants to change the preferences.\n registerEventListeners(body, loggedInUserId);\n return;\n })\n .catch(Notification.exception);\n };\n\n /**\n * Initialise the settings page by adding event listeners to\n * the checkboxes.\n *\n * @param {string} namespace The route namespace.\n * @param {Object} header The settings header element.\n * @param {Object} body The settings body element.\n * @param {Object} footer The footer body element.\n * @param {Number} loggedInUserId The logged in user id.\n * @return {Object} jQuery promise\n */\n var show = function(namespace, header, body, footer, loggedInUserId) {\n if (!body.attr('data-init')) {\n init(body, loggedInUserId);\n body.attr('data-init', true);\n }\n\n return $.Deferred().resolve().promise();\n };\n\n /**\n * String describing this page used for aria-labels.\n *\n * @return {Object} jQuery promise\n */\n var description = function() {\n return Str.get_string('messagedrawerviewsettings', 'core_message');\n };\n\n return {\n show: show,\n description: description,\n };\n});\n"],"names":["define","$","Notification","Str","PubSub","Templates","Repository","CustomEvents","MessageDrawerEvents","SELECTORS","TEMPLATES","savePreferences","loggedInUserId","preferences","then","publish","PREFERENCES_UPDATED","catch","exception","init","body","getUserMessagePreferences","response","value","find","each","index","input","val","prop","setPrivacyPreference","blocknoncontacts","checkbox","setEnterToSend","entertosend","notificationProcessors","components","length","forEach","component","notifications","filter","notification","preferencekey","configuration","processors","map","processor","checked","loggedin","loggedoff","displayname","name","locked","lockedmessage","container","removeClass","render","html","append","addClass","settingsContainer","events","activate","on","e","checkboxes","target","closest","values","toArray","reduce","carry","push","attr","newValue","join","type","registerEventListeners","show","namespace","header","footer","Deferred","resolve","promise","description","get_string"],"mappings":";;;;;;;AAsBAA,mDACA,CACI,SACA,oBACA,WACA,cACA,iBACA,kCACA,iCACA,uCAEJ,SACIC,EACAC,aACAC,IACAC,OACAC,UACAC,WACAC,aACAC,yBAGIC,mBACU,yBADVA,mBAEU,2BAFVA,6BAGoB,2DAHpBA,mCAI0B,2DAJ1BA,mCAK0B,yDAL1BA,6CAMoC,oDANpCA,4BAOmB,oCAPnBA,gCAQuB,wCAGvBC,mCAC0B,kFAgD1BC,gBAAkB,SAASC,eAAgBC,oBACpCP,WAAWK,gBAAgBC,eAAgBC,aAC7CC,MAAK,WACFV,OAAOW,QAAQP,oBAAoBQ,oBAAqBH,gBAG3DI,MAAMf,aAAagB,YAoFxBC,KAAO,SAASC,KAAMR,gBAEtBN,WAAWe,0BAA0BT,gBAChCE,MAAK,SAASQ,WAlII,SAASF,KAAMG,OACzBH,KAAKI,KAAKf,8BAChBgB,MAAK,SAASC,MAAOC,QACxBA,MAAQ1B,EAAE0B,QACAC,OAASL,MACfI,MAAME,KAAK,WAAW,GAEtBF,MAAME,KAAK,WAAW,MA6HtBC,CAAqBV,KAAME,SAASS,kBAlH3B,SAASX,KAAMG,WAC5BS,SAAWZ,KAAKI,KAAKf,oCAErBc,MACAS,SAASH,KAAK,WAAW,GAEzBG,SAASH,KAAK,WAAW,GA6GrBI,CAAeb,KAAME,SAASY,iBAG1BC,uBAAyB,GACzBb,SAAST,YAAYuB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