Fix annoying bug with mwsuggest that makes it shown suggestions after search box...
authorRobert Stojnić <rainman@users.mediawiki.org>
Mon, 4 May 2009 21:07:18 +0000 (21:07 +0000)
committerRobert Stojnić <rainman@users.mediawiki.org>
Mon, 4 May 2009 21:07:18 +0000 (21:07 +0000)
Introduce additional attribute that tells the suggestion container that it should stay hidden.

includes/DefaultSettings.php
skins/common/mwsuggest.js

index fc6424e..bd71fc5 100644 (file)
@@ -1477,7 +1477,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '217';
+$wgStyleVersion = '218';
 
 
 # Server-side caching:
index 061a645..503c739 100644 (file)
@@ -78,6 +78,7 @@ function os_Results(name, formname){
        this.containerRow = 0; // height of result field in the container
        this.containerTotal = 0; // total height of the container will all results
        this.visible = false; // if container is visible
+       this.stayHidden = false; // don't try to show if lost focus
 }
 
 /** Hide results div */
@@ -93,6 +94,8 @@ function os_hideResults(r){
 function os_showResults(r){
        if(os_is_stopped)
                return;
+       if(r.stayHidden)
+               return
        os_fitContainer(r);
        var c = document.getElementById(r.container);
        r.selected = -1;
@@ -442,6 +445,7 @@ function os_delayedFetch(){
 /** Init timed update via os_delayedUpdate() */
 function os_fetchResults(r, query, timeout){
        if(query == ""){
+               r.query = "";
                os_hideResults(r);
                return;
        } else if(query == r.query)
@@ -622,13 +626,19 @@ function os_eventBlur(e){
        var r = os_map[targ.id];
        if(r == null)
                return; // not our event
-       if(!os_mouse_pressed)
+       if(!os_mouse_pressed){
                os_hideResults(r);
+               r.stayHidden = true
+       }
 }
 
 /** Event: focus (catch only when stopped) */
 function os_eventFocus(e){
-       // nothing happens here?
+       var targ = os_getTarget(e);
+       var r = os_map[targ.id];
+       if(r == null)
+               return; // not our event
+       r.stayHidden = false
 }