Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing JS bugs, renamed :position values

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1007 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 48b4d28d81f07204b6ae2c5c6b034e9fb9983788 1 parent 8e76a59
@dhh dhh authored
View
6 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -153,14 +153,14 @@ def escape_javascript(javascript)
(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 @@ def build_callbacks(options)
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
View
31 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);
Please sign in to comment.
Something went wrong with that request. Please try again.