[richfaces-svn-commits] JBoss Rich Faces SVN: r5329 - in trunk/sandbox/ui/combobox/src/main: templates and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sat Jan 12 09:24:24 EST 2008


Author: vmolotkov
Date: 2008-01-12 09:24:24 -0500 (Sat, 12 Jan 2008)
New Revision: 5329

Modified:
   trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
   trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
Log:
scroll handler was added

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-12 13:40:19 UTC (rev 5328)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2008-01-12 14:24:24 UTC (rev 5329)
@@ -3,7 +3,7 @@
 
 Richfaces.ComboBox.prototype = {
 	
-	initialize: function(combobox, listId, parentListId, fieldId, buttonId,buttonBGId, classes, listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, selectFirstOnUpdate, onlistcall, onselected, defaultMessage, isDisabled) {
+	initialize: function(combobox, listId, parentListId, fieldId, buttonId,buttonBGId, classes, listWidth, listHeight, itemsText, directInputSuggestions, filterNewValue, selectFirstOnUpdate, onlistcall, onselected, defaultMessage, isDisabled, value) {
 		this.directInputSuggestions = directInputSuggestions;
 		this.filterNewValue = filterNewValue;
 		
@@ -15,9 +15,19 @@
 		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;
 		
+		if (value) {
+			var item = this.comboList.findItemBySubstr(value);
+			if (item) {
+				this.comboList.doSelectItem(item);
+			}
+		} else {
+			if (this.defaultMessage) {
+				this.applyDefaultText();
+			}
+		}
+		
 		this.onselected = onselected;
 		
 		this.isSelection = true;
@@ -34,7 +44,7 @@
 		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.button.observe("mousedown", function(e){this.listMousedownHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mousedown", function(e){this.buttonMousedownHandler(e);}.bindAsEventListener(this));
 		
 		this.field.observe("keyup", function(e){this.dataUpdating(e);}.bindAsEventListener(this));
 		
@@ -45,10 +55,6 @@
 			this.combobox.observe("rich:onitemselected", this.onselected);
 		}
 		
-		if (this.defaultMessage) {
-			this.applyDefaultText();
-		}
-		
 		if (this.isDisabled) {
 			this.doDisable();
 		}
@@ -81,6 +87,22 @@
 	},
 	
 	listMousedownHandler : function(e) {
+		if (Prototype.Browser.IE) {
+			if (!this.comboList.getEventItem(e)) {
+				this.clickOnScroll = true;
+			}
+			this.comboList.isList = true;
+			//this.field.focus();
+		} else if (Prototype.Browser.Gecko) {
+			if (this.comboList.getEventItem(e)) {
+				this.comboList.isList = true;			
+			}
+		} else {
+			this.comboList.isList = true;
+		}
+	},
+	
+	buttonMousedownHandler : function(e) {
 		this.comboList.isList = true;
 	},
 	
@@ -168,6 +190,13 @@
 		} else {
 			this.doActive();
 		}
+		
+		//IE only 
+		if (this.clickOnScroll) {
+			this.field.focus();
+			this.comboList.isList = false;
+			this.clickOnScroll = false;
+		}
 	},
 	
 	applyDefaultText : function() {
@@ -288,6 +317,7 @@
 		
 		if (this.selectedItem) {
 			//was created new item list, so necessary to recreate selectedItem
+			//alert(this.selectedItem.innerHTML);
 			this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML));
 		}
 		
@@ -517,7 +547,17 @@
 	
 	createNewList : function(items) {
 		//FIX for FF
+		if (this.selectedItem) {
+			var text = this.selectedItem.innerHTML;			
+		}
 		this.list.innerHTML = items.join("");
+		//was created new item list, so necessary to recreate selectedItem
+		if (this.selectedItem) {
+			var item = this.findItemBySubstr(text);
+			if (item) {
+				this.doSelectItem(item);
+			}
+		}
 		//this.listParent.appendChild(tempList);
 	},
 	

Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-12 13:40:19 UTC (rev 5328)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx	2008-01-12 14:24:24 UTC (rev 5329)
@@ -53,8 +53,8 @@
 	    	String inputSize = (String) component.getAttributes().get("inputSize");
 	    	variables.setVariable("inputSize", inputSize);
 	    	
-	    	String defaultMessage = (String) component.getAttributes().get("defaultMessage");
-	    	variables.setVariable("defaultMessage", defaultMessage);
+	    	String defaultLabel = (String) component.getAttributes().get("defaultLabel");
+	    	variables.setVariable("defaultLabel", defaultLabel);
 	    	
 	    	Boolean selectFirstOnUpdate = (Boolean) component.getAttributes().get("selectFirstOnUpdate");
 	        variables.setVariable("selectFirstOnUpdate", selectFirstOnUpdate);
@@ -271,7 +271,7 @@
 											   #{selectFirstOnUpdate},
 											   #{this:getAsEventHandler(context, component, "onlistcall")}, 
 											   #{this:getAsEventHandler(context, component, "onitemselected")},
-											   "#{defaultMessage}",
-											   #{disabled});
+											   "#{defaultLabel}",
+											   #{disabled}, "#{value}");
 	</script>
 </f:root>	
\ No newline at end of file




More information about the richfaces-svn-commits mailing list