aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/javascripts/prototype.js
diff options
context:
space:
mode:
authorSam Stephenson <sam@37signals.com>2006-03-27 05:47:17 +0000
committerSam Stephenson <sam@37signals.com>2006-03-27 05:47:17 +0000
commitb8e23e37dd2342d156b36480662e6fe31b12d0ad (patch)
tree3cac4e8c7de941de6e1081b1b874ec759db152b5 /actionpack/lib/action_view/helpers/javascripts/prototype.js
parent9efca53908c09b7f188183aec6c0a4a2df347316 (diff)
downloadrails-b8e23e37dd2342d156b36480662e6fe31b12d0ad.tar.gz
rails-b8e23e37dd2342d156b36480662e6fe31b12d0ad.tar.bz2
rails-b8e23e37dd2342d156b36480662e6fe31b12d0ad.zip
Update to Prototype 1.5.0_pre1
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4063 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascripts/prototype.js')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js36
1 files changed, 31 insertions, 5 deletions
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(' && ');
},