"use strict";var getBrandInfo={fetchBrand:function(){console.log("fetching brand info...");$.ajax({url:"/api/async.php?t=brand&m=brand&a=get_brand_info&brandUrl="+window.pageInfo.brandUrl,method:"GET",dataType:"json",context:this,success:function(data){console.log("Data Success:"),console.log(data);var mainBrandImage,brandInfo=data.retArr,hasSampleImages=!1;brandInfo.collectionTitle,(mainBrandImage=brandInfo.mainBrandImage)&&$("#brand-banner .container-fluid").html('<img src="'+mainBrandImage+'" class="mx-auto d-block w-100 h-auto">');var textImageBlocks,countSamples=0;if(console.log("BRAND SAMPLE IMAGES LENGTH"),console.log(brandInfo.sampleImages.length),console.log(brandInfo.sampleImages),textImageBlocks=void 0!==brandInfo.sampleImages&&brandInfo.sampleImages.length?'\t\t\t\t\t<div class="col-12 col-md-6">\t\t\t\t\t\t<div id="brand-sample-images" class="brand-slider owl-carousel"></div>\t\t\t\t\t</div>\t\t\t\t\t<div class="col-12 col-md-6">\t\t\t\t\t\t<div class="d-flex justify-content-center flex-column h-100 text-center text-md-left">\t\t\t\t\t\t\t<h5 class="text-center text-md-left mb-20">Learn about the '+$("#brandSampleImages").data("brand-word")+'</h5>\t\t\t\t\t\t\t<p class="text-center text-md-left mb-0">'+$("#brandSampleImages").data("brand-copy")+"</p>\t\t\t\t\t\t</div>\t\t\t\t\t</div>":'\t\t\t\t\t<div class="col-12">\t\t\t\t\t\t<div class="d-flex justify-content-center flex-column h-100 text-center">\t\t\t\t\t\t\t<h5 class="text-center mb-20">Learn about the '+$("#brandSampleImages").data("brand-word")+'</h5>\t\t\t\t\t\t\t<p class="text-center mb-0 max-width-md-66">'+$("#brandSampleImages").data("brand-copy")+"</p>\t\t\t\t\t\t</div>\t\t\t\t\t</div>",$("#brandSampleImages").html(textImageBlocks),$.each(brandInfo.sampleImages,(function(index,item){console.log(item);var finalImage=item.collectionImg;-1==item.collectionImg.indexOf("/images/collection/sample-images/")&&-1==item.collectionImg.indexOf("/images/collections/")&&(finalImage="//collections.jewelryimages.net/png_images_v3/"+item.collectionImg),$("#brand-sample-images").append('<div><img data-src="'+finalImage+'" class="lazy"></div>'),hasSampleImages=!0,countSamples++})),hasSampleImages){var samplesNav=!1,samplesDots=!0;countSamples>10&&(samplesNav=!0,samplesDots=!1),$("#brand-sample-images").owlCarousel({autoplay:!0,center:!1,autoHeight:!0,animateOut:"fadeOut",animateIn:"fadeIn",loop:!0,dots:samplesDots,margin:0,responsiveClass:!0,nav:samplesNav,navText:['<i class="icon-chevron-left"></i>','<i class="icon-chevron-right"></i>'],items:1,onInitialize:reinitBrandLazyLoads($("#brand-sample-images")),onInitialized:refreshBrandSamples()})}getBrandInfo.fetchBrandProducts(brandInfo.collectionUrl,brandInfo.collectionTitle)},error:function(err){console.log("Data Error: "+err)}})},fetchBrandCategories:function(){$.ajax({url:"/api/async.php?t=brand&m=brand&a=get_brand_categories&brandUrl="+window.pageInfo.brandUrl,method:"GET",dataType:"json",context:this,success:function(data){console.log("brand categories..."),console.log(data);var brandInfo=data.retArr,categoryList="",categoryText="",countVars=(window.pageInfo.brandUrl,"");if(countVars=0,brandInfo){countVars=Object.keys(brandInfo).length;var count=0;$.each(brandInfo,(function(index,item){count++,categoryText+=count<countVars&&count+1==countVars?'<a href="/jewelry/'+index+'" style="font-weight:bold;color:inherit !important;">'+item+"</a> or ":count<countVars?'<a href="/jewelry/'+index+'" style="font-weight:bold;color:inherit !important;">'+item+"</a>, ":'<a href="/jewelry/'+index+'" style="font-weight:bold;color:inherit !important;">'+item+"</a>",categoryList+='<a class="btn btn-outline-dark btn-md mx-1 mb-2" href="/jewelry/'+index+'">'+item+"</a>"})),$("#brandCategoryList").html(categoryList),categoryList&&$("#brandCategoryListRow").removeClass("d-none"),""===categoryText||$("#brandCategoryText").html(" "+categoryText)}},error:function(err){console.log("Data Error: "+err)}})},fetchOneBrandItem:function(){console.log("fetching brand item...");$.ajax({url:"/api/async.php?t=grid&m=fetch&a=get_results&catOrBrand=brandFirst&brand="+window.pageInfo.brandUrl+"&itemsPerPage=1",method:"GET",dataType:"json",context:this,success:function(data){var itemInfo=data.rows,fullImage=itemInfo[0].fullImage;console.log("Item URL: "+itemInfo[0].itemUrl),console.log("Full Image: "+fullImage),$.each(itemInfo[0],(function(index,item){}))},error:function(err){console.log("Data Error: "+err)}})},fetchBrandProducts(collectionUrl,collectionTitle){$.ajax({url:"/api/async.php?t=brand&m=brand&a=get_brand_products&brandLink="+collectionUrl,method:"GET",dataType:"json",success:function(data){console.log("fetchBrandProducts......."),console.log(data);var i=0;if($.each(data.products,(function(){var urlDesc=this.itemUrl.split("/"),altTagExtras="";$.each(urlDesc,(function(key,val){"jewelry-details"!=val&&0==$.isNumeric(parseInt(val))&&(altTagExtras+=" "+val)})),$("#brand-carousel").append('<div><a href="'+this.itemUrl+'"><img data-src="'+this.fullImage+'" alt="'+collectionTitle+altTagExtras+'" class="lazy px-20 py-20 border"></a></div>'),i++,$("#brandCategoryListRow").removeClass("d-none")})),i>0){var shopBrand='<a href="/jewelry/brand/'+collectionUrl+'" class="btn btn-outline-dark btn-md btn-block-xs mb-30">Shop All '+collectionTitle+"</a>";$("#brand-products-link").html(shopBrand);var countClass="";i<5&&(countClass="under5"),$("#brand-carousel").addClass(countClass),$("#brand-carousel").owlCarousel({center:!1,loop:!1,dots:!1,margin:10,autoHeight:!0,responsiveClass:!0,nav:!0,onInitialized:function(){reinitBrandLazyLoads($("#brand-carousel"))},navText:['<i class="icon-chevron-left"></i>','<i class="icon-chevron-right"></i>'],responsive:{0:{items:2,center:!0,loop:!0},768:{items:4},992:{items:4},1200:{items:5}}}),$("#brand-carousel").parent().animate({opacity:1},600)}},error:function(err){console.log("Data Error: "+err)}})}};function refreshBrandSamples(){$("#brand-sample-images").trigger("refresh.owl.carousel")}function reinitBrandLazyLoads(type=""){$(type).find("[data-src].lazy").each((function(index,element){$(element).data("src")&&$(element).lazy({scrollDirection:"vertical",effect:"fadeIn",visibleOnly:!1,enableThrottle:!0,throttle:500,afterLoad:function(elem){elem.removeClass("lazy"),$(".grid:not(.widget-social-grid):not(.widget-product-grid):not(.widget-custom-jewelry-grid)").each((function(i,e){$(e).isotope("layout")})),$(".column-slider").each((function(i,e){$(e).trigger("refresh.owl.carousel")})),setTimeout(refreshBrandSamples(),2e3),null==elem.attr("src")?console.log("lazy-loaded(reinitLazyLoads(type) in main.js): "+elem.css("background-image")):console.log("lazy-loaded(reinitLazyLoads(type) in main.js): "+elem.attr("src"))}})}))}self.getBrandInfo.fetchBrand(),self.getBrandInfo.fetchBrandCategories();