aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js89
1 files changed, 50 insertions, 39 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 5f1ccadb11..37635ccfab 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -1,4 +1,4 @@
-/* Prototype JavaScript framework, version 1.3.0
+/* Prototype JavaScript framework, version 1.3.1
* (c) 2005 Sam Stephenson <sam@conio.net>
*
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -11,7 +11,7 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.3.0',
+ Version: '1.3.1',
emptyFunction: function() {}
}
@@ -266,12 +266,16 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
respondToReadyState: function(readyState) {
var event = Ajax.Request.Events[readyState];
- if (event == 'Complete' && this.responseIsFailure())
+ if (event == 'Complete')
(this.options['on' + this.transport.status]
- || this.options.onFailure
+ || this.options['on' + this.responseIsSuccess() ? 'Success' : 'Failure']
|| Prototype.emptyFunction)(this.transport);
- (this.options['on' + event] || Prototype.emptyFunction)(this.transport);
+ (this.options['on' + event] || Prototype.emptyFunction)(this.transport);
+
+ /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
+ if (event == 'Complete')
+ this.transport.onreadystatechange = Prototype.emptyFunction;
}
});
@@ -292,7 +296,7 @@ Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({
var onComplete = this.options.onComplete || Prototype.emptyFunction;
this.options.onComplete = (function() {
this.updateContent();
- onComplete(this.transport);
+ onComplete(this.transport);
}).bind(this);
this.request(url);
@@ -889,53 +893,60 @@ Object.extend(Event, {
return element;
},
+ observers: false,
+
+ _observeAndCache: function(element, name, observer, useCapture) {
+ if (!this.observers) this.observers = [];
+ if (element.addEventListener) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.addEventListener(name, observer, useCapture);
+ } else if (element.attachEvent) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.attachEvent('on' + name, observer);
+ }
+ },
+
+ unloadCache: function() {
+ if (!Event.observers) return;
+ for (var i = 0; i < Event.observers.length; i++) {
+ Event.stopObserving.apply(this, Event.observers[i]);
+ Event.observers[i][0] = null;
+ }
+ Event.observers = false;
+ },
+
observe: function(element, name, observer, useCapture) {
var element = $(element);
useCapture = useCapture || false;
- if (name == 'keypress') {
- if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
- element.addEventListener('keydown', observer, useCapture);
- return;
- }
- if (element.addEventListener) {
- element.addEventListener('keypress', observer, useCapture);
- } else if (element.attachEvent) {
- element.attachEvent('onkeydown', observer);
- }
- } else {
- if (element.addEventListener) {
- element.addEventListener(name, observer, useCapture);
- } else if (element.attachEvent) {
- element.attachEvent('on' + name, observer);
- }
- }
+ if (name == 'keypress' &&
+ ((navigator.appVersion.indexOf('AppleWebKit') > 0)
+ || element.attachEvent))
+ name = 'keydown';
+
+ this._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(element, name, observer, useCapture) {
var element = $(element);
useCapture = useCapture || false;
- if (name == 'keypress') {
- if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
- element.removeEventListener('keydown', observer, useCapture);
- return;
- }
- if (element.removeEventListener) {
- element.removeEventListener('keypress', observer, useCapture);
- } else if (element.detachEvent) {
- element.detachEvent('onkeydown', observer);
- }
- } else {
- if (element.removeEventListener) {
- element.removeEventListener(name, observer, useCapture);
- } else if (element.detachEvent) {
- element.detachEvent('on' + name, observer);
- }
+ if (name == 'keypress' &&
+ ((navigator.appVersion.indexOf('AppleWebKit') > 0)
+ || element.detachEvent))
+ name = 'keydown';
+
+ if (element.removeEventListener) {
+ element.removeEventListener(name, observer, useCapture);
+ } else if (element.detachEvent) {
+ element.detachEvent('on' + name, observer);
}
}
});
+/* prevent memory leaks in IE */
+Event.observe(window, 'unload', Event.unloadCache, false);
+
var Position = {
// set to true if needed, warning: firefox performance problems