summaryrefslogtreecommitdiffstats
path: root/theme/javascript/core
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-27 17:36:12 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-27 17:36:12 +0200
commit99ce48b146c2d6f17a97d04405c6834737cc431c (patch)
treedd592621b223114c60a52bb8c694d7b6ef9bc6e7 /theme/javascript/core
parent6a33ad9ef7a73faaeb8faa839b2004fbcd502ec7 (diff)
downloadgitbook-99ce48b146c2d6f17a97d04405c6834737cc431c.zip
gitbook-99ce48b146c2d6f17a97d04405c6834737cc431c.tar.gz
gitbook-99ce48b146c2d6f17a97d04405c6834737cc431c.tar.bz2
Add base loading indicator for navigation
#161
Diffstat (limited to 'theme/javascript/core')
-rw-r--r--theme/javascript/core/loading.js18
-rwxr-xr-xtheme/javascript/core/navigation.js9
2 files changed, 23 insertions, 4 deletions
diff --git a/theme/javascript/core/loading.js b/theme/javascript/core/loading.js
new file mode 100644
index 0000000..193531f
--- /dev/null
+++ b/theme/javascript/core/loading.js
@@ -0,0 +1,18 @@
+define([
+ "jQuery"
+], function($) {
+ var showLoading = function(p) {
+ var $book = $(".book");
+
+ $book.addClass("is-loading");
+ p.always(function() {
+ $book.removeClass("is-loading");
+ });
+
+ return p;
+ };
+
+ return {
+ show: showLoading
+ };
+}); \ No newline at end of file
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js
index d8dc8b9..e614392 100755
--- a/theme/javascript/core/navigation.js
+++ b/theme/javascript/core/navigation.js
@@ -6,8 +6,9 @@ define([
"core/search",
"core/progress",
"core/exercise",
- "core/quiz"
-], function($, path, events, state, search, progress, exercises, quiz) {
+ "core/quiz",
+ "core/loading"
+], function($, path, events, state, search, progress, exercises, quiz, loading) {
var prev, next;
var githubCountStars, githubCountWatch;
@@ -23,7 +24,7 @@ define([
return
}
- return $.get(url)
+ return loading.show($.get(url)
.done(function (html) {
// Push url to history
if (push) history.pushState({ path: url }, null, url);
@@ -59,7 +60,7 @@ define([
})
.fail(function (e) {
location.href = relativeUrl;
- });
+ }));
};
var updateGitHubCounts = function() {