diff options
author | Richard Worth <rdworth@gmail.com> | 2008-09-20 02:43:18 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2008-09-20 02:43:18 +0000 |
commit | 0bae0870d920842f10322763c66bc59541b9158c (patch) | |
tree | 4133b7ebeb79260c75efc5f8a7f1133bbce85c9f /ui/ui.autocomplete.js | |
parent | 1285c6e76302a65f8eaf6380b33c010a1900519c (diff) | |
download | jquery-ui-0bae0870d920842f10322763c66bc59541b9158c.tar.gz jquery-ui-0bae0870d920842f10322763c66bc59541b9158c.zip |
whitespace
Diffstat (limited to 'ui/ui.autocomplete.js')
-rw-r--r-- | ui/ui.autocomplete.js | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/ui/ui.autocomplete.js b/ui/ui.autocomplete.js index 8c2487a38..b065f093c 100644 --- a/ui/ui.autocomplete.js +++ b/ui/ui.autocomplete.js @@ -15,7 +15,7 @@ $.widget("ui.autocomplete", { _init: function() { - + $.extend(this.options, { delay: this.options.url ? $.Autocompleter.defaults.delay : 10, max: !this.options.scroll ? 10 : 150, @@ -46,7 +46,7 @@ $.widget("ui.autocomplete", { }); $.Autocompleter = function(input, options) { - + var KEY = { UP: 38, DOWN: 40, @@ -59,11 +59,11 @@ $.Autocompleter = function(input, options) { PAGEDOWN: 34, BACKSPACE: 8 }; - + // Create $ object for input element var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass); if(options.result) $input.bind('result.autocomplete', options.result); - + var timeout; var previousValue = ""; var cache = $.Autocompleter.Cache(options); @@ -89,7 +89,7 @@ $.Autocompleter = function(input, options) { // track last key pressed lastKeyPressCode = event.keyCode; switch(event.keyCode) { - + case KEY.UP: event.preventDefault(); if ( select.visible() ) { @@ -98,7 +98,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.DOWN: event.preventDefault(); if ( select.visible() ) { @@ -107,7 +107,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.PAGEUP: event.preventDefault(); if ( select.visible() ) { @@ -116,7 +116,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.PAGEDOWN: event.preventDefault(); if ( select.visible() ) { @@ -137,11 +137,11 @@ $.Autocompleter = function(input, options) { return false; } break; - + case KEY.ESC: select.hide(); break; - + default: clearTimeout(timeout); timeout = setTimeout(onChange, options.delay); @@ -193,7 +193,6 @@ $.Autocompleter = function(input, options) { $(input.form).unbind(".autocomplete"); }); - function selectCurrent() { var selected = select.selected(); if( !selected ) @@ -274,12 +273,12 @@ $.Autocompleter = function(input, options) { $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length); } }; - + function hideResults() { clearTimeout(timeout); timeout = setTimeout(hideResultsNow, 200); }; - + function hideResultsNow() { var wasVisible = select.visible(); select.hide(); @@ -304,7 +303,7 @@ $.Autocompleter = function(input, options) { // position cursor at end of input field $.Autocompleter.Selection(input, input.value.length, input.value.length); }; - + function receiveData(q, data) { if ( data && data.length && hasFocus ) { stopLoading(); @@ -315,7 +314,7 @@ $.Autocompleter = function(input, options) { hideResultsNow(); } }; - + function request(term, success, failure) { if (!options.matchCase) term = term.toLowerCase(); @@ -352,11 +351,11 @@ $.Autocompleter = function(input, options) { } }); } - + else if (options.source && typeof options.source == 'function') { var resultData = options.source(term); var parsed = (options.parse) ? options.parse(resultData) : resultData; - + cache.add(term, parsed); success(term, parsed); } else { @@ -382,11 +381,11 @@ $.Autocompleter = function(input, options) { } return parsed; }; - + function stopLoading() { $input.removeClass(options.loadingClass); }; - + }; $.Autocompleter.defaults = { @@ -421,7 +420,7 @@ $.extend($.ui.autocomplete, { }); $.Autocompleter.Cache = function(options) { - + var data = {}; var length = 0; @@ -448,7 +447,7 @@ $.Autocompleter.Cache = function(options) { // track the matches var stMatchSets = {}, nullData = 0; - + // no url was specified, we need to adjust the cache length to make sure it fits the local data store if( !options.url ) options.cacheLength = 1; @@ -464,12 +463,12 @@ $.Autocompleter.Cache = function(options) { var value = options.formatMatch(rawValue, i+1, options.data.length); if ( value === false ) continue; - + var firstChar = value.charAt(0).toLowerCase(); // if no lookup array for this character exists, look it up now if( !stMatchSets[firstChar] ) stMatchSets[firstChar] = []; - + // if the match is a string var row = { value: value, @@ -479,13 +478,13 @@ $.Autocompleter.Cache = function(options) { // push the current match into the set list stMatchSets[firstChar].push(row); - + // keep track of minChars zero items if ( nullData++ < options.max ) { stMatchSets[""].push(row); } }; - + // add the data items to the cache $.each(stMatchSets, function(i, value) { // increase the cache size @@ -578,7 +577,7 @@ $.Autocompleter.Select = function (options, input, select, config) { .addClass(options.resultsClass) .css("position", "absolute") .appendTo(document.body); - + list = $("<ul/>").appendTo(element).mouseover( function(event) { if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') { active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event)); @@ -598,7 +597,7 @@ $.Autocompleter.Select = function (options, input, select, config) { if( options.width > 0 ) element.css("width", options.width); - + needsInit = false; } @@ -611,7 +610,7 @@ $.Autocompleter.Select = function (options, input, select, config) { return []; return element; } - + function moveSelect(step) { listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE); movePosition(step); |