{"version":3,"sources":["https:\/\/magistere.education.fr\/ac-paris\/lib\/amd\/src\/search-input.js"],"names":["define","$","wrapper","toggleForm","ev","hasClass","hideForm","showForm","windowWidth","document","width","type","keyCode","submitForm","preventDefault","addClass","find","focus","removeClass","submit","init","id","on"],"mappings":"AAyBAA,OAAM,qBAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,IAOvBC,CAAAA,CAAO,CAAG,IAPa,CAgBvBC,CAAU,CAAG,SAASC,CAAT,CAAa,CAE1B,GAAIF,CAAO,CAACG,QAAR,CAAiB,UAAjB,CAAJ,CAAkC,CAC9BC,CAAQ,EACX,CAFD,IAEO,CACHC,CAAQ,CAACH,CAAD,CACX,CACJ,CAvB0B,CAgCvBG,CAAQ,CAAG,SAASH,CAAT,CAAa,CAExB,GAAII,CAAAA,CAAW,CAAGP,CAAC,CAACQ,QAAD,CAAD,CAAYC,KAAZ,EAAlB,CAGA,GAAgB,SAAZ,GAAAN,CAAE,CAACO,IAAH,EAAwC,EAAf,GAAAP,CAAE,CAACQ,OAA5B,EAA6D,EAAf,GAAAR,CAAE,CAACQ,OAArD,CAAqE,CACjE,MACH,CAED,GAAK,CAAgB,GAAf,EAAAJ,CAAW,EAA2B,GAAf,EAAAA,CAAW,EAA0B,IAAf,EAAAA,CAA9C,IAAqF,OAAZ,GAAAJ,CAAE,CAACO,IAAH,EAAmC,SAAZ,GAAAP,CAAE,CAACO,IAAnG,CAAL,CAA6H,CAEzHE,CAAU,GACV,MACH,CAJD,IAIO,IAAmB,GAAf,EAAAL,CAAW,EAA2B,GAAf,EAAAA,CAAW,EAA0B,IAAf,EAAAA,CAAjD,CAAwE,CAE3E,MACH,CAED,GAAgB,SAAZ,GAAAJ,CAAE,CAACO,IAAP,CAA2B,CAEvBP,CAAE,CAACU,cAAH,EACH,CAEDZ,CAAO,CAACa,QAAR,CAAiB,UAAjB,EACAb,CAAO,CAACc,IAAR,CAAa,MAAb,EAAqBD,QAArB,CAA8B,UAA9B,EACAb,CAAO,CAACc,IAAR,CAAa,OAAb,EAAsBC,KAAtB,EACH,CA1D0B,CAkEvBX,CAAQ,CAAG,UAAW,CACtBJ,CAAO,CAACgB,WAAR,CAAoB,UAApB,EACAhB,CAAO,CAACc,IAAR,CAAa,MAAb,EAAqBE,WAArB,CAAiC,UAAjC,CACH,CArE0B,CA8EvBL,CAAU,CAAG,UAAW,CACxBX,CAAO,CAACc,IAAR,CAAa,MAAb,EAAqBG,MAArB,EACH,CAhF0B,CAkF3B,MAA8C,CAS1CC,IAAI,CAAE,cAASC,CAAT,CAAa,CACfnB,CAAO,CAAGD,CAAC,CAAC,IAAMoB,CAAP,CAAX,CACAnB,CAAO,CAACoB,EAAR,CAAW,yBAAX,CAAsC,KAAtC,CAA6CnB,CAA7C,CACH,CAZyC,CAcjD,CAhGK,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 * Search box.\n *\n * @module core\/search-input\n * @class search-input\n * @package core\n * @copyright 2016 David Monllao {@link http:\/\/www.davidmonllao.com}\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n * @since Moodle 3.1\n *\/\ndefine(['jquery'], function($) {\n\n \/**\n * This search box div node.\n *\n * @private\n *\/\n var wrapper = null;\n\n \/**\n * Toggles the form visibility.\n *\n * @param {Event} ev\n * @method toggleForm\n * @private\n *\/\n var toggleForm = function(ev) {\n\n if (wrapper.hasClass('expanded')) {\n hideForm();\n } else {\n showForm(ev);\n }\n };\n\n \/**\n * Shows the form or submits it depending on the window size.\n *\n * @param {Event} ev\n * @method showForm\n * @private\n *\/\n var showForm = function(ev) {\n\n var windowWidth = $(document).width();\n\n \/\/ We are only interested in enter and space keys (accessibility).\n if (ev.type === 'keydown' && ev.keyCode !== 13 && ev.keyCode !== 32) {\n return;\n }\n\n if ( (windowWidth <= 767 || (windowWidth >= 980 && windowWidth <= 1061) ) && (ev.type === 'click' || ev.type === 'keydown')) {\n \/\/ Move to the search page when using small window sizes as the input requires too much space.\n submitForm();\n return;\n } else if (windowWidth <= 767 || (windowWidth >= 980 && windowWidth <= 1061) ) {\n \/\/ Ignore mousedown events in while using small window sizes.\n return;\n }\n\n if (ev.type === 'keydown') {\n \/\/ We don't want to submit the form unless the user hits enter.\n ev.preventDefault();\n }\n\n wrapper.addClass('expanded');\n wrapper.find('form').addClass('expanded');\n wrapper.find('input').focus();\n };\n\n \/**\n * Hides the form.\n *\n * @method hideForm\n * @private\n *\/\n var hideForm = function() {\n wrapper.removeClass('expanded');\n wrapper.find('form').removeClass('expanded');\n };\n\n \/**\n * Submits the form.\n *\n * @param {Event} ev\n * @method submitForm\n * @private\n *\/\n var submitForm = function() {\n wrapper.find('form').submit();\n };\n\n return \/** @alias module:core\/search-input *\/ {\n \/\/ Public variables and functions.\n\n \/**\n * Assigns listeners to the requested select box.\n *\n * @method init\n * @param {Number} id The search wrapper div id\n *\/\n init: function(id) {\n wrapper = $('#' + id);\n wrapper.on('click mouseover keydown', 'div', toggleForm);\n }\n };\n});\n"],"file":"search-input.min.js"}