{"version":3,"sources":["https:\/\/elearning.iep.edu.gr\/study\/theme\/moove\/amd\/src\/themesettings_modal.js"],"names":["define","jQuery","Notification","CustomEvents","Modal","ModalRegistry","Ajax","registered","SELECTORS","SAVE_BUTTON","CANCEL_BUTTON","ThemeSettingsModal","root","call","request","methodname","args","done","result","document","getElementById","value","fonttype","enableaccessibilitytoolbar","checked","TYPE","prototype","Object","create","constructor","registerEventListeners","getModal","on","events","activate","formdata","getFormData","location","reload","bind","fail","error","message","addNotification","type","hide","destroy","getForm","serialize","getBody","find","register"],"mappings":"AAsBAA,OAAM,mCAAC,CAAC,QAAD,CAAW,mBAAX,CAAgC,gCAAhC,CAAkE,YAAlE,CAAgF,qBAAhF,CAAuG,WAAvG,CAAD,CACF,SAASC,CAAT,CAAiBC,CAAjB,CAA+BC,CAA\/B,CAA6CC,CAA7C,CAAoDC,CAApD,CAAmEC,CAAnE,CAAyE,IAEjEC,CAAAA,CAAU,GAFuD,CAGjEC,CAAS,CAAG,CACZC,WAAW,CAAE,wBADD,CAEZC,aAAa,CAAE,0BAFH,CAHqD,CAajEC,CAAkB,CAAG,SAASC,CAAT,CAAe,CACpCR,CAAK,CAACS,IAAN,CAAW,IAAX,CAAiBD,CAAjB,EAEA,GAAIE,CAAAA,CAAO,CAAGR,CAAI,CAACO,IAAL,CAAU,CAAC,CACrBE,UAAU,CAAE,8BADS,CAErBC,IAAI,CAAE,EAFe,CAAD,CAAV,CAAd,CAKAF,CAAO,CAAC,CAAD,CAAP,CAAWG,IAAX,CAAgB,SAASC,CAAT,CAAiB,CAC7BC,QAAQ,CAACC,cAAT,CAAwB,UAAxB,EAAoCC,KAApC,CAA4CH,CAAM,CAACI,QAAnD,CAEA,GAAIJ,CAAM,CAACK,0BAAX,CAAuC,CACnCJ,QAAQ,CAACC,cAAT,CAAwB,4BAAxB,EAAsDI,OAAtD,GACH,CACJ,CAND,CAOH,CA5BoE,CA8BrEb,CAAkB,CAACc,IAAnB,CAA0B,iCAA1B,CACAd,CA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UAAW,CACjF,KAAKmC,IAAL,GACA,KAAKC,OAAL,EACH,CAHyE,CAGxEP,IAHwE,CAGnE,IAHmE,CAA1E,CAIH,CApCD,CA4CA5B,CAAkB,CAACe,SAAnB,CAA6BU,WAA7B,CAA2C,UAAW,CAClD,MAAO,MAAKW,OAAL,GAAeC,SAAf,EACV,CAFD,CAUArC,CAAkB,CAACe,SAAnB,CAA6BqB,OAA7B,CAAuC,UAAW,CAC9C,MAAO,MAAKE,OAAL,GAAeC,IAAf,CAAoB,MAApB,CACV,CAFD,CAMA,GAAI,CAAC3C,CAAL,CAAiB,CACbF,CAAa,CAAC8C,QAAd,CAAuBxC,CAAkB,CAACc,IAA1C,CAAgDd,CAAhD,CAAoE,iCAApE,EACAJ,CAAU,GACb,CAED,MAAOI,CAAAA,CACV,CA1GC,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 .\n\n\/**\n * Theme settings modal js.\n *\n * @package theme_moove\n * @copyright 2020 Willian Mano - http:\/\/conecti.me\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine(['jquery', 'core\/notification', 'core\/custom_interaction_events', 'core\/modal', 'core\/modal_registry', 'core\/ajax'],\n function(jQuery, Notification, CustomEvents, Modal, ModalRegistry, Ajax) {\n\n var registered = false;\n var SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]'\n };\n\n \/**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n *\/\n var ThemeSettingsModal = function(root) {\n Modal.call(this, root);\n\n var request = Ajax.call([{\n methodname: 'theme_moove_getthemesettings',\n args: {}\n }]);\n\n request[0].done(function(result) {\n document.getElementById('fonttype').value = result.fonttype;\n\n if (result.enableaccessibilitytoolbar) {\n document.getElementById('enableaccessibilitytoolbar').checked = true;\n }\n });\n };\n\n ThemeSettingsModal.TYPE = 'theme_moove-themesettings_modal';\n ThemeSettingsModal.prototype = Object.create(Modal.prototype);\n ThemeSettingsModal.prototype.constructor = ThemeSettingsModal;\n\n \/**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n *\/\n ThemeSettingsModal.prototype.registerEventListeners = function() {\n \/\/ Apply parent event listeners.\n Modal.prototype.registerEventListeners.call(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function() {\n var request = Ajax.call([{\n methodname: 'theme_moove_savethemesettings',\n args: {\n formdata: this.getFormData()\n }\n }]);\n\n request[0].done(function() {\n document.location.reload(true);\n }.bind(this)).fail(function(error){\n var message = error.message;\n\n if (!message) {\n message = error.error;\n }\n\n Notification.addNotification({\n message: message,\n type: 'error'\n });\n\n this.hide();\n\n this.destroy();\n }.bind(this));\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function() {\n this.hide();\n this.destroy();\n }.bind(this));\n };\n\n \/**\n * Get the serialised form data.\n *\n * @method getFormData\n * @return {string} serialised form data\n *\/\n ThemeSettingsModal.prototype.getFormData = function() {\n return this.getForm().serialize();\n };\n\n \/**\n * Get the form element from the modal.\n *\n * @method getForm\n * @return {object}\n *\/\n ThemeSettingsModal.prototype.getForm = function() {\n return this.getBody().find('form');\n };\n\n \/\/ Automatically register with the modal registry the first time this module is imported so that you can create modals\n \/\/ of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(ThemeSettingsModal.TYPE, ThemeSettingsModal, 'theme_moove\/themesettings_modal');\n registered = true;\n }\n\n return ThemeSettingsModal;\n });"],"file":"themesettings_modal.min.js"}