1(self.webpackChunknodejs_dependencies=self.webpackChunknodejs_dependencies||[]).push([[4948],{7051(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;__WEBPACK_AMD_DEFINE_ARRAY__=[__webpack_require__(3787),__webpack_require__(4692),__webpack_require__(7833)],void 0===(__WEBPACK_AMD_DEFINE_RESULT__=function(facade,$,debug){var log=debug("components:search-suggestions");function SearchSuggestions(element){log("init"),this.$el=$(element),this.$inputElm=this.$el.find(".search-suggestion-input"),this.$form=this.$el.closest("form"),0==this.$form.length&&(this.$form=this.$el.find("form"));var fields=this.$form.data("typeaheadFields");return this.extraInputFields=fields?fields.split(","):[],this.searchUrl=this.$form.data("searchurl"),this.completer=this.$form.data("completer"),this.service=this.$form.data("service"),this.submitFormOnClick=this.$form.data("submitOnClick"),this.$inputElm.on("focus",this.showSuggestionPanel.bind(this)).on("blur",this.hideSuggestionPanel.bind(this)).on("keyup",this.onKeyUp.bind(this)).on("show-suggestion",this.showSuggestions.bind(this)),this.$el.on("mousedown touchstart",".search-suggestion__list__item__link",this.selectSuggestion.bind(this)),this}return SearchSuggestions.prototype.onKeyUp=function(e){var code=e.keyCode?e.keyCode:e.which;38!==code?40!==code?13!==code?this.$inputElm.trigger("show-suggestion"):(this.$form.parent().hasClass("search-page-form")||this.$form.submit(),this.hideSuggestionPanel()):this.navigateList("down"):this.navigateList("up")},SearchSuggestions.prototype.selectSuggestion=function(event){if(!this._selecting){this._selecting=!0,event.preventDefault();var $link=$(event.target).closest(".search-suggestion__list__item__link");if($link.length){var suggestionText=$.trim($link.text()).replace(/<\/?[^>]+>/g,"");this.abortPendingRequest(),clearTimeout(this.hideTimer),this.$inputElm.val(suggestionText),this.hideSuggestionPanel(!0);var self=this;setTimeout(function(){self._selecting=!1,self.$form.submit()},0)}else this._selecting=!1}},SearchSuggestions.prototype.navigateList=function(direction){var $focusElement,skip=!1,$currentActive=this.$el.find(".search-suggestion__list").find(".has--focus");$currentActive.length||($currentActive=this.$el.find(".search-suggestion__list :first"),skip=!0),"up"!==direction||skip?"down"!==direction||skip||($focusElement=$currentActive.next()):$focusElement=$currentActive.prev(),(!$focusElement||$focusElement&&!$focusElement.length)&&($focusElement=$currentActive),this.$el.find(".search-suggestion__list li").removeClass("has--focus"),$focusElement.addClass("has--focus");var suggestionTxt=$.trim($focusElement.find(".search-suggestion__list__item__link").text());this.$inputElm.val(suggestionTxt)},SearchSuggestions.prototype.showSuggestions=function(){var value=this.$inputElm.val();value.length>2?(this.$form.addClass("is-loading"),this.showSuggestionPanel(),this.fetchSuggestions(value,function(response){log(["fetchSuggestions",response]);var $list=this.buildSuggestionsList(response);if(response.suggestions.length<=0)return this.$el.find(".search-suggestion").html(""),this.$el.removeClass("has-suggestions"),!1;this.$el.addClass("has-suggestions"),this.$form.removeClass("is-loading").addClass("is-searching"),this.$el.find(".search-suggestion").html($list)}.bind(this))):(this.$el.removeClass("has-suggestions"),this.$form.removeClass("is-searching"),"top-area-searchfield"===$(this).attr("id")&&this.$form.removeClass("is-searching"),this.$el.find(".search-suggestion").html(""))},SearchSuggestions.prototype.showSuggestionPanel=function(){var value=this.$inputElm.val();this.$el.find(".search--header--suggestions").addClass("on-focus"),value.length>2?(log("Show suggestions panel"),this.$el.addClass("is-searching"),this.$el.find(".search--header--suggestions")):(this.$el.removeClass("is-searching"),this.$el.find(".search--header--suggestions"))},SearchSuggestions.prototype.hideSuggestionPanel=function(immediate){var self=this;clearTimeout(this.hideTimer);var hide=function(){self.$el.removeClass("is-searching"),self.$el.find(".search--header--suggestions").removeClass("on-focus")};immediate?hide():this.hideTimer=setTimeout(hide,200)},SearchSuggestions.prototype.abortPendingRequest=function(){this.currentRequest&&4!==this.currentRequest.readyState&&this.currentRequest.abort(),this.currentRequest=null},SearchSuggestions.prototype.getSuggestionHtml=function(input,suggestion){var searchWord=new RegExp("("+input+")","gi");return'<li class="search-suggestion__list__item"><a class="search-suggestion__list__item__link" href="'+(this.submitFormOnClick?"#":this.searchUrl+"?q="+suggestion)+'">'+suggestion.replace(searchWord,"<mark>$1</mark>")+"</a></li>"},SearchSuggestions.prototype.buildSuggestionsList=function(response){var $list=$('<ul class="search-suggestion__list">');return log("Building List",response.query,response.suggestions),response.suggestions.forEach(function(suggestion){var $listItem=this.getSuggestionHtml(response.query,suggestion.label);$list.append($listItem)}.bind(this)),log("html list created",$list.get(0)),$list},SearchSuggestions.prototype.fetchSuggestions=function(query,callback){var langParam="language:"+(window.location.href.indexOf(window.location.origin+"/en")>-1?"en":"sv");log("fetching",query);var self=this,data={q:query,fq:$("<div/>").text(langParam).html(),c:this.completer};
1this.$form.serializeArray().forEach(function(obj){if(self.extraInputFields.indexOf(obj.name)>-1&&""!=obj.value){var d=data[obj.name];Array.isArray(d)?d.push(obj.value):d=void 0===d?obj.value:[d,obj.value],data[obj.name]=d}}),this.abortPendingRequest(),this.currentRequest=$.ajax({url:this.service,data,dataType:"json",traditional:!0}).done(callback).fail(function(data){"abort"!==data.statusText&&console.log(["failure",data])})},SearchSuggestions}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__))||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.