Repository navigation
Expand file tree
/
Copy pathnext-boot.js
More file actions
83 lines (66 loc) · 2.82 KB
/
Copy pathnext-boot.js
File metadata and controls
83 lines (66 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* global NexT, CONFIG */
$(document).ready(function() {
/**
* Register JS handlers by condition option.
* Need to add config option in Front-End at 'layout/_partials/head.swig' file.
*/
CONFIG.fastclick && NexT.utils.isMobile() && window.FastClick.attach(document.body);
CONFIG.lazyload && NexT.utils.lazyLoadPostsImages();
NexT.utils.registerESCKeyEvent();
CONFIG.back2top.enable && NexT.utils.registerBackToTop();
// Mobile top menu bar.
$('.site-nav-toggle button').on('click', function() {
var $siteNav = $('.site-nav');
var ON_CLASS_NAME = 'site-nav-on';
var isSiteNavOn = $siteNav.hasClass(ON_CLASS_NAME);
var animateAction = isSiteNavOn ? 'slideUp' : 'slideDown';
var animateCallback = isSiteNavOn ? 'removeClass' : 'addClass';
$siteNav.stop()[animateAction]('fast', function() {
$siteNav[animateCallback](ON_CLASS_NAME);
});
});
CONFIG.fancybox && NexT.utils.wrapImageWithFancyBox();
CONFIG.copycode.enable && NexT.utils.registerCopyCode();
CONFIG.tabs && NexT.utils.registerTabsTag();
NexT.utils.embeddedVideoTransformer();
// Define Motion Sequence & Bootstrap Motion.
CONFIG.motion.enable && NexT.motion.integrator
.add(NexT.motion.middleWares.logo)
.add(NexT.motion.middleWares.menu)
.add(NexT.motion.middleWares.postList)
.add(NexT.motion.middleWares.sidebar)
.bootstrap();
/**
* Init Sidebar & TOC inner dimensions on all pages and for all schemes.
* Need for Sidebar/TOC inner scrolling if content taller then viewport.
*/
function updateSidebarHeight(height) {
height = height || 'auto';
$('.site-overview, .post-toc').css('max-height', height);
}
function initSidebarDimension() {
var updateSidebarHeightTimer;
$(window).on('resize', function() {
updateSidebarHeightTimer && clearTimeout(updateSidebarHeightTimer);
updateSidebarHeightTimer = setTimeout(function() {
var sidebarWrapperHeight = document.body.clientHeight - NexT.utils.getSidebarSchemePadding();
updateSidebarHeight(sidebarWrapperHeight);
}, 0);
});
// Initialize Sidebar & TOC Width.
var scrollbarWidth = NexT.utils.getScrollbarWidth();
if ($('.site-overview-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.site-overview').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}
if ($('.post-toc-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.post-toc').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}
// Initialize Sidebar & TOC Height.
updateSidebarHeight(document.body.clientHeight - NexT.utils.getSidebarSchemePadding());
}
initSidebarDimension();
function wrapTable() {
$('table').not('.gist table').wrap('<div class="table-container"></div>');
}
wrapTable();
});