%PDF- %PDF-
Direktori : /home/vacivi36/ava/message/amd/build/ |
Current File : /home/vacivi36/ava/message/amd/build/notification_processor_settings.min.js.map |
{"version":3,"file":"notification_processor_settings.min.js","sources":["../src/notification_processor_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 * Load the settings for a message processor.\n *\n * @module core_message/notification_processor_settings\n * @copyright 2016 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/notification',\n 'core/custom_interaction_events',\n 'core/modal',\n 'core/modal_registry',\n 'core/fragment',\n ],\n function(\n $,\n Ajax,\n Str,\n Notification,\n CustomEvents,\n Modal,\n ModalRegistry,\n Fragment\n ) {\n\n var registered = false;\n var SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n PROCESSOR: '[data-processor-name]',\n PREFERENCE_ROW: '[data-region=\"preference-row\"]',\n };\n\n /**\n * Constructor for the Modal.\n *\n * @class\n * @param {object} root The root jQuery element for the modal.\n */\n var NotificationProcessorSettings = function(root) {\n Modal.call(this, root);\n this.name = null;\n this.userId = null;\n this.contextId = null;\n this.element = null;\n this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n this.cancelButton = this.getFooter().find(SELECTORS.CANCEL_BUTTON);\n };\n\n NotificationProcessorSettings.TYPE = 'core_message-notification_processor_settings';\n NotificationProcessorSettings.prototype = Object.create(Modal.prototype);\n NotificationProcessorSettings.prototype.constructor = NotificationProcessorSettings;\n\n /**\n * Set the userid to the given value.\n *\n * @method setUserId\n * @param {int} id The notification userid\n */\n NotificationProcessorSettings.prototype.setUserId = function(id) {\n this.userId = id;\n };\n\n /**\n * Retrieve the current userid, if any.\n *\n * @method getUserId\n * @return {int|null} The notification userid\n */\n NotificationProcessorSettings.prototype.getUserId = function() {\n return this.userId;\n };\n\n /**\n * Set the object to the given value.\n *\n * @method setElement\n * @param {object} element The notification node element.\n */\n NotificationProcessorSettings.prototype.setElement = function(element) {\n this.element = element;\n };\n\n /**\n * Retrieve the current element, if any.\n *\n * @method getElement\n * @return {object|null} The notification node element.\n */\n NotificationProcessorSettings.prototype.getElement = function() {\n return this.element;\n };\n\n /**\n * Set the name to the given value.\n *\n * @method setName\n * @param {string} name The notification name.\n */\n NotificationProcessorSettings.prototype.setName = function(name) {\n this.name = name;\n };\n\n /**\n * Retrieve the current name, if any.\n *\n * @method getName\n * @return {string|null} The notification name.\n */\n NotificationProcessorSettings.prototype.getName = function() {\n return this.name;\n };\n /**\n * Set the context id to the given value.\n *\n * @method setContextId\n * @param {Number} id The notification context id\n */\n NotificationProcessorSettings.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the current context id, if any.\n *\n * @method getContextId\n * @return {Number|null} The notification context id\n */\n NotificationProcessorSettings.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n */\n NotificationProcessorSettings.prototype.getForm = function() {\n return this.getBody().find('form');\n };\n\n /**\n * Disable the buttons in the footer.\n *\n * @method disableButtons\n */\n NotificationProcessorSettings.prototype.disableButtons = function() {\n this.saveButton.prop('disabled', true);\n this.cancelButton.prop('disabled', true);\n };\n\n /**\n * Enable the buttons in the footer.\n *\n * @method enableButtons\n */\n NotificationProcessorSettings.prototype.enableButtons = function() {\n this.saveButton.prop('disabled', false);\n this.cancelButton.prop('disabled', false);\n };\n\n /**\n * Load the title for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadTitleContent\n * @return {object} A promise resolved with the new title text.\n */\n NotificationProcessorSettings.prototype.loadTitleContent = function() {\n this.titlePromise = Str.get_string('processorsettings', 'message');\n this.setTitle(this.titlePromise);\n\n return this.titlePromise;\n };\n\n /**\n * Load the body for the modal to the appropriate value\n * depending on message outputs.\n *\n * @method loadBodyContent\n * @return {object} A promise resolved with the fragment html and js from\n */\n NotificationProcessorSettings.prototype.loadBodyContent = function() {\n this.disableButtons();\n\n var args = {\n userid: this.getUserId(),\n type: this.getName(),\n };\n\n this.bodyPromise = Fragment.loadFragment('message', 'processor_settings', this.getContextId(), args);\n this.setBody(this.bodyPromise);\n\n this.bodyPromise.then(function() {\n this.enableButtons();\n return;\n }.bind(this))\n .fail(Notification.exception);\n\n return this.bodyPromise;\n };\n\n /**\n * Load both the title and body content.\n *\n * @method loadAllContent\n * @return {object} promise\n */\n NotificationProcessorSettings.prototype.loadAllContent = function() {\n return $.when(this.loadTitleContent(), this.loadBodyContent());\n };\n\n /**\n * Load the modal content before showing it. This\n * is to allow us to re-use the same modal for creating and\n * editing different message outputs within the page.\n *\n * @method show\n */\n NotificationProcessorSettings.prototype.show = function() {\n this.loadAllContent();\n Modal.prototype.show.call(this);\n };\n\n /**\n * Clear the notification from the modal when it's closed so\n * that it is loaded fresh next time it's displayed.\n *\n * @method hide\n */\n NotificationProcessorSettings.prototype.hide = function() {\n Modal.prototype.hide.call(this);\n this.setContextId(null);\n this.setName(null);\n this.setUserId(null);\n };\n\n /**\n * Checks if the processor has been configured. If so then remove the unconfigured\n * status from the interface.\n *\n * @method updateConfiguredStatus\n * @return {Promise|boolean}\n */\n NotificationProcessorSettings.prototype.updateConfiguredStatus = function() {\n var processorHeader = $(this.getElement()).closest(SELECTORS.PROCESSOR);\n\n if (!processorHeader.hasClass('unconfigured')) {\n return false;\n }\n\n var processorName = processorHeader.attr('data-processor-name');\n var request = {\n methodname: 'core_message_get_message_processor',\n args: {\n name: processorName,\n userid: this.userId,\n },\n };\n\n return Ajax.call([request])[0]\n .fail(Notification.exception)\n .done(function(result) {\n // Check if the user has figured configuring the processor.\n if (result.userconfigured) {\n // If they have then we can enable the settings.\n var notifications = $(SELECTORS.PREFERENCE_ROW + ' [data-processor-name=\"' + processorName + '\"]');\n processorHeader.removeClass('unconfigured');\n notifications.removeClass('disabled');\n }\n });\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n NotificationProcessorSettings.prototype.registerEventListeners = function() {\n // Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n // When the user clicks the save button we trigger the form submission.\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {\n this.getForm().submit();\n data.originalEvent.preventDefault();\n }.bind(this));\n\n this.getModal().on('mpp:formsubmitted', function(e) {\n this.hide();\n this.updateConfiguredStatus();\n e.stopPropagation();\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function(e, data) {\n this.hide();\n data.originalEvent.preventDefault();\n e.stopPropagation();\n }.bind(this));\n };\n\n // Automatically register with the modal registry the first time this module is imported\n // so that you can create modals\n // of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(\n NotificationProcessorSettings.TYPE,\n NotificationProcessorSettings,\n 'core/modal_save_cancel');\n registered = true;\n }\n\n return NotificationProcessorSettings;\n});\n"],"names":["define","$","Ajax","Str","Notification","CustomEvents","Modal","ModalRegistry","Fragment","registered","SELECTORS","NotificationProcessorSettings","root","call","this","name","userId","contextId","element","saveButton","getFooter","find","cancelButton","TYPE","prototype","Object","create","constructor","setUserId","id","getUserId","setElement","getElement","setName","getName","setContextId","getContextId","getForm","getBody","disableButtons","prop","enableButtons","loadTitleContent","titlePromise","get_string","setTitle","loadBodyContent","args","userid","type","bodyPromise","loadFragment","setBody","then","bind","fail","exception","loadAllContent","when","show","hide","updateConfiguredStatus","processorHeader","closest","hasClass","processorName","attr","request","methodname","done","result","userconfigured","notifications","removeClass","registerEventListeners","getModal","on","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","register"],"mappings":";;;;;;;AAsBAA,sDAAO,CACC,SACA,YACA,WACA,oBACA,iCACA,aACA,sBACA,kBAEA,SACIC,EACAC,KACAC,IACAC,aACAC,aACAC,MACAC,cACAC,cAGJC,YAAa,EACbC,sBACa,uBADbA,wBAEe,yBAFfA,oBAGW,wBAHXA,yBAIgB,iCAShBC,8BAAgC,SAASC,MACzCN,MAAMO,KAAKC,KAAMF,WACZG,KAAO,UACPC,OAAS,UACTC,UAAY,UACZC,QAAU,UACVC,WAAaL,KAAKM,YAAYC,KAAKX,4BACnCY,aAAeR,KAAKM,YAAYC,KAAKX,iCAG9CC,8BAA8BY,KAAO,gDACrCZ,8BAA8Ba,UAAYC,OAAOC,OAAOpB,MAAMkB,YACtBG,YAAchB,8BAQtDA,8BAA8Ba,UAAUI,UAAY,SAASC,SACpDb,OAASa,IASlBlB,8BAA8Ba,UAAUM,UAAY,kBACzChB,KAAKE,QAShBL,8BAA8Ba,UAAUO,WAAa,SAASb,cACrDA,QAAUA,SASnBP,8BAA8Ba,UAAUQ,WAAa,kBAC1ClB,KAAKI,SAShBP,8BAA8Ba,UAAUS,QAAU,SAASlB,WAClDA,KAAOA,MAShBJ,8BAA8Ba,UAAUU,QAAU,kBACvCpB,KAAKC,MAQhBJ,8BAA8Ba,UAAUW,aAAe,SAASN,SACvDZ,UAAYY,IASrBlB,8BAA8Ba,UAAUY,aAAe,kBAC5CtB,KAAKG,WAShBN,8BAA8Ba,UAAUa,QAAU,kBACvCvB,KAAKwB,UAAUjB,KAAK,SAQ/BV,8BAA8Ba,UAAUe,eAAiB,gBAChDpB,WAAWqB,KAAK,YAAY,QAC5BlB,aAAakB,KAAK,YAAY,IAQvC7B,8BAA8Ba,UAAUiB,cAAgB,gBAC/CtB,WAAWqB,KAAK,YAAY,QAC5BlB,aAAakB,KAAK,YA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