summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-11-02 16:57:08 +0100
committerSamy Pessé <samypesse@gmail.com>2015-11-02 16:57:08 +0100
commit2814fea67efd93d15a11bb56b56540573b61ff4b (patch)
treeea1164512a64acf107ce286f22af0de89e2791a5
parent3388be9db6c6ae2173652df20eb98f36186c1f9a (diff)
downloadgitbook-2814fea67efd93d15a11bb56b56540573b61ff4b.zip
gitbook-2814fea67efd93d15a11bb56b56540573b61ff4b.tar.gz
gitbook-2814fea67efd93d15a11bb56b56540573b61ff4b.tar.bz2
Trigger "start" before "page.change"
-rw-r--r--theme/assets/website/app.js17
-rwxr-xr-xtheme/javascript/index.js1
-rw-r--r--theme/javascript/navigation.js13
-rw-r--r--theme/javascript/toolbar.js3
4 files changed, 26 insertions, 8 deletions
diff --git a/theme/assets/website/app.js b/theme/assets/website/app.js
index ea8144f..1e8d3c8 100644
--- a/theme/assets/website/app.js
+++ b/theme/assets/website/app.js
@@ -24403,6 +24403,7 @@ function start(config) {
});
events.trigger('start', config);
+ navigation.notify();
}
// Export APIs for plugins
@@ -24581,7 +24582,11 @@ function updateNavigationPosition() {
$('.navigation-next').css('margin-right', (bodyInnerWidth - pageWrapperWidth) + 'px');
}
-function preparePage() {
+function notifyPageChange() {
+ events.trigger('page.change');
+}
+
+function preparePage(notify) {
var $bookBody = $('.book-body');
var $bookInner = $bookBody.find('.body-inner');
var $pageWrapper = $bookInner.find('.page-wrapper');
@@ -24597,7 +24602,7 @@ function preparePage() {
$bookBody.scrollTop(0);
// Notify
- events.trigger('page.change');
+ if (notify !== false) notifyPageChange();
}
function isLeftClickEvent(e) {
@@ -24656,13 +24661,14 @@ function init() {
$(window).resize(updateNavigationPosition);
// Prepare current page
- preparePage();
+ preparePage(false);
}
module.exports = {
init: init,
goNext: goNext,
- goPrev: goPrev
+ goPrev: goPrev,
+ notify: notifyPageChange
};
},{"./events":12,"./loading":15,"./state":19,"jquery":8,"url":7}],17:[function(require,module,exports){
@@ -24955,6 +24961,8 @@ function updateButton(opts) {
$result = $btn;
}
+ $result.addClass('js-toolbar-action');
+
if (_.isNumber(opts.index) && opts.index >= 0) {
insertAt($toolbar, '.btn, .dropdown, h1', opts.index, $result);
} else {
@@ -24964,6 +24972,7 @@ function updateButton(opts) {
// Update all buttons
function updateAllButtons() {
+ $('.js-toolbar-action').remove();
_.each(buttons, updateButton);
}
diff --git a/theme/javascript/index.js b/theme/javascript/index.js
index 8eff42a..b22f810 100755
--- a/theme/javascript/index.js
+++ b/theme/javascript/index.js
@@ -36,6 +36,7 @@ function start(config) {
});
events.trigger('start', config);
+ navigation.notify();
}
// Export APIs for plugins
diff --git a/theme/javascript/navigation.js b/theme/javascript/navigation.js
index 8cc420e..dd3bf2e 100644
--- a/theme/javascript/navigation.js
+++ b/theme/javascript/navigation.js
@@ -75,7 +75,11 @@ function updateNavigationPosition() {
$('.navigation-next').css('margin-right', (bodyInnerWidth - pageWrapperWidth) + 'px');
}
-function preparePage() {
+function notifyPageChange() {
+ events.trigger('page.change');
+}
+
+function preparePage(notify) {
var $bookBody = $('.book-body');
var $bookInner = $bookBody.find('.body-inner');
var $pageWrapper = $bookInner.find('.page-wrapper');
@@ -91,7 +95,7 @@ function preparePage() {
$bookBody.scrollTop(0);
// Notify
- events.trigger('page.change');
+ if (notify !== false) notifyPageChange();
}
function isLeftClickEvent(e) {
@@ -150,11 +154,12 @@ function init() {
$(window).resize(updateNavigationPosition);
// Prepare current page
- preparePage();
+ preparePage(false);
}
module.exports = {
init: init,
goNext: goNext,
- goPrev: goPrev
+ goPrev: goPrev,
+ notify: notifyPageChange
};
diff --git a/theme/javascript/toolbar.js b/theme/javascript/toolbar.js
index d65159b..de30493 100644
--- a/theme/javascript/toolbar.js
+++ b/theme/javascript/toolbar.js
@@ -156,6 +156,8 @@ function updateButton(opts) {
$result = $btn;
}
+ $result.addClass('js-toolbar-action');
+
if (_.isNumber(opts.index) && opts.index >= 0) {
insertAt($toolbar, '.btn, .dropdown, h1', opts.index, $result);
} else {
@@ -165,6 +167,7 @@ function updateButton(opts) {
// Update all buttons
function updateAllButtons() {
+ $('.js-toolbar-action').remove();
_.each(buttons, updateButton);
}