Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/ |
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/actionselector.min.js.map |
{"version":3,"sources":["../src/actionselector.js"],"names":["define","$","Notification","Ajax","Templates","Dialogue","EventBase","ActionSelector","title","message","actions","confirm","cancel","self","prototype","constructor","apply","_title","_message","_actions","_confirm","_cancel","_selectedValue","_reset","Object","create","_popup","_afterRender","_find","attr","change","val","removeAttr","_refresh","bind","click","e","preventDefault","close","length","_trigger","action","display","_render","then","html","fail","exception","selector","getContent","find","replaceWith","choices","i","push","content","render"],"mappings":"AA2BAA,OAAM,0BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,kBAJD,CAKC,oBALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAqDC,CAArD,CAAgE,CAUpE,GAAIC,CAAAA,CAAc,CAAG,SAASC,CAAT,CAAgBC,CAAhB,CAAyBC,CAAzB,CAAkCC,CAAlC,CAA2CC,CAA3C,CAAmD,CACpE,GAAIC,CAAAA,CAAI,CAAG,IAAX,CAEAP,CAAS,CAACQ,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,CAAsC,IAAtC,CAA4C,EAA5C,EACAH,CAAI,CAACI,MAAL,CAAcT,CAAd,CACAK,CAAI,CAACK,QAAL,CAAgBT,CAAhB,CACAI,CAAI,CAACM,QAAL,CAAgBT,CAAhB,CACAG,CAAI,CAACO,QAAL,CAAgBT,CAAhB,CACAE,CAAI,CAACQ,OAAL,CAAeT,CAAf,CACAC,CAAI,CAACS,cAAL,CAAsB,IAAtB,CACAT,CAAI,CAACU,MAAL,EACH,CAXD,CAaAhB,CAAc,CAACO,SAAf,CAA2BU,MAAM,CAACC,MAAP,CAAcnB,CAAS,CAACQ,SAAxB,CAA3B,CAGAP,CAAc,CAACO,SAAf,CAAyBQ,cAAzB,CAA0C,IAA1C,CA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AT,GAAcxC,CAAAA,CAAI,CAACM,QAAnB,CAA6B,CACzBiC,CAAO,CAACE,IAAR,CAAazC,CAAI,CAACM,QAAL,CAAckC,CAAd,CAAb,CACH,CACD,GAAIE,CAAAA,CAAO,CAAG,CAAC,QAAW1C,CAAI,CAACK,QAAjB,CAA2B,QAAWkC,CAAtC,CACV,QAAWvC,CAAI,CAACO,QADN,CACgB,OAAUP,CAAI,CAACQ,OAD/B,CAAd,CAGA,MAAOjB,CAAAA,CAAS,CAACoD,MAAV,CAAiB,yBAAjB,CAA4CD,CAA5C,CACV,CAVD,CAmBAhD,CAAc,CAACO,SAAf,CAAyBS,MAAzB,CAAkC,UAAW,CACzC,KAAKG,MAAL,CAAc,IAAd,CACA,KAAKJ,cAAL,CAAsB,EACzB,CAHD,CAKA,MAAmDf,CAAAA,CAEtD,CAxKK,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 * Action selector.\n *\n * To handle 'save' events use: actionselector.on('save')\n * This will receive the information to display in popup.\n * The actions have the format [{'text': sometext, 'value' : somevalue}].\n *\n * @package tool_lp\n * @copyright 2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base'],\n function($, Notification, Ajax, Templates, Dialogue, EventBase) {\n\n /**\n * Action selector class.\n * @param {String} title The title of popup.\n * @param {String} message The message to display.\n * @param {object} actions The actions that can be selected.\n * @param {String} confirm Text for confirm button.\n * @param {String} cancel Text for cancel button.\n */\n var ActionSelector = function(title, message, actions, confirm, cancel) {\n var self = this;\n\n EventBase.prototype.constructor.apply(this, []);\n self._title = title;\n self._message = message;\n self._actions = actions;\n self._confirm = confirm;\n self._cancel = cancel;\n self._selectedValue = null;\n self._reset();\n };\n\n ActionSelector.prototype = Object.create(EventBase.prototype);\n\n /** @type {String} The value that was selected. */\n ActionSelector.prototype._selectedValue = null;\n /** @type {Dialogue} The reference to the dialogue. */\n ActionSelector.prototype._popup = null;\n /** @type {String} The title of popup. */\n ActionSelector.prototype._title = null;\n /** @type {String} The message in popup. */\n ActionSelector.prototype._message = null;\n /** @type {object} The information for radion buttons. */\n ActionSelector.prototype._actions = null;\n /** @type {String} The text for confirm button. */\n ActionSelector.prototype._confirm = null;\n /** @type {String} The text for cancel button. */\n ActionSelector.prototype._cancel = null;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n ActionSelector.prototype._afterRender = function() {\n var self = this;\n\n // Confirm button is disabled until a choice is done.\n self._find('[data-action=\"action-selector-confirm\"]').attr('disabled', 'disabled');\n\n // Add listener for radio buttons change.\n self._find('[data-region=\"action-selector-radio-buttons\"]').change(function() {\n self._selectedValue = $(\"input[type='radio']:checked\").val();\n self._find('[data-action=\"action-selector-confirm\"]').removeAttr('disabled');\n self._refresh.bind(self);\n });\n\n // Add listener for cancel.\n self._find('[data-action=\"action-selector-cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for confirm.\n self._find('[data-action=\"action-selector-confirm\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedValue.length) {\n return;\n }\n self._trigger('save', {action: self._selectedValue});\n self.close();\n });\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n ActionSelector.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the action selector.\n *\n * @method display\n * @return {Promise}\n */\n ActionSelector.prototype.display = function() {\n var self = this;\n return self._render().then(function(html) {\n self._popup = new Dialogue(\n self._title,\n html,\n self._afterRender.bind(self)\n );\n return;\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery} The node\n * @method _find\n */\n ActionSelector.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n ActionSelector.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"action-selector\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n ActionSelector.prototype._render = function() {\n var self = this;\n var choices = [];\n for (var i in self._actions) {\n choices.push(self._actions[i]);\n }\n var content = {'message': self._message, 'choices': choices,\n 'confirm': self._confirm, 'cancel': self._cancel};\n\n return Templates.render('tool_lp/action_selector', content);\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n ActionSelector.prototype._reset = function() {\n this._popup = null;\n this._selectedValue = '';\n };\n\n return /** @alias module:tool_lp/actionselector */ ActionSelector;\n\n});\n"],"file":"actionselector.min.js"}