Author: jmorliaguet
Date: Sun Jan  8 14:59:45 2006
New Revision: 2190

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_navpanel_test.html
   cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html
Log:

- moved widget effects to the public API (so far: "fadein")



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sun Jan  8 
14:59:45 2006
@@ -463,6 +463,8 @@
     this.widget = widget;
     this.tag = tag;
 
+    this.effects = (tag.getAttribute("effects") || "").split(",");
+
     var observed = tag.getAttribute("observe");
     if (observed) {
       this.observed = $(observed);
@@ -473,6 +475,7 @@
     this.setup();
   },
 
+  /* Public API */
   setup: function() {
     /* to override: setup the view */
   },
@@ -481,6 +484,15 @@
     /* to override: render the view from the data */
   },
 
+  prepare: function() {
+    /* to override: prepare the widget before showing it */
+  },
+
+  teardown: function() {
+    /* to override: teardown the widget after hiding it */
+  },
+
+  /* Private API */
   getData: function() {
     if (this.observed) {
       return Canvas.getNodeData(this.observed);
@@ -491,6 +503,34 @@
   update: function() {
     var data = this.getData();
     this.render(data);
+  },
+
+  show: function() {
+    if (this.visible) return;
+
+    this.prepare();
+
+    var widget = this.widget;
+    Element.show(widget);
+    if (this.effects.indexOf("fadein") >= 0) {
+      Canvas.setOpacity(widget, 0);
+      new CPSSkins.Scheduler(widget, {
+        action: function(value) {
+          Canvas.setOpacity(widget, value);
+        }
+      });
+    }
+
+    this.visible = true;
+  },
+
+  hide: function() {
+    if (!this.visible) return;
+
+    Element.hide(this.widget);
+    this.visible = false;
+
+    this.teardown();
   }
 
 }
@@ -534,7 +574,6 @@
 
   setup: function() {
     this.visible = false;
-    this.fadein = this.tag.getAttribute("fadein") || false;
     this.url = this.tag.getAttribute("url");
     this.css_id = null;
     this.script_id = null;
@@ -570,34 +609,15 @@
     }
   },
 
-  show: function() {
-    if (this.visible) return;
-
+  prepare: function() {
     var css = this.tag.getAttribute("css");
     if (css) {
       this.css_id = "cpsskins-panel-css" + this.id;
       Canvas.addStyleSheet(this.css_id, css);
     }
-
-    var widget = this.widget;
-    Element.show(widget);
-    if (this.fadein) {
-      Canvas.setOpacity(widget, 0);
-      new CPSSkins.Scheduler(widget, {
-        action: function(value) {
-          Canvas.setOpacity(widget, value);
-        }
-      });
-    }
-    this.visible = true;
   },
 
-  hide: function() {
-    if (!this.visible) return;
-    var widget = this.widget;
-    Element.hide(widget);
-    this.visible = false;
-
+  teardown: function() {
     if (this.css_id) {
       Canvas.removeStyleSheet(this.css_id);
     }

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_navpanel_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_navpanel_test.html
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_navpanel_test.html
        Sun Jan  8 14:59:45 2006
@@ -43,7 +43,8 @@
     href="javascript:CPSSkins.switchPerspective('panels/panel1')">
   PANEL 1</a>
 
-  <cpsskins:view widget="panel"
+  <cpsskins:view
+      widget="panel"
       perspectives="panels/panel1"
       url="panel1.html">
   </cpsskins:view>
@@ -52,7 +53,8 @@
      href="javascript:CPSSkins.switchPerspective('panels/panel2')">
   PANEL 2</a>
 
-  <cpsskins:view widget="panel"
+  <cpsskins:view
+      widget="panel"
       perspectives="panels/panel2"
       url="panel2.html">
   </cpsskins:view>
@@ -61,7 +63,8 @@
     href="javascript:CPSSkins.switchPerspective('panels/panel3')">
   PANEL 3</a>
 
-  <cpsskins:view widget="panel"
+  <cpsskins:view
+      widget="panel"
       perspectives="panels/panel3"
       url="panel3.html">
   </cpsskins:view>
@@ -70,7 +73,8 @@
     href="javascript:CPSSkins.switchPerspective('panels/panel4')">
   PANEL 4</a>
 
-  <cpsskins:view widget="panel"
+  <cpsskins:view
+      widget="panel"
       perspectives="panels/panel4"
       url="panel4.html">
   </cpsskins:view>

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html    
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panel5.html    
    Sun Jan  8 14:59:45 2006
@@ -20,27 +20,42 @@
   <table style="width: 100%; padding:1em">
     <tr>
       <td>
-        <cpsskins:view widget="panel" fadein="true"
-                       perspectives="element-editor/1" url="panel1.html">
+        <cpsskins:view
+            widget="panel"
+            effects="fadein"
+            perspectives="element-editor/1"
+            url="panel1.html">
         </cpsskins:view>
       </td>
       <td>
-        <cpsskins:view widget="panel" fadein="true"
-                        perspectives="element-editor/1" url="panel2.html">
+        <cpsskins:view
+            widget="panel"
+            effects="fadein"
+            perspectives="element-editor/1"
+            url="panel2.html">
         </cpsskins:view>
       </td>
       <td>
-        <cpsskins:view widget="panel" fadein="true"
-                        perspectives="element-editor/2" url="panel3.html">
+        <cpsskins:view
+            widget="panel"
+            effects="fadein"
+            perspectives="element-editor/2"
+            url="panel3.html">
         </cpsskins:view>
       </td>
       <td>
-        <cpsskins:view widget="panel" fadein="true"
-                        perspectives="element-editor/2" url="panel4.html">
+        <cpsskins:view
+            widget="panel"
+            effects="fadein"
+            perspectives="element-editor/2"
+            url="panel4.html">
         </cpsskins:view>
       </td>
       <td>
-        <cpsskins:view widget="panel" perspectives="element-editor/3" 
url="panel6.html">
+        <cpsskins:view
+            widget="panel"
+            perspectives="element-editor/3"
+            url="panel6.html">
         </cpsskins:view>
       </td>
     </tr>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to