var Products = Products||{}; (function() { 'use strict'; /** * Event when select for dimmensions or hardness is changed.
* It updates price. */ Products.onProductPropertySelectChange = function(sender) { var productId = prodsByPriceProp[jQuery(sender).closest('[id^=prodCont_]').getAfterId()][sender.value]; if(productId != null) { var pdata = jabox.getProduct(productId); _constructPriceImages(sender, pdata.getRegularPrice(), pdata.getActionPrice()); } }; var _get$priceDiv = function(propSelect) { var $cont = jQuery(propSelect).closest('[id^=prodCont_]'); return $cont.find('#priceDiv_'+$cont.getAfterId()); }; var _get$regularPriceDiv = function(propSelect) { var $cont = jQuery(propSelect).closest('[id^=prodCont_]'); return $cont.find('#regPriceDiv_'+$cont.getAfterId()); }; /** * Construct price from images. * @param propSelect {dom} Dom element which triggered price change. * @param regularPrice {String} String representing regular price. * @param actionPrice {String} String representing action price (null if product is not in action). */ var _constructPriceImages = function(propSelect, regularPrice, actionPrice) { var $priceDiv = _get$priceDiv(propSelect).empty(); var $regPriceDiv = _get$regularPriceDiv(propSelect).remove(); if(Common.isEmptyString(regularPrice) || parseFloat(regularPrice)<=0) { return; } var activePrice = actionPrice==null?regularPrice:actionPrice; if(actionPrice != null) { var regDiv = Common.createEl('div', {c:'regularprice'}); jQuery(regDiv).append('' + regularPrice + ''); $priceDiv.before(regDiv); } Common.priceToImage($priceDiv, activePrice); }; })();