aboutsummaryrefslogtreecommitdiffstats
path: root/railties/html/javascripts/effects.js
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-12-24 22:58:33 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-12-24 22:58:33 +0000
commitcfb0babec348a5543ae4c4a8c2c5e4438644429e (patch)
treec686adcbb4b887745348836d87e32e0b41dc03c5 /railties/html/javascripts/effects.js
parentd4e02f755d4de5ddd7eb98afd95391993fbb81d9 (diff)
downloadrails-cfb0babec348a5543ae4c4a8c2c5e4438644429e.tar.gz
rails-cfb0babec348a5543ae4c4a8c2c5e4438644429e.tar.bz2
rails-cfb0babec348a5543ae4c4a8c2c5e4438644429e.zip
Added :select option for JavaScriptMacroHelper#auto_complete_field that makes it easier to only use part of the auto-complete suggestion as the value for insertion [Thomas Fuchs]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/html/javascripts/effects.js')
-rw-r--r--railties/html/javascripts/effects.js29
1 files changed, 14 insertions, 15 deletions
diff --git a/railties/html/javascripts/effects.js b/railties/html/javascripts/effects.js
index 414398ce47..035a63e62f 100644
--- a/railties/html/javascripts/effects.js
+++ b/railties/html/javascripts/effects.js
@@ -24,23 +24,22 @@ String.prototype.parseColor = function() {
return(color.length==7 ? color : (arguments[0] || this));
}
-Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
- var children = $(element).childNodes;
- var text = '';
- var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i');
-
- for (var i = 0; i < children.length; i++) {
- if(children[i].nodeType==3) {
- text+=children[i].nodeValue;
- } else {
- if((!children[i].className.match(classtest)) && children[i].hasChildNodes())
- text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass);
- }
- }
-
- return text;
+Element.collectTextNodes = function(element) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
+ }).flatten().join('');
}
+Element.collectTextNodesIgnoreClass = function(element, className) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
+ Element.collectTextNodes(node) : ''));
+ }).flatten().join('');
+}
+
+
Element.setStyle = function(element, style) {
element = $(element);
for(k in style) element.style[k.camelize()] = style[k];