includes/clientside/static/autofill.js
changeset 704 077887be639d
parent 701 dd80cde96a6c
child 747 cffe13960330
equal deleted inserted replaced
703:e492511e31ea 704:077887be639d
   150       }
   150       }
   151     
   151     
   152       // Create results
   152       // Create results
   153       var results = document.createElement("div");
   153       var results = document.createElement("div");
   154       $(results).addClass('tblholder').css('z-index', getHighestZ() + 1).css('margin-top', 0);
   154       $(results).addClass('tblholder').css('z-index', getHighestZ() + 1).css('margin-top', 0);
       
   155       $(results).css('clip', 'rect(0px,auto,auto,0px)').css('overflow', 'auto').css('max-height', '300px');
   155     
   156     
   156       // Create jQuery object for results
   157       // Create jQuery object for results
   157       // var $results = $(results);
   158       // var $results = $(results);
   158       var $results = $(results).hide().addClass(options.resultsClass).css("position", "absolute");
   159       var $results = $(results).hide().addClass(options.resultsClass).css("position", "absolute");
   159       if( options.width > 0 ) {
   160       if( options.width > 0 ) {
   239             break;
   240             break;
   240           case 9:  // tab
   241           case 9:  // tab
   241           case 13: // return
   242           case 13: // return
   242             if( selectCurrent() ){
   243             if( selectCurrent() ){
   243               // make sure to blur off the current field
   244               // make sure to blur off the current field
   244               $input.get(0).blur();
   245               // (Enano edit - why do we want this, again?)
       
   246               // $input.get(0).blur();
   245               e.preventDefault();
   247               e.preventDefault();
   246             }
   248             }
   247             break;
   249             break;
   248           default:
   250           default:
   249             active = -1;
   251             active = -1;
   295         }
   297         }
   296     
   298     
   297         lis.removeClass("row2");
   299         lis.removeClass("row2");
   298     
   300     
   299         $(lis[active]).addClass("row2");
   301         $(lis[active]).addClass("row2");
       
   302         
       
   303         // scroll the results div
       
   304         // are we going up or down?
       
   305         var td_top = $dynano(lis[active]).Top() - $dynano(results).Top();
       
   306         var td_height = $dynano(lis[active]).Height();
       
   307         var td_bottom = td_top + td_height;
       
   308         var visibleTopBoundary = getScrollOffset(results);
       
   309         var results_height = $dynano(results).Height();
       
   310         var visibleBottomBoundary = visibleTopBoundary + results_height;
       
   311         var scrollTo = false;
       
   312         console.debug('td top = %d, td height = %d, td bottom = %d, visibleTopBoundary = %d, results_height = %d, visibleBottomBoundary = %d, step = %d',
       
   313                        td_top, td_height, td_bottom, visibleTopBoundary, results_height, visibleBottomBoundary, step);
       
   314         if ( td_top < visibleTopBoundary && step < 0 )
       
   315         {
       
   316           // going up: scroll the results div to just higher than the result we're trying to see
       
   317           scrollTo = td_top - 7;
       
   318         }
       
   319         else if ( td_bottom > visibleBottomBoundary && step > 0 )
       
   320         {
       
   321           // going down is a little harder, we want the result to be at the bottom
       
   322           scrollTo = td_top - results_height + td_height + 7;
       
   323         }
       
   324         if ( scrollTo )
       
   325         {
       
   326           console.debug('scrolling the results div to %d', scrollTo);
       
   327           results.scrollTop = scrollTo;
       
   328         }
   300     
   329     
   301         // Weird behaviour in IE
   330         // Weird behaviour in IE
   302         // if (lis[active] && lis[active].scrollIntoView) {
   331         // if (lis[active] && lis[active].scrollIntoView) {
   303         // 	lis[active].scrollIntoView(false);
   332         // 	lis[active].scrollIntoView(false);
   304         // }
   333         // }
   482         if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
   511         if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
   483         
   512         
   484         for (var i=0; i < num; i++) {
   513         for (var i=0; i < num; i++) {
   485           var row = data[i];
   514           var row = data[i];
   486           if (!row) continue;
   515           if (!row) continue;
   487           
       
   488           console.debug('row good ', row);
       
   489           
   516           
   490           if ( typeof(row[0]) != 'string' )
   517           if ( typeof(row[0]) != 'string' )
   491           {
   518           {
   492             // last ditch resort if it's a 1.1.4 autocomplete plugin that doesn't provide an automatic result.
   519             // last ditch resort if it's a 1.1.4 autocomplete plugin that doesn't provide an automatic result.
   493             // hopefully this doesn't slow it down a lot.
   520             // hopefully this doesn't slow it down a lot.