summaryrefslogtreecommitdiffstats
path: root/theme/javascript
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-27 17:57:34 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-27 17:57:34 +0200
commit9fdc5da22da283f8c3a76760194bf2f61a8cebd4 (patch)
tree7d01ad53a8013595461e5128b4b5140317df0f3e /theme/javascript
parent99ce48b146c2d6f17a97d04405c6834737cc431c (diff)
downloadgitbook-9fdc5da22da283f8c3a76760194bf2f61a8cebd4.zip
gitbook-9fdc5da22da283f8c3a76760194bf2f61a8cebd4.tar.gz
gitbook-9fdc5da22da283f8c3a76760194bf2f61a8cebd4.tar.bz2
Update page when new version of application cache
Diffstat (limited to 'theme/javascript')
-rwxr-xr-xtheme/javascript/gitbook.js6
-rw-r--r--theme/javascript/utils/appcache.js15
2 files changed, 20 insertions, 1 deletions
diff --git a/theme/javascript/gitbook.js b/theme/javascript/gitbook.js
index 7dcb8d7..cb222da 100755
--- a/theme/javascript/gitbook.js
+++ b/theme/javascript/gitbook.js
@@ -2,6 +2,7 @@ define([
"jQuery",
"utils/storage",
"utils/sharing",
+ "utils/appcache",
"core/events",
"core/font-settings",
@@ -11,7 +12,7 @@ define([
"core/progress",
"core/sidebar",
"core/search"
-], function($, storage, sharing, events, fontSettings, state, keyboard, navigation, progress, sidebar, search){
+], function($, storage, appCache, sharing, events, fontSettings, state, keyboard, navigation, progress, sidebar, search){
var start = function(config) {
var $book;
$book = state.$book;
@@ -30,6 +31,9 @@ define([
// Init keyboard
keyboard.init();
+ // Init appcache
+ appCache.init();
+
// Bind sharing button
sharing.init();
diff --git a/theme/javascript/utils/appcache.js b/theme/javascript/utils/appcache.js
new file mode 100644
index 0000000..e813ab0
--- /dev/null
+++ b/theme/javascript/utils/appcache.js
@@ -0,0 +1,15 @@
+define([], function() {
+ var isAvailable = (typeof applicationCache !== "undefined");
+
+ var init = function() {
+ if (!isAvailable) return;
+
+ window.applicationCache.addEventListener('updateready', function() {
+ window.location.reload();
+ }, false);
+ };
+
+ return {
+ init: init
+ };
+}); \ No newline at end of file