--- controls_orig.js 2007-03-04 18:53:47.000000000 +0100 +++ controls.js 2007-03-04 20:02:27.000000000 +0100 @@ -56,11 +56,15 @@ else this.options = options || {}; - this.options.paramName = this.options.paramName || this.element.name; - this.options.tokens = this.options.tokens || []; - this.options.frequency = this.options.frequency || 0.4; - this.options.minChars = this.options.minChars || 1; - this.options.onShow = this.options.onShow || + // allow minChars to be 0 + if(typeof this.options.minChars=='undefined'){ + this.options.minChars = 1; + } + this.options.paramName = this.options.paramName || this.element.name; + this.options.tokens = this.options.tokens || []; + this.options.frequency = this.options.frequency || 0.4; + this.options.activateOnFocus = this.options.activateOnFocus || false; + this.options.onShow = this.options.onShow || function(element, update){ if(!update.style.position || update.style.position=='absolute') { update.style.position = 'absolute'; @@ -85,6 +89,9 @@ Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + if(this.options.activateOnFocus){ + Event.observe(this.element, "focus", this.onFocus.bindAsEventListener(this)); + } }, show: function() { @@ -183,7 +190,11 @@ this.selectEntry(); this.hide(); }, - + onFocus: function(event) { + if(this.getToken().length>=this.options.minChars) { + this.activate(); + } + }, onBlur: function(event) { // needed to make click events working setTimeout(this.hide.bind(this), 250); @@ -416,7 +427,10 @@ var partial = []; // Inside matches var entry = instance.getToken(); var count = 0; - + if(entry==''){ + return ''; + } + for (var i = 0; i < instance.options.array.length && ret.length < instance.options.choices ; i++) {