function is_touch_device() { return ('ontouchstart' in document.documentElement); } function is_ie8() { return (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE8.0"); } function is_ie() { return (navigator.userAgent.indexOf("Trident") > -1); } function m_w() { return $(window).width() < 800; } jQuery.exists = function (selector) { return (jQuery(selector).length > 0); }; $(window).scroll(function () { animated_contents(); mk_fix_modern_header(); if (m_w()) { } }); $(window).on('debouncedresize', function () { container_aspectratio_responsive(); full_height_responsive(); bg_video_resize(); }); $(document).ready(function () { container_aspectratio_responsive(); full_height_responsive(); bg_video_resize(); animated_contents(); mk_fix_modern_header(); //δΈ‹ζ‹‰θœε• $('header nav.pc a').mouseover(function (e) { var curindex = $('header nav.pc a').index(this); $('.subnav.pc .menus ._lv2').removeClass('current'); if ($('.subnav.pc .menus ._lv2').eq(curindex).html() == '') { $('.subnav.pc').removeClass('on'); } else { $('.subnav.pc').addClass('on'); $('.subnav.pc .menus ._lv2').eq(curindex).addClass('current'); } }); $('.subnav.pc').mouseleave(function (e) { $('.subnav.pc').removeClass('on'); $('.subnav.pc .menus ._lv2').removeClass('current'); }); $('header .icosbtn,header .logo').mouseover(function (e) { $('.subnav.pc').mouseleave(); }); //m_menu $('#m_menu').multilevelpushmenu({ menuWidth: '230px', menuHeight: '2000px', direction: 'rtl', fullCollapse: true, collapsed: true, wrapperClass: 'mlpm_w', menuInactiveClass: 'mlpm_inactive', onItemClick: function () { var $item = arguments[2]; var itemHref = $item.find('a:first').attr('href'); if(itemHref!=='#') {location.href = itemHref;} console.log(arguments[2].text()); }, onExpandMenuStart: function () { $('.m_menu_bg').fadeIn(); }, onCollapseMenuEnd: function () { if ($('#m_menu').width()==0) $('.m_menu_bg').fadeOut(); } }); $('header .icosbtn .icon-menu').click(function (e) { e.preventDefault(); //alert($(window).height()) if (!m_w()) { $('header .pc_pop_menu').fadeIn(); $('header .pc_pop_menu').css({ 'height': $(window).height() + 'px' }); } else { $('#m_menu').multilevelpushmenu('expand'); //$('.m_menu_bg').fadeIn(); } }); $('.m_menu_bg').click(function (e) { e.preventDefault(); $('#m_menu').multilevelpushmenu('collapse'); }); $('header .pc_pop_menu .close').click(function (e) { $('header .pc_pop_menu').fadeOut(); }); $('header .menu').mousedown(function () { if ($(this).find('.menu_bars').hasClass('on')) { $('header nav').removeClass('on'); $(this).find('.menu_bars').removeClass('on'); } else { $('header nav').addClass('on'); $(this).find('.menu_bars').addClass('on'); } }); }); function header_menu(i) { $('header nav.pc>a').eq(i).addClass('current'); } function animated_contents() { if ($.exists('.animate-element')) { $(".animate-element:in-viewport").each(function (i) { var $this = $(this); if (!$this.hasClass('in-viewport')) setTimeout(function () { $this.addClass('in-viewport'); }, 100 * i); }); } } function bg_video_resize() { if ($.exists('.bg_video')) { $('.bg_video').each(function () { var $win_width = $(this).width(); var $win_height = $(this).height(); var $this = $(this).find('video'); var bili = 1; if ($win_height < ($win_width / bili)) { $this.css('width', $win_width); $this.css('height', parseInt($win_width / bili)); $this.css('left', 0); $this.css('top', -parseInt((($win_width / bili) - $win_height) / 2)); } else { $this.css('height', $win_height); $this.css('width', parseInt($win_height * bili)); $this.css('left', -parseInt(($win_height * bili - $win_width) / 2)); $this.css('top', 0); } }); } } function full_height_responsive() { if ($.exists('.full-height-true')) { $('.full-height-true').each(function () { var $this = $(this), $header_hieght = $('header').height(), $withoutheader = $(this).attr('data-withoutheader'); if ($withoutheader=='true') $this.height($(window).height() - $header_hieght); else $this.height($(window).height()); }); } } function container_aspectratio_responsive() { if ($.exists('.container_aspectratio')) { $('.container_aspectratio').each(function () { var $this = $(this), $winwidth = $(window).width(), $ratio_num = parseFloat($(this).attr('data-aspectratio')), $ratio_type = $(this).attr('data-aspecttype'), $ratio_element = $(this).attr('data-aspectelement'); switch ($ratio_type) { //change window.width, height auto case 'winwidth_height_auto': $this.height($winwidth / $ratio_num - 2); break; //change window.width, width auto case 'winwidth_width_auto': $this.width($winwidth / $ratio_num); break; //img in container ,change window.width, width auto case 'winwidth_incon_imgwidth_auto': $this.find('img').each(function () { var $conimgratio_num = parseFloat($(this).attr('data-aspectratio')); $(this).width($winwidth / $conimgratio_num); }); break; //element in container ,change window.width, height auto case 'winwidth_incon_elementheight_auto': $this.find($ratio_element).each(function () { $(this).height($winwidth / $ratio_num); }); break; //change $this.width, height auto case 'thiswidth_height_auto': $this.height($this.width() / $ratio_num); break; //element in container ,change this.width, element.height auto case 'thiswidth_incon_elementheight_auto': $this.find($ratio_element).each(function () { var $conimgratio_num = parseFloat($(this).attr('data-aspectratio')); var $thiswidth = $(this).width(); $(this).height($thiswidth / $conimgratio_num); }); break; default: $this.height($winwidth / $ratio_num - 2); } }); } } function marquee_H(scc) { var speed = 10; if (m_w()) speed = 25; var tab = document.getElementById(scc); var tab1 = $('#' + scc + ' .marquee1')[0]; var tab2 = $('#' + scc + ' .marquee2')[0]; tab2.innerHTML = tab1.innerHTML; function Marquee() { if (tab2.offsetWidth - tab.scrollLeft <= 0) tab.scrollLeft -= tab1.offsetWidth else { tab.scrollLeft++; } } var MyMar = setInterval(Marquee, speed); tab.onmouseover = function () { clearInterval(MyMar) }; tab.onmouseout = function () { MyMar = setInterval(Marquee, speed) }; } function mk_fix_modern_header() { "use strict"; var mk_window_y = $(window).scrollTop(); //header_els = $('header,header .logo img'), //header_height = parseInt($('header').attr('data-height')), //header_height_sticky = parseInt($('header').attr('data-sticky-height')), //new_height = 0; if (!m_w()) { if (mk_window_y > 0) { if (!($("header").hasClass("mk-fixed"))) { //$(".mk-header-padding-wrapper").css("padding-top", header_height + 'px'); $("header").addClass("mk-fixed").css({ "top": 0 }); //$('.sub_nav').css({ 'top': 51 }); } } else { if (($("header").hasClass("mk-fixed"))) { //$(".mk-header-toolbar").show(); $("header").css({ "top": 0 }).removeClass("mk-fixed"); //$(".mk-header-padding-wrapper").css("padding-top", ""); //$('.sub_nav').css({ 'top': 70 }); } } //if (mk_window_y < (header_height - header_height_sticky)) { new_height = header_height - mk_window_y; } else { new_height = header_height_sticky; } //header_els.css({ height: new_height + 'px', lineHeight: (new_height - 6) + 'px' }); //$("header .main-navigation-ul > li > a,header .main-navigation-ul .menu-item span").css({ height: new_height - 3 + 'px', lineHeight: (new_height - 1) + 'px' }); } else { if (mk_window_y > 0) { $("header").addClass("mk-fixed").css({ "top": 0 }); } else { $("header").removeClass("mk-fixed"); } } } function IL_pop_init(id,swipertonum){ $(id).removeClass('off'); $(id).addClass('on'); $(id).find('.timerun .icon-timerun1').addClass('on'); if(!$.exists(id+' .swiper-container')){ $(id).find('.icons .btn_close').click(function(){ $(id).removeClass('on'); $(id).addClass('off'); }); } new Swiper(id+' .swiper-container', { effect: 'fade', autoplay:{delay: 10000,disableOnInteraction: false},loop:true, navigation: { nextEl: id+' .icons .btn_right', prevEl: id+' .icons .btn_left', }, on: { init: function () { var $curr_pop = $(this.el).parent().parent(); var $this_swel = this; $this_swel.slideTo(swipertonum); $curr_pop.find('.icons .btn_close').click(function(){ $(id).removeClass('on'); $(id).addClass('off'); $(id).find('.timerun .icon-timerun1').removeClass('on'); //console.log($this_swel); $this_swel.destroy(false,true); //photoswiper=null; }); }, transitionStart: function () { var $curr_pop=$(this.el).parent().parent(); $curr_pop.find('.timerun .icon-timerun1').removeClass('on'); setTimeout(function() { $curr_pop.find('.timerun .icon-timerun1').addClass('on'); },500); $curr_pop.find('.photo_curnum').text((this.realIndex + 1) + ' / ' + (this.slides.length - 2)); if($curr_pop.find('.txtcon section').length!=1){ $curr_pop.find('.txtcon section').removeClass('on'); $curr_pop.find('.txtcon section').eq(this.realIndex).addClass('on'); } //console.log('swiper.activeIndex:' + this.realIndex); //console.log($(this.el).parent().parent().find('.txtcon section')); }, transitionEnd: function () { //console.log('swiper.activeIndex:' + this.realIndex); } } }); }