var isMobile = false,
mobile = false,
scrollSpend = false,
scrollName,
win_width = 0,
win_height = 0,
navItem = 0,
atH = 80,
$menuBtn = $('.menu-handler'),
$menuClose = $('.menubarM-close'),
menuM = $(".menubarM");
var pageInit = {
init: function () {
pageInit.getCommon();
nav.init();
menu.init();
pageNav.init();
pageInit.linkSelect();
if(!isMobile){
$('.item-span').each(function(i) {
pageInit.setSplitshun($(this));
pageInit.setTimeDelayshun($(this), 80, 250, false);
});
}
$('.item-roud').each(function(i) {
pageInit.setSplit($(this));
pageInit.setround($(this));
});
$(window).on('load', function () {
var hash = location.href.split("#")[1];
if (hash) {
pageInit.setScroll("#" + hash,0,'');
}
});
},
getSroll: function () {
function init() {
new SmoothScroll(document, 80, 20)
}
function SmoothScroll(target, speed, smooth) {
if (target === document)
target = (document.scrollingElement
|| document.documentElement
|| document.body.parentNode
|| document.body) // cross browser support for document scrolling
var moving = false
var pos = target.scrollTop
var frame = target === document.body
&& document.documentElement
? document.documentElement
: target // safari is the new IE
target.addEventListener('mousewheel', scrolled, { passive: false })
target.addEventListener('DOMMouseScroll', scrolled, { passive: false })
function scrolled(e) {
if (!$('body').is('.show')) {
if (!$('.noscroll').length > 0) {
e.preventDefault(); // disable default scrolling
var delta = normalizeWheelDelta(e)
pos += -delta * speed
if (scrollSpend){
pos=$(scrollName).offset().top;
scrollSpend=false;
}
pos = Math.max(0, Math.min(pos, target.scrollHeight - frame.clientHeight)) // limit scrolling
if (!moving) update()
}
}
}
//top btn
$('.scroll-top').bind('click', function (e) {
e.preventDefault();
pos = 0;
$('html, body').animate({ scrollTop: '0' }, 1200, 'easeInOutExpo');
update();
return false;
});
function doNotReload() {
if (event.keyCode == 116) { target.scrollTop = 0; pos = 0; }
}
document.onkeydown = doNotReload;
function normalizeWheelDelta(e) {
if (e.detail) {
if (e.wheelDelta)
return e.wheelDelta / e.detail / 40 * (e.detail > 0 ? 1 : -1) // Opera
else
return -e.detail / 3 // Firefox
} else
return e.wheelDelta / 120 // IE,Safari,Chrome
}
function update() {
moving = true
var delta = (pos - target.scrollTop) / smooth
target.scrollTop += delta
if (Math.abs(delta) > 0.5)
requestFrame(update)
else
moving = false
}
var requestFrame = function () { // requestAnimationFrame cross browser
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (func) {
window.setTimeout(func, 1000 / 50);
}
);
}()
}
//init();
},
getCommon: function () {
function wh() {
win_width = ('innerWidth' in window) ? window.innerWidth : document.documentElement.clientWidth;
win_height = ('innerHeight' in window) ? window.innerHeight : document.documentElement.clientHeight;
if (win_width <= 1024) {
isMobile = true;
atH = 56;
} else if (win_width > 1024) {
isMobile = false;
atH = 80;
menu.close();
};
};
wh();
$(window).resize(function () {
wh();
});
},
setImgMax: function (img, imgW, imgH, tW, tH) {
var tWidth = tW || win_width;
var tHeight = tH || win_height;
var coe = imgH / imgW;
var coe2 = tHeight / tWidth;
if (coe < coe2) {
var imgWidth = tHeight / coe;
img.css({
height: tHeight,
width: imgWidth,
left: -(imgWidth - tWidth) / 2,
top: 0
});
} else {
var imgHeight = tWidth * coe;
img.css({
height: imgHeight,
width: tWidth,
left: 0,
top: -(imgHeight - tHeight) / 2
});
};
},
setScroll: function (anchorCur,speed,antype) {
if ($(anchorCur).length >= 1) {
$("html,body").animate({
scrollTop: $(anchorCur).offset().top - atH
}, speed,antype);
scrollSpend=true;
scrollName=anchorCur;
}
},
scollHeader: function () {
function c() {
var s = $(window).scrollTop();
s > atH ? $(".top").addClass("ptop") : $(".top").removeClass("ptop");
}
$(window).scroll(c),
c();
},
setErmbox: function (obj, title) {
obj.click(function () {
var str = '
';
$("body").append(str);
$(".ermsblack").fadeIn();
$(".ermSBox").animate({
marginTop: "-132"
}, 400);
$(".ermSBox .close").click(function () {
$(".ermsblack").remove();
});
$(".ermsblack").click(function () {
$(".ermsblack").remove();
});
return false;
})
},
splitWords: function (el) {
var _test = el.html().split('
');
el.html('');
for (var i = 0; i < _test.length; i++) {
el.append('
');
_test[i] = _test[i].split('');
var _span = el.find('span');
for (var j = 0; j < _test[i].length; j++) {
_span.eq(i).append('');
var _i = _span.eq(i).find('i');
if (_test[i][j] === ' ') {
_test[i][j] = ' '
}
_i.eq(j).html(_test[i][j])
}
}
},
setWordsDelay: function (el, time, delay, reverse) {
var _span = el.find('span');
_span.each(function (i) {
var _i = $(this).find('i');
var random = 1;
_i.each(function (j) {
if (reverse) {
j = _i.length - j - 1;
}
random = Math.random();
$(this).css({
'animation-delay': delay + time * random + 'ms',
'-webkit-animation-delay': delay + time * random + 'ms'
})
})
})
},
setSplit: function (el) {
var n = el;
for (var e = 0, t = n.length; e < t; e++) {
var a = n[e],
r = a.textContent.trim();
a.innerHTML = "";
i(a, r)
}
function i(n, e) {
for (var t in e) {
var a = document.createElement("span");
a.innerHTML = e[t] === " " ? " " : e[t];
n.appendChild(a);
}
}
},
setTimeDelay: function (el, time, delay, reverse) {
var _span = el;
_span.each(function (i) {
var _i = $(this).find('span');
var random = 1;
_i.each(function (j) {
if (reverse) {
j = _i.length - j - 1;
}
random = Math.random();
$(this).css({
'animation-delay': delay + time * random + 'ms',
'-webkit-animation-delay': delay + time * random + 'ms'
})
})
})
},
setround: function (el) {
var _span = el;
_span.each(function (i) {
var _i = $(this).find('span');
var arr=$(this).attr("data-num").split(',');
for(var i in arr){
_i.eq(arr[i]-1).addClass("gree");
}
})
},
setround2: function (el) {
var _span = el;
_span.each(function (i) {
var _i = $(this).find('span');
var k1 = Math.round(Math.random() * 5);
var k2 = Math.round(Math.random() * 10);
_i.eq(k1).addClass("cor");
_i.eq(k2).addClass("cor");
})
},
setSplitshun: function(el) {
var n = el;
for (var e = 0, t = n.length; e < t; e++) {
var a = n[e],
r = a.textContent.trim();
a.innerHTML = "";
i(a, r)
}
function i(n, e) {
for (var t in e) {
var a = document.createElement("span");
a.innerHTML = e[t] === " " ? " " : e[t];
n.appendChild(a);
}
}
},
setTimeDelayshun: function(el, time, delay, reverse) {
var _span = el;
_span.each(function(i) {
var _i = $(this).find('span');
_i.each(function(j) {
if (reverse) {
j = _i.length - j - 1;
}
$(this).css({
'animation-delay': delay + time * j + 'ms',
'-webkit-animation-delay': delay + time * j + 'ms'
})
})
})
},
showbox: function (htmlAddress) {
$.ajax({
url: htmlAddress,
dataType: "html",
success: function (data) {
if (data == "" || data == null) {
return;
}
else {
if (jQuery(".md-modal").length >= 1) {
jQuery('html').removeClass('md-show');
jQuery('.md-modal').remove();
};
$("body").append('');
$('.md-modal .vertical-inner').append(data);
setTimeout(function () { $("html").addClass("md-show"); }, 50);
jQuery('.form-box-close').bind('click', function (e) {
jQuery('html').removeClass('md-show');
setTimeout(function () { jQuery('.md-modal').remove(); }, 400);
});
jQuery('.md-modal .vertical-inner').bind('click', function (e) {
if ($(e.target).hasClass('vertical-inner')) {
jQuery('html').removeClass('md-show');
setTimeout(function () { jQuery('.md-modal').remove(); }, 400);
}
});
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
jQuery('html').removeClass('md-show');
setTimeout(function () { jQuery('.md-modal').remove(); }, 400);
}
});
},
linkSelect: function () {
$('.link-select-box').click(function () {
if ($(this).hasClass('act')) {
$(this).removeClass('act');
$(this).find('.mc').stop().slideUp(300);
} else {
$(this).addClass('act');
$(this).find('.mc').stop().slideDown(300);
}
}).mouseleave(function () {
$(this).removeClass('act');
$(this).find('.mc').stop().slideUp(300);
});
},
videoShow: function () {
$(".video-sbtn").click(function () {
var videoName = $(this).data('url');
$(".videon").attr("src", videoName);
$(".pvideo-bg").addClass("overlay");
});
$(".pv-close").click(function () {
$(".pvideo-bg").removeClass("overlay");
$(".videon").attr("src", "");
});
$(".vwrap .close,.vwrap .videobtg").click(function () {
$(".vwrap").hide();
$('#videobox').html("");
});
},
pbannerH:function(){
if(jQuery('.pbanner').length>=1){
jQuery('.pbanner').addClass("act");
if (!isMobile) {
jQuery('.pbanner').css("height", jQuery(".pbanner .load-img").height());
} else {
jQuery('.pbanner').css("height", "auto");
}
}
}
},
nav = {
init: function () {
jQuery(".nav li").hover(function () {
if (jQuery(this).find(".subnav").length > 0) {
$(this).children("a").addClass("hov");
$(this).find(".subnav").stop(false, false).animate({ marginTop: "0", "opacity": "show" }, 350);
};
}, function () {
$(this).children("a").removeClass("hov");
$(this).children(".subnav").stop(false, false).fadeOut(250, function () { $(this).css("marginTop", "20px"); });
});
jQuery(".nav .subnav a").click(function (e) {
var $this = jQuery(this);
var hash = $this.attr("href").split("#")[1];
if (hash && jQuery("#" + hash).length >= 1) {
e.preventDefault();
//jQuery("html,body").animate({ scrollTop: jQuery("#" + hash).offset().top - atH }, 800, 'easeInOutExpo');
pageInit.setScroll("#" + hash,600,'easeInOutExpo');
if (isMobile) {
jQuery(this).parent().fadeOut();
}
}
});
}
},
menu = {
init: function () {
$menuBtn.click(function () {
if (navItem == 0) {
$(this).addClass("active");
$("html").addClass("menuOpen");
navItem = 1;
} else {
$(this).removeClass("active");
$("html").removeClass("menuOpen");
navItem = 0;
}
});
$(document).on("click", ".menubarM-list>li>a", function (e) {
var mnavcur = $(this);
var mnavbox = $(this).parents("li");
if (mnavbox.find(".subnav").length > 0) {
if (mnavbox.hasClass("cur")) {
mnavbox.find(".subnav").stop(false, false).slideUp();
mnavbox.removeClass("cur");
} else {
$(".menubarM-list li").removeClass("cur");
$(".subnav").stop(false, false).slideUp();
mnavbox.find(".subnav").stop(false, false).slideDown();
mnavbox.addClass("cur");
e.preventDefault();
}
}
});
$(document).on("click", ".menubarM-list a,.page-nav-btn a", function (e) {
var $this = $(this);
var hash = $this.attr("href").split("#")[1];
if (hash && $("#" + hash).length >= 1) {
e.preventDefault();
// $("html,body").animate({
// scrollTop: $("#" + hash).offset().top - atH
// }, 600);
pageInit.setScroll("#" + hash,600,'');
menu.close();
}
});
$(".pusher-black,.menubarM-close").click(function () {
if (navItem == 1) {
menu.close();
};
});
},
close: function () {
$menuBtn.removeClass("active");
$("html").removeClass("menuOpen");
navItem = 0;
}
},
pbanner = {
init: function () {
if ($(".load-img").length >= 1) {
_PreLoadImg([
$(".load-img").attr("src")
], function () {
pageInit.pbannerH();
});
$(window).resize(function () {
pageInit.pbannerH();
});
}
}
},
pageNav = {
init: function () {
$(".page-nav-btn a").click(function (e) {
var $this = $(this);
var hash = $this.attr("href").split("#")[1];
if (hash && $("#" + hash).length >= 1) {
e.preventDefault();
// $("html,body").animate({
// scrollTop: $("#" + hash).offset().top - atH
// }, 800, 'easeInOutExpo');
pageInit.setScroll("#" + hash,800,'easeInOutExpo');
}
});
var $sec_nav = $('.page-nav-box');
if ($sec_nav.length) {
var $sec_n = $sec_nav.find('.page-nav-btn'),
$current_item = $sec_nav.find('.active').parent();
if (isMobile && $current_item.length >= 1) {
$sec_n.stop().animate({
scrollLeft: $current_item.position().left
});
}
$(window).resize(function () {
if (isMobile && $current_item.length >= 1) {
$sec_n.stop().animate({
scrollLeft: $current_item.offset().left + $sec_n.scrollLeft()
});
}
});
}
}
};
pageInit.init();
pbanner.init();
function world_clock() {
function clock_action() {
var datat_number = $('.clock_ul li')
for (var index = 0; index < datat_number.length; index++) {
var _utc = datat_number.eq(index).data('clock'),
time = new Date(),
get_hour = time.getUTCHours(),
real_hour = get_hour + _utc,
minutes = time.getMinutes() * 6,
hours = real_hour * 30 + minutes * 0.05,
seconds = time.getSeconds() * 6
datat_number
.eq(index)
.children()
.find('.hours')
.css('transform', 'rotate(' + hours + 'deg)')
datat_number
.eq(index)
.children()
.find('.seconds')
.css('transform', 'rotate(' + seconds + 'deg)')
datat_number
.eq(index)
.children()
.find('.minutes')
.css('transform', 'rotate(' + minutes + 'deg)')
}
}
function refresh() {
clock_action()
setTimeout(refresh, 1000)
}
refresh()
}
document.oncontextmenu = function (){
event.preventDefault();
}