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OAAQ,SAAUC,EAASC,GACvB3B,EAAE4B,KAAK,CACHC,IAAK,iCAAmCC,mBAAmBJ,EAAQK,MAAQ,UAC3EC,SAAU,QACVC,YAAa,kCACbC,QAAS,SAAUC,GACfR,EAAS3B,EAAEoC,IAAID,EAAKE,MAAM,SAAUC,GAChC,MAAO,CACHC,MAAOD,EAAKE,MACZC,MAAOH,EAAKE,MAEpB,IACJ,GAER,EACAE,UAAW,IAGfnD,OAAOC,YAAYC,aAAaI,YAAY8C,IAAItB,EAAWrB,EAAEoB,OAErE,GACJ,EAEA7B,OAAOC,YAAYC,aAAamD,KAAO,WAGpC,IAAIC,EAAS7C,EAAET,OAAOC,YAAYC,aAAaG,OAC9CiD,EAAO5B,MAAK,WACRjB,EAAEoB,KAAK0B,YAAYC,IAAI,QAASxD,OAAOC,YAAYC,aAAaM,iBACpE,IAEAK,SAASS,iBAAiB,qBAAsBtB,OAAOC,YAAYC,aAAaqB,mBAAmBkC,KAAK5B,KAAKyB,IAAS,EAC1H,EAEAtD,OAAOC,YAAYC,aAAaC,WAAY","sources":["webpack://advanced-web/./UI/js/core/modules/autocomplete.core.js"],"sourcesContent":["/**\r\n * \r\n * Autocomplete is now lazy loaded based on user interaction with an element in the DOM\r\n * which is to have the autocomplete functionality bound to it.\r\n * \r\n * This core file is required into the javascript workflow via the global configuration object\r\n * (window.oneadvanced.required.autocomplete = true) in any of the corresponding View files in which\r\n * their component will want autocomplete functionality.\r\n * \r\n * Then in order to signal to the autocomplete core code that a specific element requires\r\n * autocomplete functionality, it can be added to a queue within the global configuration object\r\n * (window.oneadvanced.autocomplete.queue). Again this is added in the associated View code where\r\n * the element's selector is pushed onto the queue (the queue being an Array).\r\n * \r\n * The selector itself should be in the exact format needed for jQuery to wrap it as an object;\r\n * for example '#Search-Page-Filter' for an element whose id attribute is equal to 'Search-Page-Filter'.\r\n * \r\n * Autocomplete core will bind event listeners to the 'focus' event of each of the elements in the previously\r\n * mentioned queue.\r\n * \r\n * A check will be made to detect if autocomplete functionality is already present and if it is not, then\r\n * the autocomplete javascript file will be loaded and an event will fire after successfull loading of the script\r\n * to kick off the binding of autocomplete functionality to each element as required.\r\n * A map will hold a record of which elements have already had autocomplete bound to them and this will be checked\r\n * before any rebinding takes place.\r\n * \r\n * Additionally, jQuery UI's autocomplete is loaded with EPiServer Forms so the the check for autocomplete is based not\r\n * only on our own flag for signalling if we've loaded it, but also if it has been loaded by other actors in the codebase.\r\n * However, as the majority of our forms are now loaded into iframes, this prevents the form's version of autocomplete\r\n * from being accessed by the parent page, thus forcing us to essentially load autocomplete twice.\r\n * \r\n **/\r\n\r\n(function () {\r\n\r\n window.oneadvanced = window.oneadvanced || {};\r\n window.oneadvanced.autocomplete = window.oneadvanced.autocomplete || {};\r\n window.oneadvanced.autocomplete.hasLoaded = window.oneadvanced.autocomplete.hasLoaded || false;\r\n window.oneadvanced.autocomplete.script = window.oneadvanced.autocomplete.script || {};\r\n window.oneadvanced.autocomplete.script.hasLoaded = window.oneadvanced.autocomplete.script.hasLoaded || false;\r\n window.oneadvanced.autocomplete.queue = window.oneadvanced.autocomplete.queue || [];\r\n window.oneadvanced.autocomplete.hasAttached = window.oneadvanced.autocomplete.hasAttached || new Map();\r\n\r\n window.oneadvanced.autocomplete.loadAutocomplete = function () {\r\n\r\n // console.log(\"loadAutocomplete running...\");\r\n if (!(typeof $.fn.autocomplete == 'function' || window.oneadvanced.autocomplete.script.hasLoaded)) {\r\n\r\n // console.log(\"autocomplete loading...\");\r\n var jqueryUIScript = document.createElement(\"script\");\r\n jqueryUIScript.setAttribute(\"src\", window.location.origin + \"/Static/cdn/jquery-ui-1.13.0.min.js\");\r\n document.body.appendChild(jqueryUIScript);\r\n\r\n jqueryUIScript.addEventListener(\"load\", function () {\r\n window.oneadvanced.autocomplete.script.hasLoaded = true;\r\n const autocompleteLoadedEvent = new Event('autocompleteLoaded');\r\n document.dispatchEvent(autocompleteLoadedEvent);\r\n }, false);\r\n }\r\n else {\r\n // console.log(\"autocomplete already loaded.\");\r\n const autocompleteLoadedEvent = new Event('autocompleteLoaded');\r\n document.dispatchEvent(autocompleteLoadedEvent);\r\n }\r\n }\r\n\r\n window.oneadvanced.autocomplete.attachAutocomplete = function ($jQueryElements) {\r\n\r\n // console.log(\"attachAutocomplete running...\");\r\n document.removeEventListener(\"autocompleteLoaded\", window.oneadvanced.autocomplete.attachAutocomplete, false);\r\n\r\n $jQueryElements.each(function () {\r\n\r\n var $this = $(`${this}`);\r\n var $thisName = JSON.stringify(this);\r\n\r\n if (!window.oneadvanced.autocomplete.hasAttached.has($thisName)) {\r\n\r\n // console.log(\"autocomplete attaching to \" + $this + \"...\");\r\n $this.autocomplete({\r\n source: function (request, response) {\r\n $.ajax({\r\n url: \"/find_v2/_autocomplete?prefix=\" + encodeURIComponent(request.term) + \"&size=5\",\r\n dataType: \"jsonp\",\r\n contentType: 'application/json; charset=utf-8',\r\n success: function (data) {\r\n response($.map(data.hits, function (item) {\r\n return {\r\n label: item.query,\r\n value: item.query\r\n };\r\n }));\r\n }\r\n });\r\n },\r\n minLength: 2\r\n });\r\n\r\n window.oneadvanced.autocomplete.hasAttached.set($thisName, $(this));\r\n }\r\n });\r\n }\r\n\r\n window.oneadvanced.autocomplete.init = function () {\r\n\r\n // console.log(\"initialising autocomplete...\");\r\n var $queue = $(window.oneadvanced.autocomplete.queue);\r\n $queue.each(function () {\r\n $(this.toString()).one(\"focus\", window.oneadvanced.autocomplete.loadAutocomplete);\r\n });\r\n\r\n document.addEventListener(\"autocompleteLoaded\", window.oneadvanced.autocomplete.attachAutocomplete.bind(this,$queue), false);\r\n };\r\n\r\n window.oneadvanced.autocomplete.hasLoaded = true;\r\n})();"],"names":["window","oneadvanced","autocomplete","hasLoaded","script","queue","hasAttached","Map","loadAutocomplete","$","fn","autocompleteLoadedEvent","Event","document","dispatchEvent","jqueryUIScript","createElement","setAttribute","location","origin","body","appendChild","addEventListener","attachAutocomplete","$jQueryElements","removeEventListener","each","$this","concat","this","$thisName","JSON","stringify","has","source","request","response","ajax","url","encodeURIComponent","term","dataType","contentType","success","data","map","hits","item","label","query","value","minLength","set","init","$queue","toString","one","bind"],"sourceRoot":""}