summaryrefslogtreecommitdiffstats
path: root/theme/javascript/state.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-11-25 10:05:05 +0100
committerSamy Pessé <samypesse@gmail.com>2015-11-25 10:05:05 +0100
commitd5d6b3673ebccc2650bd03841011b1c7b11d8fd6 (patch)
tree2eae2df343ce0b5cc9261591f83d2c632088cf81 /theme/javascript/state.js
parentd2a2fe88d1a9e10df031216d90e17a57df513952 (diff)
downloadgitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.zip
gitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.tar.gz
gitbook-d5d6b3673ebccc2650bd03841011b1c7b11d8fd6.tar.bz2
Add bookRoot to gitbook.state
Diffstat (limited to 'theme/javascript/state.js')
-rw-r--r--theme/javascript/state.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/theme/javascript/state.js b/theme/javascript/state.js
index fb91f7a..a6a7877 100644
--- a/theme/javascript/state.js
+++ b/theme/javascript/state.js
@@ -11,6 +11,9 @@ state.update = function(dom) {
state.level = $book.data('level');
state.basePath = $book.data('basepath');
+ // If book is multilingual, language of this book
+ state.innerlanguage = $book.data('innerlanguage');
+
// Date of build
state.revision = $book.data('revision');
@@ -20,11 +23,14 @@ state.update = function(dom) {
// Title of the chapter
state.chapterTitle = $book.data('chapter-title');
- // Absolute url to the root of the book
+ // Absolute url to the root of the book (inner book)
state.root = url.resolve(
location.protocol+'//'+location.host,
path.dirname(path.resolve(location.pathname.replace(/\/$/, '/index.html'), state.basePath))
);
+
+ // Absolute root to the language (for multilingual book)
+ state.bookRoot = state.innerlanguage? url.resolve(state.root, '..') : state.root;
};
state.update($);