public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Last-minute ajax  fixes #898

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@973 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Tue Mar 22 04:13:36 -0800 2005
commit  e1ce18020e1c23c148060ec2180dc0ed794be06e
tree    1dfe8338ad00fea256c347c24cd56763032c39cf
parent  11a5492791e6ed467a73bf20e0c7b6828bf0a3e2
...
45
46
47
48
 
49
50
51
52
53
54
...
45
46
47
 
48
49
 
 
50
51
52
0
@@ -45,10 +45,8 @@
0
       # :url => { :action => "undo", :n => word_counter },
0
       # :complete => "undoRequestCompleted(request)"
0
       #
0
- # The complete list of callbacks that may be specified are:
0
+ # The c callbacks that may be specified are:
0
       #
0
- # <tt>:uninitialized</tt>:: Called before the remote document is
0
- # initialized with data.
0
       # <tt>:loading</tt>:: Called when the remote document is being
0
       # loaded with data by the browser.
0
       # <tt>:loaded</tt>:: Called when the browser has finished loading
...
1
 
2
3
4
5
6
7
8
9
10
 
11
12
13
14
...
59
60
61
62
63
64
 
65
66
67
...
73
74
75
76
 
77
78
79
80
81
82
...
145
146
147
148
 
149
150
 
 
 
151
152
153
154
155
156
157
 
 
158
159
160
161
162
163
164
 
 
 
 
 
 
 
165
166
167
168
...
189
190
191
 
 
192
193
194
 
195
196
197
...
200
201
202
203
 
204
205
206
...
 
1
2
3
4
5
6
7
 
8
 
9
10
11
12
13
...
58
59
60
 
61
 
62
63
64
65
...
71
72
73
 
74
75
76
77
78
79
80
...
143
144
145
 
146
147
 
148
149
150
151
152
153
154
155
156
 
157
158
159
160
161
162
163
164
 
165
166
167
168
169
170
171
172
173
174
175
...
196
197
198
199
200
201
202
 
203
204
205
206
...
209
210
211
 
212
213
214
215
0
@@ -1,13 +1,12 @@
0
-/* Prototype: an object-oriented Javascript library, version 1.0.0
0
+/* Prototype: an object-oriented Javascript library, version 1.0.1
0
  * (c) 2005 Sam Stephenson <sam@conio.net>
0
  *
0
  * Prototype is freely distributable under the terms of an MIT-style license.
0
  * For details, see http://prototype.conio.net/
0
  */
0
 
0
-
0
 Prototype = {
0
- Version : '1.0.0'
0
+ Version: '1.0.1'
0
 }
0
 
0
 Class = {
0
0
@@ -59,9 +58,8 @@
0
 
0
 Toggle = {
0
   display: function() {
0
- elements = $.apply(this, arguments);
0
     for (var i = 0; i < elements.length; i++) {
0
- element = elements[i];
0
+ var element = $(elements[i]);
0
       element.style.display =
0
         (element.style.display == 'none' ? '' : 'none');
0
     }
0
@@ -73,7 +71,7 @@
0
 function $() {
0
   var elements = new Array();
0
   
0
- for (i = 0; i < arguments.length; i++) {
0
+ for (var i = 0; i < arguments.length; i++) {
0
     var element = arguments[i];
0
     if (typeof element == 'string')
0
       element = document.getElementById(element);
0
0
0
0
@@ -145,23 +143,32 @@
0
     
0
       this.transport.open(this.options.method, url, true);
0
       
0
- if (this.options.asynchronous)
0
+ if (this.options.asynchronous) {
0
         this.transport.onreadystatechange = this.onStateChange.bind(this);
0
-
0
+ setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
0
+ }
0
+
0
       if (this.options.method == 'post') {
0
         this.transport.setRequestHeader('Connection', 'close');
0
         this.transport.setRequestHeader('Content-type',
0
           'application/x-www-form-urlencoded');
0
       }
0
       
0
- this.transport.send(this.options.method == 'post' ? this.options.parameters + '&_=' : null);
0
+ this.transport.send(this.options.method == 'post' ?
0
+ this.options.parameters + '&_=' : null);
0
                       
0
     } catch (e) {
0
     }
0
   },
0
       
0
   onStateChange: function() {
0
- var event = Ajax.Request.Events[this.transport.readyState];
0
+ var readyState = this.transport.readyState;
0
+ if (readyState != 1)
0
+ this.respondToReadyState(this.transport.readyState);
0
+ },
0
+
0
+ respondToReadyState: function(readyState) {
0
+ var event = Ajax.Request.Events[readyState];
0
     (this.options['on' + event] || Ajax.emptyFunction)(this.transport);
0
   }
0
 });
0
0
@@ -189,9 +196,11 @@
0
   }
0
 });
0
 
0
+/*--------------------------------------------------------------------------*/
0
+
0
 Field = {
0
   clear: function() {
0
- for (i = 0; i < arguments.length; i++)
0
+ for (var i = 0; i < arguments.length; i++)
0
       $(arguments[i]).value = '';
0
   },
0
 
0
@@ -200,7 +209,7 @@
0
   },
0
   
0
   present: function() {
0
- for (i = 0; i < arguments.length; i++)
0
+ for (var i = 0; i < arguments.length; i++)
0
       if ($(arguments[i]).value == '') return false;
0
     return true;
0
   }
...
1
 
2
3
4
5
6
7
8
9
10
 
11
12
13
14
...
59
60
61
62
63
64
 
65
66
67
...
73
74
75
76
 
77
78
79
80
81
82
...
145
146
147
148
 
149
150
 
 
 
151
152
153
154
155
156
157
 
 
158
159
160
161
162
163
164
 
 
 
 
 
 
 
165
166
167
168
...
189
190
191
 
 
192
193
194
 
195
196
197
...
200
201
202
203
 
204
205
206
...
 
1
2
3
4
5
6
7
 
8
 
9
10
11
12
13
...
58
59
60
 
61
 
62
63
64
65
...
71
72
73
 
74
75
76
77
78
79
80
...
143
144
145
 
146
147
 
148
149
150
151
152
153
154
155
156
 
157
158
159
160
161
162
163
164
 
165
166
167
168
169
170
171
172
173
174
175
...
196
197
198
199
200
201
202
 
203
204
205
206
...
209
210
211
 
212
213
214
215
0
@@ -1,13 +1,12 @@
0
-/* Prototype: an object-oriented Javascript library, version 1.0.0
0
+/* Prototype: an object-oriented Javascript library, version 1.0.1
0
  * (c) 2005 Sam Stephenson <sam@conio.net>
0
  *
0
  * Prototype is freely distributable under the terms of an MIT-style license.
0
  * For details, see http://prototype.conio.net/
0
  */
0
 
0
-
0
 Prototype = {
0
- Version : '1.0.0'
0
+ Version: '1.0.1'
0
 }
0
 
0
 Class = {
0
0
@@ -59,9 +58,8 @@
0
 
0
 Toggle = {
0
   display: function() {
0
- elements = $.apply(this, arguments);
0
     for (var i = 0; i < elements.length; i++) {
0
- element = elements[i];
0
+ var element = $(elements[i]);
0
       element.style.display =
0
         (element.style.display == 'none' ? '' : 'none');
0
     }
0
@@ -73,7 +71,7 @@
0
 function $() {
0
   var elements = new Array();
0
   
0
- for (i = 0; i < arguments.length; i++) {
0
+ for (var i = 0; i < arguments.length; i++) {
0
     var element = arguments[i];
0
     if (typeof element == 'string')
0
       element = document.getElementById(element);
0
0
0
0
@@ -145,23 +143,32 @@
0
     
0
       this.transport.open(this.options.method, url, true);
0
       
0
- if (this.options.asynchronous)
0
+ if (this.options.asynchronous) {
0
         this.transport.onreadystatechange = this.onStateChange.bind(this);
0
-
0
+ setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
0
+ }
0
+
0
       if (this.options.method == 'post') {
0
         this.transport.setRequestHeader('Connection', 'close');
0
         this.transport.setRequestHeader('Content-type',
0
           'application/x-www-form-urlencoded');
0
       }
0
       
0
- this.transport.send(this.options.method == 'post' ? this.options.parameters + '&_=' : null);
0
+ this.transport.send(this.options.method == 'post' ?
0
+ this.options.parameters + '&_=' : null);
0
                       
0
     } catch (e) {
0
     }
0
   },
0
       
0
   onStateChange: function() {
0
- var event = Ajax.Request.Events[this.transport.readyState];
0
+ var readyState = this.transport.readyState;
0
+ if (readyState != 1)
0
+ this.respondToReadyState(this.transport.readyState);
0
+ },
0
+
0
+ respondToReadyState: function(readyState) {
0
+ var event = Ajax.Request.Events[readyState];
0
     (this.options['on' + event] || Ajax.emptyFunction)(this.transport);
0
   }
0
 });
0
0
@@ -189,9 +196,11 @@
0
   }
0
 });
0
 
0
+/*--------------------------------------------------------------------------*/
0
+
0
 Field = {
0
   clear: function() {
0
- for (i = 0; i < arguments.length; i++)
0
+ for (var i = 0; i < arguments.length; i++)
0
       $(arguments[i]).value = '';
0
   },
0
 
0
@@ -200,7 +209,7 @@
0
   },
0
   
0
   present: function() {
0
- for (i = 0; i < arguments.length; i++)
0
+ for (var i = 0; i < arguments.length; i++)
0
       if ($(arguments[i]).value == '') return false;
0
     return true;
0
   }

Comments

    No one has commented yet.