Author: jmorliaguet
Date: Wed Dec 28 18:02:35 2005
New Revision: 2093

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

- simpler registration of tooltips: the <cpsskins:tooltip> tag is used to define
  the area in which the widget is active.

- the tooltip 'hint' is obtained from CDATA
  


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 Wed Dec 28 
18:02:35 2005
@@ -53,7 +53,7 @@
     controllers[id] = this;
   },
 
-  add: function(handlers) {
+  register: function(handlers) {
     Object.extend(this.handlers, handlers);
   }
 
@@ -150,6 +150,12 @@
       }
     }
     return null;
+  },
+
+  addWidget: function(element){
+    body = document.getElementsByTagName('body');
+    if (!body.length) return;
+    body[0].appendChild(element);
   }
 
 });
@@ -189,14 +195,14 @@
 
   tooltip: function(node) {
     var tooltip = document.createElement('div');
-    Element.addClassName(tooltip, node.getAttribute('class'))
+    Element.addClassName(tooltip, 'tooltip')
     tooltip.style.position = 'absolute';
     tooltip.style.display = 'none';
-    node.parentNode.replaceChild(tooltip, node)
-    var area = node.getAttribute('area');
     var options = {
       delay: node.getAttribute('delay') || 1000,
     }
+    var area = node.parentNode;
+    Canvas.addWidget(tooltip);
     new CPSSkins.Tooltip(tooltip, area, options);
   }
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_tooltip.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_tooltip.html
      (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_tooltip.html
      Wed Dec 28 18:02:35 2005
@@ -8,6 +8,7 @@
   <title>CPSSkins Unit test file</title>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <script src="../../prototype.js" type="text/javascript"></script>
+  <script src="../../json.js" type="text/javascript"></script>
   <script src="../../cpsskins.js" type="text/javascript"></script>
   <link rel="stylesheet" href="tooltip.css" type="text/css" />
 </head>
@@ -16,26 +17,38 @@
   <h1>CPSSkins tooltip</h1>
 
   <div id="area1">
-    <a href="#" hint="Click here to open.">Open</a>
-    <a href="#" hint="Click here to save.">Save</a>
-    <a href="#" hint="Click here to close.">Close</a>
-    <p>Delay: 1.5s</p>
-  </div>
 
-  <div id="area2">
-    <a href="#" hint="Click here to open.">Open</a>
-    <a href="#" hint="Click here to save.">Save</a>
-    <a href="#" hint="Click here to close.">Close</a>
+    <![CDATA[{"hint":"Click here to open."}]]>
+    <a href="#">Open</a>
+
+    <![CDATA[{"hint":"Click here to save."}]]>
+    <a href="#">Save</a>
+
+    <![CDATA[{"hint":"Click here to close."}]]>
+    <a href="#">Close</a>
+
+    <cpsskins:tooltip delay="100">
+    </cpsskins:tooltip>
+
     <p>Delay: 100ms</p>
   </div>
 
-  <cpsskins:tooltip area="area1" delay="1500">
-    <div class="tooltip1">%(hint)</div>
-  </cpsskins:tooltip>
-
-  <cpsskins:tooltip area="area2" delay="100">
-    <div class="tooltip2">%(hint)</div>
-  </cpsskins:tooltip>
+  <div id="area2">
+
+    <![CDATA[{"hint":"Click here to open."}]]>
+    <a href="#">Open</a>
+
+    <![CDATA[{"hint":"Click here to save."}]]>
+    <a href="#">Save</a>
+
+    <![CDATA[{"hint":"Click here to close."}]]>
+    <a href="#">Close</a>
+
+    <cpsskins:tooltip delay="1000">
+    </cpsskins:tooltip>
+
+    <p>Delay: 1s</p>
+  </div>
 
 </body>
 </html>

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tooltip.css
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tooltip.css    
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tooltip.css    
    Wed Dec 28 18:02:35 2005
@@ -1,5 +1,5 @@
 
-.tooltip1 {
+.tooltip {
   padding: 0.5em;
   background-color: #ffc;
   border: 1px solid gray;
@@ -7,15 +7,6 @@
   font: 13px verdana, arial, sans-serif;
 }
 
-.tooltip2 {
-  padding: 0.8em;
-  background-color: #f3f3f9;
-  border-width: 1px 2px 2px 1px;
-  border-color: #666;
-  border-style: solid;
-  font: italic 13px arial, sans-serif;
-}
-
 #area1 {
   margin: 1em;
   padding: 2em;
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to