[richfaces-svn-commits] JBoss Rich Faces SVN: r5148 - in trunk/sandbox/ui/combobox/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jan 4 13:23:12 EST 2008


Author: vmolotkov
Date: 2008-01-04 13:23:12 -0500 (Fri, 04 Jan 2008)
New Revision: 5148

Modified:
   trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss
   trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
   trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
Log:
latest version

Modified: trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss
===================================================================
--- trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss	2008-01-04 18:16:08 UTC (rev 5147)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/css/combobox.xcss	2008-01-04 18:23:12 UTC (rev 5148)
@@ -6,13 +6,19 @@
 <f:verbatim>
 <![CDATA[
 
+.rich-combobox-button-disabled {
+}
+
+.rich-combobox-field-disabled {
+}
+
 .rich-combobox-list {
 	z-index: 1000;
 	overflow: auto;
 	white-space:nowrap;
 }
 
-.cb_list_position{ position : absolute; top:-5px; left:0px;}
+.cb_list_position{ position : absolute;}
 .cb_list_decoration{ border : 1px solid #c0c0c0 /*panelBorderColor*/;  padding : 0px; background : #FFFFFF; /*tableBackgroundColor*/}
 .cb_list_scroll{ overflow : auto;}
 .cb_list_cord{ position : relative; font-size : 0px; /*display:none;*/ top: 2px;}/*DDL is hidden!!!!!*/

Modified: trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
--- trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2008-01-04 18:16:08 UTC (rev 5147)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2008-01-04 18:23:12 UTC (rev 5148)
@@ -3,14 +3,17 @@
 
 Richfaces.ComboBox.prototype = {
 	
-	initialize: function(combobox, listId, fieldId, buttonId, classes, listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, onlistcall, onselected, defaultMessage) {
+	initialize: function(combobox, listId, parentListId, fieldId, buttonId, classes, listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, onlistcall, onselected, defaultMessage) {
 		this.directInputSuggestions = directInputSuggestions;
 		this.filterNewValue = filterNewValue;
 		
 		this.combobox = $(combobox); 
-		this.comboList = new Richfaces.ComboBoxList(listId, classes, listWidth, listHeight, itemsText, onlistcall);
 		this.field = $(fieldId);
 		this.button = $(buttonId);
+		//listWidth = (listWidth.length == 0) ? this.combobox.offsetWidth : listWidth;
+		var fieldDem = Richfaces.ComboBoxList.getElemXY(this.field);
+		fieldDem.height = this.field.offsetHeight;
+		this.comboList = new Richfaces.ComboBoxList(listId, parentListId, classes, listWidth, listHeight, itemsText, onlistcall, fieldDem);
 		
 		this.defaultMessage = defaultMessage;
 		
@@ -25,7 +28,8 @@
 		
 		this.field.observe("blur", function(e){this.focusHandler(e);}.bindAsEventListener(this));
 		this.field.observe("focus", function(e){this.fieldHandler(e);}.bindAsEventListener(this));
-		this.comboList.listParent.observe("mousedown", function(e){this.listMousedownHandler(e);}.bindAsEventListener(this))
+		this.comboList.listParent.observe("mousedown", function(e){this.listMousedownHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mousedown", function(e){this.listMousedownHandler(e);}.bindAsEventListener(this));
 		
 		this.field.observe("keyup", function(e){this.dataUpdating(e);}.bindAsEventListener(this));
 		
@@ -33,7 +37,7 @@
 		this.comboList.listParent.observe("click", function(e){this.valueHandler(e);}.bindAsEventListener(this));
 		
 		if (this.onselected) {
-			this.combobox.observe("rich:onselected", this.onselected);
+			this.combobox.observe("rich:onitemselected", this.onselected);
 		}
 		
 		if (this.defaultMessage) {
@@ -47,6 +51,7 @@
 		} else {
 			this.comboList.createDefaultList();
 			this.comboList.show();
+			this.comboList.isList = false;
 		}
 		this.field.focus();
 	},
@@ -84,7 +89,7 @@
 		var value = this.comboList.selectedItem.innerHTML;
 		if (toSetOnly) {
 			this.field.value = value;
-			this.combobox.fire("rich:onselected", {});
+			this.combobox.fire("rich:onitemselected", {});
 		} else {
 			if (this.directInputSuggestions) {
 				var startInd = this.field.value.length; 
@@ -116,13 +121,6 @@
 		}
 	},
 	
-	/*doForce : function(){
-		if (this.el.dom.value.length > 0) {
-			this.el.dom.value = ((this.lastSelectionText === undefined) ? "" : this.lastSelectionText);
-			this.applyEmptyText();
-		}
-	},*/
-		
 	focusHandler : function(event) {
 		if (!this.comboList.isList) {
 			var value = this.field.value; 
@@ -130,6 +128,9 @@
 				this.applyDefaultText();
 			}
 			this.comboList.hide();
+			
+			this.button.className = "rich-combobox-button-disabled"; //FIXME
+			this.field.className = "rich-combobox-field-disabled"; //FIXME
 		}
 	},
 	
@@ -163,9 +164,9 @@
 Richfaces.ComboBoxList = Class.create();
 Richfaces.ComboBoxList.prototype = {
 	
-	initialize: function(listId, classes, width, height, itemsText, onlistcall) {
+	initialize: function(listId, parentListId, classes, width, height, itemsText, onlistcall, fieldXY) {
 		this.list = $(listId);
-		this.listParent = this.list.parentNode;
+		this.listParent = $(parentListId);
 		
 		this.itemsText = itemsText;
 		
@@ -178,9 +179,19 @@
 		this.classes = classes;
 		this.isList = false;
 		
+		this.defaultRowsAmount = 15; 
+		
 		this.selectedItem = null;
 		
+		this.width = width;
+		this.height = height;
+		this.fieldDimensions = fieldXY;
+		//this.initList(width, height, fieldXY);
+	},
+	
+	initList :  function(width, height, fieldXY) {
 		this.setSize(width, height);
+		this.setPosition(fieldXY.top, fieldXY.left, fieldXY.height);
 	},
 	
 	createDefaultList : function() {
@@ -196,6 +207,9 @@
 	},
 	
 	show : function() {
+		this.setSize();
+		this.setPosition(this.fieldDimensions.top, this.fieldDimensions.left, this.fieldDimensions.height);
+		
 		var curItems = this.getItems();
 		if (curItems.length != 0) {
 			this.selectItem(curItems[0]);
@@ -214,11 +228,49 @@
 		return this.listParent.visible();
 	},
 	
-	setSize : function(width, height) {
-		this.listParent.style.width = width;
+	setSize : function() {
+		this.listParent.style.width = this.width;
+		
+		var height = this.height;
+		if (!this.height) {
+			var item = this.list.childNodes[0];
+			if (item) {
+				//FIXME
+				this.listParent.style.visibility = "hidden";
+				this.listParent.show();
+								
+				var itemHeight = item.offsetHeight;
+				
+				this.listParent.hide();
+				this.listParent.style.visibility = "visible";
+				
+				var rowsAmount = this.getItems().length;
+				var k = this.defaultRowsAmount;
+				if (rowsAmount < this.defaultRowsAmount) {
+					k = rowsAmount;
+				}
+				height = k * itemHeight;
+			}
+		}
 		this.listParent.style.height = height;
 	},
 	
+	setPosition : function(fieldTop, fieldLeft, fieldHeight) {
+		var docHeight = Richfaces.getDocumentHeight();
+		var comBottom = fieldTop + fieldHeight;
+		var listHeight = this.listParent.style.height;
+		
+		var top = -4;
+		if (parseInt(listHeight) > (docHeight - comBottom)) {
+			if (fieldTop > (docHeight - comBottom)) {
+				//this.listParent.style.bottom = 0 + "px"; //FIXME
+				top -= (parseInt(listHeight) + fieldHeight);
+			}
+		} 
+		this.listParent.style.top = top + "px";
+		this.listParent.style.left = 0 + "px";
+	},
+	
 	scrolling : function(event) {
 		var increment;
 		var listTop = Richfaces.ComboBoxList.getElemXY(this.listParent).top;
@@ -306,7 +358,6 @@
 	},
 	
 	getFilteredItems : function(text) {
-				
 		var items = new Array();
 		for (var i = 0; i < this.itemsText.length; i++) {
 			var itText = this.itemsText[i];
@@ -369,5 +420,5 @@
 
 Richfaces.ComboBoxList.CLASSES = {
 	ITEM : {NORMAL : "rich-combobox-item rich-combobox-item-normal", SELECTED : "rich-combobox-item rich-combobox-item-selected"},
-	LIST : {}
+	LIST : {},
 }
\ No newline at end of file

Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-04 18:16:08 UTC (rev 5147)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-04 18:23:12 UTC (rev 5148)
@@ -42,9 +42,6 @@
 	    	variables.setVariable("listWidth", listWidth);
 	    	
 	    	String inputSize = (String) component.getAttributes().get("inputSize");
-	    	if (inputSize != null) {
-	    		inputSize = HtmlUtil.qualifySize(inputSize);
-	    	}
 	    	variables.setVariable("inputSize", inputSize);
 	    	
 	    	String defaultMessage = (String) component.getAttributes().get("defaultMessage");
@@ -63,29 +60,26 @@
 		</input>
 		<input type="text" class="rich_cb_width rich_cb_strut rich_cb_font">
 		</input>
-		<div class="cb_list_cord">
-			<div class="cb_list_position">
-				<div id="listParent#{clientId}" class="cb_list_decoration cb_list_scroll" style="display:none">
-					<div id="list#{clientId}">
-						<f:call name="encodeItems"/>
-					</div>
-				</div>
+		<div id="listParent#{clientId}" class="cb_list_cord cb_list_scroll cb_list_decoration cb_list_position" style="display:none">
+			<div id="list#{clientId}">
+				<f:call name="encodeItems"/>
 			</div>
 		</div>
 	</div>
 		
 
 	<script type="text/javascript">
-		var combobox = new Richfaces.ComboBox("#{clientId}", 
-							   "list#{clientId}", 
-							   "comboboxField#{clientId}", 
-							   "comboboxButton#{clientId}", Richfaces.ComboBoxList.CLASSES, 
-							   "#{listWidth}", "#{listHeight}",
-							   #{this:getItemsTextAsJSArray(context, component)}, 
-							   #{directInputSuggestions}, 
-							   #{filterNewValues}, 
-							   #{this:getAsEventHandler(context, component, "onlistcall")}, 
-							   #{this:getAsEventHandler(context, component, "onselected")},
-							   "#{defaultMessage}");
+		var combobox = new Richfaces.ComboBox( "#{clientId}", 
+							   				   "list#{clientId}", 
+							   				   "listParent#{clientId}",
+											   "comboboxField#{clientId}", 
+											   "comboboxButton#{clientId}", Richfaces.ComboBoxList.CLASSES, 
+											   "#{listWidth}", "#{listHeight}",
+											   #{this:getItemsTextAsJSArray(context, component)}, 
+											   #{directInputSuggestions}, 
+											   #{filterNewValues}, 
+											   #{this:getAsEventHandler(context, component, "onlistcall")}, 
+											   #{this:getAsEventHandler(context, component, "onitemselected")},
+											   "#{defaultMessage}");
 	</script>
 </f:root>	
\ No newline at end of file




More information about the richfaces-svn-commits mailing list