aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorSam Stephenson <sam@37signals.com>2005-06-29 05:20:51 +0000
committerSam Stephenson <sam@37signals.com>2005-06-29 05:20:51 +0000
commita551ba2c01f5fcc1c0eff13c8ef24082e55071b9 (patch)
tree88583a61b5c6971cc61baa2aaf1677cce507ef05 /actionpack
parent31e48939b13b5960eec0167ef0b71cd65ed36ed4 (diff)
downloadrails-a551ba2c01f5fcc1c0eff13c8ef24082e55071b9.tar.gz
rails-a551ba2c01f5fcc1c0eff13c8ef24082e55071b9.tar.bz2
rails-a551ba2c01f5fcc1c0eff13c8ef24082e55071b9.zip
Sync Prototype; closes #1539
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1558 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js89
1 files changed, 59 insertions, 30 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 0d23a344d9..a76d3e62b6 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -1,4 +1,4 @@
-/* Prototype: an object-oriented Javascript library, version 1.3.0
+/* Prototype JavaScript framework, version 1.3.0
* (c) 2005 Sam Stephenson <sam@conio.net>
*
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -152,10 +152,17 @@ String.prototype.extend({
return this.replace(/<\/?[^>]+>/gi, '');
},
+ escapeHTML: function() {
+ var div = document.createElement('div');
+ var text = document.createTextNode(this);
+ div.appendChild(text);
+ return div.innerHTML;
+ },
+
unescapeHTML: function() {
- return this.replace(/&lt;/gi,"<").replace(/&gt;/gi,">").
- replace(/&quot;/gi,'"').replace(/&apos;/gi,"'").
- replace(/&amp;/gi,"&").replace(/[\n\r]/gi,"");
+ var div = document.createElement('div');
+ div.innerHTML = this.stripTags();
+ return div.childNodes[0].nodeValue;
}
});
@@ -238,23 +245,24 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
var event = Ajax.Request.Events[readyState];
if (event == 'Complete' && this.transport.status != 200)
- (this.options['on' + this.transport.status] ||
- this.options.onFailure ||
- Prototype.emptyFunction)(this.transport);
+ (this.options['on' + this.transport.status]
+ || this.options.onFailure
+ || Prototype.emptyFunction)(this.transport);
(this.options['on' + event] || Prototype.emptyFunction)(this.transport);
}
});
Ajax.Updater = Class.create();
+Ajax.Updater.ScriptFragmentMatch = /<script.*?>((?:\n|.)*?)<\/script>/im;
+
Ajax.Updater.prototype = (new Ajax.Base()).extend({
initialize: function(container, url, options) {
this.containers = {
success: container.success ? $(container.success) : $(container),
failure: container.failure ? $(container.failure) : null
}
-
- this.script_re = /<script.*?>((?:\n|.)*?)<\/script>/im;
+
this.setOptions(options);
if (this.options.asynchronous) {
@@ -272,12 +280,12 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
var receiver =
(this.request.transport.status == 200) ?
this.containers.success : this.containers.failure;
-
- var response = this.request.transport.responseText.replace(
- this.script_re, '');
-
- var scripts = this.request.transport.responseText.match(
- this.script_re);
+
+ var response = this.request.transport.responseText.
+ replace(Ajax.Updater.ScriptFragmentMatch, '');
+
+ var scripts = this.request.transport.responseText.
+ match(Ajax.Updater.ScriptFragmentMatch);
if (receiver) {
if (this.options.insertion) {
@@ -288,13 +296,12 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
}
if (this.request.transport.status == 200) {
- if (this.onComplete) {
+ if (this.onComplete)
setTimeout((function() {this.onComplete(
this.request.transport)}).bind(this), 10);
- }
- if (this.options.script && scripts) {
- setTimeout((function() { eval(scripts[1]) }).bind(this), 10);
- }
+
+ if (this.options.evalScripts && scripts)
+ setTimeout((function() {eval(scripts[1])}).bind(this), 10);
}
}
});
@@ -340,11 +347,8 @@ Ajax.PeriodicalUpdater.prototype = (new Ajax.Base()).extend({
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
-
});
-/*--------------------------------------------------------------------------*/
-
document.getElementsByClassName = function(className) {
var children = document.getElementsByTagName('*') || document.all;
var elements = new Array();
@@ -855,31 +859,56 @@ Object.extend(Event, {
// node the event was triggered on; traverses the DOM upwards
findElement: function(event, tagName) {
var element = Event.element(event);
- while (element.parentNode && (!element.tagName ||
- (element.tagName.toUpperCase() != tagName.toUpperCase())))
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase())))
element = element.parentNode;
return element;
},
- observe: function(element, name, observer) {
+ 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, false);
+ if (navigator.appVersion.indexOf('AppleWebKit') > 0) {
+ element.addEventListener('keydown', observer, useCapture);
return;
}
if (element.addEventListener) {
- element.addEventListener('keypress', observer, false);
+ element.addEventListener('keypress', observer, useCapture);
} else if (element.attachEvent) {
element.attachEvent('onkeydown', observer);
}
} else {
if (element.addEventListener) {
- element.addEventListener(name, observer, false);
+ element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
element.attachEvent('on' + name, observer);
}
}
+ },
+
+ 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);
+ }
+ }
}
});