PageSourceSearch

https://www.serbica.com/cdn/shop/t/3/assets/option_selection.js?v=91798675127638800821457928187

js serbica.com collected 2026-10-02 12:07:46 UTC 7,652 bytes, 2 lines download raw bytes

1if(typeof Shopify=="undefined")var Shopify={};Shopify.each=function(ary,callback){for(var i=0;i<ary.length;i++)callback(ary[i],i)},Shopify.map=function(ary,callback){for(var result=[],i=0;i<ary.length;i++)result.push(callback(ary[i],i));return result},Shopify.arrayIncludes=function(ary,obj){for(var i=0;i<ary.length;i++)if(ary[i]==obj)return!0;return!1},Shopify.uniq=function(ary){for(var result=[],i=0;i<ary.length;i++)Shopify.arrayIncludes(result,ary[i])||result.push(ary[i]);return result},Shopify.isDefined=function(obj){return typeof obj!="undefined"},Shopify.getClass=function(obj){return Object.prototype.toString.call(obj).slice(8,-1)},Shopify.extend=function(subClass,baseClass){function inheritance(){}inheritance.prototype=baseClass.prototype,subClass.prototype=new inheritance,subClass.prototype.constructor=subClass,subClass.baseConstructor=baseClass,subClass.superClass=baseClass.prototype},Shopify.Product=function(json){Shopify.isDefined(json)&&this.update(json)},Shopify.Product.prototype.update=function(json){for(property in json)this[property]=json[property]},Shopify.Product.prototype.optionNames=function(){return Shopify.getClass(this.options)=="Array"?this.options:[]},Shopify.Product.prototype.optionValues=function(index){if(!Shopify.isDefined(this.variants))return null;var results=Shopify.map(this.variants,function(e){var option_col="option"+(index+1);return e[option_col]==null?null:e[option_col]});return results[0]==null?null:Shopify.uniq(results)},Shopify.Product.prototype.getVariant=function(selectedValues){var found=null;return selectedValues.length!=this.options.length||Shopify.each(this.variants,function(variant){for(var satisfied=!0,j=0;j<selectedValues.length;j++){var option_col="option"+(j+1);variant[option_col]!=selectedValues[j]&&(satisfied=!1)}if(satisfied==!0){found=variant;return}}),found},Shopify.money_format="$ {{amount}}",Shopify.formatMoney=function(cents,format){typeof cents=="string"&&(cents=cents.replace(".",""));var value="",patt=/\{\{\s*(\w+)\s*\}\}/,formatString=format||this.money_format;function addCommas(moneyString){return moneyString.replace(/(\d+)(\d{3}[\.,]?)/,"$1,$2")}switch(formatString.match(patt)[1]){case"amount":value=addCommas(floatToString(cents/100,2));break;case"amount_no_decimals":value=addCommas(floatToString(cents/100,0));break;case"amount_with_comma_separator":value=floatToString(cents/100,2).replace(/\./,",");break;case"amount_no_decimals_with_comma_separator":value=addCommas(floatToString(cents/100,0)).replace(/\./,",");break}return formatString.replace(patt,value)};function floatToString(numeric,decimals){var amount=numeric.toFixed(decimals).toString();return amount.match(/^\.\d+/)?"0"+amount:amount}Shopify.OptionSelectors=function(existingSelectorId,options){this.selectorDivClass="selector-wrapper",this.selectorClass="single-option-selector",this.variantIdFieldIdSuffix="-variant-id",this.variantIdField=null,this.selectors=[],this.domIdPrefix=existingSelectorId,this.product=new Shopify.Product(options.product),this.onVariantSelected=Shopify.isDefined(options.onVariantSelected)?options.onVariantSelected:function(){},this.replaceSelector(existingSelectorId),this.selectors[0].element.onchange();var newSelectors=$(".single-option-selector");return $.each(newSelectors,function(i,obj){obj=$(obj);var col=$("<div>",{class:"col-xs-6"}),group=$("<div>",{class:"form-group"}),label=obj.siblings("label");obj.addClass("form-control"),group.insertBefore(label),group.append(col),col.append(label),col.append(obj)}),!0},Shopify.OptionSelectors.prototype.replaceSelector=function(domId){var oldSelector=document.getElementById(domId),parent=oldSelector.parentNode;Shopify.each(this.buildSelectors(),function(el){parent.insertBefore(el,oldSelector)}),oldSelector.style.display="none",this.variantIdField=oldSelector},Shopify.OptionSelectors.prototype.insertSelectors=function(domId,messageElementId){Shopify.isDefined(messageElementId)&&this.setMessageElement(messageElementId),this.domIdPrefix="product-"+this.product.id+"-variant-selector";var parent=document.getElementById(domId);Shopify.each(this.buildSelectors(),function(el){parent.appendChild(el)})},Shopify.OptionSelectors.prototype.buildSelectors=function(){for(var i=0;i<this.product.optionNames().length;i++){var sel=new Shopify.SingleOptionSelector(this,i,this.product.optionNames()[i],this.product.optionValues(i));sel.element.disabled=!1,this.selectors.push(sel)}var divClass=this.selectorDivClass,optionNames=this.product.optionNames(),elements=Shopify.map(this.selectors,function(selector){var div=document.createElement("div");div.setAttribute("class",divClass);var label=document.createElement("label");
1return label.htmlFor=selector.element.id,label.innerHTML=selector.name,div.appendChild(label),div.appendChild(selector.element),div});return elements},Shopify.OptionSelectors.prototype.selectedValues=function(){for(var currValues=[],i=0;i<this.selectors.length;i++){var thisValue=this.selectors[i].element.value;currValues.push(thisValue)}return currValues},Shopify.OptionSelectors.prototype.updateSelectors=function(index){var currValues=this.selectedValues(),variant=this.product.getVariant(currValues);variant?(this.variantIdField.disabled=!1,this.variantIdField.value=variant.id):this.variantIdField.disabled=!0,this.onVariantSelected(variant,this)},Shopify.OptionSelectorsFromDOM=function(existingSelectorId,options){var optionNames=options.optionNames||[],priceFieldExists=options.priceFieldExists||!0,delimiter=options.delimiter||"/",productObj=this.createProductFromSelector(existingSelectorId,optionNames,priceFieldExists,delimiter);options.product=productObj,Shopify.OptionSelectorsFromDOM.baseConstructor.call(this,existingSelectorId,options)},Shopify.extend(Shopify.OptionSelectorsFromDOM,Shopify.OptionSelectors),Shopify.OptionSelectorsFromDOM.prototype.createProductFromSelector=function(domId,optionNames,priceFieldExists,delimiter){if(!Shopify.isDefined(priceFieldExists))var priceFieldExists=!0;if(!Shopify.isDefined(delimiter))var delimiter="/";var oldSelector=document.getElementById(domId),options=oldSelector.childNodes,parent=oldSelector.parentNode,optionCount=optionNames.length,variants=[],self=this;Shopify.each(options,function(option,variantIndex){if(option.nodeType==1&&option.tagName.toLowerCase()=="option"){var chunks=option.innerHTML.split(new RegExp("\\s*\\"+delimiter+"\\s*"));optionNames.length==0&&(optionCount=chunks.length-(priceFieldExists?1:0));var optionOptionValues=chunks.slice(0,optionCount),message=priceFieldExists?chunks[optionCount]:"",variantId=option.getAttribute("value"),attributes={available:!option.disabled,id:parseFloat(option.value),price:message,option1:optionOptionValues[0],option2:optionOptionValues[1],option3:optionOptionValues[2]};variants.push(attributes)}});var updateObj={variants:variants};if(optionNames.length==0){updateObj.options=[];for(var i=0;i<optionCount;i++)updateObj.options[i]="option "+(i+1)}else updateObj.options=optionNames;return updateObj},Shopify.SingleOptionSelector=function(multiSelector,index,name,values){this.multiSelector=multiSelector,this.values=values,this.index=index,this.name=name,this.element=document.createElement("select");for(var i=0;i<values.length;i++){var opt=document.createElement("option");opt.value=values[i],opt.innerHTML=values[i],this.element.appendChild(opt)}return this.element.setAttribute("class",this.multiSelector.selectorClass),this.element.id=multiSelector.domIdPrefix+"-option-"+index,this.element.onchange=function(){multiSelector.updateSelectors(index)},!0};
2//# sourceMappingURL=/cdn/shop/t/3/assets/option_selection.js.map?v=91798675127638800821457928187

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.