Author: pyaschenko
Date: 2010-07-22 12:06:49 -0400 (Thu, 22 Jul 2010)
New Revision: 18199
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
Log:
https://jira.jboss.org/browse/RF-8875
bug fix
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22
15:35:18 UTC (rev 18198)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22
16:06:49 UTC (rev 18199)
@@ -123,10 +123,10 @@
if (event.type=="mouseover") {
var index = this.items.index(element);
if (index!=this.index) {
- this.selectItem(index);
+ selectItem.call(this, index);
}
} else {
- this.changeValue(event, this.getSelectedItemValue());
+ this.__changeValue(event, getSelectedItemValue.call(this));
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
this.hide(event);
}
@@ -172,8 +172,8 @@
var _this = this;
var ajaxSuccess = function (event) {
updateItemsList.call(_this, _this.inputValue, event.componentData &&
event.componentData[_this.id]);
- if (_this.options.selectFirst) {
- _this.selectItem(0);
+ if (_this.isVisible && _this.options.selectFirst) {
+ selectItem.call(_this, 0);
}
}
@@ -223,11 +223,11 @@
var item = this.items.eq(this.index);
item.addClass(this.options.selectedItemClass);
scrollToSelectedItem.call(this);
- !noAutoFill && autoFill.call(this, this.inputValue,
this.getSelectedItemValue());
+ !noAutoFill && autoFill.call(this, this.inputValue,
getSelectedItemValue.call(this));
};
var changeValue = function (event, value) {
- this.selectItem();
+ selectItem.call(this);
if (typeof value == "undefined") {
// called from show method, not actually value changed
@@ -252,7 +252,7 @@
this.index = -1;
this.inputValue = value;
if (this.options.selectFirst) {
- this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE);
}
};
@@ -272,17 +272,18 @@
* public API functions
*/
name:"AutoComplete",
- selectItem: selectItem,
- changeValue: changeValue,
- getSelectedItemValue: getSelectedItemValue,
/*
* Protected methods
*/
+ __changeValue: changeValue,
+ /*
+ * Override abstract protected methods
+ */
__onKeyUp: function () {
- this.selectItem(-1, true);
+ selectItem.call(this, -1, true);
},
__onKeyDown: function () {
- this.selectItem(1, true);
+ selectItem.call(this, 1, true);
},
__onPageUp: function () {
@@ -293,7 +294,7 @@
__onBeforeShow: function (event) {
},
__onEnter: function (event) {
- this.changeValue(event, this.getSelectedItemValue());
+ this.__changeValue(event, getSelectedItemValue.call(this));
rf.getDomElement(this.fieldId).blur();
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
rf.getDomElement(this.fieldId).focus();
@@ -301,13 +302,13 @@
__onShow: function (event) {
if (this.items && this.items.length>0) {
//??TODO it's nessesary only if not changed value
- if (this.options.selectFirst) {
- this.selectItem(0);
+ if (this.index!=0 && this.options.selectFirst) {
+ selectItem.call(this, 0);
}
}
},
__onHide: function () {
- this.selectItem();
+ selectItem.call(this);
},
/*
* Destructor
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22
15:35:18 UTC (rev 18198)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22
16:06:49 UTC (rev 18199)
@@ -136,14 +136,14 @@
//TODO: is it needed to chesk keys?
if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
if (flag) {
- this.changeValue(event, value);
+ this.__changeValue(event, value);
onShow.call(this, event, true);
}
}
};
var onShow = function (event, noChangeValue) {
- !noChangeValue && this.changeValue(event);
+ !noChangeValue && this.__changeValue(event);
this.show(event);
};
@@ -266,7 +266,7 @@
}
},
/*
- * Protected abstract methods
+ * abstract protected methods
*/
__onKeyUp: function () {
},