// ========================================================== // 裝飾用 LOGO 滑動定位 // ========================================================== ;(function($) { $(window).on('scroll', function(e) { const footerHeight = $('footer').outerHeight() const footerTop = $('footer').offset().top const mainPaddingBottom = Math.round(parseFloat($('main').css('padding-bottom'))) const footerLimit = footerTop - $(this).height() / 2 - $('.film-logo').height() / 2 - mainPaddingBottom if($(this).scrollTop() > footerLimit) { $('body').addClass('over-footer') } else { $('body').removeClass('over-footer') } }).trigger('scroll') $(window).on('resize', function(e) { $(this).trigger('scroll') }) })($) // ========================================================== // 影音列表youtube跳窗 // ========================================================== ;(function($) { $(document).on('click', '#controlButton', function(e) { e.preventDefault() const youtubeID = $(this).attr('data-youtube') const replaceDOM = ` ` $('body').append(replaceDOM).addClass('overflow-hidden') }) })($) ;(function($) { $(document).on('click', '.PopupYoutube', function(e) { if(e.currentTarget === e.target || $(e.target).hasClass('modal-closer')) { e.preventDefault() $(e.currentTarget).remove() $('body').removeClass('overflow-hidden') } }) })($) // ========================================================== // 影音列表頁下方輪播區塊 // ========================================================== ;(function($) { const slideTarget = $('.detail-films') if(slideTarget.length) { slideTarget.each(function(i, ele) { if($(ele).children().length > 1) { $(ele).owlCarousel({ nav: true, navText: ['', ''], dots: false, margin: 20, responsive: { 0: { items: 1, }, 576: { items: 2, }, 768: { items: 3, }, 1200: { items: 4, }, }, }) } }); } })($) // ========================================================== // 點擊圖片更換為youtube // ========================================================== ;(function($) { $(document).on('click', '.LoadingYoutube', function(e) { e.preventDefault() const youtubeID = $(this).attr('data-id') const replaceDOM = `` $(this).replaceWith(replaceDOM); }) })($) $(document).ready(function(){ $(".loveBox").click(function(){ var $this = $(this), SID = $(this).children('.love').attr('sid'), type = 'add'; if($this.find(".love").attr("class").match('red')) { //愛心是紅色狀態 type = 'del'; } $.ajax({ url:'/products/ajax/common/ajax_add_wish_list.php', type:"POST", cache:false, async:false, dataType: 'json', data:{Type:type,SID:SID}, error:function(d){ alert(d.responseText); }, success:function(d){ if(d.Msg=='OK'){ if(type == 'add'){ if(d.FBQ) { eval(d.FBQ); } $this.find(".love").addClass("red"); alert(_jsLang.新增成功); }else{ $this.find(".love").removeClass("red"); alert(_jsLang.刪除成功); } }else if(d.Msg == 'NO_MEMBER'){ alert(_jsLang.請先登入會員); }else{ alert(_jsLang.資料庫忙線中); } } }); }); });