"; html += "
"; html += " "; html += ""; return html; } function createCart(data) { if (!(JSON.stringify(data) == "[null]" || data == null)) { var html = ""; $(".shopcart-box .table").html(html); $.each(data, function(id,d) { html += renderCart(d); }); $(".shopcart-box .table").html(html); updateTotal(); $(".shopcart-box .table .quantity_itemcart").change(function(){ var id = $(this).attr("id").replace("quantity_itemcart_",""); var qty = $(this).val()-shopcart[id]["quantity"]; updateItem(undefined,id,qty); }); $(".shopcart-box .table .remove_itemcart").click(function(){ var id = $(this).attr("id").replace("remove_itemcart_",""); updateItem(undefined,id); }); $(".shopcart-widget .dropdown-menu,.shopcart-box .table .remove_itemcart,.shopcart-box .table .quantity_itemcart").click(function(e){ e.stopPropagation(); }); } } $(".order_itemcart").click(function() { var id = parseInt($(this).attr("id").replace("order_itemcart_","")); var d = {}; var idata = id; $("#item-shopcart-"+id+" .item-shopcart").each( function(v,i) { var atr = $(i).attr("id"); if (atr.substr(0,5) == "data_") { idata += $(i).val(); d["data_"+atr.substr(5).replace(/_/g," ")] = $(i).val(); } else { d[atr] = $(i).val(); } } ); var idata = enAsci(idata); d["idata"] = idata; var val = {"shopcart":{}}; val["shopcart"]["data"] = d; if ($("#quantity_itemcart_"+d["idata"]).length > 0) { $("#quantity_itemcart_"+d["idata"]).val(parseFloat($("#quantity_itemcart_"+d["idata"]).val())+parseFloat(d["quantity"])); updateItem(undefined,d["idata"],d["quantity"]); } else { updateItem(val,idata); } }); var shopcart = null; createCart(shopcart); var Ssidebar = $('#navbar-collapse'); var Swindow = $(window); var done = false; Swindow.on('scroll resize', function(e) { var offsetPixels = 80; var mh = $(".main-header").width(); Ssidebar.css({"width":mh+"px"}); if (Swindow.scrollTop() > offsetPixels) { if(!done && Swindow.width() >= 753) { done = true; Ssidebar.css({"position": "fixed","top": "0px","margin-left":"-15px","margin-right":"-15px"}); $("#navbar-collapse #logocon").css("display",""); $("#header .logo").css("display","none"); } } else { if(done) { done = false; Ssidebar.css({"position": "","top": ""}); $("#navbar-collapse #logocon").css("display","none"); $("#header .logo").css("display",""); } } }); $("#btn-scroll-up").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); $(document).ready(function() { setTimeout(function(){ $('body').addClass('loaded'); }, 500); });