/* Js for https://www.zentao.net/, Version=1663205746 */
 v.lang = {"confirmDelete":"\u60a8\u786e\u5b9a\u8981\u6267\u884c\u5220\u9664\u64cd\u4f5c\u5417\uff1f","deleteing":"\u5220\u9664\u4e2d","doing":"\u5904\u7406\u4e2d","loading":"\u52a0\u8f7d\u4e2d","updating":"\u66f4\u65b0\u4e2d...","timeout":"\u7f51\u7edc\u8d85\u65f6,\u8bf7\u91cd\u8bd5","errorThrown":"\u6267\u884c\u51fa\u9519\uff1a","continueShopping":"\u7ee7\u7eed\u8d2d\u7269","required":"\u5fc5\u586b","back":"\u8fd4\u56de","continue":"\u7ee7\u7eed","bindWechatTip":"\u53d1\u5e16\u529f\u80fd\u8bbe\u7f6e\u4e86\u7ed1\u5b9a\u5fae\u4fe1\u7684\u9650\u5236\uff0c\u8bf7\u5148\u7ed1\u5b9a\u5fae\u4fe1\u4f1a\u5458\u3002","importTip":"\u53ea\u5bfc\u5165\u4e3b\u9898\u7684\u98ce\u683c\u548c\u6837\u5f0f","fullImportTip":"\u5c06\u4f1a\u5bfc\u5165\u6d4b\u8bd5\u6570\u636e\u4ee5\u53ca\u66ff\u6362\u7ad9\u70b9\u6587\u7ae0\u3001\u4ea7\u54c1\u7b49\u6570\u636e"};;
  $(function(){
    $("#siteNav a[href*='register']").remove();
    $("#siteNav a[href*='login']").text('登录/注册');
    $("#siteNav a[href*='login']").click(function(elem)
    {
      if(window.qrCodeTimer) window.clearInterval(window.qrCodeTimer);
      const id = 'loginModal';
      showModalLogin(id, elem.target, 13, 0, 1);
      $('body').css('padding-right', 'unset');
      return false;
    });

  });
;// var html = '<ol class="carousel-indicators">'+
//     '<li data-slide-to="0" class="active"></li>'+
//     '<li data-slide-to="1"></li>'+
//     '<li data-slide-to="2"></li>'+
//     '<li data-slide-to="3"></li>'+
//     '<li data-slide-to="4"></li>'
// '</ol>';
// $('#block5 .slide').append(html);;// $(document).ready(function(){
//     $('#block1380').insertBefore('.news1');
//     $('.items .item').wrap('<div class="col-md-4"></div>');
// });;

var currentBlockID = 1380;


if(typeof($('#block' + currentBlockID).parent('.col').data('grid')) === 'undefined' && $('#block' + currentBlockID).parent('.col').data('probability') === 'undefined')
{
    var grid = $('#block' + currentBlockID).parents('.blocks').data('grid');
    grid = typeof(grid) == 'undefined' ? 12 : grid;

    $('#block' + currentBlockID).parent('.col').attr('data-grid', grid).attr('class', 'col col-' + grid);
}

$('.articleTitleA').each(function()
{
    $(this).css('max-width', $(this).parents('li').width() - $(this).prev('.category').width() - $(this).next('.sticky').width() - $(this).parent().next('.article-date').width() - 10);
})
$('.articleTitleB').each(function()
{
    $(this).css('max-width', $(this).parent('li').width() - $(this).next('.sticky').width() - 10);
})
;

var currentBlockID = 128;


if(typeof($('#block' + currentBlockID).parent('.col').data('grid')) === 'undefined' && $('#block' + currentBlockID).parent('.col').data('probability') === 'undefined')
{
    var grid = $('#block' + currentBlockID).parents('.blocks').data('grid');
    grid = typeof(grid) == 'undefined' ? 12 : grid;

    $('#block' + currentBlockID).parent('.col').attr('data-grid', grid).attr('class', 'col col-' + grid);
}

$('.articleTitleA').each(function()
{
    $(this).css('max-width', $(this).parents('li').width() - $(this).prev('.category').width() - $(this).next('.sticky').width() - $(this).parent().next('.article-date').width() - 10);
})
$('.articleTitleB').each(function()
{
    $(this).css('max-width', $(this).parent('li').width() - $(this).next('.sticky').width() - 10);
})
;$(document).ready(function()
{          
    // add "index" class to the body element.
    $('body').addClass('index');

    $('.nav-system-home:first').addClass('active');
    $('#navbar li.active').parents('li').addClass('active');
})
$('#words').attr('placeholder','全站搜索');
$('#foot').insertBefore('#footer');

$(document).ready(function(){
    if(typeof headerList != 'undefined') return ;
    headerList = true;
    $('#footer #icpInfo').after('<a class="privacy" href="/page/zentao-privacypolicy.html">隐私政策</a>');
    $('#footer #powerby').append('<a class="ipip" href="https://www.ipip.net/" target="_blank">本站IP数据由IPIP.NET提供</a>');
    $('#siteNav').append('<a class="language" href="http://www.zentao.pm/" target="_blank"><i class="icon icon-globe"></i>English</a>');
    $('.m-user-register .form-horizontal .agreement-form span').after('<span>和《<a href="/page/zentao-privacypolicy.html" target="_blank">隐私政策</a>》</span>');
});

$('.m-faq #top #toggleToc').text('隐藏目录').addClass('hide');
var isAdvanced = false;
$('.m-faq #top #toggleToc').on('click', function() {
   isAdvanced = !isAdvanced;
   if (isAdvanced) {
       $(this).text('显示目录').addClass('show').removeClass('hide');
   } else {
       $(this).text('隐藏目录').addClass('hide').removeClass('show');
   }
});

var windowScrollHeight = window.innerHeight;
var minScrollHeight = windowScrollHeight - $('#header').height() - $('#footer').height() - 54;
if($('.page-wrapper').height() < minScrollHeight) {
    $('.page-wrapper').css('minHeight', minScrollHeight)
}

$(window).scroll(function(){
    // if($(window).scrollTop()>230){
    //     $(".m-faq #top #toggleToc").addClass('fixed');
    // }else{
    //     $(".m-faq #top #toggleToc").removeClass('fixed');
    // }
    if ($(window).scrollTop()) {
        $('#header').addClass('header-fixed');
        $('.m-blog #blogNav').addClass('nav-fixed');
    } else {
        $('#header').removeClass('header-fixed');
        $('.m-blog #blogNav').removeClass('nav-fixed');
    }
});

$('.m-faq table:last-child').before('<hr>');
// 首页点击空白处登录弹框隐藏
$(document).click(function(e) {
    if($(this).children('html').hasClass('m-user-login')) {
        return
    } else {
        $('#loginModal').hide();
        if(window.qrCodeTimer) clearInterval(window.qrCodeTimer);
    }
})
$(document).on('click', '#loginModal, #privacyagreement, #agreement', function(e) {
    e.stopPropagation();
})
function showModalLogin(id, elem,  moreTop, moreLeft, showHeader, style, callback)
{
    var isVisible = document.getElementById(id) && document.getElementById(id).offsetParent;
    if(isVisible) return false;
    if(!style) {
        style = {}
    }
    var calcTopLeft = function (elem,  moreTop, moreLeft) {
        var bound = elem.getBoundingClientRect();
        var realLeft = bound.left + moreLeft;
        var realTop = bound.top + bound.height + moreTop;
        realLeft = realLeft + 410 > document.body.offsetWidth ? document.body.offsetWidth - 410 : realLeft;
        return {top: realTop, left: realLeft};
    }
    var position = calcTopLeft(elem, moreTop, moreLeft);
    var resetModalPos = function () {
        $('#' + id).css({
            'top' : position.top,
            'left': position.left,
        });
        $('#' + id).css(style);
    };
    var modalLoginOptions =
    {
        url      : "/user-loginmodal.html",
        width    : '410',
        height   : '440',
        backdrop : false,
        name     : id,
        position : 0,
        keyboard: false,
        loaded   : function() {
            $('#' + id).css({
                'position'  : 'fixed',
                'top'       : position.top,
                'left'      : position.left,
            });
            $('#' + id).css(style);
            $('#' + id + ' .modal-dialog').css({
                'margin': '0',
            });
            $('#' + id).addClass('modalLogin');
            if(showHeader == 0) $('#' + id + ' .close').hide();
            window.addEventListener('resize', resetModalPos);
            callback && callback();
        },
        onHide: function(){
            if(window.smsTimer) clearInterval(window.smsTimer);
            if(window.qrCodeTimer) clearInterval(window.qrCodeTimer);
            window.removeEventListener('resize', resetModalPos);
        }
    };
    var myModalTrigger = new $.zui.ModalTrigger(modalLoginOptions);
    myModalTrigger.show();
}$(".see-wrap .see").mouseover(function(){
    $(".see-wrap .seex").removeClass("curr");
});
$(".see-wrap .see").mouseout(function(){
    $(".see-wrap .seex").addClass("curr");
});
;
$(document).ready(function()
{
    $('a[data-download=1]').each(function()
    {   
        link = window.btoa(window.encodeURIComponent($(this).attr('href')));
        fileName = window.btoa(window.encodeURIComponent($(this).text()));
        $(this).attr('data-toggle', 'modal').attr('href', createLink('misc', 'download', 'link=' + link + '&fileName=' + fileName));
    }); 
})
;
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?731bb611021e8720f1fc3035dfd2a44f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
;
function loadCartInfo(twinkle)
{
    $('#siteNav').load(createLink('misc', 'printTopBar'),
        function()
        {
            if(twinkle) 
            {
                bootbox.dialog(
                {  
                    message: v.addToCartSuccess,  
                    buttons:
                    {  
                        back:
                        {  
                            label:     v.lang.continueShopping,
                            className: 'btn-primary',  
                            callback:  function(){location.reload();}  
                        },
                        cart:
                        {  
                            label:     v.gotoCart,  
                            className: 'btn-primary',  
                            callback:  function(){location.href = createLink('cart', 'browse');}  
                        }  
                    }  
                });
            }
        }
    );
}
;
    var userBehaviorData = JSON.parse(localStorage.getItem('userBehavior'));
    if(!userBehaviorData){ userBehaviorData = []; }
    userBehaviorData.push({
        referrer: document.referrer,
        url: document.URL,
        title: document.title,
        timestamp: Date.parse(new Date()) / 1000
    })
    localStorage.setItem('userBehavior', JSON.stringify(userBehaviorData));
