Compare commits

...
6 Commits
Author SHA1 Message Date
qingwei.li cc4ffb4ab7 -> v2.4.1 2017-02-13 23:23:25 +08:00
qingwei.li d62da2034f bump: 2.4.1 2017-02-13 23:23:13 +08:00
qingwei.li dd0c84bb40 fix(index): cover page 2017-02-13 23:21:27 +08:00
qingwei.li 02022af53c -> v2.4.0 2017-02-13 23:08:02 +08:00
qingwei.li 44d7257691 bump: 2.4.0 2017-02-13 23:07:54 +08:00
qingwei.li c6f760275c feat(hook): add doneEach 2017-02-13 23:06:30 +08:00
12 changed files with 51 additions and 13 deletions
+16
View File
@@ -1,3 +1,19 @@
### 2.4.1
> 2017-02-13
#### Bug fixes
- fix(index): cover page
### 2.4.0
> 2017-02-13
#### Features
- feat(hook): add `doneEach`
### 2.3.0
> 2017-02-13
+1 -1
View File
@@ -1,6 +1,6 @@
![logo](_media/icon.svg)
# docsify <small>2.3.0</small>
# docsify <small>2.4.1</small>
> A magical documentation site generator.
+7 -2
View File
@@ -67,7 +67,7 @@ window.$docsify = {
plugins: [
function (hook) {
hook.init(function() {
// Called when the script starts running, only trigger once.
// Called when the script starts running, only trigger once, no arguments,
})
hook.beforeEach(function(content) {
@@ -84,8 +84,13 @@ window.$docsify = {
next(html)
})
hook.doneEach(function() {
// Invoked each time after the data is fully loaded, no arguments,
// ...
})
hook.ready(function() {
// Called after initialization is complete. Only trigger once.
// Called after initialization is complete. Only trigger once, no arguments.
})
}
]
+7 -2
View File
@@ -63,7 +63,7 @@ window.$docsify = {
plugins: [
function (hook) {
hook.init(function() {
// 初始化时调用,只调用一次
// 初始化时调用,只调用一次,没有参数。
})
hook.beforeEach(function(content) {
@@ -79,8 +79,13 @@ window.$docsify = {
next(html)
})
hook.doneEach(function() {
// 每次路由切换时数据全部加载完成后调用,没有参数。
// ...
})
hook.ready(function() {
// docsify 初始化完成后调用,只调用一次
// 初始化完成后调用,只调用一次,没有参数。
})
}
]
+7 -1
View File
@@ -2818,6 +2818,7 @@ var Hook = function Hook () {
this.afterHooks = [];
this.initHooks = [];
this.readyHooks = [];
this.doneEachHooks = [];
};
Hook.prototype.beforeEach = function beforeEach (fn) {
@@ -2828,6 +2829,10 @@ Hook.prototype.afterEach = function afterEach (fn) {
this.afterHooks.push(fn);
};
Hook.prototype.doneEach = function doneEach (fn) {
this.doneEachHooks.push(fn);
};
Hook.prototype.init = function init (fn) {
this.initHooks.push(fn);
};
@@ -2951,7 +2956,7 @@ var mainRender = function (cb) {
}
// Render Cover page
if (OPTIONS.coverpage && page === OPTIONS.homepage) {
if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) {
load(OPTIONS.coverpage).then(renderCover);
}
@@ -2991,6 +2996,7 @@ var Docsify = function () {
mainRender(function (_) {
scrollIntoView();
activeLink('nav');
window.Docsify.hook.emit('doneEach');
});
};
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -290,7 +290,7 @@ var install = function () {
new SearchComponent();
!isAuto && searchPlugin();
});
isAuto && hook.beforeEach(searchPlugin);
isAuto && hook.doneEach(searchPlugin);
}, window.$docsify.plugins);
};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "2.3.0",
"version": "2.4.1",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"files": [
+5
View File
@@ -4,6 +4,7 @@ export default class Hook {
this.afterHooks = []
this.initHooks = []
this.readyHooks = []
this.doneEachHooks = []
}
beforeEach (fn) {
@@ -14,6 +15,10 @@ export default class Hook {
this.afterHooks.push(fn)
}
doneEach (fn) {
this.doneEachHooks.push(fn)
}
init (fn) {
this.initHooks.push(fn)
}
+2 -1
View File
@@ -90,7 +90,7 @@ const mainRender = function (cb) {
}
// Render Cover page
if (OPTIONS.coverpage && page === OPTIONS.homepage) {
if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) {
utils.load(OPTIONS.coverpage).then(render.renderCover)
}
@@ -130,6 +130,7 @@ const Docsify = function () {
mainRender(_ => {
scrollIntoView()
activeLink('nav')
window.Docsify.hook.emit('doneEach')
})
}
+1 -1
View File
@@ -342,7 +342,7 @@ const install = function () {
new SearchComponent()
!isAuto && searchPlugin()
})
isAuto && hook.beforeEach(searchPlugin)
isAuto && hook.doneEach(searchPlugin)
}, window.$docsify.plugins)
}