var _app = _app || {}; _app.effect = function () { $("img.lazy").lazyload({ effect: "fadeIn", threshold: 200, failure_limit: 10, skip_invisible: true, appear: null, load: null }); $("div.lazy").lazyload({ effect: "fadeIn", threshold: 200, failure_limit: 10, skip_invisible: true, appear: null, load: null }); $('.wow').each(function () { $(this).addClass('delay'); }); var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 0, mobile: true, live: true }); wow.init(); } _app.checkBrowser = function () { (function (w) { if (!("WebSocket" in w && 2 === w.WebSocket.CLOSING)) { var d = document.createElement("div"); d.className = "browsehappy"; d.innerHTML = '
\u4f60\u7684\u6d4f\u89c8\u5668\u5b9e\u5728\u592a\u592a\u65e7\u4e86\uff0c\u592a\u592a\u65e7\u4e86 \u7acb\u5373\u5347\u7ea7
'; var f = function () { var s = document.getElementsByTagName("body")[0]; if ("undefined" == typeof (s)) { setTimeout(f, 10) } else { s.insertBefore(d, s.firstChild) } }; f() } }(window)); } _app.index = function () { }; _app.share = function () { var SimpleShare = function (options) { // get share content options = options || {}; var url = options.url || window.location.href; var title = options.title || document.title; var content = options.content || ''; var pic = options.pic || ''; // fix content format url = encodeURIComponent(url); title = encodeURIComponent(title); content = encodeURIComponent(content); pic = encodeURIComponent(pic); // share target url var qzone = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}&title={title}&pics={pic}&summary={content}'; var weibo = 'http://service.weibo.com/share/share.php?url={url}&title={title}&pic={pic}&searchPic=false'; var tqq = 'http://share.v.t.qq.com/index.php?c=share&a=index&url={url}&title={title}&appkey=801cf76d3cfc44ada52ec13114e84a96'; var renren = 'http://widget.renren.com/dialog/share?resourceUrl={url}&srcUrl={url}&title={title}&description={content}'; var douban = 'http://www.douban.com/share/service?href={url}&name={title}&text={content}&image={pic}'; var facebook = 'https://www.facebook.com/sharer/sharer.php?u={url}&t={title}&pic={pic}'; var twitter = 'https://twitter.com/intent/tweet?text={title}&url={url}'; var linkedin = 'https://www.linkedin.com/shareArticle?title={title}&summary={content}&mini=true&url={url}&ro=true'; var weixin = 'http://qr.liantu.com/api.php?text={url}'; var qq = 'http://connect.qq.com/widget/shareqq/index.html?url={url}&desc={title}&pics={pic}'; var tumblr = 'https://www.tumblr.com/widgets/share/tool?posttype=link&canonicalUrl={url}&title={title}&content={content}'; var pinterest = 'https://www.pinterest.com/pin/create/button/?url={url}&media=" + encodeURIComponent(a))'; // replace content functions function replaceAPI (api) { api = api.replace('{url}', url); api = api.replace('{title}', title); api = api.replace('{content}', content); api = api.replace('{pic}', pic); return api; } // share target this.qzone = function () { window.open(replaceAPI(qzone)); }; this.weibo = function () { window.open(replaceAPI(weibo)); }; this.tqq = function () { window.open(replaceAPI(tqq)); }; this.renren = function () { window.open(replaceAPI(renren)); }; this.douban = function () { window.open(replaceAPI(douban)); }; this.facebook = function () { window.open(replaceAPI(facebook)); }; this.twitter = function () { window.open(replaceAPI(twitter)); }; this.linkedin = function () { window.open(replaceAPI(linkedin)); }; this.qq = function () { window.open(replaceAPI(qq)); }; this.tumblr = function () { window.open(replaceAPI(tumblr)); }; this.pinterest = function () { window.open(replaceAPI(pinterest)); }; this.weixin = function (callback) { if (!callback) { // window.open(replaceAPI(weixin)); var wxHtml = '

鍒嗕韩鍒板井淇℃湅鍙嬪湀

'; $('body').append(wxHtml); } else { callback(replaceAPI(weixin)); } }; }; var share = new SimpleShare({ url: '', title: '', content: '', pic: '' }); $('.social a').on('click', function () { var type = $(this).attr('data-share'); switch (type) { case 'twitter': share.twitter(); break; case 'facebook': share.facebook(); break; case 'linkedin': share.linkedin(); break; case "weixin": share.weixin(); break; case "weibo": share.weibo(); break; case 'tumblr': share.tumblr(); break; case 'pinterest': share.pinterest(); break; default: break; } }); $(document).on('click', '.js-wxClose', function () { $('.wx-share').remove(); }); }; _app.scrollTop = function () { $(document).on('click', '[data-scroll-top]', function () { $('html,body').animate({ scrollTop: 0 }, 600); }); $(window).bind('scroll', function () { if ($(window).height() < $(window).scrollTop()) { $('[data-scroll-top]').fadeIn(); } else { $('[data-scroll-top]').fadeOut(); } }).trigger('scroll'); } _app.header = function () { $('.navbar .nav>li>a').bind('click', function (e) { if ($(window).width() > 1024) return; if ($(this).parent().find('.dropdown').length > 0) { if ($(this).parent().attr('data-status') == 0) { e.preventDefault(); $(this).parent().addClass('on').attr('data-status', 1).find('.dropdown').slideDown(); $(this).parent().siblings().removeClass('on').attr('data-status', 0).find('.dropdown').slideUp(); } else { } } }); $('.navbar .nav>li').hover(function () { if ($(window).width() < 1024) return; if ($(this).find('.dropdown').length > 0) { $(this).find('.dropdown .dropdown-menu_wrapepr').stop().slideDown(); } }, function () { if ($(window).width() < 1024) return; /* $(this).removeClass('active'); $('.dropnav').removeClass('draopnav--active'); $('.dropnav .dropnav_wrapper').html();*/ if ($(this).find('.dropdown').length > 0) { $(this).find('.dropdown .dropdown-menu_wrapepr').hide(); } }); $('.dropnav .dropnav_wrapper').hover(function () { if ($(window).width() < 1024) return; $(this).parent().addClass('draopnav--active'); }, function () { if ($(window).width() < 1024) return; $(this).parent().removeClass('draopnav--active'); }); $(document).on('click', '[data-trigger_menu]', function () { if ($(this).attr('data-status') == 0) { $(this).addClass('button_close').attr('data-status', 1); $('.navbar').slideDown(); $('.btn_inquiry').addClass('opa'); } else { $('.navbar').slideUp(); $(this).removeClass('button_close').attr('data-status', 0); $('.btn_inquiry').removeClass('opa'); } }); $(document).on('click', '[data-trigger_tools]', function () { if ($(this).attr('data-status') == 0) { $(this).addClass('btn_close').attr('data-status', 1); $('.header .btn_tools,.header .btn_inquiry').addClass('active'); $('.formsearch').removeClass('active'); } else { $(this).removeClass('btn_close').attr('data-status', 0); $('.header .btn_tools,.header .btn_inquiry').removeClass('active'); $('.formsearch').removeClass('active'); } }); $(document).on('click', '[data-trigger_search]', function () { if ($(this).attr('data-status') == 0) { $(this).attr('data-status', 1); $('.formsearch').addClass('active'); } else { $(this).attr('data-status', 0); $('.formsearch').removeClass('active'); } }); $('.navbar .bgcover,.wrapper').bind('click', function () { if ($(window).width() < 1025) return; $('.formsearch').removeClass('active'); $('[data-trigger_search]').attr('data-status', 0); }); $('.navbar .bgcover').bind('click', function () { $('.formsearch').removeClass('active'); $('[data-trigger_search]').attr('data-status', 0); if ($(window).width() < 1024) { $('.navbar .nav>li').removeClass('on').attr('data-status', 0); $('.dropdown').hide(); } }); $(document).on('click', '[data-trigger_lang]', function (e) { e.preventDefault(); e.stopPropagation(); if ($(this).attr('data-status') == 0) { $('.language-box').slideDown(); $(this).attr('data-status', 1); } else { $('.language-box').slideUp(); $(this).attr('data-status', 0); } }); $(document).bind('click', function () { $('.language-box').slideUp(); $('[data-trigger_lang]').attr('data-status', 0); }); $('.container-full .cover').bind('click', function () { $(this).parent().slideUp(); $('[data-trigger_lang]').attr('data-status', 0); }); $('.product_dropdown-menu > ul > li').hover(function () { if ($(window).width() < 1024) return; var index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $(this).closest('.dropdown-menu_wrapepr').find('.level_wrapper > ul').eq(index).stop().fadeIn().siblings().hide(); $(this).closest('.dropdown-menu_wrapepr').find('.level_wrapper > ul').eq(index).find('li:first').addClass('active').siblings().removeClass('active'); var href = $(this).closest('.dropdown-menu_wrapepr').find('.level_wrapper > ul').eq(index).find('li:first').attr('data-img'); $(this).closest('.dropdown').find('.img-box img').attr('src', href); }); $('.level_wrapper ul > li').hover(function () { if ($(window).width() < 1024) return; $(this).addClass('active').siblings().removeClass('active'); var href = $(this).attr('data-img'); $(this).closest('.dropdown').find('.img-box img').attr('src', href); }); $('.solution_dropdown .dropdown-menu li').hover(function () { if ($(window).width() < 1024) return; $('.solution_dropdown .dropdown-menu li').removeClass('active'); }, function () { if ($(window).width() < 1024) return; $('.solution_dropdown .dropdown-menu ul:first > li:first').addClass('active'); }); $('.formsearch .form-control').bind('focus', function () { $(this).parent().addClass('on'); }).bind('blur', function () { if ($(this).val() == "") { $(this).parent().removeClass('on'); } }); $('.level_wrapper').each(function (index) { $(this).find('ul:first > li:first').addClass('active'); var img = $(this).find('ul:first > li:first').attr('data-img'); console.log(img); $(this).parent().find('.img-box > img').attr('src', img); }); } _app.support = function () { $(document).on('click', '[data-select-option]', function () { if ($(this).attr('data-status') == 0) { $(this).attr('data-status', 1).addClass('active').find('.answer').slideDown(); } else { $(this).attr('data-status', 0).removeClass('active').find('.answer').slideUp(); } }); } _app.formValidate = function () { var isScroll = false; $('.validate_form .form-control').bind('focus', function (e) { /*if ($(this).val() == ""){*/ $(this).parent().addClass('on'); if ($(this).parent().find('.select').length > 0) { $(this).parent().find('.select').slideDown(); if (!isScroll) { $(".scrollBar").mCustomScrollbar(); isScroll = true; } } /* }*/ }).bind('blur', function (e) { if ($(this).val() == "") { $(this).parent().removeClass('on'); } if ($(this).parent().find('.select').length > 0) { $(this).parent().find('.select').slideUp(); } }); $('.validate_form .icon-icon_arrow').bind('click', function () { /*$(this).parent().find('.form-control').trigger('focus');*/ e.preventDefault(); e.stopPropagation(); $(this).parent().find('.select').stop().slideToggle(); if (!isScroll) { $(".scrollBar").mCustomScrollbar(); isScroll = true; } }); /*$(document).on('click', '[data-option_selected]', function() { $(this).closest('.form-group').find('.select').stop().slideToggle(); });*/ $('.select ul > li').bind('click', function () { $(this).closest('.form-group').find('[data-option_selected]').addClass('active').val($(this).text()); $(this).closest('.select').slideUp(); }); } _app.works = function () { var isScroll = false; $('.select-wrapper').hover(function () { if ($(window).width() < 1024) return; $(this).addClass('active').find('.select-list').stop().slideDown(); if (!isScroll) { if ($(this).hasClass('region_select')) { $(".scrollBar").mCustomScrollbar(); isScroll = true; } } }, function () { if ($(window).width() < 1024) return; $(this).removeClass('active').find('.select-list').slideUp(); }); $('.select-wrapper').bind('click', function () { if ($(window).width() > 1024) return; if ($(this).attr('data-status') == 0) { $(this).attr('data-status', 1).addClass('active').find('.select-list').stop().slideDown(); $(this).siblings().attr('data-status', 0).removeClass('active').find('.select-list').slideUp(); if (!isScroll) { if ($(this).hasClass('region_select')) { $(".scrollBar").mCustomScrollbar(); isScroll = true; } } } else { $(this).attr('data-status', 0).removeClass('active').find('.select-list').hide(); } }); /*$(document).bind('click',function(){ if ($(window).width() > 1024) return; $('.select-list').hide(); $('.select-wrapper').removeClass('active'); });*/ $(document).on('click', '.select-list ul > li', function (e) { e.stopPropagation(); e.preventDefault(); $(this).closest('.select-wrapper').find('.select-button').val($(this).html()); $(this).addClass('selected').siblings().removeClass('selected'); $(this).closest('.select-wrapper').find('.select-hidden').val($(this).attr('data-value')); if ($(window).width() < 1025) { $(this).closest('.select-list').hide(); $(this).closest('.select-wrapper').removeClass('active'); } $('#filterForm').submit(); }); } _app.playVideo = function () { $(document).on('click', '[data-play-video]', function () { $(this).parent().find('.videopopup').fadeIn(); video($(this).parent().find('video').attr('id')); }); $(document).on('click', '[data-pause-video]', function () { $(this).parent().fadeOut(); video($(this).parent().find('video').attr('id')); }); function video (id) { var video = document.getElementById(id); if (video.paused) { video.play(); } else { video.pause(); } } } _app.fixedBox = function () { if ($('#fixed-top').length <= 0) return; $(window).on('scroll', function(){ if ($(this).width() < 1024) { var offsetTop = $('#fixed-top').offset().top - 50; if ($(window).scrollTop() > offsetTop){ $('#fixed-navigator').addClass('fixed'); $('.nav-tabs__placeholder').addClass('fix'); }else{ $('#fixed-navigator').removeClass('fixed'); $('.nav-tabs__placeholder').removeClass('fix'); } }else{ $('#fixed-navigator').removeClass('fixed'); $('.nav-tabs__placeholder').removeClass('fix'); } }).trigger('scroll'); } _app.init = function () { _app.share(); _app.checkBrowser(); _app.effect(); _app.scrollTop(); _app.header(); _app.support(); _app.formValidate(); _app.playVideo(); _app.fixedBox(); }; _app.init();