aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js36
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/html/javascripts/prototype.js36
4 files changed, 66 insertions, 10 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 96af65a578..b102e3acb4 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Update to Prototype 1.5.0_pre1 [Sam Stephenson]
+
* Change #form_for and #fields_for so that the second argument is not required [Dave Thomas]
<% form_for :post, @post, :url => { :action => 'create' } do |f| -%>
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 5c939795c8..2d4ba34c18 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.5.0_pre0
+/* Prototype JavaScript framework, version 1.5.0_pre1
* (c) 2005 Sam Stephenson <sam@conio.net>
*
* Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,7 +7,7 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.5.0_pre0',
+ Version: '1.5.0_pre1',
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
emptyFunction: function() {},
@@ -1251,9 +1251,16 @@ Selector.prototype = {
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_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
+ }
+
+ if (expr == '*') return this.params.wildcard = true;
+
while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
modifier = match[1], clause = match[2], rest = match[3];
switch (modifier) {
@@ -1273,8 +1280,7 @@ Selector.prototype = {
var params = this.params, conditions = [], clause;
if (params.wildcard)
- return 'true';
-
+ conditions.push('true');
if (clause = params.id)
conditions.push('element.id == ' + clause.inspect());
if (clause = params.tagName)
@@ -1282,6 +1288,26 @@ Selector.prototype = {
if ((clause = params.classNames).length > 0)
for (var i = 0; i < clause.length; i++)
conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.getAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
+
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push(value + ' != null'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ }
+ });
+ }
return conditions.join(' && ');
},
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index e3785decdb..9d58def4be 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Update to Prototype 1.5.0_pre1 [Sam Stephenson]
+
* Update to script.aculo.us 1.6 [Thomas Fuchs]
* Add an integration_test generator [Jamis Buck]
diff --git a/railties/html/javascripts/prototype.js b/railties/html/javascripts/prototype.js
index 5c939795c8..2d4ba34c18 100644
--- a/railties/html/javascripts/prototype.js
+++ b/railties/html/javascripts/prototype.js
@@ -1,4 +1,4 @@
-/* Prototype JavaScript framework, version 1.5.0_pre0
+/* Prototype JavaScript framework, version 1.5.0_pre1
* (c) 2005 Sam Stephenson <sam@conio.net>
*
* Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,7 +7,7 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.5.0_pre0',
+ Version: '1.5.0_pre1',
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
emptyFunction: function() {},
@@ -1251,9 +1251,16 @@ Selector.prototype = {
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_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
+ }
+
+ if (expr == '*') return this.params.wildcard = true;
+
while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
modifier = match[1], clause = match[2], rest = match[3];
switch (modifier) {
@@ -1273,8 +1280,7 @@ Selector.prototype = {
var params = this.params, conditions = [], clause;
if (params.wildcard)
- return 'true';
-
+ conditions.push('true');
if (clause = params.id)
conditions.push('element.id == ' + clause.inspect());
if (clause = params.tagName)
@@ -1282,6 +1288,26 @@ Selector.prototype = {
if ((clause = params.classNames).length > 0)
for (var i = 0; i < clause.length; i++)
conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.getAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
+
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push(value + ' != null'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ }
+ });
+ }
return conditions.join(' && ');
},