[KSS-checkins] r42286 - kukit/kukit.js/trunk/kukit

gotcha at codespeak.net gotcha at codespeak.net
Tue Apr 24 17:36:09 CEST 2007


Author: gotcha
Date: Tue Apr 24 17:36:08 2007
New Revision: 42286

Modified:
   kukit/kukit.js/trunk/kukit/plugin.js
Log:
add withKssSetup parameter to commands that insert nodes.

It is True by default.
Setting it to False will avoid the setup of KSS rules on newly inserted nodes.
This allow to improve performance when the developer knows no ajax is needed on
inserted nodes.


Modified: kukit/kukit.js/trunk/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/plugin.js	(original)
+++ kukit/kukit.js/trunk/kukit/plugin.js	Tue Apr 24 17:36:08 2007
@@ -422,19 +422,22 @@
 /*
 *  accepts both string and dom.
 */
-    oper.completeParms(['html'], {},
+    oper.completeParms(['html'], {'withKssSetup':true},
                        'replaceInnerHTML action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     var node = oper.node;
-    var inserted;
+    var insertedNodes;
     if (typeof(oper.parms.html) == 'string') {
         node.innerHTML = oper.parms.html;
-        inserted = node.childNodes; 
+        insertedNodes = node.childNodes; 
     } else {
         oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
         kukit.dom.clearChildNodes(node);
-        inserted = kukit.dom.appendChildren(oper.parms.html.childNodes, node);
+        insertedNodes = kukit.dom.appendChildren(oper.parms.html.childNodes, node);
+    }
+    if (oper.parms.withKssSetup) {
+        kukit.engine.setupEvents(insertedNodes);
     }
-    kukit.engine.setupEvents(inserted);
 });
 kukit.commandsGlobalRegistry.registerFromAction('replaceInnerHTML', kukit.cr.makeSelectorCommand);
 
@@ -442,7 +445,8 @@
 /*
 *  accepts both string and dom.
 */
-    oper.completeParms(['html'], {}, 'replaceHTML action');
+    oper.completeParms(['html'], {'withKssSetup':true}, 'replaceHTML action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     var node = oper.node;
     oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
     var elements = oper.parms.html.childNodes;
@@ -460,7 +464,9 @@
             insertedNodes.push(inserted);
             next = inserted;
         }
-        kukit.engine.setupEvents(insertedNodes);
+        if (oper.parms.withKssSetup) {
+            kukit.engine.setupEvents(insertedNodes);
+        }
     }
 });
 kukit.commandsGlobalRegistry.registerFromAction('replaceHTML', kukit.cr.makeSelectorCommand);
@@ -499,7 +505,9 @@
 kukit.commandsGlobalRegistry.registerFromAction('removeClassName', kukit.cr.makeSelectorCommand);
 
 kukit.actionsGlobalRegistry.register('insertHTMLAfter', function(oper) {
-    oper.completeParms(['html'], {}, 'insertHTMLAfter action');
+    oper.completeParms(['html'], {'withKssSetup':true},
+                       'insertHTMLAfter action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
     var content = oper.parms.html;
     var parentNode = oper.node.parentNode;
@@ -512,12 +520,16 @@
     }
     // update the events for the new nodes
     kukit.logDebug("Inserted nodes length: "+inserted.length);
-    kukit.engine.setupEvents(inserted);
+    if (oper.parms.withKssSetup) {
+        kukit.engine.setupEvents(insertedNodes);
+    }
 });
 kukit.commandsGlobalRegistry.registerFromAction('insertHTMLAfter', kukit.cr.makeSelectorCommand);
 
 kukit.actionsGlobalRegistry.register('insertHTMLBefore', function(oper) {
-    oper.completeParms(['html'], {}, 'insertHTMLBefore action');
+    oper.completeParms(['html'], {'withKssSetup':true},
+                       'insertHTMLBefore action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
     var content = oper.parms.html;
     var toNode = oper.node;
@@ -525,23 +537,31 @@
     var inserted = kukit.dom.insertBefore(content, parentNode, toNode);
     // update the events for the new nodes
     kukit.logDebug("Inserted nodes length: "+inserted.length);
-    kukit.engine.setupEvents(inserted);
+    if (oper.parms.withKssSetup) {
+        kukit.engine.setupEvents(insertedNodes);
+    }
 });
 kukit.commandsGlobalRegistry.registerFromAction('insertHTMLBefore', kukit.cr.makeSelectorCommand);
 
 kukit.actionsGlobalRegistry.register('insertHTMLAsLastChild', function(oper) {
-    oper.completeParms(['html'], {}, 'insertHTMLAsLastChild action');
+    oper.completeParms(['html'], {'withKssSetup':true},
+                       'insertHTMLAsLastChild action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
     var inserted = kukit.dom.appendChildren(oper.parms.html, oper.node);
     inserted = kukit.dom.appendChildren(oper.parms.html.childNodes, oper.node);
     // update the events for the new nodes
     kukit.logDebug("Inserted nodes length: "+inserted.length);
-    kukit.engine.setupEvents(inserted);
+    if (oper.parms.withKssSetup) {
+        kukit.engine.setupEvents(insertedNodes);
+    }
 });
 kukit.commandsGlobalRegistry.registerFromAction('insertHTMLAsLastChild', kukit.cr.makeSelectorCommand);
 
 kukit.actionsGlobalRegistry.register('insertHTMLAsFirstChild', function(oper) {
-    oper.completeParms(['html'], {}, 'insertHTMLAsFirstChild action');
+    oper.completeParms(['html'], {'withKssSetup':true},
+                       'insertHTMLAsFirstChild action');
+    oper.evalBool('withKssSetup', 'setup events on inserted nodes');
     oper.parms.html = kukit.dom.forceToDom(oper.parms.html);
     var content = oper.parms.html;
     var parentNode = oper.node;
@@ -553,7 +573,9 @@
     }
     // update the events for the new nodes
     kukit.logDebug("Inserted nodes length: "+inserted.length);
-    kukit.engine.setupEvents(inserted);
+    if (oper.parms.withKssSetup) {
+        kukit.engine.setupEvents(insertedNodes);
+    }
 });
 kukit.commandsGlobalRegistry.registerFromAction('insertHTMLAsFirstChild', kukit.cr.makeSelectorCommand);
 


More information about the Kukit-checkins mailing list