Author: sergeyhalipov
Date: 2008-03-17 09:32:21 -0400 (Mon, 17 Mar 2008)
New Revision: 6849
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
http://jira.jboss.com/jira/browse/RF-2539
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-17
12:56:34 UTC (rev 6848)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-17
13:32:21 UTC (rev 6849)
@@ -673,12 +673,10 @@
this.changed = false;
var oldValue = this.element.value;
- if (this.oldValue!=oldValue)
- {
+ if (this.oldValue!=oldValue) {
this.startPosition = 0;
- this.endPosition = oldValue.length-1;
- if (this.options.tokens.length!=0)
- {
+ this.endPosition = oldValue.length;
+ if (this.options.tokens.length!=0) {
var tokens = this.options.tokens.join('');
this.startPosition = this.endPosition =
Richfaces.Selection.getStart(this.element);
@@ -712,8 +710,7 @@
var itm="";
this.selectedItems = [];
var newItemsCache = {};
- if (this.options.tokens.length!=0)
- {
+ if (this.options.tokens.length!=0) {
var re = new
RegExp('\\s*[\\'+this.options.tokens.join("|\\")+']\\s*');
var items = value.split(re);
for (var i=0;i<items.length;i++)
@@ -723,11 +720,11 @@
this.selectedItems.push(itm);
newItemsCache[itm.text] = itm;
}
- }
- else
- {
+ } else {
itm = this.selectedItemsCache[value];
- if (!itm) itm = {text:items[i], object: null};
+ if (!itm) {
+ itm = {text:value, object: null};
+ }
this.selectedItems.push(itm);
newItemsCache[itm.text] = itm;
}