diff options
author | Thomas Fuchs <thomas@fesch.at> | 2005-11-14 20:49:10 +0000 |
---|---|---|
committer | Thomas Fuchs <thomas@fesch.at> | 2005-11-14 20:49:10 +0000 |
commit | 415d27490f14f7ba360a0edd3d9e1211f7482c89 (patch) | |
tree | 54754d39aae29b8ab1cfd380f98874222bbc584c /railties/html/javascripts/controls.js | |
parent | 037f61c8e9ceda65538a8d847db235f9d7a5e3ad (diff) | |
download | rails-415d27490f14f7ba360a0edd3d9e1211f7482c89.tar.gz rails-415d27490f14f7ba360a0edd3d9e1211f7482c89.tar.bz2 rails-415d27490f14f7ba360a0edd3d9e1211f7482c89.zip |
Update trunk to latests script.aculo.us
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3033 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/html/javascripts/controls.js')
-rw-r--r-- | railties/html/javascripts/controls.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/railties/html/javascripts/controls.js b/railties/html/javascripts/controls.js index 6da588543b..9742b69188 100644 --- a/railties/html/javascripts/controls.js +++ b/railties/html/javascripts/controls.js @@ -80,7 +80,10 @@ Autocompleter.Base.prototype = { show: function() { if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); - if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (Element.getStyle(this.update, 'position')=='absolute')) { + if(!this.iefix && + (navigator.appVersion.indexOf('MSIE')>0) && + (navigator.userAgent.indexOf('Opera')<0) && + (Element.getStyle(this.update, 'position')=='absolute')) { new Insertion.After(this.update, '<iframe id="' + this.update.id + '_iefix" '+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + @@ -718,4 +721,30 @@ Ajax.InPlaceEditor.prototype = { Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); } } +}; + +// Delayed observer, like Form.Element.Observer, +// but waits for delay after last key input +// Ideal for live-search fields + +Form.Element.DelayedObserver = Class.create(); +Form.Element.DelayedObserver.prototype = { + initialize: function(element, delay, callback) { + this.delay = delay || 0.5; + this.element = $(element); + this.callback = callback; + this.timer = null; + this.lastValue = $F(this.element); + Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); + }, + delayedListener: function(event) { + if(this.lastValue == $F(this.element)) return; + if(this.timer) clearTimeout(this.timer); + this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); + this.lastValue = $F(this.element); + }, + onTimerEvent: function() { + this.timer = null; + this.callback(this.element, $F(this.element)); + } };
\ No newline at end of file |