"use strict"; var indexSlider; $(document).ready(function() { // alert($(window).width() + ',' + $(window).height()); $('[bg]').each(function() { $(this).addClass('coverbg'); $(this).css('background-image', 'url('+$(this).attr('bg')+')'); }); if(window.innerWidth>800){ //global.stock(); } $('.menuToggler').click(function() { if($('.menu .menulist').is(':visible')) { $(this).removeClass('active'); $('.menu .menulist').hide(); }else{ $(this).addClass('active'); $('.menu .menulist').show(); } }); global.header(); if($(window).width()<=800) { $('.header .menu .menulist li > a').click(function() { if($(this).siblings('.sub').length>0 && !$(this).siblings('.sub').hasClass('show')){ $('.header .menu .sub').removeClass('show'); $(this).siblings('.sub').addClass('show'); return false; }else{ $('.header .menu .sub').removeClass('show'); $(this).siblings('.sub').addClass('show'); } }) } // var hash = window.location.hash; if(hash.indexOf('#')>=0) { hash = hash.replace('#',''); $("html,body").animate({ scrollTop: $('.'+hash).offset().top }, 1000); } $('.header .menu .menulist li .sub dd a').click(function() { setTimeout(function(){ var hash = window.location.hash; if(hash.indexOf('#')>=0) { hash = hash.replace('#',''); $("html,body").animate({ scrollTop: $('.'+hash).offset().top }, 1000); } },100) }); $('.download .s1 .container .video .playbtn').click(function() { $('.download .s1 .container .video video').removeAttr('muted'); if(!$('.download .s1 .container .video').hasClass('active')) { $('.download .s1 .container .video').addClass('active'); var video = $('#video')[0]; video.currentTime = 0; video.muted = false; video.volume = 1; video.play(); }else{ $('.download .s1 .container .video').removeClass('active'); var video = $('#video')[0]; video.volume = 0; video.muted = true; video.pause(); } }); practice.init(); }); var index = { banner: function() { var that = this; setTimeout(function() { $('.index').addClass('loaded'); $('.loading').remove(); }, 10e3); $('.videoPop').css({height: $(window).height()}); if($(window).width()<=480&&$('#bannervideo').length>0) { var ts = $('#bannervideo').attr('data-ts'); $('#bannervideo').replaceWith(''); var tsPlayer = new JSMpeg.Player(ts, { canvas: $('#ts')[0], autoplay:true, loop: true, audio: false, progressive: true, disableWebAssembly: true, decodeFirstFrame: true, onEnded: function() { indexSlider.startAuto(); // console.log(1); } }) } $('.index .banner .slider li').css({ height: $(window).height() }); var sliderNums = $('.index .banner .slider li').length; sliderNums = sliderNums<10 ? '0' + sliderNums : sliderNums; indexSlider = $('.index .banner .slider').bxSlider({ controls: false, pager: true, auto: true, mode: 'fade', pause: 10e3, onSliderLoad: function() { $('.banner .counter').text('01 / ' + sliderNums); if($('#bannervideo').length>0) { $('#bannervideo')[0].play(); } if($(window).width()>800) { $('.header,.banner').addClass('darkfont'); } }, onSlideBefore: function ($slideElement, oldIndex, newIndex) { // if(newIndex==0&&$(window).width()>800) { // $('.header,.banner').addClass('darkfont'); // }else{ // $('.header,.banner').removeClass('darkfont'); // } if($slideElement.find('video').length>0) { indexSlider.stopAuto(); $('#bannervideo')[0].currentTime = 0; $('#bannervideo')[0].play(); }else if($slideElement.find('canvas').length>0) { indexSlider.stopAuto(); tsPlayer.play(); }else{ indexSlider.startAuto(); if(tsPlayer) { tsPlayer.stop(); } } var current = newIndex<10 ? '0' + (newIndex+1) : (newIndex+1); $('.banner .counter').text(current + ' / ' + sliderNums); } }); }, s2: function() { var itemNum = $('.index .s2 .item').length; var margin = 82; margin = $(window).width() <= 1440 ? 60 : margin; margin = $(window).width() <= 1280 ? 50 : margin; margin = $(window).width() <= 800 ? 0 : margin; var itemWidth = $('.index .s2 .item').width() + margin; var containerWidth = itemWidth * itemNum + 100; var maxOffset = containerWidth - $('.index .s2 .controls').width(); var current = 0; $('.index .s2 .container').css('width', containerWidth); $('.index .s2 .prev.btn').click(function() { current-=1; current = current<0? 0 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }) $('.index .s2 .next.btn').click(function() { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }) $('.index .s2 .item').mouseenter(function() { var index = $(this).index(); $('.index .s2 .nav li').eq(index).addClass('active').siblings().removeClass('active'); }); $('.index .s2 .item').mouseleave(function() { $('.index .s2 .nav li').removeClass('active'); }); if($(window).width()<=800) { $('.index .s2 .items .container').swipe({ swipeLeft: function(event, direction, distance, duration, fingerCount, fingerData) { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }, swipeRight: function(event, direction, distance, duration, fingerCount, fingerData) { current-=1; current = current<0? 0 : current; index.s2go(current, itemWidth, maxOffset,itemNum); }, // swipe:function(event, direction, distance, duration, fingerCount, fingerData) { // if(direction=='right') { // current-=1; // current = current<0? 0 : current; // index.s2go(current, itemWidth, maxOffset,itemNum); // } // if(direction=='left') { // current+=1; // current = current>itemNum-1? itemNum-1 : current; // index.s2go(current, itemWidth, maxOffset,itemNum); // } // }, excludedElements: "label, button, input, select, textarea, .noSwipe" }) } }, s2go: function(id, itemWidth, maxOffset, itemNum) { var ids = id+1 < 10 ? '0' + (id+1) : id+1; var nums = itemNum < 10 ? '0' + itemNum : itemNum; $('.index .s2 .controls p').text(ids+' / '+nums); $('.index .s2 .nav .current font').text(ids+' / '+nums); var offset = id * itemWidth; if($(window).width()>800) { $('.index .s2 .container').css({ 'transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-o-transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-webkit-transform': 'translateX('+-1*offset+'px) translateY(-50%)' }) }else{ $('.index .s2 .container').css({ 'transform': 'translateX('+-((1*offset)-20)+'px)', '-o-transform': 'translateX('+-((1*offset)-20)+'px)', '-webkit-transform': 'translateX('+-((1*offset)-20)+'px)' }) } }, s3: function() { var itemNum = $('.index .s3 .item').length; var itemWidth = $('.index .s3 .item').outerWidth(); var containerWidth = itemWidth * itemNum + 100; var maxOffset = containerWidth - $('.index .s3 .controls').width(); var current = 0; $('.index .s3 .container .item').css('width', itemWidth); $('.index .s3 .container').css('width', containerWidth); $('.index .s3 .prev.btn').click(function() { current-=1; current = current<0? 0 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }) $('.index .s3 .next.btn').click(function() { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }); if($(window).width()<=800) { $('.index .s3 .items .container').swipe({ swipeLeft: function(event, direction, distance, duration, fingerCount, fingerData) { current+=1; current = current>itemNum-1? itemNum-1 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }, swipeRight: function(event, direction, distance, duration, fingerCount, fingerData) { current-=1; current = current<0? 0 : current; index.s3go(current, itemWidth, maxOffset,itemNum); }, // swipe:function(event, direction, distance, duration, fingerCount, fingerData) { // if(direction=='right') { // current-=1; // current = current<0? 0 : current; // index.s3go(current, itemWidth, maxOffset,itemNum); // } // if(direction=='left') { // current+=1; // current = current>itemNum-1? itemNum-1 : current; // index.s3go(current, itemWidth, maxOffset,itemNum); // } // }, excludedElements: "label, button, input, select, textarea, .noSwipe" }) } }, s3go: function(id, itemWidth, maxOffset, itemNum) { var ids = id+1 < 10 ? '0' + (id+1) : id+1; var nums = itemNum < 10 ? '0' + itemNum : itemNum; $('.index .s3 .controls p').text(ids+' / '+nums); var offset = id * itemWidth; if($(window).width()>800) { $('.index .s3 .container').css({ 'transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-o-transform': 'translateX('+-1*offset+'px) translateY(-50%)', '-webkit-transform': 'translateX('+-1*offset+'px) translateY(-50%)' }); }else{ $('.index .s3 .container').css({ 'transform': 'translateX('+-(1*offset)+'px)', '-o-transform': 'translateX('+-(1*offset)+'px)', '-webkit-transform': 'translateX('+-(1*offset)+'px)' }); } } } var about = { init:function() { this.s4(); this.s6(); }, s4:function() { $('#charts').forslide({ step: 2, item: '.chart', callback: function() { $('#charts').bxSlider({ auto: true, pause: 10e3, speed: 1e3, controls: false }) } }) }, s6:function() { $('.s6 .tabs a').click(function() { var index = $(this).index(); $(this).addClass('active').siblings().removeClass(); $('.s6 .pages .page').removeClass('active').eq(index).addClass('active'); }) } } var brand = { init:function() { } } var invset = { init:function() { this.s2(); this.s3(); }, s3:function() { var that = this; var current = 0; var itemNum,timeout; $('.s3 .items').forslide({ tagName: 'div', tagClass: 'page', step: 2, callback: function() { $('.s3 .items .page').each(function(i) { $(this).html('