(function ($) { // To top button $("#back-to-top").on('click', function () { $('body, html').animate({ scrollTop: 0 }, 600); }); // Nav bar toggle $('#main-nav-toggle').on('click', function () { $('.nav-container-inner').slideToggle(); }); // Caption $('.article-entry').each(function(i) { $(this).find('img').each(function() { if (this.alt && !(!!$.prototype.justifiedGallery && $(this).parent('.justified-gallery').length)) { $(this).after(''); } }); }); if (typeof lightGallery != 'undefined') { var options = { selector: '.gallery-item', }; $('.article-entry').each(function(i, entry) { lightGallery(entry, options); }); lightGallery($('.article-gallery')[0], options); } if (!!$.prototype.justifiedGallery) { // if justifiedGallery method is defined var options = { rowHeight: 140, margins: 4, lastRow: 'justify' }; $('.justified-gallery').justifiedGallery(options); } // Sidebar expend $('#sidebar .sidebar-toggle').on('click', function () { if($('#sidebar').hasClass('expend')) { $('#sidebar').removeClass('expend'); } else { $('#sidebar').addClass('expend'); } }); // Remove extra main nav wrap $('.main-nav-list > li').unwrap(); // Highlight current nav item $('#main-nav > li > .main-nav-list-link').each(function () { if($('.page-title-link').length > 0){ if ($(this).html().toUpperCase() == $('.page-title-link').html().toUpperCase()) { $(this).addClass('current'); } else if ($(this).attr('href') == $('.page-title-link').attr('data-url')) { $(this).addClass('current'); } } }); // Auto hide main nav menus function autoHideMenus(){ var max_width = $('.nav-container-inner').width() - 10; var main_nav_width = $('#main-nav').width(); var sub_nav_width = $('#sub-nav').width(); if (main_nav_width + sub_nav_width > max_width) { // If more link not exists if ($('.main-nav-more').length == 0) { $(['
'); } // 对于已经包含在链接内的图片不适用lightGallery if ($(this).parent().prop("tagName") !== 'A') { $(this).wrap('