text: (window.webpackJsonp=window.webpackJsonp||[]).push([[15],{638:function(t,e,r){"use strict";r.r(e),function(t){r.d(e,"default",(function(){return u}));var a=r(12),i=r(676),o=r(669),n=r(677),s=r(671),c=r(678),h=r(750);var u=function(e){var r,i;function u(){return e.apply(this,arguments)||this}i=e,(r=u).prototype=Object.create(i.prototype),r.prototype.constructor=r,r.__proto__=i;var d=u.prototype;return d.onReady=function(){this.context&&(this.context.themeSettings.show_bulk_order_mode||this.context.useBulkOrder)&&(this.bulkOrder=Object(c.a)(this.context)),Object(o.a)(this.context),t("#facetedSearch").length>0?this.initFacetedSearch():(this.onSortBySubmit=this.onSortBySubmit.bind(this),a.c.on("sortBy-submitted",this.onSortBySubmit)),Object(s.a)(),this.context.themeSettings.categorypage_search&&this.initSearchInCategory()},d.destroy=function(){this.searchInCategory&&this.searchInCategory.destroy(),this.facetedSearch?this.facetedSearch.destroy():a.c.off("sortBy-submitted",this.onSortBySubmit)},d.initSearchInCategory=function(){var e=this;this.searchInCategory=new h.a({context:this.context,facetedSearch:this.facetedSearch,searchCallback:function(r){t("#product-listing-container").html(r.productListing),e.bulkOrder&&e.bulkOrder.reinit(),Object(s.a)(),t("body").triggerHandler("compareReset"),t("html, body").animate({scrollTop:0},100)}})},d.initFacetedSearch=function(){var e=this,r=t("#product-listing-container"),a=t("#faceted-search-container"),i={config:{category:{shop_by_price:!0,products:{limit:this.context.categoryProductsPerPage}}},template:{productListing:"category/product-listing",sidebar:"category/sidebar"},showMore:"category/show-more"};this.facetedSearch=new n.a(i,(function(i){r.html(i.productListing),a.html(i.sidebar),e.bulkOrder&&e.bulkOrder.reinit(),t("body").triggerHandler("compareReset"),t("html, body").animate({scrollTop:0},100)}))},u}(i.a)}.call(this,r(1))},750:function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return h}));var a=r(39),i=r.n(a),o=r(12),n=r(651),s=r.n(n),c=r(668),h=function(){function e(e){this.doSearch=i()(this.doSearch.bind(this),500),this.onInput=this.onInput.bind(this),this.onFormSubmit=this.onFormSubmit.bind(this),this.onClear=this.onClear.bind(this),this.onStateChange=this.onStateChange.bind(this),this.options=e,this.$body=t("body"),this.$input=t("[data-search-in-category]"),this.$form=this.$input.closest("form"),this.$clear=this.$form.find("[data-clear]").hide(),this.originalPathname=window.location.pathname,e&&e.facetedSearch&&(this.options.facetedSearch.updateViewCallback=this.updateViewFacetedSearch.bind(this)),this.bindEvents();var r=s.a.parse(c.a.getUrl(),!0);r.query.q&&(this.$input.val(r.query.q),this.$clear.show(),t(window).trigger("statechange"))}var r=e.prototype;return r.destroy=function(){this.unbindEvents()},r.bindEvents=function(){this.$input.on("input",this.onInput),this.$form.on("submit",this.onFormSubmit),this.$clear.on("click",this.onClear),0===t("#facetedSearch").length&&t(window).on("statechange",this.onStateChange)},r.unbindEvents=function(){this.$input.off("input",this.onInput),this.$form.off("submit",this.onFormSubmit),this.$clear.off("click",this.onClear),t(window).off("statechange",this.onStateChange)},r.onFormSubmit=function(){return!1},r.onClear=function(t){t.preventDefault(),this.$clear.hide(),this.$input.val(""),this.onInput()},r.onInput=function(){this.doSearch(this.$input.val())},r.onStateChange=function(){var t=this,e=c.a.getUrl(),r=s.a.parse(e,!0),a=r.query.search_query||r.query.search_query_adv||r.query.q,i={template:{productListing:"category/product-listing",sidebar:"category/sidebar"}};a&&(r.query.search_query_adv=a,delete r.query.search_query,delete r.query.q,delete r.query.category,this.options.context.categoryId?r.query["category[]"]=this.options.context.categoryId:delete r.query["category[]"],this.options.context.themeSettings.categorypage_search_subs&&(r.query.searchsubs="ON"),e="/search.php?"+c.a.buildQueryString(r.query),i={template:{productListing:"papa-supermarket/search-in-category/product-listing",sidebar:"papa-supermarket/search-in-category/sidebar"},showMore:"search/show-more"}),this.$form.addClass("loading"),this.$body.trigger("beforerequest.searchincategory"),o.a.getPage(e,i,(function(e,r){if(t.$form.removeClass("loading"),e)throw new Error(e);t.$body.trigger("beforeupdate.searchincategory"),r&&t.options.searchCallback&&t.options.searchCallback(r),t.$body.trigger("afterupdate.searchincategory")}))},r.doSearch=function(t){if(0===t.length){this.$clear.hide();var e=c.a.removeParams(c.a.getUrl(),["q","search_query","search_query_adv","category","page"]);c.a.goToUrl(e)}else if(t.length>=3){this.$clear.show();var r=c.a.removeParams(c.a.getUrl(),["q","search_query","search_query_adv","page"]);r=c.a.replaceParams(r,{q:t}),c.a.goToUrl(r)}},r.updateViewFacetedSearch=function(){var e=this,r=this.options.facetedSearch,a=c.a.getUrl(),i=r.requestOptions,n=s.a.parse(a,!0),h=n.query.q||n.query.search_query,u=["_bc_fsnf","search_query","q","sort","limit","mode","page"],d=Object.keys(n.query).filter((function(t){return-1===u.indexOf(t)}));"/search.php"===window.location.pathname&&0===d.length?(this.$input.val(""),this.$clear.hide(),a=c.a.removeParams(a,[].concat(d,["search_query","q","_bc_fsnf"])).replace("/search.php",this.originalPathname),window.history.replaceState({},document.title,a)):h?("/search.php"===window.location.pathname&&(n.query.q=h,delete n.query.search_query,Number(n.query.category)===this.options.context.categoryId&&delete n.query.category,window.history.replaceState({},document.title,this.originalPathname+"?"+c.a.buildQueryString(n.query))),delete n.query.q,n.query.search_query=h,n.query.category||(n.query.category=this.options.context.categoryId),a="/search.php?"+c.a.buildQueryString(n.query),i={template:{productListing:"papa-supermarket/search-in-category/product-listing",sidebar:"papa-supermarket/search-in-category/sidebar"},showMore:"search/show-more"}):this.$input.val(""),t(r.options.blockerSelector).show(),this.$form.addClass("loading"),this.$body.trigger("beforerequest.searchincategory"),o.a.getPage(a,i,(function(a,i){if(t(r.options.blockerSelector).hide(),e.$form.removeClass("loading"),a)throw new Error(a);e.$body.trigger("beforeupdate.searchincategory"),r.refreshView(i),e.$body.trigger("afterupdate.searchincategory")}))},e}()}).call(this,r(1))}}]);
  //# sourceMappingURL=theme-bundle.chunk.15.js.map
  