{"version":3,"file":"search.min.js","sources":["https:\/\/finedu.fintech.or.kr\/theme\/slk\/amd\/src\/search.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 .\n\n\/**\n * \uac80\uc0c9\n *\n * @module theme_slk\/search\n * @copyright 2023 Intube\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\nimport $ from 'jquery';\nimport Ajax from 'core\/ajax';\nimport Config from 'core\/config';\nimport Templates from 'core\/templates';\n\nconst SELECTORS= {\n BUTTON_SHOW_SEARCH_FORM: '#button-show-search',\n BUTTON_HIDE_SEARCH_FORM: '#button-hide-show',\n DIV_SEARCH_FORM: '.hd-search-area'\n};\n\nconst registerEventListeners = () => {\n $(document).on(\"click\", SELECTORS.BUTTON_SHOW_SEARCH_FORM, function (e) {\n e.preventDefault();\n show();\n return false;\n });\n\n $(document).on(\"click\", SELECTORS.BUTTON_HIDE_SEARCH_FORM, function (e) {\n e.preventDefault();\n hide();\n return false;\n });\n};\n\n\/**\n * \uac80\uc0c9\ucc3d \ubcf4\uc774\uae30\n *\/\nconst show = () => {\n let div = $(SELECTORS.DIV_SEARCH_FORM);\n if(div === undefined || div.length == 0) {\n let promise = add_search_form();\n $.when(promise).then(function() {\n $(SELECTORS.DIV_SEARCH_FORM).addClass('on');\n });\n }\n div.addClass('on');\n};\n\nconst add_search_form = () => {\n let div = $(SELECTORS.DIV_SEARCH_FORM);\n if(div !== undefined && div.length != 0) {\n return;\n }\n\n let promises = Ajax.call([\n {methodname: 'local_search_get_keywords', args: []}\n ]);\n\n $.when.apply($.when, promises).done(function (keywords) {\n return Templates.render(\n 'theme_slk\/components\/search_form',\n {\n keywords: keywords,\n action: Config.wwwroot + '\/local\/search\/index.php'\n }\n ).then(function (html) {\n if (html) {\n $('body').append(html);\n }\n });\n });\n};\n\nconst hide = () => {\n let div = $(SELECTORS.DIV_SEARCH_FORM);\n if(div !== undefined) {\n div.removeClass('on');\n }\n};\n\n\/**\n *\n *\/\nexport const init = () => {\n add_search_form();\n registerEventListeners();\n};"],"names":["SELECTORS","show","div","undefined","length","promise","add_search_form","when","then","addClass","promises","Ajax","call","methodname","args","apply","$","done","keywords","Templates","render","action","Config","wwwroot","html","append","hide","removeClass","document","on","e","preventDefault"],"mappings":";;;;;;;wPA2BMA,kCACuB,sBADvBA,kCAEuB,oBAFvBA,0BAGe,kBAoBfC,KAAO,eACLC,KAAM,mBAAEF,mCACDG,IAARD,KAAmC,GAAdA,IAAIE,OAAa,KACjCC,QAAUC,kCACZC,KAAKF,SAASG,MAAK,+BACfR,2BAA2BS,SAAS,SAG9CP,IAAIO,SAAS,OAGXH,gBAAkB,eAChBJ,KAAM,mBAAEF,mCACDG,IAARD,KAAmC,GAAdA,IAAIE,YAIxBM,SAAWC,cAAKC,KAAK,CACrB,CAACC,WAAY,4BAA6BC,KAAM,sBAGlDP,KAAKQ,MAAMC,gBAAET,KAAMG,UAAUO,MAAK,SAAUC,iBACnCC,mBAAUC,OACb,mCACA,CACIF,SAAUA,SACVG,OAAQC,gBAAOC,QAAU,4BAE\/Bf,MAAK,SAAUgB,MACTA,0BACE,QAAQC,OAAOD,cAM3BE,KAAO,eACLxB,KAAM,mBAAEF,gCACDG,IAARD,KACCA,IAAIyB,YAAY,qBAOJ,WAChBrB,sCA\/DEsB,UAAUC,GAAG,QAAS7B,mCAAmC,SAAU8B,UACjEA,EAAEC,iBACF9B,QACO,yBAGT2B,UAAUC,GAAG,QAAS7B,mCAAmC,SAAU8B,UACjEA,EAAEC,iBACFL,QACO"}