WooZone=(function($){"use strict";var ajaxurl=woozone_vars.ajax_url,lang=woozone_vars.lang;var current_aff={};(function init(){$(document).ready(function(){var $current_aff=$('#WooZone_current_aff');if($current_aff.length>0){current_aff=$current_aff.data('current_aff')} triggers()});var syncfront=syncfront_func();syncfront.init()})();function triggers(){checkout_email();load_amazon_reviews();fix_images()};function load_amazon_reviews(){var wrapper=$('body #amzaff-amazon-review-tab');wrapper.each(function(){var data={action:'WooZone_frontend',sub_action:'load_amazon_reviews',prodid:wrapper.data('prodid')};$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){if('valid'==response.status){wrapper.html(response.html)}}},'json').fail(function(){}).done(function(){}).always(function(){})})} function fix_images(){setInterval(function(){var $imgFound=$("img[src*='ssl-images']");$imgFound.each(function(){var that=$(this),src=that.attr('src');if(src.indexOf('//')==0){if(src.indexOf("ssl-images")!=!1){that.attr('src',"https:"+src);that.attr('srcset',"https:"+that.attr('srcset'))}}})},1000)} function checkout_email(){if(!$('.cart_totals').length)return!1;var woozone_email_wrapper=$('.woozone_email_wrapper'),woozone_checkout_email=$('#woozone_checkout_email'),woozone_email_mandatory=$('#woozone_checkout_email_required');if(woozone_checkout_email.length>0){woozone_email_wrapper.insertBefore($('.wc-proceed-to-checkout'));var checkout_btn=$('.wc-proceed-to-checkout .checkout-button'),checkout_link=checkout_btn.attr('href');if(woozone_email_mandatory.length>0&&woozone_email_mandatory.val()=='1'){checkout_btn.addClass('disabled');checkout_btn.attr('href','#amz_checkout_email')} woozone_email_wrapper.on('keyup',woozone_checkout_email,function(e){var woozone_validate_email=/([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(woozone_checkout_email.val());if(woozone_validate_email){if(woozone_email_mandatory.length>0&&woozone_email_mandatory.val()=='1'){checkout_btn.removeClass('disabled');checkout_btn.attr('href',checkout_link)} woozone_checkout_email.css({'border':'1px solid #d1d1d1'})}else{if(woozone_email_mandatory.length>0&&woozone_email_mandatory.val()=='1'){checkout_btn.addClass('disabled');checkout_btn.attr('href','#amz_checkout_email')} woozone_checkout_email.css({'border':'1px solid red'})}})} $('.wc-proceed-to-checkout').on('click','.checkout-button',function(e){if(woozone_checkout_email.length>0){if(woozone_email_mandatory.length>0&&woozone_email_mandatory.val()=='1'){if($(this).hasClass('disabled')){e.preventDefault();return!1}} if(!country_shop_checkout.allow_checkout()){country_shop_checkout.set_msg_html(!1,lang.amzcart_cancel_msg);return!1}else{country_shop_checkout.set_msg_html(!0,lang.amzcart_checkout_msg)} if(woozone_checkout_email.val()!=''){jQuery.post(woozone_vars.ajax_url,{'action':'WooZone_before_user_checkout','_nonce':$('#woozone_checkout_email_nonce').val(),'email':woozone_checkout_email.val()},function(data,textStatus){if((textStatus==='success')||(textStatus==='email_exists')){$(this).prop('href',woozone_vars.checkout_url)}else{alert(textStatus)}})}}else{if(!country_shop_checkout.allow_checkout()){country_shop_checkout.set_msg_html(!1,lang.amzcart_cancel_msg);return!1}else{country_shop_checkout.set_msg_html(!0,lang.amzcart_checkout_msg)} $(this).prop('href',woozone_vars.checkout_url)}})};function popup(url,title,params){window.open(url,title,params)};var product_country_check=(function(){var DISABLED=!1;var DEBUG=!1;var maincontainer=null,mainloader=null,product_data={},current_country={},available_countries=[],main_aff_id='',aff_ids=[],cc_template=null,us_li=null,verify_interval=300,verify_max_steps=15,updated_countries=!1;function __(){console.log('__ method')};function get_vars(){return $.extend({},{})};(function init(){if(DISABLED)return!1;$(document).ready(function(){maincontainer=$(".WooZone-country-check:first");mainloader=maincontainer.find('.WooZone-country-loader');build_main_box();build_box_minicart();triggers()})})();function triggers(){maincontainer.on('click','li .WooZone-cc_checkbox input[type="radio"]',function(e){if(DEBUG)console.log('clicked',$(this));save_product_country($(this).parents('li:first').data('country'))})};function build_box_minicart(){var newel=null,tpl=$('#WooZone-cc-small-template'),minicart=$('div.kd_small-cart .cart-details ul.kd_small_cart_items'),is_kingdom=minicart.length;var cached=$('.WooZone-cc-small-cached').html();cached=typeof cached!='undefined'?JSON&&JSON.parse(cached)||$.parseJSON(cached):cached;if(DEBUG)console.log('cached',cached);if(!tpl.length)return!1;if(!is_kingdom||!cached.length)return!1;$.each(cached,function(index,value){var current=minicart.find('li').filter(function(i){return value.cart_item_key==$(this).data('prodid')});var __=$(tpl.html()).clone();__.find(".WooZone-cc_domain").addClass(value.product_country.replace(".","-")).prop('title',value.country_name);__.find(".WooZone-cc_status").addClass(value.country_status_css).prop('title',value.country_status_text);current.find('.kd_cart_item-details').append(__)})};function build_main_box(pms){var pms=pms||{};var do_position=misc.hasOwnProperty(pms,'do_position')?pms.do_position:!1;if(!maincontainer.length){if(DEBUG)console.log('!!! ERROR: main box container not found!',maincontainer);return!1} var _product_data=maincontainer.find('.WooZone-product-data').html().replaceAll("“",'"').replaceAll("”",'"').replaceAll("″",'"');_product_data=typeof _product_data!='undefined'?JSON&&JSON.parse(_product_data)||$.parseJSON(_product_data):_product_data;var product_pms={'id':_product_data.prodid,'asin':_product_data.asin,'country':_product_data.prodcountry,'boxpos':_product_data.boxpos,'do_update':_product_data.do_update};setTimeout(function(){loading('show',lang.loading);maincontainer.show();if(do_position){position_box(product_pms)} var _update=function(){if(updated_countries){if(DEBUG)console.log('countries: already updated!');return!0} if(product_data.do_update){if(DEBUG)console.log('countries: updating...');update_countries();return!0} if(DEBUG)console.log('countries: no need to update!')} set_product_data(product_pms);build_countries_list();if(DEBUG)console.log(product_data,available_countries);load_template();build_countries_elements(_update)},0)} function position_box(pms){var newel=null,is_bravo=$('body.bravostore-body div.product#product-'+pms.id+' form.cart').length,is_kingdom=$('div.product#product-'+pms.id+' > div.row:first .kd_description').length;if('before_add_to_cart'==pms.boxpos){if(is_kingdom){newel=$('div.product#product-'+pms.id+' > div.row:first .kd_description .cart')} if(is_bravo){newel=$('div.product#product-'+pms.id+' form.cart')} maincontainer.insertBefore(newel).show()}else if('before_title_and_thumb'==pms.boxpos){newel=$('div.product#product-'+pms.id);if(newel.length) maincontainer.prependTo(newel).show();else{if(is_kingdom){newel=$('div.product#product-'+pms.id+' > div.row:first');maincontainer.insertBefore(newel).show()}}}else if('before_woocommerce_tabs'==pms.boxpos){newel=$('div.product#product-'+pms.id+' div.woocommerce-tabs.wc-tabs-wrapper');if(newel.length) maincontainer.insertBefore(newel).addClass('WooZone-boxpos-before_woocommerce_tabs').show();else{if(is_kingdom){newel=$('div.product#product-'+pms.id+' > div.row:first');maincontainer.insertAfter(newel).show()}}}};function add_country(new_country,where){var where=where||'available';if('available'==where){available_countries.push(new_country)}};function load_template(){cc_template=maincontainer.find("#WooZone-cc-template").html()};function set_product_data(pms){product_data=pms};function build_countries_list(){available_countries=[];var cached_aff_ids=maincontainer.find('.WooZone-country-affid').html().replaceAll("“",'"').replaceAll("”",'"').replaceAll("″",'"');cached_aff_ids=typeof cached_aff_ids!='undefined'?JSON&&JSON.parse(cached_aff_ids)||$.parseJSON(cached_aff_ids):cached_aff_ids;if(cached_aff_ids&&misc.hasOwnProperty(cached_aff_ids,'main_aff_id')) main_aff_id=cached_aff_ids.main_aff_id;if(cached_aff_ids&&misc.hasOwnProperty(cached_aff_ids,'aff_ids')) aff_ids=cached_aff_ids.aff_ids;var cached_countries=maincontainer.find('.WooZone-country-cached').html().replaceAll("“",'"').replaceAll("”",'"').replaceAll("″",'"');cached_countries=typeof cached_countries!='undefined'?JSON&&JSON.parse(cached_countries)||$.parseJSON(cached_countries):cached_countries;$.each(cached_countries,function(index,value){var __={'domain':value.domain,'name':value.name};if(misc.hasOwnProperty(value,'available')){__.available=value.available} add_country(__)});return!1};function build_countries_elements(callback){var cc=0;$.each(available_countries,function(key,value){var __=$(cc_template).clone();__.data('country',value.domain);__.find(".WooZone-cc_domain").addClass(value.domain.replace(".","-")).prop('title',value.name);__.find(".WooZone-cc_name > a").text(value.name).attr('href',build_product_link(value.domain,product_data.asin,!0));var _countryflag_aslink=__.find(".WooZone-cc_domain > a");if(_countryflag_aslink.length){_countryflag_aslink.attr('href',build_product_link(value.domain,product_data.asin,!0))} if(value.domain==product_data.country){__.find('.WooZone-cc_checkbox input[type=radio]').prop('checked',!0);current_country['elm']=__.find('.WooZone-cc_checkbox input[type=radio]');current_country['country']=value.domain} maincontainer.append(__);if(misc.hasOwnProperty(value,'available')){add_country_status_html(__,value.available)} cc++});setTimeout(function(){loading('close');if($.isFunction(callback)){callback()}},0)};function update_countries(){var countries=JSON.stringify(available_countries);var data={action:'WooZone_frontend',sub_action:'update_countries',product_id:product_data.id,asin:product_data.asin,product_country:current_country['country']};if(DEBUG)console.log(data);loading('show',lang.updating);$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){} if(DEBUG)console.log('countries: ajax update done!');loading('close');maincontainer.html(response.html);mainloader=maincontainer.find('.WooZone-country-loader');build_main_box({do_position:!1})},'json').fail(function(){}).done(function(){}).always(function(){updated_countries=!0})};function save_product_country(country){var data={action:'WooZone_frontend',sub_action:'save_product_country',product_id:product_data.id,product_country:country||current_country['country']};if(DEBUG)console.log(data);loading('show',lang.saving);$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){} loading('close')},'json').fail(function(){}).done(function(){}).always(function(){})};function add_country_status_html(elm,status){if(status){if(DEBUG)console.log(elm.data('country'),"product valid");elm.find(".WooZone-cc-status").html(""+lang.available_yes+""+lang.available_no+"').removeClass('success cancel').addClass(css_class).text(text);elm.html(__)};return{'v':get_vars,'__':__,'allow_checkout':allow_checkout,'set_msg_html':set_msg_html}})();var cross_sell_box=(function(){var DISABLED=!1;var DEBUG=!1;var maincontainer=null,mainloader=null,multiple_asins=[];function __(){console.log('__ method')};function get_vars(){return $.extend({},{})};(function init(){if(DISABLED)return!1;$(document).ready(function(){maincontainer=$("body");mainloader=maincontainer.find('.WooZone-cross-sell-loader');triggers();if(maincontainer.find('.main-cross-sell').length){load_box()}})})();function load_box(){var box=maincontainer.find('.main-cross-sell'),asin=maincontainer.find('.main-cross-sell').data('asin'),boxd=maincontainer.find('#WooZone-cross-sell-debug');var data={action:'WooZone_frontend',sub_action:'load_cross_sell',asin:asin};if(DEBUG)console.log(data);if(boxd.length){boxd.html('Loading Ajax : make amazon request to retrieve products ...');boxd.show()} loading('show',lang.load_cross_sell_box);$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){box.html(response.html).css({'min-height':'initial'});if(boxd.length){boxd.html(response.debug);boxd.show()}} loading('close')},'json').fail(function(){}).done(function(){}).always(function(){})};function empty_cache(that){var box=maincontainer.find('.main-cross-sell'),asin=maincontainer.find('.main-cross-sell').data('asin'),boxd=maincontainer.find('#WooZone-cross-sell-debug');var data={action:'WooZone_frontend',sub_action:'cross_sell_empty_cache',asin:asin};if(DEBUG)console.log(data);that.prop('disabled',!0).after(lang.saving);$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){window.location.reload()} loading('close')},'json').fail(function(){}).done(function(){}).always(function(){})};function triggers(){$("body").on("click",'#WooZone-cross-sell-debug button',function(e){empty_cache($(this))});$("body").on("change",'.cross-sell input',function(e){var that=$(this),row=that.parents('li').eq(0),asin=that.val(),the_thumb=$('#cross-sell-thumb-'+asin).parents('li'),buy_block=$('div.cross-sell-buy-btn');var price_dec_sep=$('.cross-sell .cross-sell-price-sep').data('price_dec_sep');buy_block.fadeOut('fast');if(that.is(':checked')){row.attr('class','');the_thumb.fadeIn('fast')}else{row.attr('class','');row.addClass('cross-sale-uncheck');the_thumb.fadeOut('fast')} var _total_price=0,remaining_items=0;$(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").each(function(){var that=$(this);var price=that.find('.cross-sell-item-price').data('item_price');_total_price=_total_price+parseFloat(price);remaining_items++});if(_total_price>0){_total_price=_total_price.toFixed(2);if(','==price_dec_sep){_total_price=numberFormat(_total_price)} $("#feq-products").show();var curr_price=$("#cross-sell-buying-price").text().match(/[\d.,]+/);$("#cross-sell-buying-price").text($("#cross-sell-buying-price").text().replace(curr_price,_total_price))}else{$("#feq-products").fadeOut('fast');var curr_price=$("#cross-sell-buying-price").text().match(/[\d.,]+/);$("#cross-sell-buying-price").text($("#cross-sell-buying-price").text().replace(curr_price,_total_price))} buy_block.fadeIn('fast')});$("body").on("click",'.cross-sell a#cross-sell-add-to-cart',function(e){e.preventDefault();var that=$(this);var totals_checked=$(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").size();$(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").each(function(){var that=$(this),q=1,asin=that.find('input').val();multiple_asins.push(asin)});if(totals_checked>0){var newurl=that.attr('href')+'?amz_cross_sell=yes&asins='+multiple_asins.join(',');$(location).attr('href',newurl)}})};function loading(status,msg){var msg=msg||'';if(''==msg&&'show'==status) msg=lang.loading;if(''!=msg) mainloader.find('.WooZone-cross-sell-loader-text').html(msg);if('show'==status) mainloader.fadeIn('fast');else mainloader.fadeOut('fast')};function numberWithCommas(number){var parts=number.toString().split(".");parts[0]=parts[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return parts.join(".")};function numberFormat(number){var formatted_number=number.replace(',','###');formatted_number=formatted_number.replace('.',',');formatted_number=formatted_number.replace('###','.');return formatted_number};return{'v':get_vars,'__':__}})();function syncfront_func(){var DISABLED=!1;var DEBUG=!1;var maincontainer=null,mod_alias='syncfront/ ',sync_wrapper='#WooZone-syncfront-wrapper',sync_content='#WooZone-syncfront-content',sync_debug='#WooZone-syncfront-debug',is_page_product=!1,sync_params={},timer=null;function init(){if(DISABLED)return!1;$(document).ready(function(){maincontainer=$("body");if($(sync_wrapper).length){is_page_product=!0} if(!is_page_product){return!1} sync_params=get_sync_params();timer=dotimer();triggers()})};function triggers(){if(DEBUG){console.log(mod_alias,'is product page: '+is_page_product)} maincontainer.on('click','#WooZone-syncfront-content .WooZone-syncfront-action-refresh-yes',function(e){e.preventDefault();timer.stop();window.location.reload()});maincontainer.on('click','#WooZone-syncfront-content .WooZone-syncfront-action-refresh-no',function(e){e.preventDefault();timer.stop();$(sync_wrapper).hide()});set_operation_time();if('yes'==sync_params.do_ajax){do_sync()}else{set_operation_msg(sync_params.do_msg)}};function get_sync_params(){var _params=$(sync_wrapper).find('.WooZone-syncfront-params').html();_params=typeof _params!='undefined'?JSON&&JSON.parse(_params)||$.parseJSON(_params):_params;if(DEBUG)console.log(mod_alias,'params',_params);return _params};function do_sync(){var time_start=new Date().getTime(),time_end=null,duration=null;set_operation_msg('STARTING AJAX TO SYNC PRODUCT...');var data={'action':'WooZone_frontend','sub_action':'do_sync','asin':sync_params.asin,'product_id':sync_params.product_id,'product_type':sync_params.product_type};$.post(ajaxurl,data,function(response){if(misc.hasOwnProperty(response,'status')){set_operation_msg(response.html);if('yes'==response.do_refresh){$(sync_wrapper).show();timer.start()} set_operation_msg('FINISHED AJAX TO SYNC PRODUCT!');if(misc.hasOwnProperty(response,'html_aftersync')){if($(sync_debug).length&&''!=response.html_aftersync){$(sync_debug).find('table tbody').prepend(response.html_aftersync);set_operation_time()}} time_end=new Date().getTime();duration=(time_end-time_start)/1000;set_operation_msg('AJAX SYNC DURATION: {duration} seconds'.replace('{duration}',duration))}},'json').fail(function(){}).done(function(){}).always(function(){})};function dotimer(){var _timer=null,$remained=$(sync_content).find('h3 span'),remained=typeof $remained!==null&&$remained.length?$remained.text():15;function start(){function doit(){_timer=setTimeout(function(){if(remained){remained--;$remained.html(remained);doit()}else{stop();window.location.reload()}},1000)} doit()} function stop(){clearTimeout(_timer);_timer=null} return{'start':start,'stop':stop}};function set_operation_msg(msg,where){var where=where||'prepend',opmsg=[];if(!$(sync_debug).length){return!1} opmsg.push('');opmsg.push(''+(new Date).toTimeString().slice(0,8)+'');opmsg.push(''+msg+'');opmsg.push('');opmsg=opmsg.join('');if('prepend'==where){$(sync_debug).find('table tbody').prepend(opmsg)}else{$(sync_debug).find('table tbody').append(opmsg)} $(sync_debug).show();return opmsg} function set_operation_time(){if(!$(sync_debug).length){return!1} var rows_upd=$(sync_debug).find('table tbody tr.wzsync-update-time');rows_upd.find('td:first').html((new Date).toTimeString().slice(0,8));rows_upd.removeClass('wzsync-update-time')} function set_operation_product_info(){} return{'init':init}};var misc={hasOwnProperty:function(obj,prop){var proto=obj.__proto__||obj.constructor.prototype;return(prop in obj)&&(!(prop in proto)||proto[prop]!==obj[prop])}};return{'popup':popup}})(jQuery)