[Pkg-javascript-commits] [sockjs-client] 245/434: #28 Introduce DocumentGuard, a singleton that knows more than document.readyState.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 7a4f7a5bb6ce1da1fc2a2e86ead30d3ad7ce3525
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Thu Dec 1 17:39:58 2011 +0000

    #28 Introduce DocumentGuard, a singleton that knows more than document.readyState.
---
 lib/dom.js | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/lib/dom.js b/lib/dom.js
index 998a4ec..55cc573 100644
--- a/lib/dom.js
+++ b/lib/dom.js
@@ -277,3 +277,35 @@ utils.createHtmlfile = function (iframe_url, error_callback) {
         loaded: unattach
     };
 };
+
+var DocumentGuard = function() {
+    var that = this;
+    var emit = function(state_name) {
+        that.state = DocumentGuard[state_name];
+        var e = {state: that.state, name: state_name};
+        that.dispatchEvent(new SimpleEvent('change', e));
+        that.dispatchEvent(new SimpleEvent(state_name, e));
+    };
+    emit('init');
+    if(!!_document.body) {
+        emit('load');
+    } else {
+        utils.attachEvent('load', function() {
+            emit('load');
+        });
+    }
+    utils.attachEvent('beforeunload', function() {
+        emit('beforeunload');
+    });
+    utils.attachEvent('unload', function() {
+        emit('unload');
+    });
+};
+
+DocumentGuard.prototype = new REventTarget();
+DocumentGuard.init = 0;
+DocumentGuard.load = 1;
+DocumentGuard.beforeunload = 2;
+DocumentGuard.unload = 3;
+
+var _document_guard = new DocumentGuard();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list