var onSale=!1,soldOut=!1,priceVaries=!1,images=[],firstVariant={},bcSfFilterSettings={general:{limit:bcSfFilterConfig.custom.products_per_page,loadProductFirst:!0,showPlaceholderProductList:!0,placeholderProductPerRow:6}};function prepareShopifyData(data){soldOut=!data.available,onSale=data.compare_at_price_min>data.price_min,priceVaries=data.price_min!=data.price_max,images=data.images_info;var firstVariant2=data.variants[0];if(getParam("variant")!==null&&getParam("variant")!=""){var paramVariant=data.variants.filter(function(e){return e.id==getParam("variant")});typeof paramVariant[0]!="undefined"&&(firstVariant2=paramVariant[0])}else for(var i=0;idata.price_min,priceVaries2=data.price_min!=data.price_max,firstVariant2=data.variants[0];if(getParam("variant")!==null&&getParam("variant")!=""){var paramVariant=data.variants.filter(function(e){return e.id==getParam("variant")});typeof paramVariant[0]!="undefined"&&(firstVariant2=paramVariant[0])}else for(var i=0;i"+data.body_html+"

").text();itemDescription=itemDescription.split(" ").length>40?itemDescription.split(" ").splice(0,40).join(" ")+"...":itemDescription.split(" ").splice(0,40).join(" "),itemHtml=itemHtml.replace(/{{itemDescription}}/g,itemDescription);var itemActiveSwapClass=bcSfFilterConfig.custom.active_image_swap?"has-bc-swap-image":"";return itemHtml=itemHtml.replace(/{{itemActiveSwapClass}}/g,itemActiveSwapClass),itemHtml=itemHtml.replace(/{{itemTitle}}/g,data.title),itemHtml=itemHtml.replace(/{{itemVendorLabel}}/g,data.vendor),itemHtml=itemHtml.replace(/{{itemUrl}}/g,this.buildProductItemUrl(data)),itemHtml};function buildGridWidthClass(){var gridWidthClass="";switch(bcSfFilterConfig.custom.products_per_row){case 2:gridWidthClass="bc-sf-filter-grid-width-2";break;case 3:gridWidthClass="bc-sf-filter-grid-width-3";break;case 5:gridWidthClass="bc-sf-filter-grid-width-5";break;default:gridWidthClass="bc-sf-filter-grid-width-4";break}switch(bcSfFilterConfig.custom.products_per_row_mobile){case 1:gridWidthClass+=" bc-sf-filter-grid-width-mb-1";break;case 3:gridWidthClass+=" bc-sf-filter-grid-width-mb-3";break;default:gridWidthClass+=" bc-sf-filter-grid-width-mb-2";break}return gridWidthClass}function buildImages(data){var html="",thumbUrl=images.length>0?bcsffilter.optimizeImage(images[0].src):bcSfFilterConfig.general.no_image_url;if(html+='',bcSfFilterConfig.custom.active_image_swap){var flipImageUrl=images.length>1?bcsffilter.optimizeImage(images[1].src):thumbUrl;html+=''}return html}function buildVendor(data){var html="";return bcSfFilterConfig.custom.show_vendor&&(html=bcSfFilterTemplate.vendorHtml),html}function buildPrice(data){var html="";return bcSfFilterConfig.custom.show_price&&(html='

',onSale?(html+=""+bcsffilter.formatMoney(data.compare_at_price_min)+" ",html+=''+bcsffilter.formatMoney(data.price_min)+""):(priceVaries&&(html+=bcSfFilterConfig.label_basic.from+" "),html+=''+bcsffilter.formatMoney(data.price_min)+""),html+="

"),html}function buildLabels(data){var soldOutLabel="";bcSfFilterConfig.custom.show_sold_out_label&&soldOut&&(soldOutLabel=bcSfFilterTemplate.soldOutLabelHtml.replace(/{{style}}/g,""));var saleLabel="";return bcSfFilterConfig.custom.show_sale_label&&onSale&&!soldOut&&(saleLabel=bcSfFilterTemplate.saleLabelHtml.replace(/{{style}}/g,"")),soldOutLabel+saleLabel}function buildTagLabels(data,showall){if(showall){var tagLabel="";if(data.tags)for(var i=0;i=0;i--)if(tag=data.tags[i],tag.indexOf("pfs:label")!==-1){var preTagLabel=bcSfFilterTemplate.tagLabelHtml.replace(/{{labelTag}}/g,tag.split("pfs:label-")[1]);tagLabel+=preTagLabel;break}}}return tagLabel}BCSfFilter.prototype.buildPagination=function(totalProduct){var currentPage=parseInt(this.queryParams.page),totalPage=Math.ceil(totalProduct/this.queryParams.limit);if(totalPage==1)return jQ(this.selector.pagination).html(""),!1;if(this.getSettingValue("general.paginationType")=="default"){var paginationHtml=bcSfFilterTemplate.paginateHtml,previousHtml=currentPage>1?bcSfFilterTemplate.previousActiveHtml:bcSfFilterTemplate.previousDisabledHtml;previousHtml=previousHtml.replace(/{{itemUrl}}/g,this.buildToolbarLink("page",currentPage,currentPage-1)),paginationHtml=paginationHtml.replace(/{{previous}}/g,previousHtml);var nextHtml=currentPagecurrentPage-3&&iBefore>0;iBefore--)beforeCurrentPageArr.unshift(iBefore);currentPage-4>0&&beforeCurrentPageArr.unshift("..."),currentPage-4>=0&&beforeCurrentPageArr.unshift(1),beforeCurrentPageArr.push(currentPage);for(var afterCurrentPageArr=[],iAfter=currentPage+1;iAfter'+sortingArr[k]+"";var html=bcSfFilterTemplate.sortingHtml.replace(/{{sortingItems}}/g,sortingItemsHtml);jQ(".bc-sf-filter-custom-sorting").html(html),jQ(".bc-sf-filter-custom-sorting").hasClass("bc-sf-filter-sort-active")&&jQ(".bc-sf-filter-custom-sorting").toggleClass("bc-sf-filter-sort-active");var labelSort="";if(paramSort.length>0){var labelHandle="sorting_"+paramSort.replace(/\-/g,"_");labelSort=bcSfFilterConfig.label[labelHandle]}else labelSort=bcSfFilterConfig.label.sorting;jQ(".bc-sf-filter-custom-sorting label span span").text(labelSort)}}},BCSfFilter.prototype.buildSortingEvent=function(){var _this=this;jQ(".bc-sf-filter-filter-dropdown a").click(function(e){e.preventDefault(),onInteractWithToolbar(e,"sort",_this.queryParams.sort,jQ(this).data("sort"))}),jQ(".bc-sf-filter-custom-sorting > label").click(function(){jQ(".bc-sf-filter-filter-dropdown").is(":animated")||(jQ(".bc-sf-filter-filter-dropdown").toggle().parent().toggleClass("bc-sf-filter-sort-active"),jQ("#bc-sf-filter-tree").hide())}),jQ(this.getSelector("filterTreeMobileButton")).click(function(){jQ("#bc-sf-filter-top-sorting-mobile .bc-sf-filter-filter-dropdown").hide()})},BCSfFilter.prototype.buildFilterDisplayType=function(){var itemHtml=""+bcSfFilterConfig.label.toolbar_viewas+"";itemHtml+='Grid view',itemHtml+='List view';var topDisplayTypeSelector=jQ(this.getSelector("topDisplayType")),listProductSelector=jQ(this.getSelector("products"));topDisplayTypeSelector.html(itemHtml),topDisplayTypeSelector.find(".bc-sf-filter-display-item").removeClass("active"),this.queryParams.display=="list"?(topDisplayTypeSelector.find(".bc-sf-filter-display-list").addClass("active"),listProductSelector.removeClass("bc-sf-filter-grid-view-items").addClass("bc-sf-filter-list-view-items")):this.queryParams.display=="grid"&&(topDisplayTypeSelector.find(".bc-sf-filter-display-grid").addClass("active"),listProductSelector.removeClass("bc-sf-filter-list-view-items").addClass("bc-sf-filter-grid-view-items"))},BCSfFilter.prototype.buildDisplayTypeEvent=function(){var _this=this,topDisplayTypeSelector=jQ(this.getSelector("topDisplayType")),listProductSelector=jQ(this.getSelector("products"));jQ(this.getSelector("topDisplayType")+" a").click(function(e){e.preventDefault(),_this.internalClick=!0,jQ(this).parent().children().removeClass("active"),jQ(this).addClass("active"),_this.queryParams.display=="list"?(topDisplayTypeSelector.find(".bc-sf-filter-display-list").addClass("active"),listProductSelector.removeClass("bc-sf-filter-grid-view-items").addClass("bc-sf-filter-list-view-items")):_this.queryParams.display=="grid"&&(topDisplayTypeSelector.find(".bc-sf-filter-display-grid").addClass("active"),listProductSelector.removeClass("bc-sf-filter-list-view-items").addClass("bc-sf-filter-grid-view-items"));var newUrl=jQ(this).attr("href");_this.onChangeData(newUrl,"display")})},BCSfFilter.prototype.buildFilterShowLimit=function(){if(bcSfFilterConfig.custom.show_limit&&bcSfFilterTemplate.hasOwnProperty("showLimitHtml")){jQ(this.selector.topShowLimit).html("");var numberList=this.getSettingValue("general.showLimitList");if(numberList!=""){for(var showLimitItemsHtml="",arr=numberList.split(","),k=0;k'+arr[k].trim()+"";var html=bcSfFilterTemplate.showLimitHtml.replace(/{{showLimitItems}}/g,showLimitItemsHtml);jQ(this.selector.topShowLimit).html(html),jQ(this.selector.topShowLimit+" select").val(this.queryParams.limit)}}},BCSfFilter.prototype.buildBreadcrumb=function(colData,apiData){if(bcSfFilterTemplate.hasOwnProperty("breadcrumbHtml")){var breadcrumbItemsHtml="";if(typeof colData!="undefined"&&colData.hasOwnProperty("collection")){var colInfo=colData.collection;typeof this.collectionTags!="undefined"&&this.collectionTags!==null?(breadcrumbItemsHtml+=bcSfFilterTemplate.breadcrumbItemLink.replace(/{{itemLink}}/g,"/collections/"+colInfo.handle).replace(/{{itemTitle}}/g,colInfo.title),breadcrumbItemsHtml+=" {{breadcrumbDivider}} ",breadcrumbItemsHtml+=bcSfFilterTemplate.breadcrumbItemSelected.replace(/{{itemTitle}}/g,this.collectionTags[0])):breadcrumbItemsHtml+=bcSfFilterTemplate.breadcrumbItemSelected.replace(/{{itemTitle}}/g,colInfo.title)}else breadcrumbItemsHtml+=bcSfFilterTemplate.breadcrumbItemSelected.replace(/{{itemTitle}}/g,this.getSettingValue("label.defaultCollectionHeader"));var html=bcSfFilterTemplate.breadcrumbHtml.replace(/{{breadcrumbItems}}/g,breadcrumbItemsHtml);html=html.replace(/{{breadcrumbDivider}}/g,bcSfFilterTemplate.breadcrumbDivider),jQ(this.selector.breadcrumb).html(html)}};function matchHeightImage(){jQ(".bc-sf-filter-product-item-main-image").load(function(){var imageContainer=jQ(this).parent(),flipImage=imageContainer.find(".bc-sf-filter-product-item-flip-image");jQ(this).attr("style","display:none !important;"),flipImage.attr("style","display:none !important;"),imageContainer.find(".custom-main-image").length==0&&imageContainer.append('
')}).each(function(){this.complete&&jQ(this).load()})}BCSfFilter.prototype.buildExtrasProductList=function(data,eventType){var self=this,alEnable=!0;(self.getSettingValue("actionlist.qvEnable")!=""||self.getSettingValue("actionlist.atcEnable")!="")&&(alEnable=self.getSettingValue("actionlist.qvEnable")||self.getSettingValue("actionlist.atcEnable")),alEnable===!0&&typeof BCActionList!="undefined"&&(typeof bcActionList=="undefined"?bcActionList=new BCActionList:typeof bcAlParams!="undefined"&&typeof bcSfFilterParams!="undefined"?(bcActionList.initFlag=!1,bcActionList.alInit(bcSfFilterParams,bcAlParams)):bcActionList.alInit()),typeof theme!="undefined"&&typeof theme.init=="function"&&$(theme.init)},BCSfFilter.prototype.buildAdditionalElements=function(data,eventType){var _this=this,totalProduct=data.total_product+" "+bcSfFilterConfig.label.items_with_count_other+"";data.total_product==1&&(totalProduct=data.total_product+" "+bcSfFilterConfig.label.items_with_count_one+""),jQ("#bc-sf-filter-total-product").html(totalProduct),matchHeightImage(),jQ(window).resize(function(){matchHeightImage()}),jQ("body").find(".bc-sf-filter-skeleton-button").remove();var isiOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;isiOS&&this.isMobile()&&jQ(".bc-sf-filter-product-item").find("a").on("touchstart",function(){isScrolling=!1}).on("touchmove",function(){isScrolling=!0}).on("touchend",function(){isScrolling||(window.location=jQ(this).attr("href"))}),(this.isMobile()||navigator.userAgent.match(/iPad/i)!=null)&&(setTimeout(function(){jQ(".bc-sf-filter-product-item-image img").each(function(){var a=jQ(this).attr("src")+"3";jQ(this).attr("src",a)})},200),setTimeout(function(){jQ(".bc-sf-filter-product-item-image img").each(function(){var a=jQ(this).attr("src")+"3";jQ(this).attr("src",a)})},2e3))},BCSfFilter.prototype.buildDefaultElements=function(){var isiOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,isSafari=/Safari/.test(navigator.userAgent),isBackButton=window.performance&&window.performance.navigation&&window.performance.navigation.type==2;if(!(isiOS&&isSafari&&isBackButton)){var self=this,url=window.location.href.split("?")[0],searchQuery=self.isSearchPage()&&self.queryParams.hasOwnProperty("q")?"&q="+self.queryParams.q:"";window.location.replace(url+"?view=bc-original"+searchQuery)}};function customizeJsonProductData(data){for(var i=0;i0?variant.featured_image={id:featureImage[0].id,product_id:data.id,position:featureImage[0].position,created_at:"",updated_at:"",alt:null,width:featureImage[0].width,height:featureImage[0].height,src:featureImage[0].src,variant_ids:[variant.id]}:variant.featured_image=""}var self=bcsffilter,itemJson={id:data.id,title:data.title,handle:data.handle,vendor:data.vendor,variants:data.variants,url:self.buildProductItemUrl(data),options_with_values:data.options_with_values,images:data.images,images_info:data.images_info,available:data.available,price_min:data.price_min,price_max:data.price_max,compare_at_price_min:data.compare_at_price_min,compare_at_price_max:data.compare_at_price_max};return itemJson}BCSfFilter.prototype.prepareProductData=function(data){for(var countData=data.length,k=0;k0?data[k].featured_image=data[k].images[0]:data[k].featured_image={src:bcSfFilterConfig.general.no_image_url,width:"",height:"",aspect_ratio:0},data[k].url="/products/"+data[k].handle;for(var optionsArr=[],countOptionsWithValues=data[k].options_with_values.length,i=0;i1){var updateMultiCurrencyPrice2=function(oldPrice,newPrice){return typeof newPrice!="undefined"?newPrice:oldPrice},updateMultiCurrencyPrice=updateMultiCurrencyPrice2,currentCurrency=bcSfFilterConfig.general.current_currency.toLowerCase().trim();data[k].price_min=updateMultiCurrencyPrice2(data[k].price_min,data[k]["price_min_"+currentCurrency]),data[k].price_max=updateMultiCurrencyPrice2(data[k].price_max,data[k]["price_max_"+currentCurrency]),data[k].compare_at_price_min=updateMultiCurrencyPrice2(data[k].compare_at_price_min,data[k]["compare_at_price_min_"+currentCurrency]),data[k].compare_at_price_max=updateMultiCurrencyPrice2(data[k].compare_at_price_max,data[k]["compare_at_price_max_"+currentCurrency])}data[k].price_min*=100,data[k].price_max*=100,data[k].compare_at_price_min*=100,data[k].compare_at_price_max*=100,data[k].price=data[k].price_min,data[k].compare_at_price=data[k].compare_at_price_min,data[k].price_varies=data[k].price_min!=data[k].price_max;var firstVariant2=data[k].variants[0];if(getParam("variant")!==null&&getParam("variant")!=""){var paramVariant=data[k].variants.filter(function(e){return e.id==getParam("variant")});typeof paramVariant[0]!="undefined"&&(firstVariant2=paramVariant[0])}else for(var countVariants=data[k].variants.length,i=0;i0&&(data[k].tags=data[k].original_tags.slice(0)),data[k].json=customizeJsonProductData(data[k])}return data};function getFilePath(fileName,ext,version){var self=bcsffilter,ext=typeof ext!="undefined"?ext:"png",version=typeof version!="undefined"?version:"1",prIndex=self.fileUrl.lastIndexOf("?");if(prIndex>0)var filePath=self.fileUrl.substring(0,prIndex);else var filePath=self.fileUrl;return filePath+=fileName+"."+ext+"?v="+version,filePath}BCSfFilter.prototype.getFilterData=function(eventType,errorCount){function BCSend(eventType2,errorCount2){var self=bcsffilter,errorCount2=typeof errorCount2!="undefined"?errorCount2:0;self.showLoading(),typeof self.buildPlaceholderProductList=="function"&&self.buildPlaceholderProductList(eventType2),self.beforeGetFilterData(eventType2),self.prepareRequestParams(eventType2),self.queryParams.callback="BCSfFilterCallback",self.queryParams.event_type=eventType2;var url=self.isSearchPage()?self.getApiUrl("search"):self.getApiUrl("filter"),script=document.createElement("script");script.type="text/javascript";var timestamp=new Date().getTime();script.src=url+"?t="+timestamp+"&"+jQ.param(self.queryParams),script.id="bc-sf-filter-script",script.async=!0;var resendAPITimer,resendAPIDuration;resendAPIDuration=2e3,script.addEventListener("error",function(e){typeof document.getElementById(script.id).remove=="function"?document.getElementById(script.id).remove():document.getElementById(script.id).outerHTML="",errorCount2<3?(errorCount2++,resendAPITimer&&clearTimeout(resendAPITimer),resendAPITimer=setTimeout(self.getFilterData("resend",errorCount2),resendAPIDuration)):self.buildDefaultElements(eventType2)}),document.getElementsByTagName("head")[0].appendChild(script),script.onload=function(){typeof document.getElementById(script.id).remove=="function"?document.getElementById(script.id).remove():document.getElementById(script.id).outerHTML=""}}this.requestFilter(BCSend,eventType,errorCount)},BCSfFilter.prototype.requestFilter=function(sendFunc,eventType,errorCount){sendFunc(eventType,errorCount)}; //# sourceMappingURL=/cdn/shop/t/87/assets/bc-sf-filter.js.map?v=99896374705491278681683054985