[KSS-checkins] r49583 - kukit/kukit.js/branch/finish-closures/kukit

gotcha at codespeak.net gotcha at codespeak.net
Sun Dec 9 20:49:15 CET 2007


Author: gotcha
Date: Sun Dec  9 20:49:15 2007
New Revision: 49583

Modified:
   kukit/kukit.js/branch/finish-closures/kukit/dom.js
Log:
class closure

Modified: kukit/kukit.js/branch/finish-closures/kukit/dom.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/dom.js	(original)
+++ kukit/kukit.js/branch/finish-closures/kukit/dom.js	Sun Dec  9 20:49:15 2007
@@ -299,6 +299,20 @@
 };
 
 /*
+* From http://xkr.us/articles/dom/iframe-document/
+* Note it's not necessary for the iframe to have the name
+* attribute since we don't access it from window.frames by name.
+*/
+var _getIframeDocument = function(framename) {
+    var iframe = document.getElementById(framename);
+    var doc = iframe.contentWindow || iframe.contentDocument;
+    if (doc.document) {
+        doc = doc.document;
+    }
+    return doc;
+};
+
+/*
 *  class EmbeddedContentLoadedScheduler
 *
 *  Scheduler for embedded window content loaded
@@ -317,87 +331,73 @@
     //this.counter.timeout();
     // XXX can't execute immediately, it fails on IE.
     this.counter.start();
-};
 
-/*
-* From http://xkr.us/articles/dom/iframe-document/
-* Note it's not necessary for the iframe to have the name
-* attribute since we don't access it from window.frames by name.
-*/
-var _getIframeDocument = function(framename) {
-    var iframe = document.getElementById(framename);
-    var doc = iframe.contentWindow || iframe.contentDocument;
-    if (doc.document) {
-        doc = doc.document;
-    }
-    return doc;
-};
-
-dom.EmbeddedContentLoadedScheduler.prototype.check = function() {
-    
-;;;kukit.logDebug('Is iframe loaded ?');
-    
-    var doc = _getIframeDocument(this.framename);
-
-    // quit if the init function has already been called
-    // XXX I believe we want to call the function too, then
-    // XXX attribute access starting with _ breaks full compression,
-    // even in strings
-    //if (doc._embeddedContentLoadedInitDone) {
-    if (doc['_' + 'embeddedContentLoadedInitDone']) {
-;;;    var msg = 'Iframe already initialized, but we execute the action';
-;;;    msg += ' anyway, as requested.';
-;;;    kukit.logWarning(msg);
-        this.counter.restart = false;
-    }
-
-    // autodetect=false implements a more reliable detection method
-    // that involves cooperation from the internal document. In this
-    // case the internal document sets the _kssReadyForLoadEvent attribute
-    // on the document, when loaded. It is safe to check for this in any 
-    // case, however if this option is selected, we rely only on this, 
-    // and skip the otherwise problematic default checking.
-    // XXX attribute access starting with _ breaks full compression,
-    // even in strings
-    //if (typeof doc._kssReadyForLoadEvent != 'undefined') {
-    if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') {
-        this.counter.restart = false;
-    } 
-
-    if (this.autodetect && this.counter.restart) {
-
-        // obviously we are not there... this happens on FF
-        if (doc.location.href == 'about:blank') {
-            return;
-        } /* */
+    this.check = function() {
         
-        // First check for Safari or
-        // if DOM methods are supported, and the body element exists
-        // (using a double-check including document.body,
-        // for the benefit of older moz builds [eg ns7.1] 
-        // in which getElementsByTagName('body')[0] is undefined,
-        // unless this script is in the body section)
+;;;    kukit.logDebug('Is iframe loaded ?');
         
-        if(/KHTML|WebKit/i.test(navigator.userAgent)) {
-            if(/loaded|complete/.test(doc.readyState)) {
-                this.counter.restart = false;
-            }
-        } else if(typeof doc.getElementsByTagName != 'undefined'
-            && (doc.getElementsByTagName('body')[0] != null ||
-                doc.body != null)) {
-            this.counter.restart = false;
-        } /* */
+        var doc = _getIframeDocument(this.framename);
 
-    }
+        // quit if the init function has already been called
+        // XXX I believe we want to call the function too, then
+        // XXX attribute access starting with _ breaks full compression,
+        // even in strings
+        //if (doc._embeddedContentLoadedInitDone) {
+        if (doc['_' + 'embeddedContentLoadedInitDone']) {
+;;;        var msg = 'Iframe already initialized, but we execute the action';
+;;;        msg += ' anyway, as requested.';
+;;;        kukit.logWarning(msg);
+            this.counter.restart = false;
+        }
 
-    if ( ! this.counter.restart) {
-;;;    kukit.logDebug('Yes, iframe is loaded.');
+        // autodetect=false implements a more reliable detection method
+        // that involves cooperation from the internal document. In this
+        // case the internal document sets the _kssReadyForLoadEvent attribute
+        // on the document, when loaded. It is safe to check for this in any 
+        // case, however if this option is selected, we rely only on this, 
+        // and skip the otherwise problematic default checking.
         // XXX attribute access starting with _ breaks full compression,
         // even in strings
-        // doc._embeddedContentLoadedInitDone = true;
-        doc['_' + 'embeddedContentLoadedInitDone'] = true;
-        this.func();
-    }
+        //if (typeof doc._kssReadyForLoadEvent != 'undefined') {
+        if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') {
+            this.counter.restart = false;
+        } 
+
+        if (this.autodetect && this.counter.restart) {
+
+            // obviously we are not there... this happens on FF
+            if (doc.location.href == 'about:blank') {
+                return;
+            } /* */
+            
+            // First check for Safari or
+            // if DOM methods are supported, and the body element exists
+            // (using a double-check including document.body,
+            // for the benefit of older moz builds [eg ns7.1] 
+            // in which getElementsByTagName('body')[0] is undefined,
+            // unless this script is in the body section)
+            
+            if(/KHTML|WebKit/i.test(navigator.userAgent)) {
+                if(/loaded|complete/.test(doc.readyState)) {
+                    this.counter.restart = false;
+                }
+            } else if(typeof doc.getElementsByTagName != 'undefined'
+                && (doc.getElementsByTagName('body')[0] != null ||
+                    doc.body != null)) {
+                this.counter.restart = false;
+            } /* */
+
+        }
+
+        if ( ! this.counter.restart) {
+;;;        kukit.logDebug('Yes, iframe is loaded.');
+            // XXX attribute access starting with _ breaks full compression,
+            // even in strings
+            // doc._embeddedContentLoadedInitDone = true;
+            doc['_' + 'embeddedContentLoadedInitDone'] = true;
+            this.func();
+        }
+    };
 };
 
 dom.getNsTags = function(dom_obj, tagName) {


More information about the Kukit-checkins mailing list