From ae5f3c74883ae2ea5c0d19151acc8fb33e5fd52c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 26 Mar 2005 15:01:11 +0000 Subject: Added :highlight effect to do YFT automatically git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1004 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../action_view/helpers/javascripts/prototype.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'actionpack/lib/action_view/helpers/javascripts') diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js index 10e5f69cf6..fa1539fca4 100644 --- a/actionpack/lib/action_view/helpers/javascripts/prototype.js +++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js @@ -203,6 +203,9 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({ updateContent: function() { this.container.innerHTML = this.request.transport.responseText; + switch(this.options.effect) { + case 'highlight': new YellowFader(this.container); break; + } if (this.onComplete) this.onComplete(this.request); } }); @@ -346,3 +349,27 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({ } }); +/*--------------------------------------------------------------------------*/ + +var YellowFader = Class.create(); +YellowFader.prototype = { + initialize: function(element) { + if (typeof element == 'string') element = $(element); + if (!element) return; + this.element = element; + this.start = 153; + this.finish = 255; + this.current = this.start; + this.fade(); + }, + fade: function() { + if (this.isFinished()) return; + if (this.timer) clearTimeout(this.timer); // prevent flicker + highlight_yellow(this.element, this.current); + this.current += 17; + this.timer = setTimeout(this.fade.bind(this), 250); + }, + isFinished: function() { + return this.current > this.finish; + } +} \ No newline at end of file -- cgit v1.2.3