mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update to Prototype 1.5.0_rc0
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3435 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
e87c4f064f
commit
75784f6bcc
4 changed files with 320 additions and 14 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Update to Prototype 1.5.0_rc0 [Sam Stephenson]
|
||||||
|
|
||||||
* Automatically discover layouts when a controller is namespaced. #2199, #3424 [me@jonnii.com rails@jeffcole.net Marcel Molina Jr.]
|
* Automatically discover layouts when a controller is namespaced. #2199, #3424 [me@jonnii.com rails@jeffcole.net Marcel Molina Jr.]
|
||||||
|
|
||||||
* Add support for multiple proxy servers to CgiRequest#host [gaetanot@comcast.net]
|
* Add support for multiple proxy servers to CgiRequest#host [gaetanot@comcast.net]
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
/* Prototype JavaScript framework, version 1.4.0
|
/* Prototype JavaScript framework, version 1.5.0_pre0
|
||||||
* (c) 2005 Sam Stephenson <sam@conio.net>
|
* (c) 2005 Sam Stephenson <sam@conio.net>
|
||||||
*
|
*
|
||||||
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
|
|
||||||
* against the source tree, available from the Prototype darcs repository.
|
|
||||||
*
|
|
||||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||||
*
|
|
||||||
* For details, see the Prototype web site: http://prototype.conio.net/
|
* For details, see the Prototype web site: http://prototype.conio.net/
|
||||||
*
|
*
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var Prototype = {
|
var Prototype = {
|
||||||
Version: '1.4.0',
|
Version: '1.5.0_pre0',
|
||||||
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
|
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
|
||||||
|
|
||||||
emptyFunction: function() {},
|
emptyFunction: function() {},
|
||||||
|
@ -140,6 +136,48 @@ function $() {
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
Object.extend(String.prototype, {
|
Object.extend(String.prototype, {
|
||||||
|
gsub: function(pattern, replacement) {
|
||||||
|
var result = '', source = this, match;
|
||||||
|
replacement = arguments.callee.prepareReplacement(replacement);
|
||||||
|
|
||||||
|
while (source.length > 0) {
|
||||||
|
if (match = source.match(pattern)) {
|
||||||
|
result += source.slice(0, match.index);
|
||||||
|
result += (replacement(match) || '').toString();
|
||||||
|
source = source.slice(match.index + match[0].length);
|
||||||
|
} else {
|
||||||
|
result += source, source = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
sub: function(pattern, replacement, count) {
|
||||||
|
replacement = this.gsub.prepareReplacement(replacement);
|
||||||
|
count = count === undefined ? 1 : count;
|
||||||
|
|
||||||
|
return this.gsub(pattern, function(match) {
|
||||||
|
if (--count < 0) return match[0];
|
||||||
|
return replacement(match);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
scan: function(pattern, iterator) {
|
||||||
|
this.gsub(pattern, iterator);
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
truncate: function(length, truncation) {
|
||||||
|
length = length || 30;
|
||||||
|
truncation = truncation === undefined ? '...' : truncation;
|
||||||
|
return this.length > length ?
|
||||||
|
this.slice(0, length - truncation.length) + truncation : this;
|
||||||
|
},
|
||||||
|
|
||||||
|
strip: function() {
|
||||||
|
return this.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||||
|
},
|
||||||
|
|
||||||
stripTags: function() {
|
stripTags: function() {
|
||||||
return this.replace(/<\/?[^>]+>/gi, '');
|
return this.replace(/<\/?[^>]+>/gi, '');
|
||||||
},
|
},
|
||||||
|
@ -203,12 +241,35 @@ Object.extend(String.prototype, {
|
||||||
},
|
},
|
||||||
|
|
||||||
inspect: function() {
|
inspect: function() {
|
||||||
return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
|
return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
String.prototype.gsub.prepareReplacement = function(replacement) {
|
||||||
|
if (typeof replacement == 'function') return replacement;
|
||||||
|
var template = new Template(replacement);
|
||||||
|
return function(match) { return template.evaluate(match) };
|
||||||
|
}
|
||||||
|
|
||||||
String.prototype.parseQuery = String.prototype.toQueryParams;
|
String.prototype.parseQuery = String.prototype.toQueryParams;
|
||||||
|
|
||||||
|
var Template = Class.create();
|
||||||
|
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
|
||||||
|
Template.prototype = {
|
||||||
|
initialize: function(template, pattern) {
|
||||||
|
this.template = template.toString();
|
||||||
|
this.pattern = pattern || Template.Pattern;
|
||||||
|
},
|
||||||
|
|
||||||
|
evaluate: function(object) {
|
||||||
|
return this.template.gsub(this.pattern, function(match) {
|
||||||
|
var before = match[1];
|
||||||
|
if (before == '\\') return match[2];
|
||||||
|
return before + (object[match[3]] || '').toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var $break = new Object();
|
var $break = new Object();
|
||||||
var $continue = new Object();
|
var $continue = new Object();
|
||||||
|
|
||||||
|
@ -920,6 +981,13 @@ Object.extend(Element, {
|
||||||
return $(element).innerHTML.match(/^\s*$/);
|
return $(element).innerHTML.match(/^\s*$/);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
childOf: function(element, ancestor) {
|
||||||
|
element = $(element), ancestor = $(ancestor);
|
||||||
|
while (element = element.parentNode)
|
||||||
|
if (element == ancestor) return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
scrollTo: function(element) {
|
scrollTo: function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var x = element.x ? element.x : element.offsetLeft,
|
var x = element.x ? element.x : element.offsetLeft,
|
||||||
|
@ -1148,6 +1216,89 @@ Element.ClassNames.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.extend(Element.ClassNames.prototype, Enumerable);
|
Object.extend(Element.ClassNames.prototype, Enumerable);
|
||||||
|
var Selector = Class.create();
|
||||||
|
Selector.prototype = {
|
||||||
|
initialize: function(expression) {
|
||||||
|
this.params = {classNames: []};
|
||||||
|
this.expression = expression.toString().strip();
|
||||||
|
this.parseExpression();
|
||||||
|
this.compileMatcher();
|
||||||
|
},
|
||||||
|
|
||||||
|
parseExpression: function() {
|
||||||
|
function abort(message) { throw 'Parse error in selector: ' + message; }
|
||||||
|
|
||||||
|
if (this.expression == '') abort('empty expression');
|
||||||
|
if (this.expression == '*') return this.params.wildcard = true;
|
||||||
|
|
||||||
|
var params = this.params, expr = this.expression, match, modifier, clause, rest;
|
||||||
|
while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
|
||||||
|
modifier = match[1], clause = match[2], rest = match[3];
|
||||||
|
switch (modifier) {
|
||||||
|
case '#': params.id = clause; break;
|
||||||
|
case '.': params.classNames.push(clause); break;
|
||||||
|
case undefined: params.tagName = clause.toUpperCase(); break;
|
||||||
|
default: abort(expr.inspect());
|
||||||
|
}
|
||||||
|
expr = rest;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expr.length > 0) abort(expr.inspect());
|
||||||
|
},
|
||||||
|
|
||||||
|
buildMatchExpression: function() {
|
||||||
|
var params = this.params, conditions = [], clause;
|
||||||
|
|
||||||
|
if (params.wildcard)
|
||||||
|
return 'true';
|
||||||
|
|
||||||
|
if (clause = params.id)
|
||||||
|
conditions.push('element.id == ' + clause.inspect());
|
||||||
|
if (clause = params.tagName)
|
||||||
|
conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
|
||||||
|
if ((clause = params.classNames).length > 0)
|
||||||
|
for (var i = 0; i < clause.length; i++)
|
||||||
|
conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
|
||||||
|
|
||||||
|
return conditions.join(' && ');
|
||||||
|
},
|
||||||
|
|
||||||
|
compileMatcher: function() {
|
||||||
|
this.match = eval('function(element) { if (!element.tagName) return false; \
|
||||||
|
return ' + this.buildMatchExpression() + ' }');
|
||||||
|
},
|
||||||
|
|
||||||
|
findElements: function(scope) {
|
||||||
|
var element;
|
||||||
|
|
||||||
|
if (element = $(this.params.id))
|
||||||
|
if (this.match(element))
|
||||||
|
if (!scope || Element.childOf(element, scope))
|
||||||
|
return [element];
|
||||||
|
|
||||||
|
scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
|
||||||
|
|
||||||
|
var results = [];
|
||||||
|
for (var i = 0; i < scope.length; i++)
|
||||||
|
if (this.match(element = scope[i]))
|
||||||
|
results.push(element);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
},
|
||||||
|
|
||||||
|
toString: function() {
|
||||||
|
return this.expression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function $$() {
|
||||||
|
return $A(arguments).map(function(expression) {
|
||||||
|
return expression.strip().split(/\s+/).inject([null], function(results, expr) {
|
||||||
|
var selector = new Selector(expr);
|
||||||
|
return results.map(selector.findElements.bind(selector)).flatten();
|
||||||
|
});
|
||||||
|
}).flatten();
|
||||||
|
}
|
||||||
var Field = {
|
var Field = {
|
||||||
clear: function() {
|
clear: function() {
|
||||||
for (var i = 0; i < arguments.length; i++)
|
for (var i = 0; i < arguments.length; i++)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Update to Prototype 1.5.0_rc0 [Sam Stephenson]
|
||||||
|
|
||||||
* Sort the list of plugins so we load in a consistent order [Rick Olson]
|
* Sort the list of plugins so we load in a consistent order [Rick Olson]
|
||||||
|
|
||||||
* Show usage when script/plugin is called without arguments [tom@craz8.com]
|
* Show usage when script/plugin is called without arguments [tom@craz8.com]
|
||||||
|
|
165
railties/html/javascripts/prototype.js
vendored
165
railties/html/javascripts/prototype.js
vendored
|
@ -1,17 +1,13 @@
|
||||||
/* Prototype JavaScript framework, version 1.4.0
|
/* Prototype JavaScript framework, version 1.5.0_pre0
|
||||||
* (c) 2005 Sam Stephenson <sam@conio.net>
|
* (c) 2005 Sam Stephenson <sam@conio.net>
|
||||||
*
|
*
|
||||||
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
|
|
||||||
* against the source tree, available from the Prototype darcs repository.
|
|
||||||
*
|
|
||||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||||
*
|
|
||||||
* For details, see the Prototype web site: http://prototype.conio.net/
|
* For details, see the Prototype web site: http://prototype.conio.net/
|
||||||
*
|
*
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var Prototype = {
|
var Prototype = {
|
||||||
Version: '1.4.0',
|
Version: '1.5.0_pre0',
|
||||||
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
|
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
|
||||||
|
|
||||||
emptyFunction: function() {},
|
emptyFunction: function() {},
|
||||||
|
@ -140,6 +136,48 @@ function $() {
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
Object.extend(String.prototype, {
|
Object.extend(String.prototype, {
|
||||||
|
gsub: function(pattern, replacement) {
|
||||||
|
var result = '', source = this, match;
|
||||||
|
replacement = arguments.callee.prepareReplacement(replacement);
|
||||||
|
|
||||||
|
while (source.length > 0) {
|
||||||
|
if (match = source.match(pattern)) {
|
||||||
|
result += source.slice(0, match.index);
|
||||||
|
result += (replacement(match) || '').toString();
|
||||||
|
source = source.slice(match.index + match[0].length);
|
||||||
|
} else {
|
||||||
|
result += source, source = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
sub: function(pattern, replacement, count) {
|
||||||
|
replacement = this.gsub.prepareReplacement(replacement);
|
||||||
|
count = count === undefined ? 1 : count;
|
||||||
|
|
||||||
|
return this.gsub(pattern, function(match) {
|
||||||
|
if (--count < 0) return match[0];
|
||||||
|
return replacement(match);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
scan: function(pattern, iterator) {
|
||||||
|
this.gsub(pattern, iterator);
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
truncate: function(length, truncation) {
|
||||||
|
length = length || 30;
|
||||||
|
truncation = truncation === undefined ? '...' : truncation;
|
||||||
|
return this.length > length ?
|
||||||
|
this.slice(0, length - truncation.length) + truncation : this;
|
||||||
|
},
|
||||||
|
|
||||||
|
strip: function() {
|
||||||
|
return this.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||||
|
},
|
||||||
|
|
||||||
stripTags: function() {
|
stripTags: function() {
|
||||||
return this.replace(/<\/?[^>]+>/gi, '');
|
return this.replace(/<\/?[^>]+>/gi, '');
|
||||||
},
|
},
|
||||||
|
@ -203,12 +241,35 @@ Object.extend(String.prototype, {
|
||||||
},
|
},
|
||||||
|
|
||||||
inspect: function() {
|
inspect: function() {
|
||||||
return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
|
return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
String.prototype.gsub.prepareReplacement = function(replacement) {
|
||||||
|
if (typeof replacement == 'function') return replacement;
|
||||||
|
var template = new Template(replacement);
|
||||||
|
return function(match) { return template.evaluate(match) };
|
||||||
|
}
|
||||||
|
|
||||||
String.prototype.parseQuery = String.prototype.toQueryParams;
|
String.prototype.parseQuery = String.prototype.toQueryParams;
|
||||||
|
|
||||||
|
var Template = Class.create();
|
||||||
|
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
|
||||||
|
Template.prototype = {
|
||||||
|
initialize: function(template, pattern) {
|
||||||
|
this.template = template.toString();
|
||||||
|
this.pattern = pattern || Template.Pattern;
|
||||||
|
},
|
||||||
|
|
||||||
|
evaluate: function(object) {
|
||||||
|
return this.template.gsub(this.pattern, function(match) {
|
||||||
|
var before = match[1];
|
||||||
|
if (before == '\\') return match[2];
|
||||||
|
return before + (object[match[3]] || '').toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var $break = new Object();
|
var $break = new Object();
|
||||||
var $continue = new Object();
|
var $continue = new Object();
|
||||||
|
|
||||||
|
@ -920,6 +981,13 @@ Object.extend(Element, {
|
||||||
return $(element).innerHTML.match(/^\s*$/);
|
return $(element).innerHTML.match(/^\s*$/);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
childOf: function(element, ancestor) {
|
||||||
|
element = $(element), ancestor = $(ancestor);
|
||||||
|
while (element = element.parentNode)
|
||||||
|
if (element == ancestor) return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
scrollTo: function(element) {
|
scrollTo: function(element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
var x = element.x ? element.x : element.offsetLeft,
|
var x = element.x ? element.x : element.offsetLeft,
|
||||||
|
@ -1148,6 +1216,89 @@ Element.ClassNames.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.extend(Element.ClassNames.prototype, Enumerable);
|
Object.extend(Element.ClassNames.prototype, Enumerable);
|
||||||
|
var Selector = Class.create();
|
||||||
|
Selector.prototype = {
|
||||||
|
initialize: function(expression) {
|
||||||
|
this.params = {classNames: []};
|
||||||
|
this.expression = expression.toString().strip();
|
||||||
|
this.parseExpression();
|
||||||
|
this.compileMatcher();
|
||||||
|
},
|
||||||
|
|
||||||
|
parseExpression: function() {
|
||||||
|
function abort(message) { throw 'Parse error in selector: ' + message; }
|
||||||
|
|
||||||
|
if (this.expression == '') abort('empty expression');
|
||||||
|
if (this.expression == '*') return this.params.wildcard = true;
|
||||||
|
|
||||||
|
var params = this.params, expr = this.expression, match, modifier, clause, rest;
|
||||||
|
while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
|
||||||
|
modifier = match[1], clause = match[2], rest = match[3];
|
||||||
|
switch (modifier) {
|
||||||
|
case '#': params.id = clause; break;
|
||||||
|
case '.': params.classNames.push(clause); break;
|
||||||
|
case undefined: params.tagName = clause.toUpperCase(); break;
|
||||||
|
default: abort(expr.inspect());
|
||||||
|
}
|
||||||
|
expr = rest;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expr.length > 0) abort(expr.inspect());
|
||||||
|
},
|
||||||
|
|
||||||
|
buildMatchExpression: function() {
|
||||||
|
var params = this.params, conditions = [], clause;
|
||||||
|
|
||||||
|
if (params.wildcard)
|
||||||
|
return 'true';
|
||||||
|
|
||||||
|
if (clause = params.id)
|
||||||
|
conditions.push('element.id == ' + clause.inspect());
|
||||||
|
if (clause = params.tagName)
|
||||||
|
conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
|
||||||
|
if ((clause = params.classNames).length > 0)
|
||||||
|
for (var i = 0; i < clause.length; i++)
|
||||||
|
conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
|
||||||
|
|
||||||
|
return conditions.join(' && ');
|
||||||
|
},
|
||||||
|
|
||||||
|
compileMatcher: function() {
|
||||||
|
this.match = eval('function(element) { if (!element.tagName) return false; \
|
||||||
|
return ' + this.buildMatchExpression() + ' }');
|
||||||
|
},
|
||||||
|
|
||||||
|
findElements: function(scope) {
|
||||||
|
var element;
|
||||||
|
|
||||||
|
if (element = $(this.params.id))
|
||||||
|
if (this.match(element))
|
||||||
|
if (!scope || Element.childOf(element, scope))
|
||||||
|
return [element];
|
||||||
|
|
||||||
|
scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
|
||||||
|
|
||||||
|
var results = [];
|
||||||
|
for (var i = 0; i < scope.length; i++)
|
||||||
|
if (this.match(element = scope[i]))
|
||||||
|
results.push(element);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
},
|
||||||
|
|
||||||
|
toString: function() {
|
||||||
|
return this.expression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function $$() {
|
||||||
|
return $A(arguments).map(function(expression) {
|
||||||
|
return expression.strip().split(/\s+/).inject([null], function(results, expr) {
|
||||||
|
var selector = new Selector(expr);
|
||||||
|
return results.map(selector.findElements.bind(selector)).flatten();
|
||||||
|
});
|
||||||
|
}).flatten();
|
||||||
|
}
|
||||||
var Field = {
|
var Field = {
|
||||||
clear: function() {
|
clear: function() {
|
||||||
for (var i = 0; i < arguments.length; i++)
|
for (var i = 0; i < arguments.length; i++)
|
||||||
|
|
Loading…
Reference in a new issue