if( !window.console ){
window.console = {
log: function(){}
}
}
/*
* jsui
* ====================================================
*/
jsui.bd = $('body')
jsui.is_signin = jsui.bd.hasClass('logged-in') ? true : false;
jsui.roll = [3, 4, 5]
if( $('.widget-nav').length ){
$('.widget-nav li').each(function(e){
$(this).hover(function(){
$(this).addClass('active').siblings().removeClass('active')
$('.widget-navcontent .item:eq('+e+')').addClass('active').siblings().removeClass('active')
})
})
}
/*
* rollbar
* ====================================================
*/
jsui.rb_comment = ''
if (jsui.bd.hasClass('comment-open')) {
jsui.rb_comment = "
去评论
"
}
jsui.bd.append('\
\
'
+jsui.rb_comment+
'去顶部
\
\
')
var scroller = $('.rollbar')
$(window).scroll(function() {
document.documentElement.scrollTop + document.body.scrollTop > 200 ? scroller.fadeIn() : scroller.fadeOut();
})
/*
* bootstrap
* ====================================================
*/
require.config({
paths : {
bootstrap : '/static/bitcoin86/js/libs/bootstrap.min'
}
});
require(['bootstrap'], function(bootstrap) {
$('.user-welcome').tooltip({
container: 'body',
placement: 'bottom'
})
})
/*
* search
* ====================================================
*/
$('.search-show').bind('click', function(){
var sbox = $('.site-search')
$(this).parent().toggleClass('active')
$(this).find('.fa').toggleClass('fa-remove')
sbox.toggleClass('active')
if( sbox.hasClass('active') ){
sbox.find('input').focus()
}
})
/*
* single
* ====================================================
*/
if (jsui.bd.hasClass('single')) {
require(['bootstrap'], function(bootstrap) {
var _sidebar = $('.sidebar')
if (_sidebar) {
var h1 = 15,
h2 = 30
var rollFirst = _sidebar.find('.widget:eq(' + (jsui.roll[0] - 1) + ')')
var sheight = rollFirst.height()
rollFirst.on('affix-top.bs.affix', function() {
rollFirst.css({
top: 0
})
sheight = rollFirst.height()
for (var i = 1; i < jsui.roll.length; i++) {
var item = jsui.roll[i] - 1
var current = _sidebar.find('.widget:eq(' + item + ')')
current.removeClass('affix').css({
top: 0
})
};
})
rollFirst.on('affix.bs.affix', function() {
rollFirst.css({
top: h1
})
for (var i = 1; i < jsui.roll.length; i++) {
var item = jsui.roll[i] - 1
var current = _sidebar.find('.widget:eq(' + item + ')')
current.addClass('affix').css({
top: sheight + h2
})
sheight += current.height() + 15
};
})
rollFirst.affix({
offset: {
top: _sidebar.height(),
bottom: $('.footer').outerHeight()
}
})
}
})
}
$('.plinks a').each(function(){
var imgSrc = $(this).attr('href')+'/favicon.ico'
$(this).prepend( '' )
})
/*
* page nav
* ====================================================
*/
if( jsui.bd.hasClass('page-template-pagesnav-php') ){
$('#navs .items a').attr('target', '_blank')
require(['bootstrap'], function(bootstrap) {
$('#navs nav ul').affix({
offset: {
top: $('#navs nav ul').offset().top,
bottom: $('.footer').height() + $('.footer').css('padding-top').split('px')[0]*2
}
})
})
if( location.hash ){
var index = location.hash.split('#')[1]
$('#navs nav .item-'+index).addClass('active')
scrollTo( '#navs .items .item-'+index )
}
$('#navs nav a').each(function(e){
$(this).click(function(){
scrollTo( '#navs .items .item-'+$(this).parent().index() )
$(this).parent().addClass('active').siblings().removeClass('active')
})
})
}
/*
* page search
* ====================================================
*/
if( jsui.bd.hasClass('search-results') ){
var val = $('.searchform .search-input').val()
var reg = eval('/'+val+'/i')
$('.excerpt h2 a, .excerpt .note').each(function(){
$(this).html( $(this).text().replace(reg, function(w){ return ''+w+'' }) )
})
}
/*
* phone
* ====================================================
*/
$('.m-icon-nav').on('click', function(){
jsui.bd.toggleClass('m-nav-show')
})
$('.m-mask').on('click', function(){
jsui.bd.removeClass('m-nav-show')
})
/* functions
* ====================================================
*/
function scrollTo(name, add, speed) {
if (!speed) speed = 300
if (!name) {
$('html,body').animate({
scrollTop: 0
}, speed)
} else {
if ($(name).length > 0) {
$('html,body').animate({
scrollTop: $(name).offset().top + (add || 0)
}, speed)
}
}
}
if (-1 == location.href.indexOf('bitcoin86.com')) {
// alert('请访问官方站点bitcoin86.com');
// location.href = 'http://bitcoin86.com';
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i 0 && username !== '' && group_name) {
html+= '您好 '+decodeURI(username)+',';
html+= '级别:'+decodeURI(group_name)+'|';
html+= '会员中心|';
html+= '退出登录|';
html+= '文章发布';
$('#bLogin').html(html);
} else {
html+= '立即注册|';
html+= '登录|';
html+= '文章发布';
$('#bLogin').html(html);
}