<script>
    $(document).ready(function(){

    //所有表格增加table类,统一表格的样式
    $('.g7-post-content table').addClass("table table-bordered");

    //css3动画初始化
        var i={animateThreshold:100};
        $(".aniview").AniView(i);

      //视差效果
        function draw() {
            requestAnimationFrame(draw);
            scrollEvent();
        }
        draw();

    //回到顶部
    $(window).bind("scroll", function() {
        if ($(window).scrollTop() > $(window).height()) {
            $('.back-to-top').addClass('active');
        }
        if ($(window).scrollTop() < $(window).height()) {
            $('.back-to-top').removeClass('active');
        }
    });

    $('.back-to-top').click(function(event) {
        event.preventDefault();
        $('html, body').animate({
            scrollTop: 0
        }, 1000);
        return false;
    });

    //分类导航存在子菜单增加箭头 dropdown-toggle
    $('.g7-catnav').find('li>ul').parent().find('>a').addClass('dropdown-toggle');
    lw = $('.g7-catnav li>ul').width();
    $('.g7-catnav li>ul>li>ul').css('left',lw);

    });

  //视差效果
    function scrollEvent() {
        viewportTop = $(window).scrollTop();
        if ($(window).width()) {
            $('.parallax').each(function() {
            elementOffset = $(this).offset().top;
            distance = -(elementOffset - viewportTop) * 0.35;
            $(this).css('transform', 'translate3d(0, ' + distance + 'px,0)');
          });
    };
    };

  //分类导航增加下拉菜单样式 dropdown-toggle
  $('.g7-catnav li').hover(function() {
    if($(this).find('li').length > 0){
    $(this).children('ul').stop(true, true).delay(150).slideDown(300);
      $(this).addClass('has-child');
    }
  },function() {
    $(this).children('ul').stop(true, true).slideUp(150);
      $(this).removeClass('has-child');
  });

  //tooltip
  $(function () {
    $('[data-toggle="tooltip"]').tooltip()
  });
</script>

<?php if(!$this->is('single')): ?>
<script>
  //滚动导航增加固定样式和浮动样式
  $(window).scroll(function(){
    if ($(this).scrollTop() >= 10) {
      $('.g7-category-header').addClass('scrolled');
    }else{
      $('.g7-category-header').removeClass('scrolled');
    }

    var before = $(window).scrollTop();
    $(window).scroll(function() {
      var after = $(window).scrollTop();
      if (before<=after) {
        $('.sticky-nav').addClass('scrolling');
          before = after;
      };
      if (before>after) {
        $('.sticky-nav').removeClass('scrolling');
          before = after;
      };
    });
  });
</script>
<?php endif; ?>