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
});
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.header = function() {
var $header = $('.header'),
$body = $('body');
function headerHeight() {
var winSTop = $(window).scrollTop();
if (winSTop > 0) {
$body.addClass('fixed-menu');
}else {
$body.removeClass('fixed-menu');
}
}
$(window).on('scroll', function() {
headerHeight();
}).trigger('scroll');
$('.js-goTop').on('click', function(){
$('html,body').stop().animate({
scrollTop : 0
}, 'slow');
});
$('.js-btnMenu').on('click', function(e){
e.preventDefault();
e.stopPropagation();
if ($body.hasClass('menu-open')) {
$body.removeClass('menu-open');
$(this).removeClass('icon-icon_btn_close');
}else {
$body.addClass('menu-open');
$(this).addClass('icon-icon_btn_close');
}
});
$('.js-closeMenu').on('click', function(){
$body.removeClass('menu-open');
});
$('.main_nav > ul > li').hover(function(){
if ($(window).width() < 1024) return;
$(this).children('a').addClass('active');
if ($(this).find('.dropdown-nav').length) {
$(this).find('.dropdown-nav').slideDown();
}
},function(){
if ($(window).width() < 1024) return;
$(this).children('a').removeClass('active');
if ($(this).find('.dropdown-nav').length) {
$(this).find('.dropdown-nav').hide();
}
});
$('.dropdown-nav__main ol li').hover(function(){
if ($(window).width() < 1024) return;
$(this).children('a').addClass('active').parent().siblings().children('a').removeClass('active');
}, function() {
if ($(window).width() < 1024) return;
$(this).children('a').removeClass('active');
});
$('.main_nav>ul>li>a').bind('click', function(e) {
if ($(window).width() > 1024 ) return;
if ($(this).parent().find('.dropdown-nav__main').length){
if (!$(this).parent().hasClass('on')){
e.preventDefault();
e.stopPropagation();
$(this).parent().addClass('on').siblings().removeClass('on');
$(this).parent().find('.dropdown-nav').slideDown();
$(this).parent().siblings().find('.dropdown-nav').hide();
}
}
});
$('.js-search__switch').bind('click', function(e) {
e.preventDefault();
e.stopPropagation();
if ( $(window).width() < 1800 && $(window).width() > 1025){
$('.js-lang--filter').hide();
}
// (this).closest('.main_nav').addClass('open');
$(this).parent().addClass('open').find('.layer_search__form').addClass('open');
});
$('.layer_search__form #keywords').bind('click',function(e) {
e.preventDefault();
e.stopPropagation();
});
$('.header .rw_lang').hover(function(){
if ($(window).width() < 1024) return;
$(this).addClass('on').find('.rw_lang__list').slideDown();
},function() {
$(this).removeClass('on').find('.rw_lang__list').slideUp();
});
$('.header .rw_lang').bind('click', function() {
if ($(window).width() > 1024) return;
$(this).toggleClass('on').find('.rw_lang__list'). slideToggle();
});
};
_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 = '![]('+replaceAPI(weixin)+')
分享到微信朋友圈
';
$('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.slidedown = function() {
$('.rw-category__nav').bind('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('.rw-tabs').find('.rw-tabs__wrap').slideToggle();
});
if ($('.about-page').length <= 0) return;
$('.rw-tabs__wrap li a').bind('click', function() {
$(this).closest('.rw-navbar__nav').find('.rw-category__nav').html($(this).text());
});
}
_app.scrollTo = function () {
if ($('#js-scroll__top').length <= 0) return;
$('#js-scroll-to').onePageNav({
currentClass: 'current',
changeHash: false,
scrollSpeed: 750,
scrollThreshold: 0.5,
filter: '',
easing: 'swing',
begin: function() {
//I get fired when the animation is starting
},
end: function() {
//I get fired when the animation is ending
},
scrollChange: function($currentListItem) {
//I get fired when you enter a section and I pass the list item of the section
$('.rw-category__nav').html($currentListItem.text());
}
});
$(window).bind('scroll',function(){
if ($(window).scrollTop() > $('#js-scroll__top').offset().top - 90) {
$('#js-navbar__nav').addClass('fixed');
$('.js-page .header').addClass('topid');
}else{
$('#js-navbar__nav').removeClass('fixed');
$('.js-page .header').removeClass('topid');
}
});
}
_app.nav = function() {
$('.subNav > li > a').on('click', function(e) {
var $link = $(e.currentTarget);
var newLoc = '#' + $link.attr('href').split('#')[1];
var target = $(newLoc);
if (target.length > 0){
scrollTo(target);
}
});
function scrollTo(target){
var offset = 0;
if ($(window).width() > 1024){
offset = target.offset().top - $('#js-scroll__top').height() + 2;
}else{
offset = target.offset().top - $('#js-scroll__top').height() - $('.header').height() + 2;
}
$('html, body').animate({
scrollTop: offset
}, 750, 'swing');
}
function init(){
var newLoc = '#' + window.location.href.split('#')[1];
var target = $(newLoc);
if (target.length > 0){
scrollTo(target);
}
};
init();
}
_app.layerZoom = function () {
var popoverWrap = $(''),
maskWrap = $(''),
contentWrap = $(''),
figureWrap = $('');
imgWrap = $('
');
closeWrap = $('');
$('.js-view__full').bind('click', function(){
var imgUrl = $(this).closest('.js-target__content').find('a').attr('data-img'),
titleWrap = $(this).closest('.js-target__content').find('h3').prop('outerHTML');
imgWrap.attr('src',imgUrl);
figureWrap.html('');
contentWrap.html('');
figureWrap.append(imgWrap,closeWrap);
contentWrap.append(figureWrap,titleWrap);
popoverWrap.append(maskWrap,contentWrap);
$('body').append(popoverWrap);
setTimeout(function() {
popoverWrap.fadeIn();
},200);
});
$(document).on('click', '.layer-zoom .layer-zoom__content .layer-zoom__close,.layer-zoom .layer-zoom__mask', function() {
$(this).closest('.layer-zoom').hide().remove();
});
}
_app.cancle = function () {
$(document).on('click', function() {
if ($(window).width() > 1024) {
$('.layer_search .layer_search__form').removeClass('open');
$('.js-lang--filter').show();
}else{
$('body').removeClass('menu-open');
$('.js-btnMenu').removeClass('icon-icon_btn_close');
$('.rw-tabs .rw-tabs__wrap').slideUp();
}
});
}
_app.video = function() {
$('.js-video--box .js-vid--btn').click(function(){
$(this).find('.js-vid--content').fadeIn(200);
var id = $(this).find('.js-vid--content video').attr('id');
document.getElementById(id).play();
$(this).closest('.js-video--box').siblings().each(function() {
var id = $(this).find('.js-vid--content video').attr('id');
document.getElementById(id).pause();
$(this).find('.js-vid--content').fadeOut(200);
});
});
$(document).on('click', '.js-vid--close', function(){
var id = $(this).parent().find('video').attr('id');
document.getElementById(id).pause();
$(this).parent().fadeOut(200);
});
}
_app.init = function() {
_app.checkBrowser();
_app.effect();
_app.header();
_app.slidedown();
_app.scrollTo();
_app.layerZoom();
_app.cancle();
_app.video();
_app.nav();
};
_app.init();