summaryrefslogtreecommitdiffstats
path: root/theme/javascript/app.js
diff options
context:
space:
mode:
authortcorral <amischol@gmail.com>2014-04-13 03:09:50 +0200
committertcorral <amischol@gmail.com>2014-04-13 03:09:50 +0200
commitd9e34fc671b3502e96a933afd3ac7c5a5cafab0f (patch)
tree26cc6bc8d1122ac953494c1043ab1c681c55331b /theme/javascript/app.js
parent2242963258b7eb12644f41e3d1d8ceb363db951c (diff)
downloadgitbook-d9e34fc671b3502e96a933afd3ac7c5a5cafab0f.zip
gitbook-d9e34fc671b3502e96a933afd3ac7c5a5cafab0f.tar.gz
gitbook-d9e34fc671b3502e96a933afd3ac7c5a5cafab0f.tar.bz2
Allow scroll in computers that put the navigation over scroll control. When the document is ready it will check the difference between the body-inner and the page-wrapper width to move the layer only this width allowing the user to scroll.
Diffstat (limited to 'theme/javascript/app.js')
-rw-r--r--theme/javascript/app.js108
1 files changed, 56 insertions, 52 deletions
diff --git a/theme/javascript/app.js b/theme/javascript/app.js
index f915330..d877c53 100644
--- a/theme/javascript/app.js
+++ b/theme/javascript/app.js
@@ -1,54 +1,58 @@
require([
- "jQuery",
- "utils/storage",
- "utils/analytic",
- "utils/sharing",
-
- "core/state",
- "core/keyboard",
- "core/exercise",
- "core/progress",
- "core/sidebar",
- "core/search"
-], function($, storage, analytic, sharing, state, keyboard, exercise, progress, sidebar, search){
- $(document).ready(function() {
- var $book, bodyInnerWidth, pageWrapperWidth;
- $book = state.$book;
-
- // Init sidebar
- sidebar.init();
-
- // Load search
- search.init();
-
- // Init keyboard
- keyboard.init();
-
- if (state.githubId) {
- // Initialize storage
- storage.setBaseKey(state.githubId);
-
- // Star and watch count
- $.getJSON("https://api.github.com/repos/"+state.githubId)
- .done(function(repo) {
- $book.find(".count-star span").text(repo.stargazers_count);
- $book.find(".count-watch span").text(repo.subscribers_count);
- });
- }
-
- // Bind exercise
- exercise.init();
-
- // Bind sharing button
- sharing.init();
-
- // Show progress
- progress.show();
-
- // Focus on content
- $(".book-body").focus();
- bodyInnerWidth = parseInt($('.body-inner').css('width'), 10);
- pageWrapperWidth = parseInt($('.page-wrapper').css('width'), 10);
- $('.navigation-next').css('margin-right', (bodyInnerWidth - pageWrapperWidth) + 'px');
- });
+ "jQuery",
+ "utils/storage",
+ "utils/analytic",
+ "utils/sharing",
+
+ "core/state",
+ "core/keyboard",
+ "core/exercise",
+ "core/quiz",
+ "core/progress",
+ "core/sidebar",
+ "core/search"
+], function($, storage, analytic, sharing, state, keyboard, exercise, quiz, progress, sidebar, search){
+ $(document).ready(function() {
+ var $book, bodyInnerWidth, pageWrapperWidth;
+ $book = state.$book;
+
+ // Init sidebar
+ sidebar.init();
+
+ // Load search
+ search.init();
+
+ // Init keyboard
+ keyboard.init();
+
+ if (state.githubId) {
+ // Initialize storage
+ storage.setBaseKey(state.githubId);
+
+ // Star and watch count
+ $.getJSON("https://api.github.com/repos/"+state.githubId)
+ .done(function(repo) {
+ $book.find(".count-star span").text(repo.stargazers_count);
+ $book.find(".count-watch span").text(repo.subscribers_count);
+ });
+ }
+
+ // Bind exercises
+ exercise.init();
+ quiz.init();
+
+ // Bind sharing button
+ sharing.init();
+
+ // Show progress
+ progress.show();
+
+ // Focus on content
+ $(".book-body").focus();
+
+ // Move, if needed, right navigation control to allow scrolling.
+ bodyInnerWidth = parseInt($('.body-inner').css('width'), 10);
+ pageWrapperWidth = parseInt($('.page-wrapper').css('width'), 10);
+ $('.navigation-next').css('margin-right', (bodyInnerWidth - pageWrapperWidth) + 'px');
+ });
});