Author: jmorliaguet
Date: Sun Jun  4 00:35:54 2006
New Revision: 3297

Modified:
   cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js

Log:

- more optimizations 



Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js
==============================================================================
--- cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    
(original)
+++ cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    Sun Jun 
 4 00:35:54 2006
@@ -51,7 +51,6 @@
   _defs: $H({}),
 
   init: function() {
-    CPSSkins._setup();
     CPSSkins._parse(document);
   },
 
@@ -154,9 +153,7 @@
     var publisher = event.publisher;
     (subscribers[eventid] || []).findAll(function(e) {
       if (event == undefined) return true;
-      if (event.scope != undefined) {
-        if (event.scope != e.scope) return false;
-      }
+      if ((event.scope != undefined) && (event.scope != e.scope)) return false;
       return (CPSSkins.compare(event.subscriber, e.subscriber) &&
               CPSSkins.compare(event.publisher, e.publisher))
     }).each(function(e) {
@@ -172,7 +169,7 @@
 
   registerEventHandler: function(eventid, subscriber, handler) {
     var handlers = subscriber._handlers;
-    if (!handlers) {
+    if (handlers == undefined) {
       subscriber._handlers = new Object();
     }
     subscriber._handlers[eventid] = handler;
@@ -184,9 +181,6 @@
 
   /* Document parsing */
 
-  _setup: function() {
-  },
-
   _jsonParse: function(el, text) {
     var res = {};
     try {
@@ -241,7 +235,7 @@
       } else {
         /* the definition is written inline */
         CPSSkins._eval(el, el.innerHTML);
-        el.innerHTML = '';
+        el.innerHTML = null;
         CPSSkins.notify('initialized', {publisher: el, scope: progress});
       }
     });
@@ -262,7 +256,7 @@
     var elements = $A(node.getElementsByTagName("ins"));
     ["view", "controller", "model"].each(function(type) {
       elements.each(function(el) {
-        if ($(el).hasClassName(type)) {
+        if (el.hasClassName(type)) {
           CPSSkins._register(node, el, type);
         }
       });
@@ -796,21 +790,20 @@
     }
     var widget = view.widget;
 
+    var getElements = document.getElementsByClassName;
+
     var shifting = this.def.shifting;
     if (shifting) {
       if (shifting.element) {
-        this._shiftablezones = document.getElementsByClassName(
-                               shifting.element, widget)
+        this._shiftablezones = getElements(shifting.element, widget);
       }
       if (shifting.container) {
-        this._containerzones = document.getElementsByClassName(
-                               shifting.container, widget)
+        this._containerzones = getElements(shifting.container, widget)
       }
     }
     if (this.def.dropping) {
       if (this.def.dropping.target) {
-        this._dropzones = document.getElementsByClassName(
-                          this.def.dropping.target, widget)
+        this._dropzones = getElements(this.def.dropping.target, widget)
       }
     }
 
@@ -2194,12 +2187,13 @@
       var options = {
         method: "post",
         onComplete: function(req) {
-          var text = req.responseText;
-          if (widget.innerHTML != text) {
-            widget.innerHTML = text;
+          var old_html = widget.innerHTML;
+          widget.innerHTML = req.responseText;
+          if (widget.innerHTML != old_html) {
+            view.detachControllers();
+            CPSSkins._parse(widget);
+            view.attachControllers();
           }
-          view.detachControllers();
-          CPSSkins._parse(widget);
         }
       };
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to