1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Redux={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+r+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function i(e,t){return function(){return t(e.apply(this,arguments))}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){var r=Object.keys(e);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(e)),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r}function a(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(r,!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(r).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function f(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}e.__DO_NOT_USE__ActionTypes=n,e.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return a({},r,{dispatch:n=f.apply(void 0,i)(r.dispatch)})}}},e.bindActionCreators=function(e,t){if("function"==typeof e)return i(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');var r={};for(var n in e){var o=e[n];"function"==typeof o&&(r[n]=i(o,t))}return r},e.combineReducers=function(e){for(var t=Object.keys(e),r={},i=0;t.length>i;i++){var u=t[i];"function"==typeof e[u]&&(r[u]=e[u])}var c,a=Object.keys(r);try{!function(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')})}(r)}catch(e){c=e}return function(e,t){if(void 0===e&&(e={}),c)throw c;for(var n=!1,i={},u=0;a.length>u;u++){var f=a[u],s=e[f],d=(0,r[f])(s,t);if(void 0===d){var l=o(f,t);throw Error(l)}i[f]=d,n=n||d!==s}return n?i:e}},e.compose=f,e.createStore=function e(r,o,i){var u;if("function"==typeof o&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(
1). This is not supported. Instead, compose them together to a single function.");if("function"==typeof o&&void 0===i&&(i=o,o=void 0),void 0!==i){if("function"!=typeof i)throw Error("Expected the enhancer to be a function.");return i(e)(r,o)}if("function"!=typeof r)throw Error("Expected the reducer to be a function.");var c=r,a=o,f=[],s=f,d=!1;function l(){s===f&&(s=f.slice())}function p(){if(d)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return a}function h(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(d)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return l(),s.push(e),function(){if(t){if(d)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,l();var r=s.indexOf(e);s.splice(r,1)}}}function y(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(d)throw Error("Reducers may not dispatch actions.");try{d=!0,a=c(a,e)}finally{d=!1}for(var t=f=s,r=0;t.length>r;r++)(0,t[r])();return e}return y({type:n.INIT}),(u={dispatch:y,subscribe:h,getState:p,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");c=e,y({type:n.REPLACE})}})[t]=function(){var e,r=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(p())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},u},Object.defineProperty(e,"__esModule",{value:!0})});var reducers={};var tlSize={current:[],dimensions:[],init:function(){tlSize.dimensions=entryData.layoutSizes;$(window).on('layoutChange',tlSize.bodyClass);tlSize.resize();$(window).on('resize',tlSize.resize)},resize:function(){$.each(tlSize.dimensions,function(key,val){var from=val[0]*1;var to=val[1];if(to){to=to*1}else{to=10000} 2var data={};var w=window.innerWidth;if(!w){w=$(window).width()} 3if(from<=w&&w<=to){if($.inArray(key,tlSize.current)===-1){tlSize.current.push(key);tlSize.current=tlSize.sort(tlSize.current);data={key:key,status:'in',from:from,to:to,current:tlSize.current};$(window).trigger('layoutChange',[data]);$(window).trigger(key+'in',[data])}}else{var index=tlSize.current.indexOf(key);if(index>-1){tlSize.current.splice(index,1);tlSize.current=tlSize.sort(tlSize.current);data={key:key,status:'out',from:from,to:to,current:tlSize.current};$(window).trigger('layoutChange',[data]);$(window).trigger(key+'out',[data])}}})},sort:function(arr){var v=[];var t=[];var tmp=[];var l=arr.length;for(var i=0;i<l;i++){tmp[i]='0w0';$.each(arr,function(key,val){v=val.split('w');v[0]=v[0]*1;v[1]=v[1]*1;if(!v[1]){v[1]=10000} 4t=tmp[i].split('w');t[0]=t[0]*1;t[1]=t[1]*1;if(t[1]<v[1]){tmp[i]=val}else if(t[1]==v[1]&&t[0]>v[0]){tmp[i]=val}});var index=arr.indexOf(tmp[i]);arr.splice(index,1)} 5return tmp},bodyClass:function(e,d){if(d.status=='in'){$('body').addClass(d.key)} 6if(d.status=='out'){$('body').removeClass(d.key)}}};if(!Object.assign){Object.defineProperty(Object,'assign',{enumerable:!1,configurable:!0,writable:!0,value:function(target,firstSource){'use strict';if(target===undefined||target===null){throw new TypeError('Cannot convert first argument to object')} 7var to=Object(target);for(var i=1;i<arguments.length;i++){var nextSource=arguments[i];if(nextSource===undefined||nextSource===null){continue} 8var keysArray=Object.keys(Object(nextSource));for(var nextIndex=0,len=keysArray.length;nextIndex<len;nextIndex++){var nextKey=keysArray[nextIndex];var desc=Object.getOwnPropertyDescriptor(nextSource,nextKey);if(desc!==undefined&&desc.enumerable){to[nextKey]=nextSource[nextKey]}}} 9return to}})} 10tl.reducers={};function tl_action(script){if(typeof jQuery=='function'){tl_start=!0;var action=function(block){var key=!0;$.each(block.js,function(j,js){var include_index=tl_include_js.indexOf(js);if(include_index==-1||tl_include_loaded.indexOf(js)==-1){key=!1}});if(key&&block&&typeof block.script==="function"){if(typeof requestIdleCallback==="function"){requestIdleCallback(block.script)}else{block.script()}} 11return key};$.each(script,function(i,block){if(!action(block)){$.each(block.js,function(j,js){var include_index=tl_include_js.indexOf(js);if(include_index==-1){tl_include_js.push(js);include_index=tl_include_js.indexOf(js);$.ajax({url:js,success:function(){tl_include_loaded.push(js);$(window).trigger('tl_action_'+include_index)},error:function(a,b,c){console.error('Error: "'+js+'" '+c)},dataType:'script',cache:!0})} 12$(window).on('tl_action_'+include_index,function(){action(block)})})}})}else{setTimeout(function(){tl_action(script)},100)} 13document.cookie="xwidth="+window.outerWidth;document.cookie="xheight="+window.outerHeight};tl(createJsUrl('main.js'),function(){$('.footerTitle, .gift-code .heading-4').click(function(){if($(window).width()>=720)return;$(this).toggleClass('active');$('~ *',this).slideToggle()})});tl.reducers.account=function(state,actions){if(!state)state=entryData.account;if(!state)state=[];var newState='';switch(actions.type){case 'LOGGED_IN':newState=JSON.parse(JSON.stringify(state));newState=actions.value.account;return newState;default:return state}} 14tl.reducers.themeSettings=function(state,actions){if(!state)state=entryData.themeSettings;if(!state)state=[];var newState='';switch(actions.type){case 'CHANGE_THEME_SETTING':newState=JSON.parse(JSON.stringify(state));newState=actions.value.account;return newState;default:return state}} 15tl.reducers.filters=function(state,actions){if(!state)state=entryData.filters;if(!state)state=[];var newState='';switch(actions.type){case 'FILTERS_CHANGE':newState=JSON.parse(JSON.stringify(state));newState=actions.value.filters;return newState;default:return state}} 16tl(createJsUrl('main.js'),function(){$('.product-listing').each(function(){var state=tl.store.getState();var $listing=$(this);var widgetId=$listing.closest('.box').attr('id').substring(4);$('.item',$listing).each(function(){ProductListing.applyItem($(this),widgetId)});tl.subscribe(['widgets',widgetId,'listingType'],function(){updateProducts($listing,widgetId)});tl.subscribe(['widgets',widgetId,'listingSorting'],function(){updateProducts($listing,widgetId)});tl.subscribe(['widgets',widgetId,'productsOnPage'],function(){updateProducts($listing,widgetId)});
16tl.subscribe(['widgets',widgetId,'pageCountUpdatePage'],function(){var state=tl.store.getState();if(state.widgets[widgetId].pageCountUpdatePage){tl.store.dispatch({type:'WIDGET_PAGE_COUNT_UPDATE_PAGE',value:{widgetId:widgetId,pageCountUpdatePage:!1,},file:'boxes/catalog/Paging'});updateProducts($listing,widgetId)}});if(state.productListings&&state.productListings.mainListing&&widgetId===state.productListings.mainListing){tl.store.dispatch({type:'PRODUCTS_LISTING_HREF',value:{href:window.location.href,},file:'boxes/ProductListing'})} 17ProductListing.productListingCols($listing);layoutChange($listing,widgetId)});tl.subscribe(['productListings','href'],function(){var state=tl.store.getState();window.history.pushState("","",state.productListings.href)}) 18if(localStorage.compareByCategory){tl.store.dispatch({type:'UPDATE_COMPARE',value:JSON.parse(localStorage.compareByCategory),file:'boxes/ProductListing'});$.get(entryData.mainUrl.replace(/\/$/,'')+'/catalog/update-compare',{compare:JSON.parse(localStorage.compareByCategory),})} 19ProductListing.fbl();function updateProducts($listing,widgetId){var listingName=$listing.data('listing-name');var sendData={};var url=entryData.mainUrl;var state=tl.store.getState();if(listingName==='cart'){url=url+'cart/index'} 20if(state.productListings&&state.productListings.mainListing&&widgetId===state.productListings.mainListing){url=state.productListings.href} 21sendData.productListing=1;sendData.onlyProducts=1;$listing.addClass('loader');$.ajax({url:url,data:sendData,dataType:'json'}).done(function(data){$listing.removeClass('loader');var state=tl.store.getState();var listingType=state.widgets[widgetId].listingType;$listing.attr('data-listing-type',listingType);var listingClasses=$listing.attr('class');listingClasses=listingClasses.replace(/(\sw-list-)([a-zA-Z0-9\-\_]+)/,'$1'+listingType);listingClasses=listingClasses.replace(/(\slist-)([a-zA-Z0-9\-\_]+)/,'$1'+listingType);$listing.attr('class',listingClasses);tl.store.dispatch({type:'ADD_PRODUCTS',value:{products:data.entryData.products,},file:'boxes/ProductListing'});tl.store.dispatch({type:'PRODUCTS_LISTING_ITEM_ELEMENTS',value:{listingName:data.entryData.widgets.w0.listingName,itemElements:data.entryData.productListings[data.entryData.widgets.w0.listingName].itemElements,},file:'boxes/ProductListing'});$listing.html(data.html);$(window).scrollTop($listing.offset().top-100) 22tl.store.dispatch({type:'WIDGET_CHANGE_NUMBER_OF_PRODUCTS',value:{widgetId:widgetId,numberOfProducts:data.entryData.widgets.w0.numberOfProducts,},file:'boxes/ProductListing'});var $productListingStyles=$('#productListingStyles');if($productListingStyles.length>0){$productListingStyles.remove()} 23$('head').append('<style type="text/css" id="productListingStyles">'+data.css+'</style>') 24$('.item',$listing).each(function(){ProductListing.applyItem($(this),widgetId)});ProductListing.productListingCols($listing)})} 25function layoutChange($listing,widgetId){var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'colInRow'],state)||!isElementExist(['widgets',widgetId,'colInRowCarousel'],state))return!1;$(window).on('layoutChange',function(event,d){if(state.widgets[widgetId].colInRowCarousel[d.to]){ProductListing.productListingCols($listing)}})} 26ProductListing.carousel()});if(!ProductListing)var ProductListing={};ProductListing.applyItemData=function($item,widgetId){var productId=$item.data('id');var state=tl.store.getState();tl.store.dispatch({type:'WIDGET_PRODUCT_CAN_ADD_TO_CART',value:{widgetId:widgetId,productId:productId,canAddToCart:state.products[productId].stock_indicator.flags.can_add_to_cart,},file:'boxes/ProductListing/applyItemData'});tl.store.dispatch({type:'WIDGET_PRODUCT_IN_CART',value:{widgetId:widgetId,productId:productId,productInCart:state.products[productId].product_in_cart,},file:'boxes/ProductListing/applyItemData'})} 27if(!ProductListing)var ProductListing={};ProductListing.applyItemImage=function($item,widgetId){var productId=$item.data('id');tl(createJsUrl('jquery.lazy.min.js'),function(){$('.image img',$item).lazy({bind:'event',beforeLoad:function(){$('source',$item).each(function(){let srcset=$(this).data('srcset');$(this).attr('srcset',srcset).removeAttr('data-srcset')})}})})} 28if(!ProductListing)var ProductListing={};ProductListing.applyItemPrice=function($item,widgetId){var productId=$item.data('id');tl.subscribe(['widgets',widgetId,'products',productId,'price'],function(){var state=tl.store.getState();var price={};if(isElementExist(['widgets',widgetId,'products',productId,'price'],state)){price=state.widgets[widgetId].products[productId].price}else if(isElementExist(['products',productId,'price'],state)){price=state.products[productId].price} 29if(price){if(price.old&&price.special){$('.price .current',$item).hide().html('') 30$('.price .old',$item).show().html(price.old) 31$('.price .special',$item).show().html(price.special)}else if(price.current){$('.price .current',$item).show().html(price.current) 32$('.price .old',$item).hide('') 33$('.price .special',$item).hide('')}}})} 34if(!ProductListing)var ProductListing={};ProductListing.applyItemAttributes=function($item,widgetId){var productId=$item.data('id');var $box=$('.attributes',$item);
34var $inputs=$('input[type="radio"], select',$box);var $qty=$('.qty-inp',$box);var attributes={};var state=tl.store.getState();if(isElementExist(['widgets',widgetId,'batchSelectedWidget'],state)){$box.find('input[type="radio"], select').each(function(){$(this).attr('name',(this.name.indexOf('list')===0?this.name:('list'+this.name)))})} 35$inputs.serializeArray().forEach(function(element){attributes[element.name]=element.value});$qty.quantity();tl.store.dispatch({type:'WIDGET_CLEAR_PRODUCT_MIX_ATTRIBUTE',value:{widgetId:widgetId,productId:productId,},file:'boxes/ProductListing/applyItemAttributes',}) 36$qty.on('change',function(){var attributeId=$(this).closest('.mix-attributes').data('id');var optionId=$(this).closest('.attribute-qty-block').data('id');var qty=$(this).val();tl.store.dispatch({type:'WIDGET_CHANGE_PRODUCT_MIX_ATTRIBUTE',value:{widgetId:widgetId,productId:productId,attributeId:attributeId,optionId:optionId,qty:qty,},file:'boxes/ProductListing/applyItemAttributes',})});$inputs.on('change',function(){$box.addClass('loader');var data={} 37$inputs.serializeArray().forEach(function(element){attributes[element.name]=element.value 38data[element.name]=element.value}) 39var state=tl.store.getState();data.products_id=productId;data.qty=state.widgets[widgetId].products[productId].qty;data.type='productListing';ProductListing.updateAttributes(widgetId,productId,data,$item)});tl.store.dispatch({type:'WIDGET_CHANGE_PRODUCT_ATTRIBUTE',value:{widgetId:widgetId,productId:productId,attributes:attributes,},file:'boxes/ProductListing/applyItemAttributes',})} 40if(!ProductListing)var ProductListing={};ProductListing.applyItemBuyButton=function($item,widgetId){var productId=$item.data('id');var $buyBox=$('.buyButton',$item);var $btnBuy=$('.btn-buy',$buyBox);var $btnPreloader=$('.btn-preloader',$buyBox);var $btnChooseOptions=$('.btn-choose-options',$buyBox);var $btnInCart=$('.btn-in-cart',$buyBox);var $loadedQty=$('.loaded-qty',$buyBox);var state=tl.store.getState();var product=state.products[productId];if(entryData.GROUPS_DISABLE_CHECKOUT){$buyBox.hide().html('');return''} 41var listingName=state.widgets[widgetId].listingName;var itemElements=state.productListings[listingName].itemElements;var hasAttributes=+state.products[productId].product_has_attributes;var isBundle=+state.products[productId].isBundle;if(!itemElements.attributes&&hasAttributes||isBundle){$btnChooseOptions.show();$btnBuy.hide();$btnInCart.hide();return''} 42canAddToCart();tl.subscribe(['widgets',widgetId,'products',productId,'canAddToCart'],function(){canAddToCart()});switchBuyButton();tl.subscribe(['widgets',widgetId,'products',productId,'productInCart'],function(){switchBuyButton()});tl.subscribe(['widgets',widgetId,'products',productId,'addingToCart'],function(){state=tl.store.getState() 43if(isElementExist(['widgets',widgetId,'products',productId,'addingToCart'],state)&&state.widgets[widgetId].products[productId].addingToCart){$btnInCart.addClass('hide');$btnBuy.addClass('hide');$btnPreloader.show()}else{$btnInCart.removeClass('hide');$btnBuy.removeClass('hide');$btnPreloader.hide()}});tl.subscribe(['productListings','cart','products',productId,'qty'],function(){loadedQty()});$btnBuy.on('click',function(e){e.preventDefault();var state=tl.store.getState() 44if(+product.product_has_attributes&&!isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){window.location.href=product.link} 45ProductListing.addProductToCart(widgetId,productId)});function loadedQty(){state=tl.store.getState() 46if(isElementExist(['productListings','cart','products',productId,'qty'],state)&&state.productListings.cart.products[productId].qty>0){$loadedQty.show();$('span',$loadedQty).html(state.productListings.cart.products[productId].qty)}else{$loadedQty.hide()}} 47function switchBuyButton(){var state=tl.store.getState();if(isElementExist(['widgets',widgetId,'products',productId,'productInCart'],state)&&!isElementExist(['themeSettings','showInCartButton'],state)){$btnInCart.show();$btnBuy.hide()}else{$btnInCart.hide();$btnBuy.show()}} 48function canAddToCart(){var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'products',productId,'canAddToCart'],state)&&!(+state.products[productId].is_virtual)){$buyBox.hide()}else{$buyBox.show()}}} 49if(!ProductListing)var ProductListing={};ProductListing.applyItemQtyInput=function($item,widgetId){var productId=$item.data('id');var $box=$('.qtyInput',$item);var $input=$('input',$box);var state=tl.store.getState();var product=state.products[productId];if(entryData.GROUPS_DISABLE_CHECKOUT||product.show_attributes_quantity){$('> *',$box).hide();return''}
50var listingName=state.widgets[widgetId].listingName;var itemElements=state.productListings[listingName].itemElements;var hasAttributes=+state.products[productId].product_has_attributes;var isBundle=+state.products[productId].isBundle;if(!itemElements.attributes&&hasAttributes||isBundle){$('> *',$box).remove();return''} 51tl.subscribe(['widgets',widgetId,'products',productId,'canAddToCart'],function(){var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'products',productId,'canAddToCart'],state)&&!(+state.products[productId].is_virtual)){$box.hide()}else{$box.show()}});$input.quantity();$input.on('change',changeQty);if(isElementExist(['widgets',widgetId,'products',productId,'qty'],state)){$input.val(state.widgets[widgetId].products[productId].qty)}else{changeQty()} 52function changeQty(){tl.store.dispatch({type:'WIDGET_CHANGE_PRODUCT_QTY',value:{widgetId:widgetId,productId:productId,qty:$input.val(),},file:'boxes/ProductListing/applyItemQtyInput'})}} 53if(!ProductListing)var ProductListing={};ProductListing.applyItemCompare=function($item,widgetId){var productId=$item.data('id');var $checkbox=$('.compare input',$item);var $viewButton=$('.compare .view',$item);var params={};params.compare=[];var currentCategoryId=0 54if(isElementExist(['compare','currentCategory','id'],entryData)){currentCategoryId=entryData.compare.currentCategory.id} 55tl.subscribe(['productListings','compare','byCategory'],function(){var state=tl.store.getState();params.compare=state.productListings.compare.byCategory;if(isElementExist(['productListings','compare','byCategory',currentCategoryId],state)&&state.productListings.compare.byCategory[currentCategoryId].indexOf(productId)!==-1){$checkbox.prop('checked',!0);if(state.productListings.compare.byCategory[currentCategoryId].length>1){$viewButton.show()}else{$viewButton.hide()}}else{$checkbox.removeAttr('checked');$viewButton.hide()}});$viewButton.on('click',function(e){var state=tl.store.getState();if(isElementExist(['productListings','compare','byCategory',currentCategoryId],state)){params.compare=state.productListings.compare.byCategory[currentCategoryId]} 56e.preventDefault();window.location=$viewButton.attr('href')+'?'+$.param(params)}) 57$checkbox.on('change',function(){var qty=0;if($checkbox.prop('checked')){tl.store.dispatch({type:'ADD_TO_COMPARE',value:{productId:productId,categoryId:currentCategoryId||0,},file:'boxes/ProductListing/applyItemCompare'});updateCompare('add-to-compare',productId)}else{if(isElementExist(['compare','currentCategory','id'],entryData)){tl.store.dispatch({type:'REMOVE_FROM_COMPARE',value:{productId:productId,categoryId:currentCategoryId,},file:'boxes/ProductListing/applyItemCompare'})} 58updateCompare('remove-from-compare',productId)} 59var state=tl.store.getState();localStorage.setItem('compareByCategory',JSON.stringify(state.productListings.compare.byCategory))}) 60function updateCompare(action,productId){$.get(entryData.mainUrl.replace(/\/$/,'')+'/catalog/'+action,{productId:productId,categoryId:currentCategoryId||0},function(response){if(!currentCategoryId){tl.store.dispatch({type:'UPDATE_COMPARE',value:response,file:'boxes/ProductListing/applyItemCompare'});localStorage.setItem('compareByCategory',JSON.stringify(response))}},'json')}} 61if(!ProductListing)var ProductListing={};ProductListing.applyItemWishlistButton=function($item,widgetId){var productId=$item.data('id');var $checkbox=$('.wishlistButton input',$item);var $wishlistAdd=$('.wishlistButton label',$item);var state=tl.store.getState();var listingName=state.widgets[widgetId].listingName;var itemElements=state.productListings[listingName].itemElements;var hasAttributes=+state.products[productId].product_has_attributes;var isBundle=+state.products[productId].isBundle;if(!itemElements.attributes&&hasAttributes||isBundle){$wishlistAdd.hide();return''} 62if(isElementExist(['products',productId,'show_attributes_quantity'],state)){$wishlistAdd.hide()} 63checkBox();tl.subscribe(['productListings','wishList','products'],checkBox);tl.subscribe(['widgets',widgetId,'products',productId,'attributes'],checkBox);$checkbox.on('change',function(e){var state=tl.store.getState();if(state.account.isGuest){$checkbox.prop('checked',!1);var $accountDropdown=$('.w-account .account-title:first').clone();$('> a',$accountDropdown).remove();$('> ul',$accountDropdown).css({display:'block',position:'static',margin:'0 auto',border:'none'});$('form',$accountDropdown).on('submit',function(e){e.preventDefault();$.post($(this).attr('action'),$(this).serializeArray(),function(){window.location.reload()})}) 64alertMessage($accountDropdown,'w-account login-popup') 65return} 66var uprid=productId;if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){} 67var postData=[];postData.push({name:'qty',value:1});postData.push({name:'products_id',value:productId});if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){var attributes=state.widgets[widgetId].products[productId].attributes;for(var attrKey in attributes){postData.push({name:attrKey,value:attributes[attrKey]})}} 68if(isElementExist(['widgets',widgetId,'products',productId,'mixAttributes'],state)){var attributes=state.widgets[widgetId].products[productId].mixAttributes;for(var attributeId in attributes){for(var optionId in attributes[attributeId]){if(attributes[attributeId][optionId]){postData.push({name:'mix_attr['+productId+'][]['+attributeId+']',value:optionId});postData.push({name:'mix[]',value:productId});postData.push({name:'mix_qty['+productId+'][]',value:attributes[attributeId][optionId]})}}}} 69postData.push({name:'_csrf',value:$('meta[name="csrf-token"]').attr('content')});postData.push({name:'json',value:1});if($checkbox.prop('checked')){$.post(getMainUrl()+'/personal-catalog/add',postData,function(d){alertMessage(d.message)});tl.store.dispatch({type:'ADD_PRODUCT_IN_LIST',value:{listingName:'wishList',productId:uprid,},file:'boxes/ProductListing/applyItemWishlistButton'})}else{$.post(getMainUrl()+'/personal-catalog/confirm-delete',postData,function(d){alertMessage(d.message)})}}) 70function checkBox(){var state=tl.store.getState();var uprid=productId;if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){var uprid=helpers.getUprid(productId,state.widgets[widgetId].products[productId].attributes)} 71if(isElementExist(['productListings','wishList','products',uprid],state)){$checkbox.prop('checked',!0)}else{$checkbox.prop('checked',!1)}}} 72if(!ProductListing)var ProductListing={};ProductListing.applyItemBatchSelect=function($item,widgetId){var productId=$item.data('id');var $checkbox=$('.batchSelect input',$item);var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'batchSelectedWidget'],state)){$('.batchSelect',$item).hide();return''} 73var batchSelectedWidgetId=state.widgets[widgetId].batchSelectedWidget;tl.subscribe(['productListings','batchSelectedProducts'+batchSelectedWidgetId,'products'],checkUncheck);tl.subscribe(['widgets',widgetId,'products',productId,'attributes'],checkUncheck);$checkbox.on('change',function(){var state=tl.store.getState();var uprid=productId;var attributes=!1;if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){attributes=state.widgets[widgetId].products[productId].attributes;uprid=helpers.getUprid(productId,attributes)} 74if($checkbox.prop('checked')){tl.store.dispatch({type:'ADD_PRODUCT_TO_BATCH',value:{productId:uprid,attributes:attributes,widgetId:batchSelectedWidgetId},file:'boxes/ProductListing/applyItemBatchSelect'})}else{tl.store.dispatch({type:'REMOVE_PRODUCT_FROM_BATCH',value:{productId:uprid,widgetId:batchSelectedWidgetId},file:'boxes/ProductListing/applyItemBatchSelect'})}}).trigger('change');function checkUncheck(){var state=tl.store.getState();var uprid=productId;if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){uprid=helpers.getUprid(productId,state.widgets[widgetId].products[productId].attributes)} 75if(isElementExist(['productListings','batchSelectedProducts'+batchSelectedWidgetId,'products',uprid],state)){$checkbox.prop('checked',!0)}else{$checkbox.removeAttr('checked')}}} 76if(!ProductListing)var ProductListing={};ProductListing.applyItemBatchRemove=function($item,widgetId){var productId=$item.data('id');$('.btn-batch-remove',$item).on('click',function(){tl.store.dispatch({type:'REMOVE_PRODUCT_FROM_BATCH',value:{productId:productId,widgetId:widgetId,},file:'boxes/ProductListing/applyItemBatchRemove'})})} 77if(!ProductListing)var ProductListing={};ProductListing.applyItemProductGroup=function($item,widgetId){var $rootBox=$('#box-'+widgetId);var $_listing=$rootBox.find('.product-listing');
77if($rootBox.data('group-init'))return;$rootBox.on('click','.js-list-prod',function(event){var $link=$(event.currentTarget);var prodUrl=$link.attr('href');var prodId=$link.data('productsId');var $itemBox=$link.parents('.item');var $productsListing=$link.parents('.products-listing');var listType=$productsListing.attr('data-listing-type');var listParam=$productsListing.attr('data-listing-param');var listCallback=$productsListing.attr('data-listing-callback');var boxId=$itemBox.parents('.box').attr('id')||'';var ajaxParam={'products_id':prodId,'onlyFilter':'','productListing':1,'onlyProducts':1,'listType':listType,'listParam':listParam,'boxId':boxId};var listPreCallback=$productsListing.attr('data-listing-pre-callback');if(listPreCallback&&typeof window[listPreCallback]==='function'){(window[listPreCallback])(event,ajaxParam)} 78$.get(window.productCellUrl?window.productCellUrl:window.location.href,ajaxParam,function(data){if(listCallback&&typeof window[listCallback]==='function'){if(!(window[listCallback])(data)){return}} 79var $newItem=$('<div>'+data.html+'</div>');var $items=$('.item',$newItem);tl.store.dispatch({type:'ADD_PRODUCTS',value:{products:data.entryData.products,},file:'boxes/ProductListing'});$items.each(function(){ProductListing.applyItem($(this),widgetId)});if($itemBox.hasClass('slick-slide')){$itemBox.attr('data-id',$items.attr('data-id'));$itemBox.data('id',$items.attr('data-id'));$itemBox.attr('data-name',$items.attr('data-name'));$itemBox.data('name',$items.attr('data-name'));$itemBox.children().replaceWith($items.children())}else{$itemBox.replaceWith($items)} 80ProductListing.alignItems($_listing);if($('.new_arrivals').length>0){if($(window).width()>800){setTimeout(function(){$('.new_arrivals .item:nth-child(2) .image').removeAttr('style');var wrapHeight=$('.new_arrivals .item:nth-child(1)').innerHeight()+$('.new_arrivals .item:nth-child(3)').innerHeight();var secondHeight=$('.new_arrivals .item:nth-child(2)').innerHeight();var secondHeightImg=(wrapHeight-secondHeight+$('.new_arrivals .item:nth-child(2) .image').innerHeight());$('.new_arrivals .item:nth-child(2) .image').css('min-height',secondHeightImg)},1)}}},'json').fail(function(){window.location.href=prodUrl});return!1});$rootBox.data('group-init',!0)} 81if(!ProductListing)var ProductListing={};ProductListing.applyItem=function($item,widgetId){var productId=$item.data('id');var state=tl.store.getState();ProductListing.applyItemData($item,widgetId);ProductListing.applyItemImage($item,widgetId);ProductListing.applyItemPrice($item,widgetId);ProductListing.applyItemQtyInput($item,widgetId);ProductListing.applyItemBuyButton($item,widgetId);ProductListing.applyItemAttributes($item,widgetId);ProductListing.applyItemCompare($item,widgetId);ProductListing.applyItemWishlistButton($item,widgetId);ProductListing.applyItemBatchSelect($item,widgetId);ProductListing.applyItemBatchRemove($item,widgetId);ProductListing.applyItemProductGroup($item,widgetId);if(isElementExist(['products',productId,'show_attributes_quantity'],state)){ProductListing.updateAttributes(widgetId,productId,{products_id:productId,type:'productListing'},$item)} 82if(isElementExist(['extensions','productListing','applyItem'],tl)){for(var extension in tl.extensions.productListing.applyItem){tl.extensions.productListing.applyItem[extension]($item,widgetId)}} 83if(pCarousel&&pCarousel.addItem){var product=state.products[productId];var productImage='<img\ 84 src="'+product.image+'"\ 85 alt="'+product.image_alt+'"\ 86 title="'+product.image_title+'"'+(product.srcset?'srcset="'+product.srcset+'"':'')+(product.sizes?'srcset="'+product.sizes+'"':'')+'\>';var productPrice='<div class="price">'+(product.price.special?'<span class="old">'+product.price.old+'</span>':'')+ 87+(product.price.special?'<span class="specials">'+product.price.special+'</span>':'')+ 88+(!product.price.special?'<span class="current">'+product.price.current+'</span>':'')+'</div>' 89pCarousel.addItem(productId,product.link,product.products_name,productImage,productPrice)}} 90if(!ProductListing)var ProductListing={};ProductListing.carousel=function(){tl(createJsUrl('slick.min.js'),function(){$('.products-listing').each(function(){var $listing=$(this);var widgetId=$listing.closest('.box').attr('id').substring(4);var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'viewAs'],state)||!state.widgets[widgetId].viewAs==='carousel')return'';$listing.parent().css('position','relative');var tabs=$listing.parents('.tabs');tabs.find('> .block').show();var responsive=[];for(var size in state.widgets[widgetId].colInRowCarousel){responsive.push({breakpoint:size,settings:{slidesToShow:+state.widgets[widgetId].colInRowCarousel[size],slidesToScroll:+state.widgets[widgetId].colInRowCarousel[size]}})} 91$listing.slick({slidesToShow:+state.widgets[widgetId].productListingCols,slidesToScroll:+state.widgets[widgetId].productListingCols,infinite:!1,responsive:responsive});setTimeout(function(){tabs.trigger('tabHide')},100)})})} 92if(!ProductListing)var ProductListing={};ProductListing.updateAttributes=function(widgetId,productId,data,$item){var $box=$('.attributes',$item);if(widgetId&&typeof data.boxId==='undefined'){data.boxId=widgetId} 93$.ajax({url:getMainUrl()+'/catalog/product-attributes',data:data,dataType:'json'}).done(function(data){var price={current:data.product_price,old:data.special_price?data.product_price:'',special:data.special_price,} 94tl.store.dispatch({type:'WIDGET_CHANGE_PRODUCT_PRICE',value:{widgetId:widgetId,productId:productId,price:price,},file:'boxes/ProductListing/updateAttributes',}) 95if(typeof data.stock_indicator.can_add_to_cart!=="undefined"){tl.store.dispatch({type:'WIDGET_PRODUCT_CAN_ADD_TO_CART',value:{widgetId:widgetId,productId:productId,canAddToCart:data.stock_indicator.can_add_to_cart,},file:'boxes/ProductListing/updateAttributes'})} 96tl.store.dispatch({type:'WIDGET_PRODUCT_IN_CART',value:{widgetId:widgetId,productId:productId,productInCart:data.product_in_cart,},file:'boxes/ProductListing/updateAttributes'});$box.removeClass('loader');$box.html(data.product_attributes);ProductListing.applyItemAttributes($item,widgetId) 97ProductListing.alignItems($('#box-'+widgetId+' .products-listing'))}).fail(function(){})} 98if(!ProductListing)var ProductListing={};ProductListing.addProductToCart=function(widgetId,productId){var state=tl.store.getState();var qty;if(isElementExist(['widgets',widgetId,'products',productId,'qty'],state)){qty=state.widgets[widgetId].products[productId].qty}else{qty=1} 99tl.store.dispatch({type:'WIDGET_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'cart',},file:'boxes/ProductListing'});var postData=[];postData.push({name:'action',value:'buy_now'});postData.push({name:'qty',value:qty});postData.push({name:'products_id',value:productId});if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){var attributes=state.widgets[widgetId].products[productId].attributes;for(var attrKey in attributes){postData.push({name:attrKey,value:attributes[attrKey]})}} 100if(isElementExist(['widgets',widgetId,'products',productId,'mixAttributes'],state)){var attributes=state.widgets[widgetId].products[productId].mixAttributes;for(var attributeId in attributes){for(var optionId in attributes[attributeId]){if(attributes[attributeId][optionId]){postData.push({name:'mix_attr['+productId+'][]['+attributeId+']',value:optionId});postData.push({name:'mix[]',value:productId});postData.push({name:'mix_qty['+productId+'][]',value:attributes[attributeId][optionId]})}}}} 101postData.push({name:'_csrf',value:$('meta[name="csrf-token"]').attr('content')});postData.push({name:'json',value:1});$.ajax({url:getMainUrl()+'/?action=add_product',data:postData,method:'post',dataType:'json'}).done(function(data){var state=tl.store.getState();if(data.error){window.location.href=state.products[productId].link} 102var products={};
102data.products.forEach(function(prod){products[prod.stock_products_id]={id:prod.id,qty:prod.quantity}});tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'cart',},file:'boxes/ProductListing/addProductToCart'});tl.store.dispatch({type:'UPDATE_PRODUCTS_IN_LIST',value:{listingName:'cart',products:products,},file:'boxes/ProductListing/addProductToCart'});tl.store.dispatch({type:'WIDGET_PRODUCT_IN_CART',value:{widgetId:widgetId,productId:productId,productInCart:!0,},file:'boxes/ProductListing/addProductToCart'});if(isElementExist(['widgets',widgetId,'showPopup'],state)&&state.widgets[widgetId].showPopup){window.location.href=getMainUrl()+'/shopping-cart'}else{$('<a href="'+getMainUrl()+'/shopping-cart?popup=1" data-class="cart-popup"></a>').popUp().trigger('click')}}).fail(function(){tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'cart',},file:'boxes/ProductListing/addProductToCart'})})} 103if(!ProductListing)var ProductListing={};ProductListing.alignItems=function($listing){var widgetId=$listing.closest('.box').attr('id').substring(4);var state=tl.store.getState();if(!isElementExist(['widgets',widgetId,'colInRow'],state))return!1;$('.image img',$listing).on('load',function(){$listing.inRow(['.image'],state.widgets[widgetId].productListingCols)});$listing.inRow(['.image','.name','.price','.description','.attributes','.bonusPoints','.model','.qtyInput','.buyButton','.productGroup'],state.widgets[widgetId].productListingCols)} 104if(!ProductListing)var ProductListing={};ProductListing.productListingCols=function($listing){var widgetId=$listing.closest('.box').attr('id').substring(4);var state=tl.store.getState();var productListingCols=1 105if(state.widgets[widgetId].listingType===state.widgets[widgetId].listingTypeCol||!state.widgets[widgetId].listingTypeCol){if(isElementExist(['widgets',widgetId,'colInRow'],state)){productListingCols=state.widgets[widgetId].colInRow} 106if(isElementExist(['widgets',widgetId,'colInRowCarousel'],state)){var currentSize=$(window).width();var difference=10000;var findSize=0;for(var size in state.widgets[widgetId].colInRowCarousel){if(0<(size-currentSize)&&(size-currentSize)<difference){difference=findSize-currentSize;findSize=size}} 107if(findSize){productListingCols=state.widgets[widgetId].colInRowCarousel[findSize]}}} 108tl.store.dispatch({type:'WIDGET_CHANGE_SETTINGS',value:{widgetId:widgetId,settingName:'productListingCols',settingValue:productListingCols,},file:'boxes/ProductListing/productListingCols'});var listingClasses=$listing.attr('class');listingClasses=listingClasses.replace(/(\scols-)([0-9])/,'$1'+productListingCols) 109$listing.attr('class',listingClasses);ProductListing.alignItems($listing)} 110if(!ProductListing)var ProductListing={};ProductListing.fbl=function(){var state=tl.store.getState();var listingId=state.productListings.mainListing;if(!isElementExist(['widgets',listingId,'fbl'],state))return!1;var $listing=$('#box-'+listingId+' .products-listing');var url=state.productListings.href;var sentRequest=!1;var sendData={};var pageCount=state.widgets[listingId].pageCount;var allPages=Math.ceil(state.widgets[listingId].numberOfProducts/state.widgets[listingId].productsOnPage);sendData.productListing=1;sendData.onlyProducts=1;tl.subscribe(['widgets',listingId,'pageCount'],function(){var state=tl.store.getState();sentRequest=!1;pageCount=state.widgets[listingId].pageCount});tl.subscribe(['widgets',listingId,'numberOfProducts'],function(){var state=tl.store.getState();allPages=Math.ceil(state.widgets[listingId].numberOfProducts/state.widgets[listingId].productsOnPage)});tl.subscribe(['widgets',listingId,'productsOnPage'],function(){var state=tl.store.getState();allPages=Math.ceil(state.widgets[listingId].numberOfProducts/state.widgets[listingId].productsOnPage)});tl.subscribe(['productListings','href'],function(){var state=tl.store.getState();url=state.productListings.href});$(window).on('scroll',function(){if($listing.height()-$(window).scrollTop()<$(window).height()&&!sentRequest&&pageCount<allPages){var state=tl.store.getState();sentRequest=!0;sendData.page=pageCount+1;$.ajax({url:url,data:sendData,dataType:'json'}).done(function(data){sentRequest=!0;tl.store.dispatch({type:'ADD_PRODUCTS',value:{products:data.entryData.products,},file:'boxes/ProductListing'});var $newItems=$('<div>'+data.html+'</div>');var $items=$('.item',$newItems);$items.each(function(){ProductListing.applyItem($(this),listingId)});tl.store.dispatch({type:'WIDGET_CHANGE_PAGE_COUNT',value:{widgetId:listingId,pageCount:pageCount+1,},file:'boxes/ProductListing'});
110$listing.append($items);ProductListing.alignItems($listing)})}})} 111tl.reducers.products=function(state,actions){if(!state)state=entryData.products;if(!state)state=[];var newState='';switch(actions.type){case 'CHANGE_PRODUCT':case 'ADD_PRODUCT':newState=JSON.parse(JSON.stringify(state));newState[actions.value.id]=actions.value.product;return newState;case 'ADD_PRODUCTS':newState=JSON.parse(JSON.stringify(state));for(var id in actions.value.products){newState[id]=actions.value.products[id]} 112return newState;case 'CHANGE_PRODUCT_IMAGE':newState=JSON.parse(JSON.stringify(state));newState[actions.value.id].defaultImage=actions.value.defaultImage;return newState;case 'CHANGE_PRODUCT_IMAGES':newState=JSON.parse(JSON.stringify(state));if(actions.value.defaultImage){newState[actions.value.id].defaultImage=actions.value.defaultImage} 113if(actions.value.images){newState[actions.value.id].images=actions.value.images} 114return newState;default:return state}} 115tl.reducers.productListings=function(state,actions){if(!state)state=entryData.productListings;if(!state)state=[];var listingName,productId,qty,products,href,paramName,paramValue;if(actions&&actions.value){if(actions.value.listingName)listingName=actions.value.listingName;if(actions.value.productId)productId=actions.value.productId;if(actions.value.qty||actions.value.qty===0)qty=actions.value.qty;if(actions.value.products)products=actions.value.products;if(actions.value.href)href=actions.value.href;if(actions.value.paramName)paramName=actions.value.paramName;if(actions.value.paramValue)paramValue=actions.value.paramValue;if(actions.value.widgetId)widgetId=actions.value.widgetId} 116var newState='';switch(actions.type){case 'CHANGE_LISTING':case 'ADD_PRODUCT_IN_LIST':case 'UPDATE_PRODUCTS_IN_LIST':case 'REMOVE_PRODUCT_FROM_LIST':if(!listingName){console.error(actions.type+": lack of listingName");return state} 117newState=JSON.parse(JSON.stringify(state))} 118switch(actions.type){case 'ADD_PRODUCT_IN_LIST':if(!productId){console.error("ADD_PRODUCT_TO_LIST: lack of productId");return state} 119if(!qty){if(isElementExist([listingName,'products',productId,'qty'],newState)){qty=newState[listingName].products[productId].qty}else{qty=1}} 120setElementInObject([listingName,'products',productId,'qty'],newState,qty);if(actions.value.attributes){setElementInObject([listingName,'products',productId,'attributes'],newState,actions.value.attributes)} 121return newState;case 'REMOVE_PRODUCT_FROM_LIST':if(!productId){console.error("REMOVE_PRODUCT_FROM_LIST: lack of productId");return state} 122if(isElementExist([listingName,'products',productId],newState)){delete newState[listingName].products[productId]} 123return newState;case 'UPDATE_PRODUCTS_IN_LIST':products=JSON.parse(JSON.stringify(products));setElementInObject([listingName,'products'],newState,products);return newState;case 'PRODUCTS_LISTING_HREF':newState=JSON.parse(JSON.stringify(state));newState.href=href;return newState;case 'PRODUCTS_LISTING_HREF_GET_PARAM':newState=JSON.parse(JSON.stringify(state));newState.href=setGetParam(newState.href,paramName,paramValue);return newState;case 'ADD_PRODUCT_TO_COMPARE':newState=JSON.parse(JSON.stringify(state));if(!newState.compare)newState.compare={};if(!newState.compare.products)newState.compare.products=[];if(newState.compare.products.indexOf(productId)===-1){newState.compare.products.push(productId)} 124return newState;case 'REMOVE_PRODUCT_FROM_COMPARE':newState=JSON.parse(JSON.stringify(state));newState.compare.products.splice(newState.compare.products.indexOf(productId),1);return newState;case 'ADD_PRODUCT_TO_BATCH':newState=JSON.parse(JSON.stringify(state));if(!newState['batchSelectedProducts'+widgetId]) 125newState['batchSelectedProducts'+widgetId]={};if(!newState['batchSelectedProducts'+widgetId].products) 126newState['batchSelectedProducts'+widgetId].products={};var sortOrder=0;for(var _dummy in newState['batchSelectedProducts'+widgetId].products)sortOrder++;newState['batchSelectedProducts'+widgetId].products[productId]={'products_id':productId,attributes:(actions.value.attributes||!1),sortOrder:sortOrder+1};return newState;case 'REMOVE_PRODUCT_FROM_BATCH':newState=JSON.parse(JSON.stringify(state));if(isElementExist(['batchSelectedProducts'+widgetId,'products',productId],newState)){delete newState['batchSelectedProducts'+widgetId].products[productId]} 127return newState;case 'PRODUCTS_LISTING_ITEM_ELEMENTS':newState=JSON.parse(JSON.stringify(state));setElementInObject([listingName,'itemElements'],newState,actions.value.itemElements);return newState;case 'UPDATE_COMPARE':newState=JSON.parse(JSON.stringify(state));if(!newState.compare)newState.compare={};newState.compare.byCategory=actions.value;return newState;case 'ADD_TO_COMPARE':newState=JSON.parse(JSON.stringify(state));if(!newState.compare) 128newState.compare={};if(!newState.compare.byCategory) 129newState.compare.byCategory={};if(!newState.compare.byCategory[actions.value.categoryId]) 130newState.compare.byCategory[actions.value.categoryId]=[];if(!newState.compare.byCategory[actions.value.categoryId].includes(+actions.value.productId)) 131newState.compare.byCategory[actions.value.categoryId].push(+actions.value.productId) 132return newState;case 'REMOVE_FROM_COMPARE':newState=JSON.parse(JSON.stringify(state));if(!actions.value.productId){console.error(actions.type+": need productId");return state} 133if(!actions.value.categoryId){console.error(actions.type+": need categoryId");return state} 134if(!newState.compare)return state;if(!newState.compare.byCategory)return state;if(!newState.compare.byCategory[actions.value.categoryId])return state;if(!newState.compare.byCategory[actions.value.categoryId].includes(actions.value.productId))return state;var index=newState.compare.byCategory[actions.value.categoryId].indexOf(actions.value.productId);if(index>-1){newState.compare.byCategory[actions.value.categoryId].splice(index,1)} 135return newState;default:return state}} 136tl.reducers.widgets=function(state,actions){if(!state)state=entryData.widgets;if(!state)state=[];var widgetId,productId,qty,price,attributes,canAddToCart,productInCart,list,attributeId,optionI,listingType;if(actions&&actions.value){if(actions.value.widgetId)widgetId=actions.value.widgetId;if(actions.value.productId)productId=actions.value.productId;if(actions.value.qty)qty=actions.value.qty;if(actions.value.price)price=actions.value.price;if(actions.value.attributes)attributes=JSON.parse(JSON.stringify(actions.value.attributes));if(actions.value.canAddToCart)canAddToCart=actions.value.canAddToCart;if(actions.value.productInCart)productInCart=actions.value.productInCart;if(actions.value.list)list=actions.value.list;if(actions.value.attributeId)attributeId=actions.value.attributeId;if(actions.value.optionId)optionId=actions.value.optionId;if(actions.value.listingType)listingType=actions.value.listingType} 137var newState='';switch(actions.type){case 'WIDGET_CHANGE_PRODUCT_PRICE':case 'WIDGET_CHANGE_PRODUCT_ATTRIBUTE':case 'WIDGET_CHANGE_PRODUCT_MIX_ATTRIBUTE':case 'WIDGET_CLEAR_PRODUCT_MIX_ATTRIBUTE':case 'WIDGET_CHANGE_PRODUCT_QTY':case 'WIDGET_ADDING_PRODUCT_TO_LIST':case 'WIDGET_NO_ADDING_PRODUCT_TO_LIST':case 'WIDGET_PRODUCT_CAN_ADD_TO_CART':case 'WIDGET_PRODUCT_IN_CART':if(!widgetId||!productId){console.error(actions.type+": lack of parameters");return state} 138newState=JSON.parse(JSON.stringify(state))} 139switch(actions.type){case 'WIDGET_CHANGE_LISTING_TYPE':case 'WIDGET_CHANGE_SETTINGS':case 'WIDGET_CHANGE_LISTING_SORTING':case 'WIDGET_CHANGE_PRODUCTS_ON_PAGE':case 'WIDGET_CHANGE_NUMBER_OF_PRODUCTS':case 'WIDGET_CHANGE_PAGE_COUNT':case 'WIDGET_PAGE_COUNT_UPDATE_PAGE':case 'WIDGET_CLEAR_PRODUCTS':if(!widgetId){console.error(actions.type+": lack of widgetId");return state} 140newState=JSON.parse(JSON.stringify(state))} 141switch(actions.type){case 'WIDGET_CHANGE_PRODUCT_PRICE':setElementInObject([widgetId,'products',productId,'price'],newState,price);return newState;case 'WIDGET_CHANGE_PRODUCT_ATTRIBUTE':setElementInObject([widgetId,'products',productId,'attributes'],newState,attributes);return newState;case 'WIDGET_CHANGE_PRODUCT_MIX_ATTRIBUTE':setElementInObject([widgetId,'products',productId,'mixAttributes',attributeId,optionId],newState,qty);return newState;case 'WIDGET_CLEAR_PRODUCT_MIX_ATTRIBUTE':setElementInObject([widgetId,'products',productId,'mixAttributes'],newState,{});return newState;case 'WIDGET_CHANGE_PRODUCT_QTY':setElementInObject([widgetId,'products',productId,'qty'],newState,qty);return newState;case 'WIDGET_ADDING_PRODUCT_TO_LIST':list=list.charAt(0).toUpperCase()+list.slice(1);setElementInObject([widgetId,'products',productId,'addingTo'+list],newState,!0);return newState;case 'WIDGET_NO_ADDING_PRODUCT_TO_LIST':list=list.charAt(0).toUpperCase()+list.slice(1);setElementInObject([widgetId,'products',productId,'addingTo'+list],newState,!1);return newState;case 'WIDGET_PRODUCT_CAN_ADD_TO_CART':setElementInObject([widgetId,'products',productId,'canAddToCart'],newState,canAddToCart);return newState;case 'WIDGET_PRODUCT_IN_CART':setElementInObject([widgetId,'products',productId,'productInCart'],newState,productInCart);return newState;case 'WIDGET_CHANGE_LISTING_TYPE':setElementInObject([widgetId,'listingType'],newState,listingType);return newState;case 'WIDGET_CHANGE_LISTING_SORTING':setElementInObject([widgetId,'listingSorting'],newState,actions.value.listingSorting);return newState;case 'WIDGET_CHANGE_PRODUCTS_ON_PAGE':setElementInObject([widgetId,'productsOnPage'],newState,actions.value.productsOnPage);return newState;case 'WIDGET_CHANGE_NUMBER_OF_PRODUCTS':setElementInObject([widgetId,'numberOfProducts'],newState,actions.value.numberOfProducts);return newState;case 'WIDGET_CHANGE_PAGE_COUNT':setElementInObject([widgetId,'page
141Count'],newState,actions.value.pageCount);return newState;case 'WIDGET_PAGE_COUNT_UPDATE_PAGE':setElementInObject([widgetId,'pageCountUpdatePage'],newState,actions.value.pageCountUpdatePage);return newState;case 'WIDGET_CLEAR_PRODUCTS':setElementInObject([widgetId,'products'],newState,{});return newState;case 'WIDGET_CHANGE_SETTINGS':setElementInObject([widgetId,actions.value.settingName],newState,actions.value.settingValue);return newState;default:return state}} 142if(!helpers)var helpers={};helpers.getUprid=function($productId,attributes){if(!$productId)return!1;var uprid=$productId;if(typeof attributes==="object"){var newAttributes={};var attributeIds=[];for(var attributeId in attributes){if(!attributes.hasOwnProperty(attributeId))continue;var optionId=attributes[attributeId];if(attributeId.search('[a-z]')!==-1){attributeId=attributeId.match('[0-9]+')[0]} 143attributeIds.push(+attributeId) 144newAttributes[attributeId]=optionId} 145attributeIds=attributeIds.sort(function(a,b){return a-b});var attrId=0;var key=0;for(key
145in attributeIds){attrId=attributeIds[key];uprid=uprid+'{'+attrId+'}'+newAttributes[attrId]}} 146return uprid} 147tl([entryData.jsPathUrl+'/main.js',entryData.jsPathUrl+'/jquery-ui.min.js',],function(){tl(['//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js'],function(){$('head').append('<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css"/>');applyFilters();function applyFilters(){var state=tl.store.getState();var filters=state.filters.filters_array;$('.w-filters').each(function(){var $filterBox=$(this);openCloseElements($filterBox);for(var key in filters){var $filter=filters[key];if($filter.type=='slider'){var $slider=$('#slider-'+$filter.name,$filterBox);var $min=$("#min_"+$filter.name,$filterBox);var $max=$("#max_"+$filter.name,$filterBox);var min_val='';var max_val='';$slider.slider({change:function(event,ui){$(this).parents('form').trigger('change')},step:$filter.step,range:'min',min:$filter.min,max:$filter.max,values:$filter.min,values:[($filter.paramfrom>0?$filter.paramfrom:$filter.min),($filter.paramto>
1470?$filter.paramto:$filter.max)],slide:function(e,ui){if(ui.values[0]>$min.attr('placeholder')){$min.val(ui.values[0])}else{$min.val('')} 148if(ui.values[1]<$max.attr('placeholder')){$max.val(ui.values[1])}else{$max.val('')}}});$("#min_"+$filter.name+", #max_"+$filter.name,$filterBox).change(function(){if($min.val()>0){min_val=$min.val()}else{min_val=$filter.min;$min.val('')} 149if($max.val()>0){max_val=$max.val()}else{max_val=$filter.max;$max.val('')} 150$slider.slider({values:[min_val,max_val]})})}} 151$('a.close-filter span').click(function(){var id=$(this).data('id');var type=$(this).data('type');$('input[name="'+type+'[]"][value="'+id+'"]').trigger('click');$('form[name="filters"]').change()}) 152$('form[name="filters"]',$filterBox).on('change',function(){var data=$(this).serializeArray();if(isElementExist(['filters','settings',0,'align_position'],state)){var state_array=[];state_array.push({name:'align_position',value:state.filters.settings[0].align_position}) 153console.log(state.filters.settings[0].align_position)} 154data.push({name:'onlyFilter',value:'1'});$filterBox.addClass('loader');$.ajax({url:$(this).attr('action'),data:data,dataType:'json',}).done(function(response){if(!state.productListings.mainListing){window.location.href=setGetParam(response.filters.filters_url_full,'onlyFilter','');return} 155$filterBox.removeClass('loader');var listingId=state.productListings.mainListing;tl.store.dispatch({type:'WIDGET_CHANGE_PAGE_COUNT',value:{widgetId:listingId,pageCount:1,},file:'extensions/ProductPropertiesFilters/js/filters'});tl.store.dispatch({type:'FILTERS_CHANGE',value:{filters:response.filters,},file:'extensions/ProductPropertiesFilters/js/filters'});tl.store.dispatch({type:'PRODUCTS_LISTING_HREF',value:{href:setGetParam(response.filters.filters_url_full,'onlyFilter','')},file:'extensions/ProductPropertiesFilters/js/filters'});tl.store.dispatch({type:'WIDGET_PAGE_COUNT_UPDATE_PAGE',value:{widgetId:listingId,pageCountUpdatePage:!0,},file:'extensions/ProductPropertiesFilters/js/filters'});$('.w-filters').html(response.html);applyFilters()})})})} 156function openCloseElements($filterBox){var state=tl.store.getState();var visibleOptions=7;if(isElementExist(['filters','settings',0,'visible_options'],state)){visibleOptions=state.filters.settings[0].visible_options} 157var closed=!1;if(isElementExist(['filters','settings',0,'open_filter'],state)&&state.filters.settings[0].open_filter=='closed'){closed=!0} 158$('.mobileCollapse',$filterBox).click(function(){$(this).parent().next().slideToggle();$(this).toggleClass('active');return!1});$('.filter-box-head',$filterBox).click(function(){$(this).toggleClass('clouse');$(this).parent().next().slideToggle()});var c_data=$.cookie('closed_data');if(!c_data)c_data='';var closed_data=c_data.split('|');var a_data=$.cookie('active_data');if(!a_data)a_data='';var active_data=a_data.split('|');$('.filter-box',$filterBox).each(function(){var head=$('.filter-box-head',this);var content=$('.filter-box-content',this);var icon=$('> span',head);var tab=$('>.tab-li',head);var tab_a=$('>.tab-li>a',head);var _id=$(this).attr('id');var data_tab=tab.data('tab');var in_closed_data=closed_data.indexOf(_id);var in_active_data=active_data.indexOf(data_tab);if(in_closed_data==-1){in_closed_data=!1}else{in_closed_data=!0} 159if(in_active_data==-1){in_active_data=!1}else{in_active_data=!0} 160if(closed&&!in_closed_data||!closed&&in_closed_data){icon.addClass('close');content.hide()} 161if(in_active_data){tab_a.addClass('active');$("#"+activeClass).show()} 162head.off('click').on('click',function(){if(icon.hasClass('close')){icon.removeClass('close');content.show();if(!isElementExist(['filters','settings',0,'align_position'],state)){if(closed&&!in_closed_data){$.cookie('closed_data',c_data+_id+'|')}else{$.cookie('closed_data',c_data.replace(_id+'|',''))}}}else{icon.addClass('close');content.hide();if(!isElementExist(['filters','settings',0,'align_position'],state)){if(!closed&&!in_closed_data){$.cookie('closed_data',c_data+_id+'|')}else{$.cookie('closed_data',c_data.replace(_id+'|',''))}}}}) 163$('.filter_tabs .tab-li a').click(function(){$('.tab-li a').removeClass('active');$(this).addClass('active');var activeClass=$('.filter_tabs a.active').closest('.tab-li').data('tab');console.log(activeClass);$('.filter_wrap >ul').hideTab();$("#"+activeClass).showTab();return!1})});var true_click=!0;$('.view_more',$filterBox).click(function(){if(true_click){$(this).parents('ul').find('li:nth-child('+visibleOptions+')~li').show();true_click=!1;$(this).html(entryData.tr.FILTER_LESS)}else{$(this).parents('ul').find('li:nth-child('+visibleOptions+')~li').hide();true_click=!0;$(this).html(entryData.tr.TEXT_MORE)} 164return!1});if($(window).width()>900){$('.filter_buttons',$filterBox).hide()} 165$(window).on('layoutChange',function(e,data){if(data.to<900||data.to<=900&&data.status=='in'){$('.filter_buttons',$filterBox).show()}else{$('.filter_buttons',$filterBox).hide()}})}})})
166setElementInObject(['extensions','productListing','applyItem','quotation'],tl,function($item,widgetId){var productId=$item.data('id');var $quoteBox=$('.quoteButton',$item);var $btnQuote=$('.btn-rfq',$quoteBox);if($btnQuote.length===0){return!1} 167var $btnPreloader=$('.btn-preloader',$quoteBox);var state=tl.store.getState();var product=state.products[productId];tl.subscribe(['widgets',widgetId,'products',productId,'addingToQuote'],function(){state=tl.store.getState() 168if(isElementExist(['widgets',widgetId,'products',productId,'addingToQuote'],state)&&state.widgets[widgetId].products[productId].addingToQuote){$btnQuote.addClass('hide');$btnPreloader.show()}else{$btnQuote.removeClass('hide');$btnPreloader.hide()}});$btnQuote.on('click',function(e){e.preventDefault();var state=tl.store.getState() 169if(+product.product_has_attributes&&!isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){window.location.href=product.link} 170addProductToQuote(widgetId,productId)});function addProductToQuote(widgetId,productId){var state=tl.store.getState();var qty;if(isElementExist(['widgets',widgetId,'products',productId,'qty'],state)){qty=state.widgets[widgetId].products[productId].qty}else{qty=1} 171tl.store.dispatch({type:'WIDGET_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'quote'},file:'boxes/ProductListing'});var postData={action:'buy_now',qty:qty,products_id:productId,add_to_quote:1,json:1,_csrf:$('meta[name="csrf-token"]').attr('content'),};if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){var attributes=state.widgets[widgetId].products[productId].attributes;for(var attrKey in attributes){postData[attrKey]=attributes[attrKey]}} 172$.ajax({url:entryData.mainUrl+'?action=add_product',data:postData,method:'post',dataType:'json'}).done(function(data){if(data.error){var state=tl.store.getState();window.location.href=state.products[productId].link} 173var products={};data.products.forEach(function(prod){products[prod.stock_products_id]={id:prod.id,qty:prod.quantity}});tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'quote'},file:'boxes/ProductListing'});tl.store.dispatch({type:'UPDATE_PRODUCTS_IN_LIST',value:{listingName:'quote',products:products,},file:'boxes/ProductListing'})}).fail(function(){tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'quote'},file:'boxes/ProductListing'})})}});setElementInObject(['extensions','productListing','applyItem','samples'],tl,function($item,widgetId){var productId=$item.data('id');var $sampleBox=$('.sampleButton ',$item);var $btnSample=$('.btn-rfq',$sampleBox);if($btnSample.length===0){return!1} 174var $btnPreloader=$('.btn-preloader',$sampleBox);var state=tl.store.getState();var product=state.products[productId];tl.subscribe(['widgets',widgetId,'products',productId,'addingToSamples'],function(){state=tl.store.getState() 175if(isElementExist(['widgets',widgetId,'products',productId,'addingToSamples'],state)&&state.widgets[widgetId].products[productId].addingToSamples){$btnSample.addClass('hide');$btnPreloader.show()}else{$btnSample.removeClass('hide');$btnPreloader.hide()}});$btnSample.on('click',function(e){e.preventDefault();var state=tl.store.getState() 176if(+product.product_has_attributes&&!isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){window.location.href=product.link} 177addProductToSample(widgetId,productId)});function addProductToSample(widgetId,productId){var state=tl.store.getState();var qty;if(isElementExist(['widgets',widgetId,'products',productId,'qty'],state)){qty=state.widgets[widgetId].products[productId].qty}else{qty=1} 178tl.store.dispatch({type:'WIDGET_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'samples'},file:'boxes/ProductListing'});var postData={action:'buy_now',qty:qty,products_id:productId,add_to_sample:1,json:1,_csrf:$('meta[name="csrf-token"]').attr('content'),};if(isElementExist(['widgets',widgetId,'products',productId,'attributes'],state)){var attributes=state.widgets[widgetId].products[productId].attributes;for(var attrKey in attributes){postData[attrKey]=attributes[attrKey]}} 179$.ajax({url:entryData.mainUrl+'?action=add_product',data:postData,method:'post',dataType:'json'}).done(function(data){if(data.error){var state=tl.store.getState();window.location.href=state.products[productId].link} 180var products={};
180data.products.forEach(function(prod){products[prod.stock_products_id]={id:prod.id,qty:prod.quantity}});tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'samples'},file:'boxes/ProductListing'});tl.store.dispatch({type:'UPDATE_PRODUCTS_IN_LIST',value:{listingName:'samples',products:products,},file:'boxes/ProductListing'})}).fail(function(){tl.store.dispatch({type:'WIDGET_NO_ADDING_PRODUCT_TO_LIST',value:{widgetId:widgetId,productId:productId,list:'samples'},file:'boxes/ProductListing'})})}});tl(createJsUrl('jquery.lazy.min.js'),function(){$('.w-banner').each(function(){var widgetId=$(this).attr('id');if(!widgetId){return''} 181widgetId=widgetId.substring(4);if(!isElementExist(['widgets',widgetId,'lazyLoad'],entryData)){return''} 182$('picture',this).each(function(){var item=this;$('img',item).lazy({bind:'event',beforeLoad:function(){$('source',item).each(function(){let srcset=$(this).data('srcset');$(this).attr('srcset',srcset).removeAttr('data-srcset')})},afterLoad:function(){$('img',item).removeClass('na-banner');$('source',item).each(function(){$(this).removeClass('na-banner')})}})})})});tl(createJsUrl('jquery.lazy.min.js'),function(){$('.w-image').each(function(){var widgetId=$(this).attr('id');if(!widgetId){return''} 183widgetId=widgetId.substring(4);if(!isElementExist(['widgets',widgetId,'lazyLoad'],entryData)){return''} 184var e=$('img',this).lazy({bind:'event'})})});tl.combineReducers=Redux.combineReducers(tl.reducers);tl.store=Redux.createStore(tl.combineReducers,window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__()) 185tl.backState=tl.store.getState();tl.allSubscribers=[];tl.subscribe=function(key,callBack){tl.allSubscribers.push({key:key,callBack:callBack})} 186tl.store.subscribe(function(){var state=tl.store.getState();tl.allSubscribers.forEach(function(subscribe){var key=subscribe.key;var callBack=subscribe.callBack;if(typeof key==='string'){if(JSON.stringify(state[key])!==JSON.stringify(tl.backState[key])){callBack()}} 187if(Array.isArray(key)){if(isDifferentElements(key,state,tl.backState)){callBack()}}}) 188tl.backState=state});function isDifferentElements(path,obj1,obj2){if(path.length>1){if(typeof obj1[path[0]]==='object'&&typeof obj2[path[0]]==='object'){return isDifferentElements(path.slice(1),obj1[path[0]],obj2[path[0]])}else if(typeof obj1[path[0]]==='object'&&isElementExist(path,obj1)||typeof obj2[path[0]]==='object'&&isElementExist(path,obj2)){return!0}}else if(JSON.stringify(obj1[path[0]])!==JSON.stringify(obj2[path[0]])){return!0} 189return!1} 190function isElementExist(path,obj){if(path.length>1){if(obj&&typeof obj[path[0]]==='object'){return isElementExist(path.slice(1),obj[path[0]])}}else if(obj[path[0]]){return!0} 191return!1} 192function setElementInObject(path,obj,value){var link=obj;path.slice(0,-1).forEach(function(element){if(!link[element])link[element]={};link=link[element]}) 193link[path.pop()]=value} 194function setGetParam(href,paramName,paramValue){var res='';var d=href.split("#")[0].split("?");var base=d[0];var query=d[1];if(query){var params=query.split("&");for(var i=0;i<params.length;i++){var keyval=params[i].split("=");if(keyval[0]!=paramName){res+=encodeURI($('<div>'+decodeURI(params[i])+'</div>').text())+'&'}}} 195res+=paramName+'='+encodeURI($('<div>'+decodeURI(paramValue)+'</div>').text());return base+'?'+res} 196function getMainUrl(){var mainUrl='';if((typeof(entryData)==='object')&&(entryData!==null)&&(typeof(entryData.mainUrl)==='string')){mainUrl=(''+entryData.mainUrl).replace(/(\/|\\)+$/g,'')} 197return mainUrl} 198function createJsUrl(file){if(typeof entryData.jsPathUrl!=='string'){return file} 199var newUrl=entryData.jsPathUrl.replace(/(\/|\\)+$/g,'');if(!file){return newUrl} 200newUrl=newUrl+'/'+file+(entryData.themeVersion?'?'+entryData.themeVersion:'');return newUrl} 201tl(tlSize.init);tl_action(tl_js)
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.