Skip to content
This repository
Browse code

Update Railties to Prototype 1.3.1

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1807 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 1911f8eee928915f1020753a4a3ba34c81131a66 1 parent 325c5ef
Sam Stephenson authored July 11, 2005

Showing 1 changed file with 50 additions and 39 deletions. Show diff stats Hide diff stats

  1. 89  railties/html/javascripts/prototype.js
89  railties/html/javascripts/prototype.js
... ...
@@ -1,4 +1,4 @@
1  
-/*  Prototype JavaScript framework, version 1.3.0
  1
+/*  Prototype JavaScript framework, version 1.3.1
2 2
  *  (c) 2005 Sam Stephenson <sam@conio.net>
3 3
  *
4 4
  *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -11,7 +11,7 @@
11 11
 /*--------------------------------------------------------------------------*/
12 12
 
13 13
 var Prototype = {
14  
-  Version: '1.3.0',
  14
+  Version: '1.3.1',
15 15
   emptyFunction: function() {}
16 16
 }
17 17
 
@@ -266,12 +266,16 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
266 266
   respondToReadyState: function(readyState) {
267 267
     var event = Ajax.Request.Events[readyState];
268 268
 
269  
-    if (event == 'Complete' && this.responseIsFailure())
  269
+    if (event == 'Complete')
270 270
       (this.options['on' + this.transport.status]
271  
-       || this.options.onFailure
  271
+       || this.options['on' + this.responseIsSuccess() ? 'Success' : 'Failure']
272 272
        || Prototype.emptyFunction)(this.transport);
273 273
 
274  
-    (this.options['on' + event] || Prototype.emptyFunction)(this.transport);    
  274
+    (this.options['on' + event] || Prototype.emptyFunction)(this.transport);
  275
+
  276
+    /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
  277
+    if (event == 'Complete')
  278
+      this.transport.onreadystatechange = Prototype.emptyFunction;
275 279
   }
276 280
 });
277 281
 
@@ -292,7 +296,7 @@ Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({
292 296
     var onComplete = this.options.onComplete || Prototype.emptyFunction;
293 297
     this.options.onComplete = (function() {
294 298
       this.updateContent();
295  
-      onComplete(this.transport);      
  299
+      onComplete(this.transport);
296 300
     }).bind(this);
297 301
 
298 302
     this.request(url);
@@ -889,53 +893,60 @@ Object.extend(Event, {
889 893
     return element;
890 894
   },
891 895
 
  896
+  observers: false,
  897
+  
  898
+  _observeAndCache: function(element, name, observer, useCapture) {
  899
+    if (!this.observers) this.observers = [];
  900
+    if (element.addEventListener) {
  901
+      this.observers.push([element, name, observer, useCapture]);
  902
+      element.addEventListener(name, observer, useCapture);
  903
+    } else if (element.attachEvent) {
  904
+      this.observers.push([element, name, observer, useCapture]);
  905
+      element.attachEvent('on' + name, observer);
  906
+    }
  907
+  },
  908
+  
  909
+  unloadCache: function() {
  910
+    if (!Event.observers) return;
  911
+    for (var i = 0; i < Event.observers.length; i++) {
  912
+      Event.stopObserving.apply(this, Event.observers[i]);
  913
+      Event.observers[i][0] = null;
  914
+    }
  915
+    Event.observers = false;
  916
+  },
  917
+
892 918
   observe: function(element, name, observer, useCapture) {
893 919
     var element = $(element);
894 920
     useCapture = useCapture || false;
895 921
     
896  
-    if (name == 'keypress') {
897  
-      if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
898  
-        element.addEventListener('keydown', observer, useCapture);
899  
-        return;
900  
-      }
901  
-      if (element.addEventListener) {
902  
-        element.addEventListener('keypress', observer, useCapture);
903  
-      } else if (element.attachEvent) {
904  
-        element.attachEvent('onkeydown', observer);
905  
-      }
906  
-    } else {
907  
-      if (element.addEventListener) {
908  
-        element.addEventListener(name, observer, useCapture);
909  
-      } else if (element.attachEvent) {
910  
-        element.attachEvent('on' + name, observer);
911  
-      }
912  
-    }
  922
+    if (name == 'keypress' &&
  923
+        ((navigator.appVersion.indexOf('AppleWebKit') > 0) 
  924
+        || element.attachEvent))
  925
+      name = 'keydown';
  926
+    
  927
+    this._observeAndCache(element, name, observer, useCapture);
913 928
   },
914 929
 
915 930
   stopObserving: function(element, name, observer, useCapture) {
916 931
     var element = $(element);
917 932
     useCapture = useCapture || false;
918 933
     
919  
-    if (name == 'keypress') {
920  
-      if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
921  
-        element.removeEventListener('keydown', observer, useCapture);
922  
-        return;
923  
-      }
924  
-      if (element.removeEventListener) {
925  
-        element.removeEventListener('keypress', observer, useCapture);
926  
-      } else if (element.detachEvent) {
927  
-        element.detachEvent('onkeydown', observer);
928  
-      }
929  
-    } else {
930  
-      if (element.removeEventListener) {
931  
-        element.removeEventListener(name, observer, useCapture);
932  
-      } else if (element.detachEvent) {
933  
-        element.detachEvent('on' + name, observer);
934  
-      }
  934
+    if (name == 'keypress' &&
  935
+        ((navigator.appVersion.indexOf('AppleWebKit') > 0) 
  936
+        || element.detachEvent))
  937
+      name = 'keydown';
  938
+    
  939
+    if (element.removeEventListener) {
  940
+      element.removeEventListener(name, observer, useCapture);
  941
+    } else if (element.detachEvent) {
  942
+      element.detachEvent('on' + name, observer);
935 943
     }
936 944
   }
937 945
 });
938 946
 
  947
+/* prevent memory leaks in IE */
  948
+Event.observe(window, 'unload', Event.unloadCache, false);
  949
+
939 950
 var Position = {
940 951
 
941 952
   // set to true if needed, warning: firefox performance problems

0 notes on commit 1911f8e

Please sign in to comment.
Something went wrong with that request. Please try again.