(function($) { /** * autor: CTAPbIu_MABP * email: ctapbiumabp@gmail.com * site: http://mabp.kiev.ua/content/2008/04/08/autocomplete/ * license: MIT & GPL * last update: 14.09.2009 * version: 1.3 */ var ac = function(c, o) { this.cache = {}; // main chache {mask:[text]} this.store = {}; // secondary cache {mask:strind} this.pairs = {}; // cache of values {text:value} this.init(c, o); }; ac.prototype = { // html elements ac : null, // main input ul : null, // autocomplete list img : null, // image container : null, // outer div // timeouts close : null, // ac hide timeout : null, // ac search // system definitons chars : 0, // previous search string lenght // user definitons url : null, // url for ajax request source : null, // ") .addClass(select.attr('class')) .attr('tabindex', select.attr('tabindex')) .attr('id', 'ac_' + select.attr('id')); select.after(input).hide(); // add text input and hide the select $("label[for='"+select.attr('id')+"']") .attr('for', 'ac_' + select.attr('id')); new ac(input, $.extend({ source: this, values: true, fillin: true, writable : false, onSelect: function() { select.val(this.pairs[this.ac.val()]); } }, options)); } else if (this.tagName == 'INPUT'){ new ac(this, options); } }); return this; }; })(jQuery);