summaryrefslogtreecommitdiffstats
path: root/theme/javascript/core/navigation.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2015-08-07 16:46:23 +0200
committerAaron O'Mullan <aaron.omullan@gmail.com>2015-08-07 16:46:23 +0200
commit578c9dcfc6f38222d883113bc8d715ad52d328be (patch)
tree6c0d20b9c1aab536cd87d668eaf6fbc783566562 /theme/javascript/core/navigation.js
parent501843d6243e0be3bcab0e7c9cc1b6ff2886d4f4 (diff)
downloadgitbook-578c9dcfc6f38222d883113bc8d715ad52d328be.zip
gitbook-578c9dcfc6f38222d883113bc8d715ad52d328be.tar.gz
gitbook-578c9dcfc6f38222d883113bc8d715ad52d328be.tar.bz2
Improve header merge on page change
Prevents flickering (style reset) Fixes #782, #838, #840
Diffstat (limited to 'theme/javascript/core/navigation.js')
-rwxr-xr-xtheme/javascript/core/navigation.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js
index e2ae5bc..a4a5b43 100755
--- a/theme/javascript/core/navigation.js
+++ b/theme/javascript/core/navigation.js
@@ -35,13 +35,25 @@ define([
var $pageHead = $page.find("[data-element=head]");
var $pageBody = $page.find('.book');
+ ////
// Merge heads
- var headContent = $pageHead.html()
+ // !! Warning !!: we only update necessary portions to avoid strange behavior (page flickering etc ...)
+ ////
- $("head style").each(function() {
- headContent = headContent + this.outerHTML
- });
- $("head").html(headContent);
+ // Update title
+ document.title = $pageHead.find("title").text();
+
+ // Reference to $("head");
+ var $head = $("head");
+
+ // Update next & prev <link> tags
+ // Remove old
+ $head.find("link[rel=prev]").remove();
+ $head.find("link[rel=next]").remove();
+
+ // Add new next * prev <link> tags
+ $head.append($pageHead.find("link[rel=prev]"));
+ $head.append($pageHead.find("link[rel=next]"));
// Merge body
var bodyClass = $(".book").attr("class");