Author: jmorliaguet
Date: Sat Jan  7 16:16:28 2006
New Revision: 2184

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

- example of a contextual menu observing a "non-contextual" model.
  (when "observe" is explicitly specified)



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 Sat Jan  7 
16:16:28 2006
@@ -684,7 +684,10 @@
     Canvas.moveTo(widget, x, y);
     Canvas.fitInsideScreen(widget);
 
-    CPSSkins.addObserver(selected, this);
+    // TODO: move this elsewhere
+    if (!this.tag.getAttribute("observe")) {
+      CPSSkins.addObserver(selected, this);
+    }
 
     new CPSSkins.Scheduler(widget, {
       action: function(value) {

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html
        Sat Jan  7 16:16:28 2006
@@ -13,6 +13,11 @@
   <link rel="stylesheet" href="../../cpsskins.css" type="text/css" />
 
   <style type="text/css">
+    h2 {
+      border-bottom: 1px solid #ccc;
+      margin-top: 1.5em;
+    }
+
     #data-provider {
       border: 1px solid orange;
       padding: 0.7em;
@@ -22,6 +27,14 @@
       cursor: default;
     }
 
+    #info {
+      background-color: #ffc;
+      border: 1px solid orange;
+      padding: 1em;
+      width: 120px;
+      cursor: default;
+    }
+
     .counter {
       font-size: 2em;
       width: 460px;
@@ -42,7 +55,7 @@
 
     function start() {
       if (timer) return;
-      timer = setInterval("updateModel()", 100);
+      timer = setInterval("updateModel()", 250);
     }
 
     function stop() {
@@ -112,17 +125,17 @@
     "sizeinfo": [{"choice":"", "label":""}]
   }
   -->
-  <div id="data-provider">DATA PROVIDER</div>
-
-  <!-- tooltip view -->
-  <cpsskins:view widget="tooltip" showdelay="1500"></cpsskins:view>
-
-  <!-- contextual menu view -->
-  <cpsskins:view widget="contextmenu">
-    <submenu label="Size info">
-      <items choices="sizeinfo"></items>
-    </submenu>
-  </cpsskins:view>
+  <div id="data-provider">DATA PROVIDER
+    <!-- tooltip view -->
+    <cpsskins:view widget="tooltip" showdelay="1500"></cpsskins:view>
+
+    <!-- contextual menu view -->
+    <cpsskins:view widget="contextmenu">
+      <submenu label="Size info">
+        <items choices="sizeinfo"></items>
+      </submenu>
+    </cpsskins:view>
+  </div>
 
   <h2>progress bar widget</h2>
   <cpsskins:view widget="progressbar" observe="data-provider"></cpsskins:view>
@@ -130,8 +143,19 @@
   <h2>counter widget</h2>
   <cpsskins:view widget="counter" observe="data-provider"></cpsskins:view>
 
-  <button onclick="start()">START</button>
-  <button onclick="stop()">STOP</button>
+  <h2>menu widget</h2>
+  <div id="info">
+    Info
+    <!-- menu view observing the data provider -->
+    <cpsskins:view widget="contextmenu" observe="data-provider">
+      <items choices="sizeinfo"></items>
+    </cpsskins:view>
+  </div>
+
+  <p>
+    <button onclick="start()">START</button>
+    <button onclick="stop()">STOP</button>
+  </p>
 
 </body>
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to