function pnCallback(e){$(".sharehrefpn .count").html(e.count)}function shareInit(e){document.location.href;var t=(t=window.location.host).replace("mall.",""),t=window.location.protocol+"//"+t+"/"+username+"/"+itemid,o=($(".sharehreffb").attr("href","https://www.facebook.com/sharer/sharer.php?app_id=1574354049466790&sdk=joey&u="+t),"Shopee"),a=(window.twitter_text&&(o=(o=(o=window.twitter_text.replace("{{product_name}}",e.item_detail.name)).replace("{{price}}",dollarsign_getter(e.item_detail.currency)+bee_dollarfy(e.item_detail.price,e.item_detail.currency))).replace("{{product_link}}",t),o=encodeURIComponent(o)),"Shopee"),e=(window.pinterest_text&&(a=(a=(a=window.pinterest_text.replace("{{product_name}}",e.item_detail.name)).replace("{{price}}",dollarsign_getter(e.item_detail.currency)+bee_dollarfy(e.item_detail.price,e.item_detail.currency))).replace("{{product_link}}",t),a=encodeURIComponent(a)),$(".sharehreftw").attr("href","https://twitter.com/intent/tweet?original_referer="+encodeURIComponent(t)+"&text="+o+"&tw_p=tweetbutton"),$(".sharehrefpn").attr("href","http://www.pinterest.com/pin/create/button/?url="+encodeURIComponent(t)+"&media="+encodeURIComponent(topImage)+"&description="+a),"/shop/"+shopid+"/item/"+itemid+"/fb_share_count/"),o=(getJSON(e,function(e){$(".sharehreffb .count").html(e.count)}),"https://api.pinterest.com/v1/urls/count.json?callback=pnCallback&url="+encodeURIComponent(t));$.ajax({type:"POST",dataType:"jsonp",url:o,success:function(e){}})}function showWebQuantityPanel(e){0==stock?alert_message(i18n.t("label_tag_out_of_stock")):0!==itemModels.length||window.canUseWholesale?setTimeout(function(){e?$("#ok-button").text(i18n.t("label_add_to_cart")):$("#ok-button").text(i18n.t("label_buy")),$("#second-layer").show(),$("#second-layer").velocity({bottom:0},200,"easeInOutCubic"),$("#cover").show(),($("#float-bottom").hasClass("hidden")?$("#float-bottom-for-buyer"):$("#float-bottom")).velocity({bottom:"-200px"},200,"easeInOutCubic")},100):add_to_cart(e)}function hideWebQuantityPanel(){$("#second-layer").velocity({bottom:"-350px"},200,"easeInOutCubic",function(){$("#second-layer").hide()}),$("#cover").hide(),($("#float-bottom").hasClass("hidden")?$("#float-bottom-for-buyer"):$("#float-bottom")).velocity({bottom:0},200,"easeInOutCubic")}function trackPricezaItemPurchase(e){var t=[],o=[];if(e&&e.itemId&&e.quantity)for(var a=e.quantity;0<a;a--)t.push(e.itemId),o.push(e.price);var r={type:"purchase",merchantId:PRICEZA_MERCHANT_ID,productId:t.join("|"),value:o.join("|")};ShopeeLib.priceza.sendTracking(r)}var adding;function add_to_cart(i){var e,n,t;adding||(adding=!0,"priceza"==$.query.get("utm_source")&&trackPricezaItemPurchase({itemId:itemid,price:price/PRICE_INFLATION_FACTOR,quantity:quantity}),e=$("#second-layer .models .model.selected").data("modelid"),n={refererItems:t=[]},t.push({shopID:shopid,itemID:itemid}),t={shopid:shopid,itemid:itemid,quantity:quantity,donot_add_quantity:!1,csrfmiddlewaretoken:csrf,source:JSON.stringify({refer_urls:BJUtil.getTrackingReferUrls(itemid)})},e&&(t.modelid=e),$.post("/buyer/cart/add_to_cart/",t,function(e){if(0==e.error){hideWebQuantityPanel();try{$("#item-price .dollarfy_sign").text();var t=$("#item-price .dollarfy_val").attr("val"),o=$("#item-price .dollarfy_val").attr("currency"),a=t*quantity/PRICE_INFLATION_FACTOR;_track_add_to_cart(a,o),_fb_track_add_to_cart_conversion(a,o),window.fbq&&fbq("track","AddToCart",{value:a,currency:o,content_type:"product",content_ids:itemid.toString()})}catch(e){console.log(e)}var r;i?alert_message(i18n.t("msg_item_has_been_added_to_cart")):(r="/buyer/cart/",r=generateGetUri("/buyer/cart/",{pass_back_string:encodeURIComponent(JSON.stringify(n))}),setTimeout(function(){navigate(r)},50))}else{hideWebQuantityPanel();t=e.error;6==t?alert_message(i18n.t("label_tag_out_of_stock")):3==t?alert_message(i18n.t("msg_cart_limit_per_shop_hit")):alert_message(i18n.t("msg_item_not_available"))}adding=!1}).fail(function(e){alert_message(i18n.t("msg_server_error")),adding=!1}),button_disabled=!1)}
//# sourceMappingURL=../../source_maps/shop/item_web.js.map
