From e79801d7f254572e195a0048fc912571b51aa23d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 26 Mar 2005 15:22:18 +0000 Subject: [PATCH] Fixed highlight effect git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../action_view/helpers/javascripts/prototype.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js index fa1539fca4223..d634c5c6b5b88 100644 --- a/actionpack/lib/action_view/helpers/javascripts/prototype.js +++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js @@ -89,9 +89,10 @@ function getElementsByClassName(className, element) { var all = document.all ? document.all : document.getElementsByTagName(element); var elements = new Array(); - for (var e = 0; e < all.length; e++) + for (var e = 0; e < all.length; e++) { if (all[e].className == className) elements[elements.length] = all[e]; + } return elements; } @@ -351,6 +352,12 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({ /*--------------------------------------------------------------------------*/ +Number.prototype.toColorPart = function() { + var digits = this.toString(16); + if (this < 16) return '0' + digits; + return digits; +} + var YellowFader = Class.create(); YellowFader.prototype = { initialize: function(element) { @@ -365,11 +372,14 @@ YellowFader.prototype = { fade: function() { if (this.isFinished()) return; if (this.timer) clearTimeout(this.timer); // prevent flicker - highlight_yellow(this.element, this.current); + this.highlight(this.element, this.current); this.current += 17; this.timer = setTimeout(this.fade.bind(this), 250); }, isFinished: function() { return this.current > this.finish; + }, + highlight: function(element, current) { + element.style.backgroundColor = "#ffff" + current.toColorPart(); } } \ No newline at end of file