diff options
author | portix <none@none> | 2012-04-19 00:58:47 +0200 |
---|---|---|
committer | portix <none@none> | 2012-04-19 00:58:47 +0200 |
commit | d10a7d948d82b4598317fab809e22bd3f7ca6cdc (patch) | |
tree | c25451a1931306f074ffb0bd0fe8a86dd8cbb121 /scripts | |
parent | 60a84aa9e82661d0930a1591543d641898401a14 (diff) | |
download | dwb-d10a7d948d82b4598317fab809e22bd3f7ca6cdc.zip |
Implementing inject and resource request
--HG--
branch : scripts
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/enums.js | 7 | ||||
-rw-r--r-- | scripts/lib/signals.js | 21 |
2 files changed, 22 insertions, 6 deletions
diff --git a/scripts/lib/enums.js b/scripts/lib/enums.js new file mode 100644 index 00000000..f782744e --- /dev/null +++ b/scripts/lib/enums.js @@ -0,0 +1,7 @@ +const LoadStatus = { + provisional : 0, + committed : 1, + finished : 2, + firstVisualLayout : 3, + failed : 4 +}; diff --git a/scripts/lib/signals.js b/scripts/lib/signals.js index 27f465a3..04c72229 100644 --- a/scripts/lib/signals.js +++ b/scripts/lib/signals.js @@ -1,4 +1,3 @@ - Object.defineProperty(signals, "_registered", { value : {} }); @@ -9,22 +8,32 @@ Object.defineProperty(signals, "_maxId", { Object.defineProperty(signals, "emit", { value : function(sig, wv, o) { var sigs = signals._registered[sig]; + var ret = false; for (var i=0; i<sigs.length; i++) { - sigs[i].callback(wv, o); + ret = sigs[i].callback(wv, o) || ret; } + return ret; } }); Object.defineProperty(signals, "connect", { value : function(sig, func) { - signals._maxId++; if (signals._registered[sig] === undefined || signals._registered[sig] === null) { signals._registered[sig] = []; signals[sig] = function (wv, o) { - signals.emit(sig, wv, o); + return signals.emit(sig, wv, o); }; } - signals._registered[sig].push({callback : func, id : signals._maxId }); - return signals._maxId; + if (func !== null && typeof func === "function") { + signals._maxId++; + signals._registered[sig].push({callback : func, id : signals._maxId }); + return signals._maxId; + } + return -1; + } +}); +Object.defineProperty(signals, "register", { + value : function (sig) { + signals.connect(sig, null); } }); Object.defineProperty(signals, "disconnect", { |