[richfaces-svn-commits] JBoss Rich Faces SVN: r5342 - 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
Mon Jan 14 05:30:46 EST 2008


Author: vmolotkov
Date: 2008-01-14 05:30:46 -0500 (Mon, 14 Jan 2008)
New Revision: 5342

Modified:
   trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
   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 changes

Modified: trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
===================================================================
--- trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml	2008-01-14 10:30:40 UTC (rev 5341)
+++ trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml	2008-01-14 10:30:46 UTC (rev 5342)
@@ -62,6 +62,26 @@
 	            <description></description>
 	        </property>
 	        
+	        <property>
+	            <name>showDelay</name>
+	            <classname>java.lang.Integer</classname>
+	            <description></description>
+	            <defaultvalue><![CDATA[0]]></defaultvalue>
+	        </property>
+	        <property>
+	            <name>hideDelay</name>
+	            <classname>java.lang.Integer</classname>
+	            <description></description>
+	            <defaultvalue><![CDATA[0]]></defaultvalue>
+	        </property>
+	        
+	        <property>
+	            <name>width</name>
+	            <classname>java.lang.String</classname>
+	            <description></description>
+	            <defaultvalue><![CDATA["150"]]></defaultvalue>
+	        </property>
+	        
 	         <property>
 	            <name>width</name>
 	            <classname>java.lang.String</classname>

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-14 10:30:40 UTC (rev 5341)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2008-01-14 10:30:46 UTC (rev 5342)
@@ -3,7 +3,11 @@
 
 Richfaces.ComboBox.prototype = {
 	
-	initialize: function(combobox, listId, parentListId, fieldId, buttonId,buttonBGId, classes, listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, selectFirstOnUpdate, onlistcall, onselected, defaultMessage, isDisabled, value) {
+	initialize: function(combobox, listId, parentListId, fieldId, buttonId, buttonBGId, classes, 
+						 listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, 
+						 selectFirstOnUpdate, onlistcall, onselected, defaultMessage, isDisabled, value,
+						 showDelay, hideDelay) {
+		
 		this.directInputSuggestions = directInputSuggestions;
 		this.filterNewValue = filterNewValue;
 		
@@ -14,9 +18,10 @@
 		var fieldDem = Richfaces.ComboBoxList.getElemXY(this.field);
 		fieldDem.height = this.field.offsetHeight;
 		listWidth = (!listWidth) ? this.getCurrentWidth() : listWidth;
-		this.comboList = new Richfaces.ComboBoxList(listId, parentListId, selectFirstOnUpdate, classes.COMBO_LIST, listWidth, listHeight, itemsText, onlistcall, fieldDem);
-		this.defaultMessage = defaultMessage;
 		
+		this.comboList = new Richfaces.ComboBoxList(listId, parentListId, selectFirstOnUpdate, classes.COMBO_LIST, listWidth, 
+													listHeight, itemsText, onlistcall, fieldDem, showDelay, hideDelay);
+		this.defaultMessage = defaultMessage;
 		if (value) {
 			var item = this.comboList.findItemBySubstr(value);
 			if (item) {
@@ -27,22 +32,16 @@
 				this.applyDefaultText();
 			}
 		}
-		
 		this.onselected = onselected;
-		
 		this.isSelection = true;
-		
 		this.classes = classes;
 		this.isDisabled = isDisabled;
-		
 		if (this.onselected) {
 			this.combobox.observe("rich:onitemselected", this.onselected);
 		}
-		
 		if (this.isDisabled) {
 			this.doDisable();
 		}
-		
 		this.initHandlers();
 	},
 	
@@ -65,10 +64,10 @@
 	
 	buttonClickHandler : function(event) {
 		if (this.comboList.visible()) {
-			this.comboList.hide();
+			this.comboList.hideWithDelay();
 		} else {
 			this.comboList.createDefaultList();
-			this.comboList.show();
+			this.comboList.showWithDelay();
 			if (this.comboList.selectedItem) {
 				this.comboList.scrollingUpToItem(this.comboList.selectedItem);
 			}
@@ -128,27 +127,22 @@
 		this.isSelection = false;
 		this.field.focus();
 		this.setValue(true);
-		this.comboList.hide();
+		this.comboList.hideWithDelay();
 	},
 	
 	fieldKeyDownHandler : function(event) {
 		switch (event.keyCode) {
 			case Event.KEY_RETURN : 
 				this.setValue(true);
-				this.comboList.hide();
+				this.comboList.hideWithDelay();
 				Event.stop(event);
 				break;
-			//case Event.KEY_BACKSPACE : 
-			//	this.comboList.hide();
-			//	break;
 			case Event.KEY_DOWN : 
 				this.comboList.moveActiveItem(event);
 				break;
 			case Event.KEY_UP :
 				this.comboList.moveActiveItem(event);
 				break; 
-			default : 
-				//this.dataUpdating(event);
 		}
 	},
 	
@@ -175,7 +169,7 @@
 					this.comboList.doSelectItem(item);
 				}
 			}
-			this.comboList.hide();
+			this.comboList.hideWithDelay();
 			this.doNormal();
 		} else {
 			this.doActive();
@@ -191,16 +185,16 @@
 	
 	dataUpdating : function(event) {
 		if (Richfaces.ComboBox.SPECIAL_KEYS.indexOf(event.keyCode) == -1) {
-			this.comboList.hide();
+			this.comboList.hideWithDelay();
 			if (this.filterNewValue) {
 				this.comboList.dataFilter(this.field.value);
 				if (this.comboList.getItems() && this.comboList.getItems().length != 0) {
 					var isSearchSuccessful = true;
-					this.comboList.show();					
+					this.comboList.showWithDelay();					
 				}
 			} else {
 				if (!this.comboList.visible()) {
-					this.comboList.show();
+					this.comboList.showWithDelay();
 				}
 				var item = this.comboList.findItemBySubstr(this.field.value);
 				if (item) {
@@ -292,7 +286,8 @@
 Richfaces.ComboBoxList = Class.create();
 Richfaces.ComboBoxList.prototype = {
 	
-	initialize: function(listId, parentListId, selectFirstOnUpdate, classes, width, height, itemsText, onlistcall, fieldXY) {
+	initialize: function(listId, parentListId, selectFirstOnUpdate, classes, width, height, itemsText, onlistcall, fieldXY,
+						 showDelay, hideDelay) {
 		 
 		this.list = $(listId);
 		this.listParent = $(parentListId);
@@ -314,6 +309,8 @@
 		this.selectedItem = null;
 		this.activeItem = null;
 		
+		this.showDelay = showDelay;
+		this.hideDelay = hideDelay;
 		
 		this.width = width;
 		this.height = height;
@@ -346,13 +343,19 @@
 		return this.list.childNodes;
 	},
 	
+	showWithDelay : function() {
+		this.show();
+		/*setTimeout(function(){
+			this.show();
+		}.bind(this), this.showDelay);*/
+	},
+	
 	show : function() {
 		this.setSize();
 		this.setPosition(this.fieldDimensions.top, this.fieldDimensions.left, this.fieldDimensions.height);
 		
 		if (this.selectedItem) {
 			//was created new item list, so necessary to recreate selectedItem
-			//alert(this.selectedItem.innerHTML);
 			this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML));
 		}
 		
@@ -371,6 +374,13 @@
 		
 	},
 	
+	hideWithDelay : function() {
+		/*setTimeout(function(){
+			this.hide();
+		}.bind(this), this.hideDelay);*/
+		this.hide();
+	},
+	
 	hide : function() {
 		this.resetState();
 		this.listParent.hide();
@@ -398,7 +408,6 @@
 			rowsAmount = this.getItems().length;
 			currentItemsHeight = itemHeight * rowsAmount;
 		}
-		
 		if (this.height && (parseInt(this.height) < currentItemsHeight)) {
 			if (this.height < currentItemsHeight) {
 				height = currentItemsHeight;
@@ -410,16 +419,9 @@
 				height = itemHeight * this.defaultRowsAmount;
 			}
 		}
-		
-		/*if (Prototype.Browser.IE) {
-			height = parseInt(height) + Richfaces.ComboBoxList.LAYOUT_BORDER_V + Richfaces.ComboBoxList.LAYOUT_PADDING_V;
-		}*/
-		//this.listParent.style.height = height;
 		this.list.style.height = height;
 		
-		//if (this.width) {
 		this.setWidth(this.width);
-		//}
 	},
 	
 	setWidth : function(width) {
@@ -432,8 +434,6 @@
 		positionElem.style.width = width;
 		
 		this.list.style.width = parseInt(width) - Richfaces.getBorderWidth(positionElem.firstChild, "lr") - Richfaces.getPaddingWidth(positionElem.firstChild, "lr");
-			
-		//this.list.style.width = width;
 	},
 	
 	setPosition : function(fieldTop, fieldLeft, fieldHeight) {
@@ -444,7 +444,6 @@
 		var top = -4;
 		if (parseInt(listHeight) > (docHeight - comBottom)) {
 			if (fieldTop > (docHeight - comBottom)) {
-				//this.listParent.style.bottom = 0 + "px"; //FIXME
 				top -= (parseInt(listHeight) + fieldHeight);
 			}
 		} 
@@ -454,7 +453,6 @@
 	
 	scrolling : function(event) {
 		var increment;
-		//var scrollElem = this.listParent;
 		var scrollElem = this.list;
 		var listTop = Richfaces.ComboBoxList.getElemXY(scrollElem).top;
 		var scrollTop = scrollElem.scrollTop;
@@ -476,7 +474,6 @@
 	},
 	
 	scrollingUpToItem : function(item) {
-		//var scrollElem = this.listParent;
 		var scrollElem = this.list;
 		var increment = (Richfaces.ComboBoxList.getElemXY(item).top - scrollElem.scrollTop) - Richfaces.ComboBoxList.getElemXY(scrollElem).top;
 		scrollElem.scrollTop += increment;
@@ -533,15 +530,12 @@
 	},
 	
 	itemsRearrangement : function(item, newItem) {
-		//this.doNormalItem(item);
 		this.doActiveItem(newItem);
 	},
 	
 	resetState : function() {
 		var tempList = this.list.cloneNode(false);
-		//this.listParent.replaceChild(tempList, this.listParent.firstChild);
 		this.listParent.childNodes[1].firstChild.replaceChild(tempList, this.list);
-		//this.list = this.listParent.firstChild;
 		this.list = $(tempList.id);
 		this.activeItem = null;
 		this.isList = false;
@@ -573,13 +567,6 @@
 		}
 	},
 	
-	/*findItemByText : function(text) {
-		var id = this.itemsText.indexOf(text);
-		if (id != -1) {
-			return this.getItems()[this.itemsText.indexOf(text)];
-		}
-	},*/
-	
 	createNewList : function(items) {
 		//FIX for FF
 		if (this.selectedItem) {
@@ -593,7 +580,6 @@
 				this.doSelectItem(item);
 			}
 		}
-		//this.listParent.appendChild(tempList);
 	},
 	
 	createItem : function(text, className) {

Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-14 10:30:40 UTC (rev 5341)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-14 10:30:46 UTC (rev 5342)
@@ -192,8 +192,9 @@
 				   value="#{value}" 
 				   size="#{inputSize}" 
 				   autocomplete="off" 
+				   onchange='#{component.attributes["onchange"]}'
 				   style="width:#{width}; #{inputStyle}"
-				   x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled"
+				   x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled,onchange"
 				   />
 			<input id="comboBoxButtonBG#{clientId}" readonly="true" type="text" value="" class="rich-combobox-font rich-combobox-button-background rich-combobox-button"/>
 			<input id="comboboxButton#{clientId}" readonly="true" disabled="#{disabled}" type="text" value="" style="#{buttonStyle}" 
@@ -272,6 +273,7 @@
 											   #{this:getAsEventHandler(context, component, "onlistcall")}, 
 											   #{this:getAsEventHandler(context, component, "onitemselected")},
 											   "#{defaultLabel}",
-											   #{disabled}, "#{value}");
+											   #{disabled}, "#{value}", 
+											   #{component.attributes["showDelay"]},  #{component.attributes["hideDelay"]});
 	</script>
 </f:root>	
\ No newline at end of file




More information about the richfaces-svn-commits mailing list