PageSourceSearch

https://riverparkinn.com/js/configurable.min.js

js riverparkinn.com collected 2026-10-10 00:09:49 UTC 12,474 bytes, 22 lines download raw bytes

1(function(){'use strict';$.widget('configurable',{component:'configurable',options:{superSelector:'.super-attribute-select',selectSimpleProduct:'[name="selected_configurable_option"]',priceHolderSelector:'.price-box',spConfig:{},state:{},priceFormat:{},optionTemplate:'<%- data.label %>'+'<% if (typeof data.finalPrice.value !== "undefined") { %>'+' <%- data.finalPrice.formatted %>'+'<% } %>',mediaGallerySelector:'[data-gallery-role=gallery-placeholder]',mediaGalleryInitial:null,slyOldPriceSelector:'.sly-old-price',normalPriceLabelSelector:'.product-info-main .normal-price .price-label',gallerySwitchStrategy:'replace',tierPriceTemplateSelector:'#tier-prices-template',tierPriceBlockSelector:'[data-role="tier-price-block"]',tierPriceTemplate:''},_create:function(){if($(this.options.priceHolderSelector).priceBox('instance')){this._onPriceFormatReady();}else{$(this.options.priceHolderSelector).on('price-box-initialized',this._onPriceFormatReady.bind(this));}},_onPriceFormatReady:function(){this._initializeOptions();this._overrideDefaults();this._setupChangeEvents();this._fillState();this._setChildSettings();this._configureForValues();$(this.element).trigger('configurable.initialized');},_initializeOptions:function(){var options=this.options,gallery=$(options.mediaGallerySelector),priceBox=$(this.options.priceHolderSelector).priceBox('instance'),priceBoxOptions=null;if(priceBox){priceBoxOptions=priceBox.option('priceConfig');}
2if(priceBoxOptions&&priceBoxOptions.optionTemplate){options.optionTemplate=priceBoxOptions.optionTemplate;}
3if(priceBoxOptions&&priceBoxOptions.priceFormat){options.priceFormat=priceBoxOptions.priceFormat;}
4options.optionTemplate=_.template(options.optionTemplate);options.tierPriceTemplate=$(this.options.tierPriceTemplateSelector).html();options.settings=options.spConfig.containerId?$('body').find(options.spConfig.containerId).find(options.superSelector):$(options.superSelector);options.values=options.spConfig.defaultValues||{};options.parentImage=$('[data-role=base-image-container] img').attr('src');this.inputSimpleProduct=this.element.find(options.selectSimpleProduct);gallery.gallery&&gallery.gallery('instance')?this._onGalleryLoaded(gallery):gallery.on('gallery:loaded',this._onGalleryLoaded.bind(this,gallery));},_overrideDefaults:function(){var hashIndex=window.location.href.indexOf('#');if(hashIndex!==-1){this._parseQueryParams(window.location.href.substr(hashIndex+1));}
5if(this.options.spConfig.inputsInitialized){this._setValuesByAttribute();}
6this._setInitialOptionsLabels();},_parseQueryParams:function(queryString){var queryParams=$.parseQuery(queryString);$.each(queryParams,function(key,value){if(this.options.spConfig.attributes[key]!==undefined&&_.find(this.options.spConfig.attributes[key].options,function(element){return element.id===value;})){this.options.values[key]=value;}}.bind(this));},_setValuesByAttribute:function(){this.options.values={};$.each(this.options.settings,function(index,element){var attributeId;
6if(element.value){attributeId=element.id.replace(/[a-z]*/,'');if(this.options.spConfig.attributes[attributeId]!==undefined&&_.find(this.options.spConfig.attributes[attributeId].options,function(optionElement){return optionElement.id===element.value;})){this.options.values[attributeId]=element.value;}}}.bind(this));},_setInitialOptionsLabels:function(){$.each(this.options.spConfig.attributes,function(index,element){$.each(element.options,function(optIndex,optElement){this.options.spConfig.attributes[index].options[optIndex].initialLabel=optElement.label;}.bind(this));}.bind(this));},_setupChangeEvents:function(){$.each(this.options.settings,function(index,element){$(element).on('change',this,this._configure);}.bind(this));},_fillState:function(){$.each(this.options.settings,function(index,element){var attributeId=element.id.replace(/[a-z]*/,'');if(attributeId&&this.options.spConfig.attributes[attributeId]){element.config=this.options.spConfig.attributes[attributeId];element.attributeId=attributeId;this.options.state[attributeId]=false;}}.bind(this));},_setChildSettings:function(){var childSettings=[],settings=this.options.settings,index=settings.length,option;while(index--){option=settings[index];if(index){option.disabled=true;}else{this._fillSelect(option);}
7_.extend(option,{childSettings:childSettings.slice(),prevSetting:settings[index-1],nextSetting:settings[index+1]});childSettings.push(option);}},_configureForValues:function(){if(this.options.values){this.options.settings.each(function(index,element){var attributeId=element.attributeId;element.value=this.options.values[attributeId]||'';this._configureElement(element);}.bind(this));}},_configure:function(event){event.data._configureElement(this);},_configureElement:function(element){this.simpleProduct=this._getSimpleProductId(element);if(element.value){this.options.state[element.config.id]=element.value;if(element.nextSetting){element.nextSetting.disabled=false;this._fillSelect(element.nextSetting);this._resetChildren(element.nextSetting);}else{if(!!document.documentMode){this.inputSimpleProduct.val(element.options[element.selectedIndex].config.allowedProducts[0]);}else{this.inputSimpleProduct.val(element.selectedOptions[0].config.allowedProducts[0]);}}}else{this._resetChildren(element);}
8this._reloadPrice();this._displayRegularPriceBlock(this.simpleProduct);this._displayTierPriceBlock(this.simpleProduct);this._displayNormalPriceLabel();this._changeProductImage();},_changeProductImage:function(){var images,initialImages=this.options.mediaGalleryInitial,galleryEl=$(this.options.mediaGallerySelector),gallery;if(galleryEl.gallery){gallery=galleryEl.gallery('instance');}
9if(_.isUndefined(gallery)){galleryEl.on('gallery:loaded',function(){this._changeProductImage();}.bind(this));return;}
10images=this.options.spConfig.images[this.simpleProduct];if(images){images=this._sortImages(images);if(this.options.gallerySwitchStrategy==='prepend'){images=images.concat(initialImages);}
11images=$.extend(true,[],images);gallery.updateData(images);}else{gallery.updateData(initialImages);}},_sortImages:function(images){return _.sortBy(images,function(image){return image.position;});},_resetChildren:function(element){if(element.childSettings){_.each(element.childSettings,function(set){set.selectedIndex=0;set.disabled=true;});if(element.config){this.options.state[element.config.id]=false;}}}
11,_fillSelect:function(element){var attributeId=element.id.replace(/[a-z]*/,''),options=this._getAttributeOptions(attributeId),prevConfig,index=1,allowedProducts,allowedProductsByOption,allowedProductsAll,i,j,finalPrice=parseFloat(this.options.spConfig.prices.finalPrice.amount),optionFinalPrice,optionPriceDiff,optionPrices=this.options.spConfig.optionPrices,allowedOptions=[],indexKey,allowedProductMinPrice,allowedProductsAllMinPrice;this._clearSelect(element);element.options[0]=new Option('','');element.options[0].innerHTML=this.options.spConfig.chooseText;prevConfig=false;if(element.prevSetting){prevConfig=element.prevSetting.options[element.prevSetting.selectedIndex];}
12if(options){for(indexKey in this.options.spConfig.index){if(this.options.spConfig.index.hasOwnProperty(indexKey)){allowedOptions=allowedOptions.concat(_.values(this.options.spConfig.index[indexKey]));}}
13if(prevConfig){allowedProductsByOption={};allowedProductsAll=[];for(i=0;i<options.length;i++){for(j=0;j<options[i].products.length;j++){if(prevConfig.config&&prevConfig.config.allowedProducts&&prevConfig.config.allowedProducts.indexOf(options[i].products[j])>-1){if(!allowedProductsByOption[i]){allowedProductsByOption[i]=[];}
14allowedProductsByOption[i].push(options[i].products[j]);allowedProductsAll.push(options[i].products[j]);}}}
15if(typeof allowedProductsAll[0]!=='undefined'&&typeof optionPrices[allowedProductsAll[0]]!=='undefined'){allowedProductsAllMinPrice=this._getAllowedProductWithMinPrice(allowedProductsAll);finalPrice=parseFloat(optionPrices[allowedProductsAllMinPrice].finalPrice.amount);}}
16for(i=0;i<options.length;i++){if(prevConfig&&typeof allowedProductsByOption[i]==='undefined'){continue;}
17allowedProducts=prevConfig?allowedProductsByOption[i]:options[i].products.slice(0);optionPriceDiff=0;if(typeof allowedProducts[0]!=='undefined'&&typeof optionPrices[allowedProducts[0]]!=='undefined'){allowedProductMinPrice=this._getAllowedProductWithMinPrice(allowedProducts);optionFinalPrice=parseFloat(optionPrices[allowedProductMinPrice].finalPrice.amount);optionPriceDiff=optionFinalPrice-finalPrice;options[i].label=options[i].initialLabel;if(optionPriceDiff!==0){options[i].label+=' '+$.catalog.priceUtils.formatPrice(optionPriceDiff,this.options.priceFormat,true);}}
18if(allowedProducts.length>0||_.include(allowedOptions,options[i].id)){options[i].allowedProducts=allowedProducts;element.options[index]=new Option(this._getOptionLabel(options[i]),options[i].id);if(typeof options[i].price!=='undefined'){element.options[index].setAttribute('price',options[i].price);}
19if(allowedProducts.length===0){element.options[index].disabled=true;}
20element.options[index].config=options[i];index++;}}}},_getOptionLabel:function(option){return option.label;},_clearSelect:function(element){var i;for(i=element.options.length-1;i>=0;i--){element.remove(i);}},_getAttributeOptions:function(attributeId){if(this.options.spConfig.attributes[attributeId]){return this.options.spConfig.attributes[attributeId].options;}},_reloadPrice:function(){$(this.options.priceHolderSelector).trigger('updatePrice',this._getPrices());},_getPrices:function(){var prices={},elements=_.toArray(this.options.settings),allowedProduct;_.each(elements,function(element){var selected=element.options[element.selectedIndex],config=selected&&selected.config,priceValue={};if(config&&config.allowedProducts.length===1){priceValue=this._calculatePrice(config);}else if(element.value){allowedProduct=this._getAllowedProductWithMinPrice(config.allowedProducts);priceValue=this._calculatePrice({'allowedProducts':[allowedProduct]});}
21if(!_.isEmpty(priceValue)){prices.prices=priceValue;}},this);return prices;},_getAllowedProductWithMinPrice:function(allowedProducts){var optionPrices=this.options.spConfig.optionPrices,product={},optionMinPrice,optionFinalPrice;_.each(allowedProducts,function(allowedProduct){optionFinalPrice=parseFloat(optionPrices[allowedProduct].finalPrice.amount);if(_.isEmpty(product)||optionFinalPrice<optionMinPrice){optionMinPrice=optionFinalPrice;product=allowedProduct;}},this);return product;},_calculatePrice:function(config){var displayPrices=$(this.options.priceHolderSelector).priceBox('option').prices,newPrices=this.options.spConfig.optionPrices[_.first(config.allowedProducts)];_.each(displayPrices,function(price,code){if(newPrices[code]){displayPrices[code].amount=newPrices[code].amount-displayPrices[code].amount;}});
21return displayPrices;},_getSimpleProductId:function(element){var allOptions=element.config.options,value=element.value,config;config=_.filter(allOptions,function(option){return option.id===value;});config=_.first(config);return _.isEmpty(config)?undefined:_.first(config.allowedProducts);},_displayRegularPriceBlock:function(optionId){var shouldBeShown=true;_.each(this.options.settings,function(element){if(element.value===''){shouldBeShown=false;}});if(shouldBeShown&&this.options.spConfig.optionPrices[optionId].oldPrice.amount!==this.options.spConfig.optionPrices[optionId].finalPrice.amount){$(this.options.slyOldPriceSelector).show();}else{$(this.options.slyOldPriceSelector).hide();}
22$(document).trigger('updateMsrpPriceBlock',[optionId,this.options.spConfig.optionPrices]);},_displayNormalPriceLabel:function(){var shouldBeShown=false;_.each(this.options.settings,function(element){if(element.value===''){shouldBeShown=true;}});if(shouldBeShown){$(this.options.normalPriceLabelSelector).show();}else{$(this.options.normalPriceLabelSelector).hide();}},_onGalleryLoaded:function(element){this.options.mediaGalleryInitial=element.gallery('instance').returnCurrentImages();},_displayTierPriceBlock:function(optionId){var tierPrices=typeof optionId!='undefined'&&this.options.spConfig.optionPrices[optionId].tierPrices;if(_.isArray(tierPrices)&&tierPrices.length>0){if(this.options.tierPriceTemplate){$(this.options.tierPriceBlockSelector).html(_.template(this.options.tierPriceTemplate)({'tierPrices':tierPrices,'$t':$.__,'currencyFormat':this.options.spConfig.currencyFormat,'priceUtils':$.catalog.priceUtils})).show();}}else{$(this.options.tierPriceBlockSelector).hide();}}});})();

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.