$(function(){ $(".showbox").owlCarousel({ loop : true, items : 1, nav : true, navText : ['',''], dots:false, autoplay:false, navSpeed:1000, }); $(".productbox .slidebox").owlCarousel({ loop : false, items : 6, responsive:{ 0:{ items : 2 }, 660:{ items : 3 }, 768:{ items : 4 }, 960:{ items : 6 }, 1024:{ items : 8 } }, nav : true, navText : ['',''], dots:false, autoplay:false, navSpeed:1000, }); //定位圖片將view more按鈕釘在圖片下方 $(".showbox").on("refreshed.owl.carousel",function(){ $(window).resize() }) var popupOpen = false $(".lookbookbox").on('click', '.item', function(event) { $(".popupbox").addClass('open'); popupOpen = true $(window).on("resize", function(){ $(".in_open").css({"top":($(".active img").height()+20+"px")}) }) }); $(".popupbox").on('click', '.close', function(event) { $(".popupbox").removeClass('open'); popupOpen = false $(window).off("resize") $(this).trigger("showBoxClose") }); var my_delay = 2000; function load_image(){ var _grid = $('.lookbookbox').imagesLoaded(function(){ _grid.masonry({ itemSelector:'.item', gutter:0, }); }); } function load_image2(){ /*var _grid = $('.lookbookbox').imagesLoaded(function(){ _grid.masonry({ itemSelector:'.item', gutter:0, }); }); _grid.masonry('reloadItems');*/ var $owl = $(".showbox"); $owl.trigger('destroy.owl.carousel'); $owl.owlCarousel({ loop : true, items : 1, nav : true, navText : ['',''], dots:false, autoplay:false, navSpeed:1000, }); } function ajax_get(page,cid,Max_Pic){ $.ajax({ type : "POST", url : "/lookbook/ajax/ajax_get_data.php", dataType : 'json', async : true, cache : false, data : {page:page,cid:cid,Max_Pic:Max_Pic}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success : function(e){ if(e.Status == 1){ var page = $("#look_page").val(); page = parseInt(page); $("#look_page").val(page+1); $(".lookbookbox").append(e.data1); $(".showbox").append(e.data2); $(".Max_Pic").html(e.Max_Pic); setTimeout(load_image2(),my_delay); } } }); } //load_image(); function updateShowBox(e,page){ $("#look_page").val(page+1); $(".lookbookbox").append(e.data1); $(".showbox").append(e.data2); $(".Max_Pic").html(e.Max_Pic); load_image2() } var timer; $(window).scroll(function() { if(timer) { window.clearTimeout(timer); } timer = window.setTimeout(function() { var scrollTop = $(window).scrollTop(); var document_height = $(document).height(); var document_body_height = $(document.body).height(); var header_height = $(".header-01").height(); var wallbox_height = $("article").height(); var page = $("#look_page").val(); var cid = $("#look_cid").val(); var Max_Pic = $(".Max_Pic").html(); page = parseInt(page); if(((scrollTop + document_body_height) > (wallbox_height+header_height)) && !popupOpen){ setTimeout(ajax_get(page,cid,Max_Pic),my_delay); } }, 500); }); //開關推薦商品 $(document).on("click", ".in_open", function(){ $(".productbox").addClass("open") }) $(document).on("click", ".in_close", function(){ $(".productbox").removeClass("open") }) //點旁邊黑色區塊關閉 $(document).on("click", ".productbox", function(e){ if($(e.target).hasClass("productbox") || $(e.target).hasClass("product-container")){ $(this).removeClass("open") } }) }) $(document).on("click",".look_pic",function(){ var pid = $(this).data('pid'); var Look_ID = $(this).data('id'); if(pid){ var $owl = $(".showbox"); $owl.trigger('to.owl.carousel',[(pid-1),0,true]); $.ajax({ type : "POST", url : "/lookbook/ajax/ajax_get_prod.php", dataType : 'json', async : true, cache : false, data : {Look_ID:Look_ID}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success : function(e){ $(".product-container").html(''); if(e.Status == 1){ $(".product-container").append(e.data); } } }); } }) $(document).on("click",".owl-prev,.owl-next",function(){ var Look_ID = $(".owl-stage .active").find(".pic").data('id'); $.ajax({ type : "POST", url : "/lookbook/ajax/ajax_get_prod.php", dataType : 'json', async : true, cache : false, data : {Look_ID:Look_ID}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success : function(e){ $(".product-container").html(''); if(e.Status == 1){ $(".product-container").append(e.data); } } }); });