diff --git a/package.json b/package.json index a90f5b43e851aa07524afab86b21828c4970f13f..d56d294c0f46a886c8e67d8aaec0c819db22bb6b 100644 --- a/package.json +++ b/package.json @@ -8,17 +8,17 @@ }, "dependencies": {}, "devDependencies": { - "browserify": "13.0.0", - "eslint": "2.7.0", - "font-awesome": "4.5.0", + "browserify": "13.1.0", + "eslint": "3.6.1", + "font-awesome": "4.6.3", "preboot": "git+https://github.com/mdo/preboot.git#4aab4edd85f076d50609cbe28e4fe66cc0771701", "gitbook-logos": "git+https://github.com/GitbookIO/logos.git#2.0.2", "gitbook-markdown-css": "1.0.1", - "jquery": "2.1.4", - "less": "2.6.0", + "jquery": "3.1.1", + "less": "2.7.1", "less-plugin-clean-css": "1.5.1", - "mousetrap": "1.5.3", - "uglify-js": "2.6.1" + "mousetrap": "1.6.0", + "uglify-js": "2.7.3" }, "scripts": { "prepublish": "./src/build.sh" diff --git a/src/js/theme/navigation.js b/src/js/theme/navigation.js index 4b96f08c4363b4553e0793c09b4c81d657f479c5..f1ff54f218a6ed93ca25bf698257dec5f5bfe31a 100644 --- a/src/js/theme/navigation.js +++ b/src/js/theme/navigation.js @@ -98,10 +98,17 @@ function setChapterActive($chapter, hash) { // If hash is provided, set as active chapter if (!!hash) { - $chapter = $chapters.filter(function() { - var titleId = getChapterHash($(this)); - return titleId == hash; - }).first(); + // Multiple chapters for this file + if ($chapters.length > 1) { + $chapter = $chapters.filter(function() { + var titleId = getChapterHash($(this)); + return titleId == hash; + }).first(); + } + // Only one chapter, no need to search + else { + $chapter = $chapters.first(); + } } // Don't update current chapter @@ -324,9 +331,13 @@ function preparePage(resetScroll) { // Focus on content $pageWrapper.focus(); + // Get scroller + var $scroller = getScroller(); + // Reset scroll - if (resetScroll !== false) $bookInner.scrollTop(0); - $bookBody.scrollTop(0); + if (resetScroll !== false) { + $scroller.scrollTop(0); + } // Get current page summary chapters $chapters = $('.book-summary .summary .chapter') @@ -347,10 +358,13 @@ function preparePage(resetScroll) { }); // Bind scrolling if summary contains more than one link to this page - var $scroller = getScroller(); if ($chapters.length > 1) { $scroller.scroll(handleScrolling); } + // Else, set only chapter in summary as active + else { + $activeChapter = $chapters.first(); + } } function isLeftClickEvent(e) { @@ -417,7 +431,7 @@ function init() { $(window).resize(updateNavigationPosition); // Prepare current page - preparePage(); + preparePage(false); } module.exports = { diff --git a/src/js/theme/toolbar.js b/src/js/theme/toolbar.js index 3ed45ee3c1dbe249473363f48ae46bd968cb76f2..d3474c62561244294b01bbb998c3396f65fdcbfb 100644 --- a/src/js/theme/toolbar.js +++ b/src/js/theme/toolbar.js @@ -13,7 +13,7 @@ function generateId() { // Insert a jquery element at a specific position function insertAt(parent, selector, index, element) { - var lastIndex = parent.children(selector).size(); + var lastIndex = parent.children(selector).length; if (index < 0) { index = Math.max(0, lastIndex + 1 + index); }