mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Switch to URI.js for url parsing, basic replacement for Archived urls
This commit is contained in:
parent
af5583191e
commit
13467128e5
18 changed files with 2677 additions and 207 deletions
18
src/hook.js
18
src/hook.js
|
@ -14,8 +14,17 @@ function Hook(context){
|
|||
};
|
||||
|
||||
// Adds a function to be run before a hook completes
|
||||
Hook.prototype.register = function(func){
|
||||
this.hooks.push(func);
|
||||
Hook.prototype.register = function(){
|
||||
for(var i = 0; i < arguments.length; ++i) {
|
||||
if (typeof arguments[i] === "function") {
|
||||
this.hooks.push(arguments[i]);
|
||||
} else {
|
||||
// unpack array
|
||||
for(var j = 0; j < arguments[i].length; ++j) {
|
||||
this.hooks.push(arguments[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Triggers a hook to run all functions
|
||||
|
@ -38,4 +47,9 @@ Hook.prototype.trigger = function(){
|
|||
return RSVP.all(promises);
|
||||
};
|
||||
|
||||
// Adds a function to be run before a hook completes
|
||||
Hook.prototype.list = function(){
|
||||
return this.hooks;
|
||||
};
|
||||
|
||||
module.exports = Hook;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue