(function($){ /* 回到購買處 */ $('.gobuy').on('click',function(){ var tol = $(window).height(); console.log(tol); var buy = $('.button-line').offset().top-tol+50 ; $("html,body").scrollTop(buy); }); /*為JQ添加naturalWidth()和naturalHeight()方法,抓取圖片原始尺寸*/ var props = ['Width', 'Height'], prop; while (prop = props.pop()) { (function (natural, prop) { $.fn[natural] = (natural in new Image()) ? function () { return this[0][natural]; } : function () { var node = this[0], img, value; if (node.tagName.toLowerCase() === 'img') { img = new Image(); img.src = node.src, value = img[prop]; } return value; }; }('natural' + prop, prop.toLowerCase())); } var _window = $(window); var change = 0; var moreview = false; //關閉跳窗 $(".inner").on('click','.close,.add_to_cart',function(){ $(".selectPopupBox").removeClass('is-show'); }); /* $('article').on('click','.open-preview',function(){ var nowitem = $('.productImg .active').prevAll('.owl-item').length; $('article .previewbox').css('display','block') .find('img').eq(nowitem).css('display','block'); }); $('article').on('click','.close',function(){ $('article .previewbox').removeAttr('style') .find('img').removeAttr('style'); }); //*/ smallPicBox($(".prod-itemBox .productView")); videoBox(); $('.productImg.mobile').owlCarousel({ loop : false, items : 1, nav : true, }); $('.productImg.mobile').on('changed.owl.carousel',function(e){ var num = e.item.index; if(document.getElementById("Video")){ if($(".productView").find(".owl-item").eq(num).find("#Video").attr("style")){ $("#big_picture").hide(); document.getElementById("Video").play(); }else{ $("#big_picture").show(); document.getElementById("Video").pause(); } } }); // ========================================================== // 折價券 // ========================================================== $('.product-coupon .coupon-list').owlCarousel({ loop : true, margin: 25, navText : ['',''], responsive:{ 0:{ items : 1, nav : false, dots: true, }, 769:{ items : 2, nav : false, dots: true, }, 1201:{ items : 3, nav : true, dots: false, } }, }); //關聯商品輪播&手機版解除輪播 relatedCarousel($(".related-carousel")) $(window).on("resize", function(){ relatedCarousel($(".related-carousel")) }) }(jQuery)); function relatedCarousel(carouselbox){ if($(window).width() < 768){ carouselbox.trigger("destroy.owl.carousel") }else{ carouselbox.owlCarousel({ responsive:{ 0: { items:2, margin: 10 }, 769: { items:3, margin: 32 }, 1025: { items:4, margin: 32 }, 1681: { items:4, margin: 44 } }, nav: true, dots: false }) } }