Author: pyaschenko
Date: 2010-07-07 08:55:57 -0400 (Wed, 07 Jul 2010)
New Revision: 17758
Removed:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-07
11:46:04 UTC (rev 17757)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-07
12:55:57 UTC (rev 17758)
@@ -49,7 +49,7 @@
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "richfaces-event.js"),
@ResourceDependency(name = "richfaces-base-component.js"),
- @ResourceDependency(library = "org.richfaces", name =
"richfaces-selection.js"),
+ @ResourceDependency(name = "richfaces-selection.js"),
@ResourceDependency(library = "org.richfaces", name =
"SelectBase.js"),
@ResourceDependency(library = "org.richfaces", name =
"ComboBox.js"),
@ResourceDependency(library = "org.richfaces", name =
"ComboBox.ecss")
@@ -108,7 +108,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.LI_ELEMENT, comboBox);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font",
null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font
rf-ac-i", null);
if (comboBox.getChildCount() > 0) {
for (UIComponent child: comboBox.getChildren()) {
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss 2010-07-07
11:46:04 UTC (rev 17757)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss 2010-07-07
12:55:57 UTC (rev 17758)
@@ -13,7 +13,8 @@
}
.cb_list_height {
- height: 100px;
+ max-height: 100px;
+ min-height: 20px;
}
input.cb_font {
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-07
11:46:04 UTC (rev 17757)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-07
12:55:57 UTC (rev 17758)
@@ -71,7 +71,9 @@
var defaultOptions = {
selectedItemClass:'cb_select',
- autoFill:true
+ autoFill:true,
+ minChars:0,
+ selectFirst:false
};
var ID = {
@@ -80,16 +82,14 @@
};
var bindEventHandlers = function () {
- rf.Event.bindById(this.componentId+ID.ITEMS, "mouseover"+this.namespace,
onMouseOver, this);
+ rf.Event.bind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode,
"mouseover"+this.namespace, onMouseOver, this);
};
var onMouseOver = function(event) {
- //console && console.log && console.log("mouseOver");
- var element = event.target;
- while (element.parentNode && element.parentNode!=event.currentTarget) {
- element = element.parentNode;
- };
- if (element.parentNode) {
+ console && console.log && console.log("mouseOver");
+ var element = $(event.target).closest(".rf-ac-i",
event.currentTarget).get(0);
+
+ if (element) {
var index = this.items.index(element);
if (index!=this.index) {
this.selectItem(index);
@@ -98,7 +98,7 @@
};
var updateItemsList = function (value) {
- this.items = $(rf.getDomElement(this.componentId+ID.ITEMS)).children();
+ this.items =
$(rf.getDomElement(this.componentId+ID.ITEMS)).find(".rf-ac-i");
this.cache = new rf.utils.Cache(this.items, {
parse: getData,
key: value
@@ -118,7 +118,7 @@
this.items.slice(0, this.index).each(function() {
offset += this.offsetHeight;
});
- var itemsContainer = this.items.first().parent();
+ var itemsContainer = this.items.first().parent().parent();
if(offset < itemsContainer.scrollTop()) {
itemsContainer.scrollTop(offset);
} else {
@@ -143,7 +143,8 @@
name:"CompoBox",
destroy: function () {
//TODO: add all unbind
- $super.destroy.call(this);
+ rf.Event.unbind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode,
this.namespace);
+ $super.destroy.call(this);
},
getNamespace: function () {
return this.namespace;
@@ -204,16 +205,21 @@
this.selectItem();
var newItems = this.cache.getItems(value);
this.items = $(newItems);
+ //TODO: works only with simple markup, not with <tr>
$(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
this.index = -1;
this.newValue = value;
- this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ if (this.options.selectFirst) {
+ this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ }
},
onShow: function (event) {
if (this.items && this.items.length>0) {
//??TODO it's nessesary only if not changed value
- this.selectItem(0);
+ if (this.options.selectFirst) {
+ this.selectItem(0);
+ }
}
},
Deleted:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js 2010-07-07
11:46:04 UTC (rev 17757)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js 2010-07-07
12:55:57 UTC (rev 17758)
@@ -1,45 +0,0 @@
-(function (richfaces) {
-
- richfaces.Selection = richfaces.Selection || {};
-
- richfaces.Selection.set = function (field, start, end) {
- if(field.setSelectionRange) {
- field.focus();
- field.setSelectionRange(start, end);
- } else if (field.createTextRange){
- var range = field.createTextRange();
- range.collapse(true);
- range.moveEnd('character', end);
- range.moveStart('character', start);
- range.select();
- }
- }
-
- richfaces.Selection.getStart = function(field)
- {
- if (field.setSelectionRange) {
- return field.selectionStart;
- } else if (document.selection && document.selection.createRange) {
- var r = document.selection.createRange().duplicate();
- r.moveEnd('character', field.value.length);
- if (r.text == '') return field.value.length;
- return field.value.lastIndexOf(r.text);
- }
- }
-
- richfaces.Selection.getEnd = function(field)
- {
- if (field.setSelectionRange) {
- return field.selectionEnd;
- } else if (document.selection && document.selection.createRange) {
- var r = document.selection.createRange().duplicate();
- r.moveStart('character', -field.value.length);
- return r.text.length;
- }
- }
-
- richfaces.Selection.setCaretTo = function (field, pos)
- {
- richfaces.Selection.set(field, pos, pos);
- }
-})(window.RichFaces || (window.RichFaces={}));
\ No newline at end of file