Author: jkuhnert
Date: Mon Aug 27 10:33:10 2007
New Revision: 570190

URL: http://svn.apache.org/viewvc?rev=570190&view=rev
Log:
Various javascript form input hell related to making things work nicer in 
safari / ie.

Modified:
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
    
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/css/timetracker.css
    
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html?rev=570190&r1=570189&r2=570190&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html 
(original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html 
Mon Aug 27 10:33:10 2007
@@ -57,7 +57,7 @@
 
 <a jwcid="@DirectLink" listener="listener:showDialog" 
updateComponents="testDialog">Show Dialog</a><br/>
 
-<div jwcid="[EMAIL PROTECTED]" hidden="ognl:dlHidden" >
+<div jwcid="[EMAIL PROTECTED]" hidden="ognl:dlHidden" class="dialog">
     <p style="display:block;background:#ffffff;width:20em;">
         This is content hidden in a Dialog.
 

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/css/timetracker.css
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/css/timetracker.css?rev=570190&r1=570189&r2=570190&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/css/timetracker.css
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/css/timetracker.css
 Mon Aug 27 10:33:10 2007
@@ -90,3 +90,12 @@
     clear:both;
     width:95%;
 }
+
+.dialog, .dojoDialog {
+    margin-left: 9%;
+    margin-right: 9%;
+    display: block;
+    position: absolute;
+    padding: 0.2em;
+    background-color: #ffffff;
+}

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js?rev=570190&r1=570189&r2=570190&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
 Mon Aug 27 10:33:10 2007
@@ -22,8 +22,9 @@
     dropdownNode:null, // drop down div container
     bgIframe:null,
     options:[], // option div nodes
-    dropdownPositioned:false,
     showing:false,
+    preventBlur:false,
+    hasFocus:false,
 
     postCreate: function() {
         this.inputNode = dojo.byId(this.inputNodeId);
@@ -68,18 +69,22 @@
 
         dojo.body().appendChild(this.dropdownNode);
 
-        if (dojo.render.html.ie){
+        if(dojo.render.html.ie55||dojo.render.html.ie60){
             this.bgIframe = new dojo.html.BackgroundIframe();
             this.bgIframe.setZIndex(this.dropdownNode);
         }
         
         dojo.event.connect(this.inputNode, "onclick", this, "onInputClick");
-        dojo.event.connect(this.inputNode, "onblur", this, "hide");
+        dojo.event.connect(this.inputNode, "onblur", this, "onInputBlur");
+
+        dojo.event.connect(this.dropdownNode, "onmouseover", this, 
"onDropdownMouseOver");
+        dojo.event.connect(this.dropdownNode, "onmouseout", this, 
"onDropdownMouseOut");
         
         dojo.event.connect(dojo.body(), "onkeyup", this, "onKeyUp");
     },
 
     onOptionMouseOver: function(evt) {
+        this.preventBlur=true;
         if (!dojo.html.hasClass(evt.target, this.optionHoverClass)) {
             dojo.html.addClass(evt.target, this.optionHoverClass);
         }
@@ -106,7 +111,9 @@
             this.hide();
             return;
         }
-        
+
+        this.hasFocus=true;
+        this.preventBlur=true;
         this.show();
 
         if (this.selectedNode){
@@ -114,6 +121,30 @@
         }
     },
 
+    onInputBlur: function(evt) {
+        this.hasFocus=false;
+        if (this.preventBlur){
+            return;
+        }
+
+        this.hide();
+    },
+
+    onDropdownMouseOver: function(evt) {
+        this.preventBlur=true;
+    },
+
+    onDropdownMouseOut: function(evt) {
+        this.preventBlur=false;
+
+        if (this.isWidgetNode(evt["relatedTarget"])){
+            return;
+        }
+        if (!this.hasFocus){
+            this.hide(evt);
+        }
+    },
+
     onKeyUp: function(evt) {
         if (evt.keyCode == evt.KEY_ESCAPE) {
             this.hide(evt);
@@ -122,21 +153,20 @@
 
     hide: function(evt) {
         dojo.html.hide(this.dropdownNode);
-        
+
         if (this.bgIframe){
             this.bgIframe.hide();
         }
 
+        this.hasFocus=false;
+        this.preventBlur=false;
         this.showing=false;
     },
 
     show: function(evt) {
-        if (!this.dropdownPositioned){
-            dojo.html.placeOnScreenAroundElement(this.dropdownNode, 
this.inputNode,
-                                            null, 
dojo.html.boxSizing.BORDER_BOX,
-                                            {'BL': 'TL', 'TL': 'BL'});
-            this.dropdownPositioned = true;
-        }
+
+        dojo.html.placeOnScreenAroundElement(this.dropdownNode, this.inputNode,
+                null, dojo.html.boxSizing.BORDER_BOX, {'BL': 'TL', 'TL': 
'BL'});
 
         dojo.html.show(this.dropdownNode);
         
@@ -148,14 +178,24 @@
         this.showing=true;
     },
 
+    isWidgetNode: function(node){
+        if (!node){return false;}
+        
+        return dojo.html.hasClass(node, this.dropdownOptionClass)
+            || dojo.html.hasClass(node, this.dropdownClass);
+    },
+
     destroyRendering: function(finalize){
         try{
             dojo.widget.HtmlWidget.prototype.destroyRendering.call(this, 
finalize);
 
             dojo.event.disconnect(this.inputNode, "onclick", this, 
"onInputClick");
-            dojo.event.disconnect(this.inputNode, "onblur", this, "hide");
+            dojo.event.disconnect(this.inputNode, "onblur", this, 
"onInputBlur");
             dojo.event.browser.clean(this.inputNode);
-            
+
+            dojo.event.disconnect(this.dropdownNode, "onmouseover", this, 
"onDropdownMouseOver");
+            dojo.event.disconnect(this.dropdownNode, "onmouseout", this, 
"onDropdownMouseOut");
+
             dojo.dom.destroyNode(this.dropdownNode);
             delete this.dropdownNode;
 


Reply via email to