text: var Sonata=Sonata||{};Sonata.Product={url:{infoStockPrice:null},targets:{inputAddBasket:null,productPrice:null,submitBasketBtn:null,addBasketError:null},variations:{fields:null,form:null,unavailableError:null},init:function(a){this.setOptions(a);this.initAddBasket()},setOptions:function(a){a=a||[];for(property in a){this[property]=a[property]}},initVariation:function(){for(field in this.variations.fields){this.variations.fields[field].change(jQuery.proxy(this.changeVariation,this))}},changeVariation:function(b){this.variations.unavailableError.text("");this.variations.unavailableError.css("display","none");var a=this.variations.form.attr("action");jQuery.ajax({url:a,type:"GET",data:this.variations.form.serialize(),success:jQuery.proxy(this.processChangeVariationResults,this)})},processChangeVariationResults:function(a){if(a.error){this.variations.unavailableError.text(a.error);this.variations.unavailableError.css("display","block")}else{window.location.href=a.variation_url}},initAddBasket:function(){this.targets.inputAddBasket.on("input",jQuery.proxy(this.changeAddBasket,this))},changeAddBasket:function(b){this.resetElements();var a=this.buildInfoStockPriceUrl(b.currentTarget.value);jQuery.getJSON(a,jQuery.proxy(this.processAddBasketResults,this))},resetElements:function(){this.targets.addBasketError.css("display","none");this.targets.submitBasketBtn.removeClass("disabled");this.targets.submitBasketBtn.prop("disabled",false)},processAddBasketResults:function(a){if(a.errors.stock){jQuery.proxy(this.addBasketAddErrors(a.errors),this)}jQuery.proxy(this.addBasketProcessPrice(a.price_text),this)},buildInfoStockPriceUrl:function(a){return this.url.infoStockPrice+"?quantity="+a},addBasketAddErrors:function(a){this.targets.addBasketError.text(a.stock);this.targets.addBasketError.css("display","block");this.targets.submitBasketBtn.addClass("disabled");this.targets.submitBasketBtn.prop("disabled",true)},addBasketProcessPrice:function(a){this.targets.productPrice.text(a)}};