aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-26 20:27:04 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-26 20:27:04 +0000
commit48b4d28d81f07204b6ae2c5c6b034e9fb9983788 (patch)
treea87e26578058e7cf496848cbf5d2d2b9329b8909
parent8e76a5920e2daaf0ea44b5b6195b75788c5de44c (diff)
downloadrails-48b4d28d81f07204b6ae2c5c6b034e9fb9983788.tar.gz
rails-48b4d28d81f07204b6ae2c5c6b034e9fb9983788.tar.bz2
rails-48b4d28d81f07204b6ae2c5c6b034e9fb9983788.zip
Fixing JS bugs, renamed :position values
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1007 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js31
2 files changed, 9 insertions, 28 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 1d70073069..6a0117a163 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -153,14 +153,14 @@ module ActionView
(javascript || '').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end
- private
+ private
def options_for_ajax(options)
js_options = build_callbacks(options)
js_options['asynchronous'] = options[:type] != :synchronous
js_options['method'] = options[:method] if options[:method]
js_options['position'] = options[:position] ? "'#{options[:position].to_s}'" : "'replace'"
- js_options['effect'] = ("\'"+options[:effect].to_s+"\'") if options[:effect]
+ js_options['effect'] = ("\'" + options[:effect].to_s + "\'") if options[:effect]
if options[:form]
js_options['parameters'] = 'Form.serialize(this)'
@@ -184,7 +184,7 @@ module ActionView
CALLBACKS.inject({}) do |callbacks, callback|
if options[callback]
name = 'on' + callback.to_s.capitalize
- code = escape_javascript(options[callback])
+ code = options[callback]
callbacks[name] = "function(request){#{code}}"
end
callbacks
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 60dbd5d419..8cddf224e2 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -97,24 +97,6 @@ function getElementsByClassName(className, element) {
return elements;
}
-// function getElementsByClassName(className, element) {
-// var children = (element || document).getElementsByTagName('*');
-// var elements = new Array();
-//
-// for (var i = 0; i < children.length; i++) {
-// var child = children[i];
-// var classNames = child.className.split(' ');
-// for (var j = 0; j < classNames.length; j++) {
-// if (classNames[j] == className) {
-// elements.push(child);
-// break;
-// }
-// }
-// }
-//
-// return elements;
-// }
-
/*--------------------------------------------------------------------------*/
Ajax = {
@@ -204,12 +186,10 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
},
updateContent: function() {
- this.container.innerHTML = this.request.transport.responseText;
-
if (this.options.position.toLowerCase() == 'replace') {
this.container.innerHTML = this.request.transport.responseText;
} else {
- Insert[this.options.position.toLowerCase()]( this.container, this.request.transport.responseText );
+ Insert[this.options.position.toLowerCase()](this.container, this.request.transport.responseText);
}
switch(this.options.effect) {
@@ -393,10 +373,11 @@ YellowFader.prototype = {
}
}
+
/*--------------------------------------------------------------------------*/
Insert = {
- before_begin: function(dom, html) {
+ before: function(dom, html) {
dom = $(dom);
if (dom.insertAdjacentHTML) {
dom.insertAdjacentHTML('BeforeBegin', html);
@@ -408,7 +389,7 @@ Insert = {
}
},
- after_begin: function(dom, html) {
+ top: function(dom, html) {
dom = $(dom);
if (dom.insertAdjacentHTML) {
dom.insertAdjacentHTML('AfterBegin', html);
@@ -421,7 +402,7 @@ Insert = {
}
},
- before_end: function(dom, html) {
+ bottom: function(dom, html) {
dom = $(dom);
if (dom.insertAdjacentHTML) {
dom.insertAdjacentHTML('BeforeEnd', html);
@@ -434,7 +415,7 @@ Insert = {
}
},
- after_end: function(dom, html) {
+ after: function(dom, html) {
dom = $(dom);
if (dom.insertAdjacentHTML) {
dom.insertAdjacentHTML('BeforeBegin', html);