PageSourceSearch

https://turk3.org/js/price-box.min.js

js turk3.org collected 2026-09-29 21:36:57 UTC 4,013 bytes, 9 lines download raw bytes

1(function(){'use strict';var globalOptions={productId:null,priceConfig:null,prices:{},priceTemplate:'<span class="price"><%- data.formatted %></span>'};$.widget('priceBox',{component:'priceBox',options:globalOptions,qtyInfo:'#qty',_init:function(){var box=this.element;box.trigger('updatePrice');this.cache.displayPrices=$.catalog.priceUtils.deepClone(this.options.prices);},_create:function(){var box=this.element;this.cache={};this._setDefaultsFromPriceConfig();this._setDefaultsFromDataSet();box.on('reloadPrice',this.reloadPrice.bind(this));box.on('updatePrice',this.onUpdatePrice.bind(this));$(this.qtyInfo).on('input',this.updateProductTierPrice.bind(this));setTimeout(()=>{box.trigger('price-box-initialized');});},onUpdatePrice:function(event,prices){return this.updatePrice(prices);},updatePrice:function(newPrices){var prices=this.cache.displayPrices,additionalPrice={},pricesCode=[],priceValue,origin,finalPrice;this.cache.additionalPriceObject=this.cache.additionalPriceObject||{};if(newPrices){$.extend(this.cache.additionalPriceObject,newPrices);}
2if(!_.isEmpty(additionalPrice)){pricesCode=_.keys(additionalPrice);}else if(!_.isEmpty(prices)){pricesCode=_.keys(prices);}
3_.each(this.cache.additionalPriceObject,function(additional){if(additional&&!_.isEmpty(additional)){pricesCode=_.keys(additional);}
4_.each(pricesCode,function(priceCode){priceValue=additional[priceCode]||{};priceValue.amount=+priceValue.amount||0;priceValue.adjustments=priceValue.adjustments||{};additionalPrice[priceCode]=additionalPrice[priceCode]||{'amount':0,'adjustments':{}};additionalPrice[priceCode].amount=0+(additionalPrice[priceCode].amount||0)+
5priceValue.amount;_.each(priceValue.adjustments,function(adValue,adCode){additionalPrice[priceCode].adjustments[adCode]=0+
6(additionalPrice[priceCode].adjustments[adCode]||0)+adValue;});});});if(_.isEmpty(additionalPrice)){this.cache.displayPrices=$.catalog.priceUtils.deepClone(this.options.prices);}else{_.each(additionalPrice,function(option,priceCode){origin=this.options.prices[priceCode]||{};finalPrice=prices[priceCode]||{};option.amount=option.amount||0;origin.amount=origin.amount||0;origin.adjustments=origin.adjustments||{};finalPrice.adjustments=finalPrice.adjustments||{};finalPrice.amount=0+origin.amount+option.amount;_.each(option.adjustments,function(pa,paCode){finalPrice.adjustments[paCode]=0+(origin.adjustments[paCode]||0)+pa;});},this);}
7this.element.trigger('reloadPrice');},reloadPrice:function(){var priceFormat=(this.options.priceConfig&&this.options.priceConfig.priceFormat)||{},priceTemplate=_.template(this.options.priceTemplate);_.each(this.cache.displayPrices,function(price,priceCode){price.final=_.reduce(price.adjustments,function(memo,amount){return memo+amount;},price.amount);price.formatted=$.catalog.priceUtils.formatPrice(price.final,priceFormat);$('[data-price-type="'+priceCode+'"]',this.element).html(priceTemplate({data:price}));},this);},setDefault:function(prices){this.cache.displayPrices=$.catalog.priceUtils.deepClone(prices);this.options.prices=$.catalog.priceUtils.deepClone(prices);},_setDefaultsFromDataSet:function(){var box=this.element,priceHolders=$('[data-price-type]',box),prices=this.options.prices;this.options.productId=box.data('productId');if(_.isEmpty(prices)){priceHolders.each(function(index,element){var type=$(element).data('priceType'),amount=parseFloat($(element).data('priceAmount'));if(type&&!_.isNaN(amount)){prices[type]={amount:amount};}});}},_setDefaultsFromPriceConfig:function(){var config=this.options.priceConfig;if(config&&config.prices){this.options.prices=config.prices;}},updateProductTierPrice:function(){var productQty=$(this.qtyInfo).val(),originalPrice=this.options.prices.finalPrice.amount,tierPrice;if(!this.options.priceConfig||!this.options.priceConfig.tierPrices){return;}
8_.find(this.options.priceConfig.tierPrices,function(rule){if(productQty<rule.qty){return true;}
9tierPrice=rule.price;});this.updatePrice({prices:{finalPrice:{amount:tierPrice-originalPrice}}});}});})();

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.