includes/clientside/static/autofill.js
changeset 266 917dcc6c4ceb
parent 263 d57af0b0302e
child 367 ee4defc9321a
equal deleted inserted replaced
265:7e0cdf71b1bb 266:917dcc6c4ceb
     1 /**
     1 /**
     2  * Javascript auto-completion for form fields.
     2  * Javascript auto-completion for form fields. This supercedes the code in autocomplete.js for MOZILLA ONLY. It doesn't seem to work real
       
     3  * well with other browsers yet.
     3  */
     4  */
     4  
     5  
     5 var af_current = false;
     6 var af_current = false;
     6  
     7  
     7 function AutofillUsername(parent, event, allowanon)
     8 function AutofillUsername(parent, event, allowanon)
   243         {
   244         {
   244           // user hit enter after accepting a suggestion - submit the form
   245           // user hit enter after accepting a suggestion - submit the form
   245           form._af_acting = false;
   246           form._af_acting = false;
   246           return true;
   247           return true;
   247         }
   248         }
   248       }
   249         else
   249       form._af_acting = true;
   250         {
       
   251           form._af_acting = true;
       
   252           return true;
       
   253         }
       
   254       }
   250     }
   255     }
   251   }
   256   }
   252   
   257   
   253   this.keyhandler = function()
   258   this.keyhandler = function()
   254   {
   259   {
   255     var key = this.event.keyCode;
   260     var key = this.event.keyCode;
   256     if ( key == this.KEY_ENTER && !this.repeat )
   261     if ( key == this.KEY_ENTER && !this.repeat )
   257     {
   262     {
       
   263       submitAuthorized = true;
   258       var form = findParentForm($(this.field_id).object);
   264       var form = findParentForm($(this.field_id).object);
   259         form._af_acting = false;
   265       form._af_acting = false;
   260       return true;
   266       return true;
   261     }
   267     }
   262     switch(key)
   268     switch(key)
   263     {
   269     {
   264       case this.KEY_UP:
   270       case this.KEY_UP:
   418       var div = document.getElementById(this.boxes[i]);
   424       var div = document.getElementById(this.boxes[i]);
   419       if ( div )
   425       if ( div )
   420         setTimeout('var body = document.getElementsByTagName("body")[0]; var div = document.getElementById("'+div.id+'"); if ( div ) body.removeChild(div);', 20);
   426         setTimeout('var body = document.getElementsByTagName("body")[0]; var div = document.getElementById("'+div.id+'"); if ( div ) body.removeChild(div);', 20);
   421       delete(this.boxes[i]);
   427       delete(this.boxes[i]);
   422     }
   428     }
       
   429     this.boxes = new Array();
   423     this.box_id = false;
   430     this.box_id = false;
   424     this.state = false;
   431     this.state = false;
   425   }
   432   }
   426   
   433   
   427   this.set = function(val)
   434   this.set = function(val)
   430     if ( val )
   437     if ( val )
   431       ta.value = val;
   438       ta.value = val;
   432     else if ( this.state )
   439     else if ( this.state )
   433       ta.value = this.state;
   440       ta.value = this.state;
   434     this.destroy();
   441     this.destroy();
       
   442     findParentForm($(this.field_id.object))._af_acting = false;
   435   }
   443   }
   436   
   444   
   437   this.sleep = function()
   445   this.sleep = function()
   438   {
   446   {
   439     if ( this.box_id )
   447     if ( this.box_id )