aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb3
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js27
2 files changed, 29 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 5a07ebdc6e..513074cddd 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -159,7 +159,8 @@ module ActionView
js_options['asynchronous'] = options[:type] != :synchronous
js_options['method'] = options[:method] if options[:method]
-
+ js_options['effect'] = ("\'"+options[:effect].to_s+"\'") if options[:effect]
+
if options[:form]
js_options['parameters'] = 'Form.serialize(this)'
elsif options[:with]
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