jQuery(function($){
//highlight
hljs.initHighlightingOnLoad();

//to-top
$(window).scroll(function(){
if ($(this).scrollTop() >= 30) {
if (!$(".to-top").hasClass("topbtnfadein"))
$(".to-top").removeClass("topbtnfadeout topbtnhide").addClass("topbtnfadein topbtnshow").removeClass("topbtnfadein");
//$(".to-top").stop().animate({bottom: 30, opacity: 100});
} else {
if (!$(".to-top").hasClass("topbtnfadeout"))
$(".to-top").removeClass("topbtnfadein topbtnshow").addClass("topbtnfadeout topbtnhide").removeClass("topbtnfadeout");
}
})

$(".to-top").click(function(){
$("body, html").stop().animate({scrollTop:0});
});

//poshytip
$('.widget a').poshytip({
className: 'tip-twitter',
showTimeout: 1,
alignTo: 'target',
alignX: 'center',
alignY: 'bottom',
offsetY: 5,
allowTipHover: false,
});

$('.face-img a').poshytip({
className: 'tip-twitter',
showTimeout: 1,
alignTo: 'target',
alignX: 'center',
alignY: 'bottom',
offsetY: 5,
allowTipHover: false,
});

//menu
var idxY = null;
idxY=-15;
$(".nav ul li").each(function(){
var navY = $(this).position().top;
if ($(this).hasClass("current-menu-item") || $(this).hasClass('current-category-ancestor') || $(this).hasClass("current-post-ancestor")) {
idxY = navY;
}
$("#nav-current").css({top: idxY+15});
$(this).mouseenter(function(){
$("#nav-current").stop().animate({top: navY+15}, 300);
});
});
$(".nav ul").mouseleave(function(){
$("#nav-current").stop().animate({top: idxY+15}, 500);
});

//Switch of screen width controller
$(".wider-switch").click(function(){
if ($(this).find('i').hasClass('fa-expand')) {
toWider();
} else {
toNarrow();
}
});

var listHideLeft = 110;
var showLeft = 320;
var weiboHideLeft = 60;
var toWider = function(){
listHideLeft = -150;
weiboHideLeft = -200;
showLeft = 60;
$(".left").css('left', '-260px').addClass('iswider');
$(".container").css('margin-left', '80px');
$('.list').css('left', listHideLeft);
$('.weibo-show').css('left', weiboHideLeft);
$(".wider-switch").find('i').removeClass('fa-expand').addClass('fa-compress');
setCookie('widerCookie',"true", 86400);
}
var toNarrow = function(){
listHideLeft = 110;
weiboHideLeft = 60;
showLeft = 320;
$(".wider-switch").find('i').removeClass('fa-compress').addClass('fa-expand');
$(".left").css('left', '0').removeClass('iswider');
$(".container").css('margin-left', '340px');
$('.list').css('left', listHideLeft);
$('.weibo-show').css('left', weiboHideLeft);
setCookie('widerCookie',"false", 86400);
}
if (getCookie('widerCookie')=='true') {
toWider();
} else {
toNarrow();
}

//side icon
$(".icon-category").click(function(){
if ($(this).hasClass("list-open")) {
$(this).removeClass('list-open').children('span').html('灞曞紑鍒嗙被鐩綍');
$(".list").stop().animate({left: listHideLeft}, 500);
}
else {
$(this).addClass('list-open').children('span').html('鍏抽棴鍒嗙被鐩綍');
if ($('.sns-weibo').hasClass('sns-weibo-open'))
{
$('.sns-weibo').click();
}
$(".list").stop().animate({left: showLeft}, 500);
}
});
$(".sns-weibo").click(function(){
if ($(this).hasClass("sns-weibo-open")) {
$(this).removeClass('sns-weibo-open').children('span').html('灞曞紑寰崥绐楀彛');
$(".weibo-show").stop().animate({left: weiboHideLeft}, 500);
}
else {
$(this).addClass('sns-weibo-open').children('span').html('鍏抽棴寰崥绐楀彛');
if ($('.icon-category').hasClass('list-open'))
{
$('.icon-category').click();
}
$(".weibo-show").stop().animate({left: showLeft}, 500);
}
});


document.addEventListener("touchstart", function(){}, true);

//Sidebox Close and Open
$(".sidebox > h2").click(function(){
if ($(this).parent().height()>50) {
$(this).parent().height(50);
} else {
$(this).parent().height('');
}
});

//#categories
$("#categories").find('select').change(function(){
window.location.href=$(this).val();
});

//loading
$('.loading').animate({'width':'95%'},9000);
$(window).load(function()
{
$('.circle-loading').fadeOut(300);
$('.loading').stop().animate({'width':'100%'},300,function()
{
$(this).fadeOut(300);
});
});

//list nicescroll
$(function(){
$(".list").niceScroll({
cursorcolor:"rgba(255,255,255,0.5)",
cursoropacitymax:1,
touchbehavior:false,
cursorwidth:"5px",
cursorborder:"0",
cursorborderradius:"5px",
horizrailenabled: false,
zindex: 3
});
});

//fix embed height
var embedHeight = null;
if ($(".mejs-mediaelement embed").length>0) {
$(".mejs-mediaelement embed").each(function(){
if (embedHeight==null)
{
$embedHeight = $(this).width()/16*9+50;
}
$(this).height($embedHeight);
});
}

});

//鍙栧緱cookie
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';'); //鎶奵ookie鍒嗗壊鎴愮粍
for (var i = 0; i < ca.length; i++) {
var c = ca[i]; //鍙栧緱瀛楃涓
while (c.charAt(0) == ' ') { //鍒ゆ柇涓涓嬪瓧绗︿覆鏈夋病鏈夊墠瀵肩┖鏍
c = c.substring(1, c.length); //鏈夌殑璇濓紝浠庣浜屼綅寮濮嬪彇
}
if (c.indexOf(nameEQ) == 0) { //濡傛灉鍚湁鎴戜滑瑕佺殑name
return unescape(c.substring(nameEQ.length, c.length)); //瑙g爜骞舵埅鍙栨垜浠鍊
}
}
return false;
}

//娓呴櫎cookie
function clearCookie(name) {
setCookie(name, "", -1);
}

//璁剧疆cookie
function setCookie(name, value, seconds) {
seconds = seconds || 0; //seconds鏈夊煎氨鐩存帴璧嬪硷紝娌℃湁涓0锛岃繖涓窡php涓嶄竴鏍枫
var expires = "";
if (seconds != 0) { //璁剧疆cookie鐢熷瓨鏃堕棿
var date = new Date();
date.setTime(date.getTime() + (seconds * 1000));
expires = "; expires=" + date.toGMTString();
}
document.cookie = name + "=" + escape(value) + expires + "; path=/"; //杞爜骞惰祴鍊
}


Back to home | File page

Subscribe | Register | Login | N