mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixing JS bugs, renamed :position values
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1007 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
8e76a5920e
commit
48b4d28d81
2 changed files with 9 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue