1(function(){'use strict';$.widget('SwatchRendererTooltip',{options:{delay:200,tooltipClass:'swatch-option-tooltip'},_init:function(){var $widget=this,$this=this.element,$element=$('.'+$widget.options.tooltipClass),timer,type=parseInt($this.data('option-type'),10),label=$this.data('option-label'),thumb=$this.data('option-tooltip-thumb'),value=$this.data('option-tooltip-value'),width=$this.data('thumb-width'),height=$this.data('thumb-height'),$image,$title,$corner;if(!$element.length){$element=$('<div class="'+ 2$widget.options.tooltipClass+'" ><div class="image"></div><div class="title"></div><div class="corner"></div></div>');$('body').append($element);} 3$image=$element.find('.image');$title=$element.find('.title');$corner=$element.find('.corner');$this.hover(function(){if($this.hasClass('disabled')){return;} 4timer=setTimeout(function(){var leftOpt=null,leftCorner=0,left,$window;if(type===2){$image.css({'background':'url("'+thumb+'") no-repeat center','background-size':'initial','width':width+'px','height':height+'px'});$image.show();}else if(type===1){$image.css({background:value});$image.show();}else if(type===0||type===3){$image.hide();} 5$title.text(label);$element.hide();$element.show();leftOpt=$this.offset().left;left=leftOpt+$this.width()/ 2-$element.width()/ 2;$window=$(window);if(left<0){left=5;}else if(left+$element.width()>$window.width()){left=$window.width()-$element.width()-5;} 6leftCorner=0;if($element.width()<$this.width()){leftCorner=$element.width()/ 2-3;}else{leftCorner=(leftOpt>left?leftOpt-left:left-leftOpt)+$this.width()/ 2-6;} 7$corner.css({left:leftCorner});$element.css({left:left,top:$this.offset().top-$element.height()-$corner.height()-18}).show();},$widget.options.delay);},function(){$element.hide();clearTimeout(timer);});$(document).on('tap.SwatchRendererTooltip',function(){$element.hide();clearTimeout(timer);});$this.on('tap',function(event){event.stopPropagation();});},destroy:function(){$(document).off('tap.SwatchRendererTooltip');this._super();}});$.widget('SwatchRenderer',{component:'Magento_Swatches/js/swatch-renderer',options:{classes:{attributeClass:'swatch-attribute',attributeLabelClass:'swatch-attribute-label',attributeSelectedOptionLabelClass:'swatch-attribute-selected-option',attributeOptionsWrapper:'swatch-attribute-options',attributeInput:'swatch-input',optionClass:'swatch-option',selectClass:'swatch-select',moreButton:'swatch-more',loader:'swatch-option-loading'},jsonConfig:{},jsonSwatchConfig:{},selectorProduct:'.product-info-main',selectorProductPrice:'[data-role=priceBox]',mediaGallerySelector:'[data-gallery-role=gallery-placeholder]',selectorProductTile:'.product-item',numberToShow:false,onlySwatches:false,enableControlLabel:true,controlLabelId:'',moreButtonText:$.__('More'),mediaCallback:'',mediaCache:{},mediaGalleryInitial:[{}],useAjax:false,gallerySwitchStrategy:'replace',inProductList:false,slyOldPriceSelector:'.sly-old-price',slyOldPricepercent:'.discount-percent',tierPriceTemplateSelector:'#tier-prices-template',tierPriceBlockSelector:'[data-role="tier-price-block"]',tierPriceTemplate:'',normalPriceLabelSelector:'.product-info-main .normal-price .price-label'},getProduct:function(){var products=this._CalcProducts();return _.isArray(products)?products[0]:null;},getProductId:function(){var products=this._CalcProducts();return _.isArray(products)&&products.length===1?products[0]:null;},_init:function(){if($(this.element).attr('data-rendered')){return;} 8this._markup=this.element.html();$(this.element).attr('data-rendered',true);if(_.isEmpty(this.options.jsonConfig.images)){this.options.useAjax=true;this._debouncedLoadProductMedia=_.debounce(this._LoadProductMedia.bind(this),500);} 9this.options.tierPriceTemplate=$(this.options.tierPriceTemplateSelector).html();if(this.options.jsonConfig!==''&&this.options.jsonSwatchConfig!==''){this.options.jsonConfig.mappedAttributes=_.clone(this.options.jsonConfig.attributes);this._sortAttributes();this._RenderControls();this._setPreSelectedGallery();$(this.element).trigger('swatch.initialized');}else{console.log('SwatchRenderer: No input data received');}},destroy:function(){$(this.element).removeAttr('data-rendered').html(this._markup);this._super();},_sortAttributes:function(){this.options.jsonConfig.attributes=_.sortBy(this.options.jsonConfig.attributes,function(attribute){return parseInt(attribute.position,10);});},_create:function(){var options=this.options,gallery=$('.column.main').find('[data-gallery-role="gallery-placeholder"]'),productData=this._determineProductData(),$main=productData.isInProductView?this.element.parents('.column.main'):this.element.parents('.product-item-info');if(productData.isInProductView){gallery.gallery('instance')?this._onGalleryLoaded(gallery):gallery.on('gallery:loaded',this._onGalleryLoaded.bind(this,gallery));}else{options.mediaGalleryInitial=[{'img':$main.find('.product-image-photo').attr('src')}];} 10this.productForm=this.element.parents(this.options.selectorProductTile).find('form').first('first');this.inProductList=this.productForm.length>0;},_determineProductData:function(){var productId,isInProductView=false;productId=this.element.parents('.product-item-info').find('.price-box.price-final_price').attr('data-product-id');if(!productId){productId=$('[name=product]').val();isInProductView=productId>0;} 11return{productId:productId,isInProductView:isInProductView};},_RenderControls:function(){var $widget=this,container=this.element,classes=this.options.classes,chooseText=this.options.jsonConfig.chooseText,showTooltip=this.options.showTooltip;$widget.optionsMap={};$.each(this.options.jsonConfig.attributes,function(){var item=this,control
11LabelId='option-label-'+item.code+'-'+item.id,options=$widget._RenderSwatchOptions(item,controlLabelId),select=$widget._RenderSwatchSelect(item,chooseText),input=$widget._RenderFormInput(item),listLabel='',label='';if($widget.options.onlySwatches&&!$widget.options.jsonSwatchConfig.hasOwnProperty(item.id)){return;} 12if($widget.options.enableControlLabel){label+='<span id="'+controlLabelId+'" class="'+classes.attributeLabelClass+'">'+ 13$('<i></i>').text(item.label).html()+' : </span>'+'<span class="'+classes.attributeSelectedOptionLabelClass+'"></span>';} 14if($widget.inProductList){$widget.productForm.append(input);input='';listLabel='aria-label="'+$('<i></i>').text(item.label).html()+'"';}else{listLabel='aria-labelledby="'+controlLabelId+'"';} 15container.append('<div class="'+classes.attributeClass+' '+item.code+'" '+'data-attribute-code="'+item.code+'" '+'data-attribute-id="'+item.id+'">'+ 16label+'<div aria-activedescendant="" '+'aria-invalid="false" '+'aria-required="true" '+'role="listbox" '+listLabel+'class="'+classes.attributeOptionsWrapper+' clearfix">'+ 17options+select+'</div>'+input+'</div>');if(!$('body').hasClass('catalog-product-view')){$('.swatch-attribute.size').hide()} 18$widget.optionsMap[item.id]={};$.each(item.options,function(){if(this.products.length>0){$widget.optionsMap[item.id][this.id]={price:parseInt($widget.options.jsonConfig.optionPrices[this.products[0]].finalPrice.amount,10),products:this.products};}});});if(showTooltip===1){container.find('[data-option-type="1"], [data-option-type="2"],'+' [data-option-type="0"], [data-option-type="3"]').SwatchRendererTooltip();} 19$('.'+classes.moreButton).nextAll().hide();$widget._EventListener();$widget._Rewind(container);setTimeout(function(){$widget._EmulateSelected($.parseQuery());$widget._EmulateSelected($widget._getSelectedAttributes());},80);},_RenderSwatchOptions:function(config,controlId){var optionConfig=this.options.jsonSwatchConfig[config.id],optionClass=this.options.classes.optionClass,sizeConfig=this.options.jsonSwatchImageSizeConfig,moreLimit=parseInt(this.options.numberToShow,10),moreClass=this.options.classes.moreButton,moreText=this.options.moreButtonText,countAttributes=0,html='';if(!this.options.jsonSwatchConfig.hasOwnProperty(config.id)){return'';} 20$.each(config.options,function(index){var id,type,value,thumb,label,width,height,attr,swatchImageWidth,swatchImageHeight;if(!optionConfig.hasOwnProperty(this.id)){return'';} 21if(moreLimit===countAttributes++){html+='<a href="#" class="'+moreClass+'"><span>'+moreText+'</span></a>';} 22id=this.id;type=parseInt(optionConfig[id].type,10);value=optionConfig[id].hasOwnProperty('value')?$('<i></i>').text(optionConfig[id].value).html():'';thumb=optionConfig[id].hasOwnProperty('thumb')?optionConfig[id].thumb:'';width=_.has(sizeConfig,'swatchThumb')?sizeConfig.swatchThumb.width:110;height=_.has(sizeConfig,'swatchThumb')?sizeConfig.swatchThumb.height:90;label=this.label?$('<i></i>').text(this.label).html():'';attr=' index="'+index+'"'+' aria-checked="false"'+' aria-describedby="'+controlId+'"'+' tabindex="0"'+' data-option-type="'+type+'"'+' data-option-id="'+id+'"'+' data-option-label="'+label+'"'+' aria-label="'+label+'"'+' role="option"'+' data-thumb-width="'+width+'"'+' data-thumb-height="'+height+'"';attr+=thumb!==''?' data-option-tooltip-thumb="'+thumb+'"':'';attr+=value!==''?' data-option-tooltip-value="'+value+'"':'';swatchImageWidth=_.has(sizeConfig,'swatchImage')?sizeConfig.swatchImage.width:30;swatchImageHeight=_.has(sizeConfig,'swatchImage')?sizeConfig.swatchImage.height:17;if(!this.hasOwnProperty('products')||this.products.length<=0){attr+=' data-option-empty="true"';} 23if(type===0){html+='<div class="'+optionClass+' text" '+attr+'>'+(value?value:label)+'</div>';}else if(type===1){html+='<div class="'+optionClass+' color" '+attr+' style="background: '+value+' no-repeat center; background-size: initial;">'+''+'</div>';}else if(type===2){html+='<div class="'+optionClass+' image" '+attr+' style="background: url('+value+') no-repeat center; background-size: initial;width:'+ 24swatchImageWidth+'px; height:'+swatchImageHeight+'px">'+''+'</div>';}else if(type===3){html+='<div class="'+optionClass+'" '+attr+'></div>';}else{html+='<div class="'+optionClass+'" '+attr+'>'+label+'</div>';}});return html;},_RenderSwatchSelect:function(config,chooseText){var html;if(this.options.jsonSwatchConfig.hasOwnProperty(config.id)){return'';} 25html='<select class="'+this.options.classes.selectClass+' '+config.code+'">'+'<option value="0" data-option-id="0">'+chooseText+'</option>';$.each(config.options,function(){var label=this.label,attr=' value="'+this.id+'" data-option-id="'+this.id+'"';if(!this.hasOwnProperty('products')||this.products.length<=0){attr+=' data-option-empty="true"';} 26html+='<option '+attr+'>'+label+'</option>';});html+='</select>';return html;},_RenderFormInput:function(config){return'<input class="'+this.options.classes.attributeInput+' super-attribute-select" '+'name="super_attribute['+config.id+']" '+'type="text" '+'value="" '+'data-selector="super_attribute['+config.id+']" '+'data-validate="{required: true}" '+'aria-required="true" '+'aria-invalid="false">';},_EventListener:function(){var $widget=this,options=this.options.classes,target;$widget.element.on('click','.'+options.optionClass,function(){return $widget._OnClick($(this),$widget);});$widget.element.on('change','.'+options.selectClass,function(){return $widget._OnChange($(this),$widget);});$widget.element.on('click','.'+options.moreButton,function(e){e.preventDefault();return $widget._OnMoreClick($(this));});$widget.element.on('keydown',function(e){if(e.which===13){target=$(e.target);if(target.is('.'+options.optionClass)){return $widget._OnClick(target,$widget);}else if(target.is('.'+options.selectClass)){return $widget._OnChange(target,$widget);}else if(target.is('.'+options.moreButton)){e.preventDefault();return $widget._OnMoreClick(target);}}});},_loadMedia:function(){var $main=this.inProductList?this.element.parents('.product-item-info'):this.element.parents('.column.main'),images;if(this.options.useAjax){this._debouncedLoadProductMedia();}else{images=this.options.jsonConfig.images[this.getProduct()];if(!images){images=this.options.mediaGalleryInitial;} 27this.updateBaseImage(this._sortImages(images),$main,!this.inProductList);}},_sortImages:function(images){return _.sortBy(images,function(image){return parseInt(image.position,10);});},_OnClick:function($this,$widget){var $parent=$this.parents('.'+$widget.options.classes.attributeClass),$wrapper=$this.parents('.'+$widget.options.classes.attributeOptionsWrapper),$label=$parent.find('.'+$widget.options.classes.attributeSelectedOptionLabelClass),attributeId=$parent.data('attribute-id'),$input
27=$parent.find('.'+$widget.options.classes.attributeInput),checkAdditionalData=JSON.parse(this.options.jsonSwatchConfig[attributeId]['additional_data']),$priceBox=$widget._getProductWrapper().find(this.options.selectorProductPrice);if($widget.inProductList){$input=$widget.productForm.find('.'+$widget.options.classes.attributeInput+'[name="super_attribute['+attributeId+']"]');} 28if($this.hasClass('disabled')){return;} 29if($this.hasClass('selected')){$parent.removeAttr('data-option-selected').find('.selected').removeClass('selected');$input.val('');$label.text('');$this.attr('aria-checked',false);}else{$parent.attr('data-option-selected',$this.data('option-id')).find('.selected').removeClass('selected');$label.text($this.data('option-label'));$input.val($this.data('option-id'));$input.attr('data-attr-name',this._getAttributeCodeById(attributeId));$this.addClass('selected');$widget._toggleCheckedAttributes($this,$wrapper);} 30$widget._Rebuild();if($priceBox.priceBox('instance')){$widget._UpdatePrice();} 31$(document).trigger('updateMsrpPriceBlock',[this._getSelectedOptionPriceIndex(),$widget.options.jsonConfig.optionPrices,$priceBox]);if(parseInt(checkAdditionalData['update_product_preview_image'],10)===1){$widget._loadMedia();} 32$input.trigger('change');},_getSelectedOptionPriceIndex:function(){var allowedProduct=this._getAllowedProductWithMinPrice(this._CalcProducts());if(_.isEmpty(allowedProduct)){return undefined;} 33return allowedProduct;},_getAttributeCodeById:function(attributeId){var attribute=this.options.jsonConfig.mappedAttributes[attributeId];return attribute?attribute.code:attributeId;},_toggleCheckedAttributes:function($this,$wrapper){$wrapper.attr('aria-activedescendant',$this.attr('id')).find('.'+this.options.classes.optionClass).attr('aria-checked',fal
33se);$this.attr('aria-checked',true);},_OnChange:function($this,$widget){var $parent=$this.parents('.'+$widget.options.classes.attributeClass),attributeId=$parent.data('attribute-id'),$input=$parent.find('.'+$widget.options.classes.attributeInput);if($widget.productForm.length>0){$input=$widget.productForm.find('.'+$widget.options.classes.attributeInput+'[name="super_attribute['+attributeId+']"]');} 34if($this.val()>0){$parent.attr('data-option-selected',$this.val());$input.val($this.val());}else{$parent.removeAttr('data-option-selected');$input.val('');} 35$widget._Rebuild();$widget._UpdatePrice();$widget._loadMedia();$input.trigger('change');},_OnMoreClick:function($this){$this.nextAll().show();$this.blur().remove();},_Rewind:function(controls){controls.find('div[data-option-id], option[data-option-id]').removeClass('disabled').removeAttr('disabled');controls.find('div[data-option-empty], option[data-option-empty]').attr('disabled',true).addClass('disabled').attr('tabindex','-1');},_Rebuild:function(){var $widget=this,controls=$widget.element.find('.'+$widget.options.classes.attributeClass+'[data-attribute-id]'),selected=controls.filter('[data-option-selected]');$widget._Rewind(controls);if(selected.length<=0){return;} 36controls.each(function(){var $this=$(this),id=$this.data('attribute-id'),products=$widget._CalcProducts(id);if(selected.length===1&&selected.first().data('attribute-id')===id){return;} 37$this.find('[data-option-id]').each(function(){var $element=$(this),option=$element.data('option-id');if(!$widget.optionsMap.hasOwnProperty(id)||!$widget.optionsMap[id].hasOwnProperty(option)||$element.hasClass('selected')||$element.is(':selected')){return;} 38if(_.intersection(products,$widget.optionsMap[id][option].products).length<=0){$element.attr('disabled',true).addClass('disabled');}});});},_CalcProducts:function($skipAttributeId){var $widget=this,selectedOptions='.'+$widget.options.classes.attributeClass+'[data-option-selected]',products=[];$widget.element.find(selectedOptions).each(function(){var id=$(this).data('attribute-id'),option=$(this).attr('data-option-selected');if($skipAttributeId!==undefined&&$skipAttributeId===id){return;} 39if(!$widget.optionsMap.hasOwnProperty(id)||!$widget.optionsMap[id].hasOwnProperty(option)){return;} 40if(products.length===0){products=$widget.optionsMap[id][option].products;}else{products=_.intersection(products,$widget.optionsMap[id][option].products);}});return products;},_UpdatePrice:function(){var $widget=this,$product=$widget._getProductWrapper(),$productPrice=$product.find(this.options.selectorProductPrice),result=$widget._getNewPrices(),tierPriceHtml,isShow;$productPrice.trigger('updatePrice',{'prices':$widget._getPrices(result,$productPrice.priceBox('option').prices)});isShow=typeof result!='undefined'&&result.oldPrice.amount!==result.finalPrice.amount;$productPrice.find('span').first().toggleClass('special-price',isShow);$product.find(this.options.slyOldPricepercent)[isShow?'show':'hide']();$product.find(this.options.slyOldPriceSelector)[isShow?'show':'hide']();if(typeof result!='undefined'&&result.tierPrices&&result.tierPrices.length){if(this.options.tierPriceTemplate){tierPriceHtml=_.template(this.options.tierPriceTemplate)({'tierPrices':result.tierPrices,'$t':$.__,'currencyFormat':this.options.jsonConfig.currencyFormat,'priceUtils':$.catalog.priceUtils});$(this.options.tierPriceBlockSelector).html(tierPriceHtml).show();}}else{$(this.options.tierPriceBlockSelector).hide();} 41$(this.options.normalPriceLabelSelector).hide();_.each($('.'+this.options.classes.attributeOptionsWrapper),function(attribute){if($(attribute).find('.'+this.options.classes.optionClass+'.selected').length===0){if($(attribute).find('.'+this.options.classes.selectClass).length>0){_.each($(attribute).find('.'+this.options.classes.selectClass),function(dropdown){if($(dropdown).val()==='0'){$(this.options.normalPriceLabelSelector).show();}}.bind(this));}else{$(this.options.normalPriceLabelSelector).show();}}}.bind(this));},_getProductWrapper:function(){var selector=this.options.selectorProduct.replace('.product-item-details','.product-item-details'),wrapper=this.element.closest(selector);if(!wrapper.length){wrapper=this.element.closest('.column.main').find(selector);} 42return wrapper;},_getNewPrices:function(){var $widget=this,newPrices=$widget.options.jsonConfig.prices,allowedProduct=this._getAllowedProductWithMinPrice(this._CalcProducts());if(!_.isEmpty(allowedProduct)){newPrices=this.options.jsonConfig.optionPrices[allowedProduct];} 43var discountPer=Math.round((1-(newPrices.finalPrice.amount / newPrices.baseOldPrice.amount))*100);if(discountPer<5){$('[data-product-id="'+$widget.options.jsonConfig.productId+'"]').find('.discount-percent').hide();}else{$('[data-product-id="'+$widget.options.jsonConfig.productId+'"]').find('.discount-percent').text(discountPer+'% off');} 44return newPrices;},_getPrices:function(newPrices,displayPrices){var $widget=this;if(_.isEmpty(newPrices)){newPrices=$widget._getNewPrices();} 45_.each(displayPrices,function(price,code){if(newPrices[code]){displayPrices[code].amount=newPrices[code].amount-displayPrices[code].amount;}});
45return displayPrices;},_getAllowedProductWithMinPrice:function(allowedProducts){var optionPrices=this.options.jsonConfig.optionPrices,product={},optionFinalPrice,optionMinPrice;_.each(allowedProducts,function(allowedProduct){optionFinalPrice=parseFloat(optionPrices[allowedProduct].finalPrice.amount);if(_.isEmpty(product)||optionFinalPrice<optionMinPrice){optionMinPrice=optionFinalPrice;product=allowedProduct;}},this);return product;},_LoadProductMedia:function(){var $widget=this,$this=$widget.element,productData=this._determineProductData(),mediaCallData,mediaCacheKey,mediaSuccessCallback=function(data){if(!(mediaCacheKey in $widget.options.mediaCache)){$widget.options.mediaCache[mediaCacheKey]=data;} 46$widget._ProductMediaCallback($this,data,productData.isInProductView);};if(!$widget.options.mediaCallback){return;} 47mediaCallData={'product_id':this.getProduct()};mediaCacheKey=JSON.stringify(mediaCallData);if(mediaCacheKey in $widget.options.mediaCache){$widget._EnableProductMediaLoader($this);mediaSuccessCallback($widget.options.mediaCache[mediaCacheKey]);}else{mediaCallData.isAjax=true;$widget._EnableProductMediaLoader($this);$widget.xhr=$.request.get({url:$widget.options.mediaCallback,data:mediaCallData}).then(function(response){mediaSuccessCallback(response.body);});}},_EnableProductMediaLoader:function(element){element.parents('.product-item-info').addClass('product-item-info-image-loading').find('.product-image-photo').addClass(this.options.classes.loader);},_DisableProductMediaLoader:function(element){element.parents('.product-item-info').removeClass('product-item-info-image-loading').find('.product-image-photo').removeClass(this.options.classes.loader);},_ProductMediaCallback:function($this,response,isInProductView){var $main=isInProductView?$this.parents('.column.main'):$this.parents('.product-item-info'),$widget=this,images=[],support=function(e){return e.hasOwnProperty('large')&&e.hasOwnProperty('medium')&&e.hasOwnProperty('small');};if(_.size($widget)<1||!support(response)){this.updateBaseImage(this.options.mediaGalleryInitial,$main,isInProductView);return;} 48images.push({full:response.large,img:response.medium,thumb:response.small,srcset:response.srcset,isMain:true});if(response.hasOwnProperty('gallery')){$.each(response.gallery,function(){if(!support(this)||response.large===this.large){return;} 49images.push({full:this.large,img:this.medium,thumb:this.small,srcset:this.srcset});});} 50this.updateBaseImage(images,$main,isInProductView);},_setImageType:function(images){var initial=this.options.mediaGalleryInitial[0].img;if(images[0].img===initial){images=$.extend(true,[],this.options.mediaGalleryInitial);}else{images.map(function(img){if(!img.type){img.type='image';}});} 51return images;},updateBaseImage:function(images,context,isInProductView){var self=this,justAnImage=images[0],initialImages=this.options.mediaGalleryInitial,imagesToUpdate,galleryEl=context.find(this.options.mediaGallerySelector),gallery,photo=context.find('.product-image-photo'),isInitial;if(galleryEl.gallery){gallery=galleryEl.gallery('instance');} 52if(isInProductView){if(!gallery){galleryEl.on('gallery:loaded',function(){this.updateBaseImage(images,context,isInProductView);}.bind(this));return;} 53imagesToUpdate=images.length?this._setImageType($.extend(true,[],images)):[];isInitial=_.isEqual(imagesToUpdate,initialImages);if(this.options.gallerySwitchStrategy==='prepend'&&!isInitial){imagesToUpdate=imagesToUpdate.concat(initialImages);} 54gallery.updateData(imagesToUpdate);}else if(justAnImage&&justAnImage.img){photo.on('load',function(){setTimeout(function(){self._DisableProductMediaLoader(self.element);},100);});photo.attr('src',justAnImage.img);if(justAnImage.srcset&&justAnImage.srcset.medium){photo.attr('srcset',justAnImage.srcset.medium);if(!photo.attr('sizes')){photo.attr('sizes',photo.attr('data-sizes'));}}else{photo.attr('data-sizes',photo.attr('sizes'));photo.removeAttr('sizes');}}},_EmulateSelected:function(selectedAttributes){$.each(selectedAttributes,function(attributeCode,optionId){var elem=this.element.find('.'+this.options.classes.attributeClass+'[data-attribute-code="'+attributeCode+'"] [data-option-id="'+optionId+'"]'),parentInput=elem.parent();if(elem.hasClass('selected')){return;} 55if(parentInput.hasClass(this.options.classes.selectClass)){parentInput.val(optionId);parentInput.trigger('change');}else{elem.trigger('click');}}.bind(this));},_EmulateSelectedByAttributeId:function(selectedAttributes){$.each(selectedAttributes,function(attributeId,optionId){var elem=this.element.find('.'+this.options.classes.attributeClass+'[data-attribute-id="'+attributeId+'"] [data-option-id="'+optionId+'"]'),parentInput=elem.parent();if(elem.hasClass('selected')){return;} 56if(parentInput.hasClass(this.options.classes.selectClass)){parentInput.val(optionId);parentInput.trigger('change');}else{elem.trigger('click');}}.bind(this));},_getSelectedAttributes:function(){var hashIndex=window.location.href.indexOf('#'),selectedAttributes={},newparams={},smallPriceId,lowestPrice=Infinity,havelowestPrice=false,params;if(hashIndex!==-1){params=$.parseQuery(window.location.href.substr(hashIndex+1));}else{let optionPrices=_.mapObject(this.option('jsonConfig.optionPrices'),function(attr,attrIndex){
56if(attr.finalPrice.amount<lowestPrice){lowestPrice=attr.finalPrice.amount;smallPriceId=attrIndex;havelowestPrice=true;}});if(havelowestPrice&&smallPriceId){params=_.mapObject(this.option('jsonConfig.mappedAttributes'),function(attr,attrIndex){let options=attr.options;let optionsArr=_.mapObject(attr.options,function(option,optionsIndex){for(var i=0;i<option.products.length;i++){if(option.products[i]==smallPriceId){let optionId=options[optionsIndex].id;newparams[attrIndex]=optionId;}}});}.bind(this));}else{params=_.mapObject(this.option('jsonConfig.mappedAttributes'),function(attr,attrIndex){let options=this.option('jsonConfig.mappedAttributes.'+attrIndex,{}).options;return options[0].id}.bind(this));}} 57if(havelowestPrice&&smallPriceId){selectedAttributes=_.invert(_.mapObject(_.invert(newparams),function(attributeId){return this.option('jsonConfig.mappedAttributes.'+attributeId,{}).code||attributeId;}.bind(this)));}else{selectedAttributes=_.invert(_.mapObject(_.invert(params),function(attributeId){return this.option('jsonConfig.mappedAttributes.'+attributeId,{}).code||attributeId;}.bind(this)));} 58return selectedAttributes;},_onGalleryLoaded:function(element){this.options.mediaGalleryInitial=element.gallery('instance').returnCurrentImages();},_setPreSelectedGallery:function(){var mediaCallData;if(this.options.jsonConfig.preSelectedGallery){mediaCallData={'product_id':this.getProduct()};this.options.mediaCache[JSON.stringify(mediaCallData)]=this.options.jsonConfig.preSelectedGallery;}}});})();
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.