aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
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 /actionpack
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 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/controls.js3
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/effects.js3
2 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/controls.js b/actionpack/lib/action_view/helpers/javascripts/controls.js
index f13733d5f0..a8e7ec7452 100644
--- a/actionpack/lib/action_view/helpers/javascripts/controls.js
+++ b/actionpack/lib/action_view/helpers/javascripts/controls.js
@@ -221,13 +221,14 @@ Autocompleter.Base.prototype = {
this.options.updateElement(selectedElement);
return;
}
+
var value = '';
if (this.options.select) {
var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
+
var lastTokenPos = this.findLastToken();
if (lastTokenPos != -1) {
var newValue = this.element.value.substr(0, lastTokenPos + 1);
diff --git a/actionpack/lib/action_view/helpers/javascripts/effects.js b/actionpack/lib/action_view/helpers/javascripts/effects.js
index ebca0c490a..035a63e62f 100644
--- a/actionpack/lib/action_view/helpers/javascripts/effects.js
+++ b/actionpack/lib/action_view/helpers/javascripts/effects.js
@@ -22,7 +22,7 @@ String.prototype.parseColor = function() {
}
}
return(color.length==7 ? color : (arguments[0] || this));
-}
+}
Element.collectTextNodes = function(element) {
return $A($(element).childNodes).collect( function(node) {
@@ -39,6 +39,7 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
}).flatten().join('');
}
+
Element.setStyle = function(element, style) {
element = $(element);
for(k in style) element.style[k.camelize()] = style[k];