Current Path : C:/xampp/htdocs/moodle/mod/lti/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/lti/amd/build/form-field.min.js.map |
{"version":3,"sources":["../src/form-field.js"],"names":["define","$","FormField","name","type","resetIfUndefined","defaultValue","id","selector","TYPES","TEXT","SELECT","CHECKBOX","EDITOR","prototype","setFieldValue","value","prop","text","attoEditor","length","html","tinyMCE","execInstanceCommand","val"],"mappings":"AAyBAA,OAAM,sBAAC,CAAC,QAAD,CAAD,CACF,SAASC,CAAT,CAAY,CAUR,GAAIC,CAAAA,CAAS,CAAG,SAASC,CAAT,CAAeC,CAAf,CAAqBC,CAArB,CAAuCC,CAAvC,CAAqD,CACjE,KAAKH,IAAL,CAAYA,CAAZ,CACA,KAAKI,EAAL,CAAU,MAAQ,KAAKJ,IAAvB,CACA,KAAKK,QAAL,CAAgB,IAAM,KAAKD,EAA3B,CACA,KAAKH,IAAL,CAAYA,CAAZ,CACA,KAAKC,gBAAL,CAAwBA,CAAxB,CACA,KAAKC,YAAL,CAAoBA,CACvB,CAPD,CAcAJ,CAAS,CAACO,KAAV,CAAkB,CACdC,IAAI,CAAE,CADQ,CAEdC,MAAM,CAAE,CAFM,CAGdC,QAAQ,CAAE,CAHI,CAIdC,MAAM,CAAE,CAJM,CAAlB,CAYAX,CAAS,CAACY,SAAV,CAAoBC,aAApB,CAAoC,SAASC,CAAT,CAAgB,CAChD,GAAc,IAAV,GAAAA,CAAJ,CAAoB,CAChB,GAAI,KAAKX,gBAAT,CAA2B,CACvBW,CAAK,CAAG,KAAKV,YAChB,CAFD,IAEO,CAEH,MACH,CACJ,CAED,OAAQ,KAAKF,IAAb,EACI,IAAKF,CAAAA,CAAS,CAACO,KAAV,CAAgBG,QAArB,CACI,GAAII,CAAJ,CAAW,CACPf,CAAC,CAAC,KAAKO,QAAN,CAAD,CAAiBS,IAAjB,CAAsB,SAAtB,IACH,CAFD,IAEO,CACHhB,CAAC,CAAC,KAAKO,QAAN,CAAD,CAAiBS,IAAjB,CAAsB,SAAtB,IACH,CACD,MACJ,IAAKf,CAAAA,CAAS,CAACO,KAAV,CAAgBI,MAArB,CACI,GAA0B,WAAtB,QAAOG,CAAAA,CAAK,CAACE,IAAjB,CAAuC,CAKnC,GAAIC,CAAAA,CAAU,CAAGlB,CAAC,CAAC,KAAKO,QAAL,CAAgB,UAAjB,CAAlB,CACA,GAAIW,CAAU,CAACC,MAAf,CAAuB,CACnBD,CAAU,CAACE,IAAX,CAAgBL,CAAK,CAACE,IAAtB,CACH,CAFD,IAEO,IAAuB,WAAnB,QAAOI,CAAAA,OAAX,CAAoC,CAEvCA,OAAO,CAACC,mBAAR,CAA4B,KAAKhB,EAAjC,CAAqC,kBAArC,IAAgES,CAAK,CAACE,IAAtE,CACH,CAGDjB,CAAC,CAAC,KAAKO,QAAN,CAAD,CAAiBgB,GAAjB,CAAqBR,CAAK,CAACE,IAA3B,CACH,CACD,MACJ,QACIjB,CAAC,CAAC,KAAKO,QAAN,CAAD,CAAiBgB,GAAjB,CAAqBR,CAArB,EACA,MA5BR,CA8BH,CAxCD,CA0CA,MAAOd,CAAAA,CACV,CAhFC,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 * A module that enables the setting of form field values on the client side.\n *\n * @module mod_lti/form-field\n * @class form-field\n * @package mod_lti\n * @copyright 2016 Jun Pataleta <jun@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.2\n */\ndefine(['jquery'],\n function($) {\n /**\n * Form field class.\n *\n * @param {string} name Field name.\n * @param {number} type The field type.\n * @param {boolean} resetIfUndefined Flag to reset the field to the default value if undefined in the return data.\n * @param {string|number|boolean} defaultValue The default value to use for the field.\n * @constructor\n */\n var FormField = function(name, type, resetIfUndefined, defaultValue) {\n this.name = name;\n this.id = 'id_' + this.name;\n this.selector = '#' + this.id;\n this.type = type;\n this.resetIfUndefined = resetIfUndefined;\n this.defaultValue = defaultValue;\n };\n\n /**\n * Form field types.\n *\n * @type {{TEXT: number, SELECT: number, CHECKBOX: number, EDITOR: number}}\n */\n FormField.TYPES = {\n TEXT: 1,\n SELECT: 2,\n CHECKBOX: 3,\n EDITOR: 4\n };\n\n /**\n * Sets the values for a form field.\n *\n * @param {string|boolean|number} value The value to be set into the field.\n */\n FormField.prototype.setFieldValue = function(value) {\n if (value === null) {\n if (this.resetIfUndefined) {\n value = this.defaultValue;\n } else {\n // No need set the field value if value is null and there's no need to reset the field.\n return;\n }\n }\n\n switch (this.type) {\n case FormField.TYPES.CHECKBOX:\n if (value) {\n $(this.selector).prop('checked', true);\n } else {\n $(this.selector).prop('checked', false);\n }\n break;\n case FormField.TYPES.EDITOR:\n if (typeof value.text !== 'undefined') {\n /* global tinyMCE:false */\n\n // Set text in editor's editable content, if applicable.\n // Check if it is an Atto editor.\n var attoEditor = $(this.selector + 'editable');\n if (attoEditor.length) {\n attoEditor.html(value.text);\n } else if (typeof tinyMCE !== 'undefined') {\n // If the editor is not Atto, try to fallback to TinyMCE.\n tinyMCE.execInstanceCommand(this.id, 'mceInsertContent', false, value.text);\n }\n\n // Set text to actual editor text area.\n $(this.selector).val(value.text);\n }\n break;\n default:\n $(this.selector).val(value);\n break;\n }\n };\n\n return FormField;\n }\n);\n"],"file":"form-field.min.js"}