Skip to content

Commit

Permalink
Fixed highlight effect
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Mar 26, 2005
1 parent ae5f3c7 commit e79801d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions actionpack/lib/action_view/helpers/javascripts/prototype.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
}

0 comments on commit e79801d

Please sign in to comment.