AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"preferences_processor_form.min.js","sources":["../src/preferences_processor_form.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 * Manages the processor form on the message preferences page.\n *\n * @module core_message/preferences_processor_form\n * @copyright 2016 Ryan Wyllie <ryan@moodle.com>\n * @license htt
p://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/notification'],\n function($, Ajax, Notification) {\n /**\n * Constructor for the ProcessorForm.\n *\n * @class\n * @param {object} element jQuery object root element of the preference\n */\n var ProcessorForm = function(element) {\n this.root = $(element);\n this.userId = this.root.attr('data-user-id');\n this.name = this.root.attr('data-processor-name');\n\n this.root.find('form').on('submit', function(e) {\n e.preventDefault();\n this.save().done(function() {\n $(element).trigger('mpp:formsubmitted');\n });\n }.bind(this));\n };\n\n /**\n * Flag the processor as loading.\n *\n * @method startLoading\n */\n ProcessorForm.prototype.startLoading = function() {\n this.root.addClass('loading');\n };\n\n /**\n * Remove the loading flag for this processor.\n
*\n * @method stopLoading\n */\n ProcessorForm.prototype.stopLoading = function() {\n this.root.removeClass('loading');\n };\n\n /**\n * Check if this processor is loading.\n *\n * @method isLoading\n * @return {bool}\n */\n ProcessorForm.prototype.isLoading = function() {\n return this.root.hasClass('loading');\n };\n\n /**\n * Persist the processor configuration.\n *\n * @method save\n * @return {object} jQuery promise\n */\n ProcessorForm.prototype.save = function() {\n if (this.isLoading()) {\n return $.Deferred();\n }\n\n this.startLoading();\n\n var data = this.root.find('form').serializeArray();\n var request = {\n methodname: 'core_message_message_processor_config_form',\n args: {\n userid: this.userId,\n name: this.name,\n formvalues: data,\n }\n };\n\n return Ajax.call([request])[
0]\n .fail(Notification.exception)\n .always(function() {\n this.stopLoading();\n }.bind(this));\n };\n\n return ProcessorForm;\n});\n"],"names":["define","$","Ajax","Notification","ProcessorForm","element","root","userId","this","attr","name","find","on","e","preventDefault","save","done","trigger","bind","prototype","startLoading","addClass","stopLoading","removeClass","isLoading","hasClass","Deferred","data","serializeArray","request","methodname","args","userid","formvalues","call","fail","exception","always"],"mappings":";;;;;;;AAsBAA,iDAAO,CAAC,SAAU,YAAa,sBACvB,SAASC,EAAGC,KAAMC,kBAOlBC,cAAgB,SAASC,cACpBC,KAAOL,EAAEI,cACTE,OAASC,KAAKF,KAAKG,KAAK,qBACxBC,KAAOF,KAAKF,KAAKG,KAAK,4BAEtBH,KAAKK,KAAK,QAAQC,GAAG,SAAU,SAASC,GACzCA,EAAEC,sBACGC,OAAOC,MAAK,WACbf,EAAEI,SAASY,QAAQ,yBAEzBC,KAAKV,eAQXJ,cAAce,UAAUC,aAAe,gBAC9Bd,KAAKe,SAAS,YAQvBjB,cAAce,UAAUG,YAAc,gBAC7BhB,KAAKiB,YAAY,YAS1BnB,cAAce,UAAUK,UAAY,kBACzBhB,KAAKF,KAAKmB,SAAS,YAS9BrB,cAAce,UAAUJ,KAAO,cACv
BP,KAAKgB,mBACEvB,EAAEyB,gBAGRN,mBAEDO,KAAOnB,KAAKF,KAAKK,KAAK,QAAQiB,iBAC9BC,QAAU,CACVC,WAAY,6CACZC,KAAM,CACFC,OAAQxB,KAAKD,OACbG,KAAMF,KAAKE,KACXuB,WAAYN,cAIbzB,KAAKgC,KAAK,CAACL,UAAU,GACvBM,KAAKhC,aAAaiC,WAClBC,OAAO,gBACCf,eACPJ,KAAKV,QAGRJ"}