diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-22 12:13:36 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-22 12:13:36 +0000 |
commit | e1ce18020e1c23c148060ec2180dc0ed794be06e (patch) | |
tree | 1dfe8338ad00fea256c347c24cd56763032c39cf /railties | |
parent | 11a5492791e6ed467a73bf20e0c7b6828bf0a3e2 (diff) | |
download | rails-e1ce18020e1c23c148060ec2180dc0ed794be06e.tar.gz rails-e1ce18020e1c23c148060ec2180dc0ed794be06e.tar.bz2 rails-e1ce18020e1c23c148060ec2180dc0ed794be06e.zip |
Last-minute ajax fixes #898
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@973 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/html/javascripts/prototype.js | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/railties/html/javascripts/prototype.js b/railties/html/javascripts/prototype.js index 9790d3b689..b998985235 100644 --- a/railties/html/javascripts/prototype.js +++ b/railties/html/javascripts/prototype.js @@ -1,13 +1,12 @@ -/* Prototype: an object-oriented Javascript library, version 1.0.0 +/* Prototype: an object-oriented Javascript library, version 1.0.1 * (c) 2005 Sam Stephenson <sam@conio.net> * * Prototype is freely distributable under the terms of an MIT-style license. * For details, see http://prototype.conio.net/ */ - Prototype = { - Version : '1.0.0' + Version: '1.0.1' } Class = { @@ -59,9 +58,8 @@ Try = { Toggle = { display: function() { - elements = $.apply(this, arguments); for (var i = 0; i < elements.length; i++) { - element = elements[i]; + var element = $(elements[i]); element.style.display = (element.style.display == 'none' ? '' : 'none'); } @@ -73,7 +71,7 @@ Toggle = { function $() { var elements = new Array(); - for (i = 0; i < arguments.length; i++) { + for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); @@ -145,23 +143,32 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({ this.transport.open(this.options.method, url, true); - if (this.options.asynchronous) + if (this.options.asynchronous) { this.transport.onreadystatechange = this.onStateChange.bind(this); - + setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); + } + if (this.options.method == 'post') { this.transport.setRequestHeader('Connection', 'close'); this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); } - this.transport.send(this.options.method == 'post' ? this.options.parameters + '&_=' : null); + this.transport.send(this.options.method == 'post' ? + this.options.parameters + '&_=' : null); } catch (e) { } }, onStateChange: function() { - var event = Ajax.Request.Events[this.transport.readyState]; + var readyState = this.transport.readyState; + if (readyState != 1) + this.respondToReadyState(this.transport.readyState); + }, + + respondToReadyState: function(readyState) { + var event = Ajax.Request.Events[readyState]; (this.options['on' + event] || Ajax.emptyFunction)(this.transport); } }); @@ -189,9 +196,11 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({ } }); +/*--------------------------------------------------------------------------*/ + Field = { clear: function() { - for (i = 0; i < arguments.length; i++) + for (var i = 0; i < arguments.length; i++) $(arguments[i]).value = ''; }, @@ -200,7 +209,7 @@ Field = { }, present: function() { - for (i = 0; i < arguments.length; i++) + for (var i = 0; i < arguments.length; i++) if ($(arguments[i]).value == '') return false; return true; } |