Author: jcompagner
Date: Mon Jun 22 08:55:20 2009
New Revision: 787169

URL: http://svn.apache.org/viewvc?rev=787169&view=rev
Log:
from 1.3: more fixes for auto compleet (IE and so on)

Modified:
    wicket/trunk/wicket-extensions/   (props changed)
    
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:append = true

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:label = Jira Issue:

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:message = Issue: WICKET-%BUGID%

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:url = https://issues.apache.org/jira/browse/WICKET-%BUGID%

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
    bugtraq:warnifnoissue = false

Propchange: wicket/trunk/wicket-extensions/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun 22 08:55:20 2009
@@ -1,3 +1,3 @@
-/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions:659248,661657,662360,677853,688992,698612,700502,701879,725634,760368,769440,772653
+/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions:659248,661657,662360,677853,688992,698612,700502,701879,725634,760368,769440,772653,786424
 
/wicket/sandbox/jthomerson/experimental/wicket-devutils/wicket-extensions:760296-760351,760353-760355
 /wicket/trunk/wicket-devutils/wicket-extensions:760352

Modified: 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js?rev=787169&r1=787168&r2=787169&view=diff
==============================================================================
--- 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
 (original)
+++ 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
 Mon Jun 22 08:55:20 2009
@@ -53,9 +53,7 @@
        var objonchange;
        var objonchangeoriginal;
        
-       // holds the eventual margins, padding, etc. of the menu container.
-       // it is computed when the menu is first rendered, and then reused.
-       var initialDelta = -1;
+      var ignoreOneFocusGain = false; // on FF, clicking an option in the 
popup would make field loose focus; focus() call only has effect in FF after 
popup is hidden, so the re-focusing must not show popup again in this case
 
        // holds a throttler, for not sending many requests if the user types
        // too quickly.
@@ -90,6 +88,7 @@
                 
        obj.onblur=function(event){                     
                if(mouseactive==1){
+                  ignoreOneFocusGain = true;
                        Wicket.$(elementId).focus();
                        return killEvent(event);
                }
@@ -99,13 +98,14 @@
        
        obj.onfocus=function(event){
                        if (mouseactive==1) return killEvent(event);
-            if (cfg.showListOnFocusGain) {
+            if (!ignoreOneFocusGain && cfg.showListOnFocusGain) {
                 if (cfg.showCompleteListOnFocusGain) {
                     updateChoices(true);
                 } else {
                     updateChoices();
                 }
             }
+            ignoreOneFocusGain = false;
                if(typeof objonfocus=="function")objonfocus.apply(this,[event]);
         }
 
@@ -121,9 +121,7 @@
                    if(Wicket.Browser.isSafari())return killEvent(event);
                        break;
                 case KEY_DOWN:
-                               if(selected<elementCount-1){
-                           selected++;
-                       }
+                               if(selected<elementCount-1) selected++;
                    if(visible==0){
                            updateChoices();
                    } else {
@@ -326,15 +324,16 @@
     }
 
         function getPosition(obj) {
-        var leftPosition=0;
-        var topPosition=0;
-        do {
+        var leftPosition = obj.offsetLeft || 0;
+        var topPosition = obj.offsetTop || 0;
+        obj = obj.offsetParent;
+        while (obj && obj != document.documentElement && obj != document.body) 
{
             topPosition += obj.offsetTop || 0;
                topPosition -= obj.scrollTop || 0;
             leftPosition += obj.offsetLeft || 0;
                leftPosition -= obj.scrollLeft || 0;
             obj = obj.offsetParent;
-        } while (obj);
+        }
  
         return [leftPosition,topPosition];
     }
@@ -363,9 +362,15 @@
                                if (typeof objonchange=="function") 
{objonchange.apply(wicketGet(elementId), [event]);}
                        }
                        hideAutoComplete();
+                if (Wicket.Focus.getFocusedElement() != input)
+                {
+                    ignoreOneFocusGain = true;
+                    input.focus();
+                }
                };
                        
                var mouseOverFunc = function(event){
+                mouseactive=1; // Opera needs this as mousemove for menu is 
not always triggered
                        selected = getElementIndex(this);
                        render();
                        showAutoComplete();
@@ -457,18 +462,17 @@
                        if (classNames != origClassNames)
                 node.className = classNames;
        
-                       if ((cfg.maxHeight > -1) && (height < cfg.maxHeight))
+                       if (cfg.maxHeight > -1)
                                height+=node.offsetHeight;
        
                        node = node.nextSibling;
                }
         if (cfg.maxHeight > -1) {
-                       // If we don't exceed the maximum size, we add the 
extra space 
-                       // that may be there due to padding, margins, etc.
-                       if (initialDelta == -1)
-                               initialDelta = menu.parentNode.offsetHeight - 
height;
-               height = height<cfg.maxHeight ? height+initialDelta : 
cfg.maxHeight;
-               menu.parentNode.style.height=height+"px";
+               if (height<cfg.maxHeight) {
+                menu.parentNode.style.height="auto";
+            } else {
+                   menu.parentNode.style.height=cfg.maxHeight+"px";
+            }
         }
     }
     


Reply via email to