[richfaces-svn-commits] JBoss Rich Faces SVN: r5108 - trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sat Dec 29 09:54:35 EST 2007


Author: vmolotkov
Date: 2007-12-29 09:54:35 -0500 (Sat, 29 Dec 2007)
New Revision: 5108

Modified:
   trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
Log:
focus handler

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	2007-12-29 14:20:24 UTC (rev 5107)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2007-12-29 14:54:35 UTC (rev 5108)
@@ -12,7 +12,7 @@
 		this.field = $(fieldId);
 		this.button = $(buttonId);
 		
-		this.defaultMessage = defaultMessage;
+		this.defaultMessage = "Select a state..."; //defaultMessage;
 		
 		this.onselected = onselected;
 		
@@ -22,7 +22,11 @@
 	initCombobox : function() {
 		this.button.observe("click", function(e){this.clickHandler(e);}.bindAsEventListener(this));
 		this.field.observe("keydown", function(e){this.keyboardManager(e);}.bindAsEventListener(this));
-		//this.field.observe("blur", function(e){this.focusHandler(e);}.bindAsEventListener(this));
+		
+		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.field.observe("keyup", function(e){this.dataUpdating(e);}.bindAsEventListener(this));
 		
 		this.comboList.listParent.observe("mousemove", function(e){this.listListener(e)}.bindAsEventListener(this));
@@ -51,6 +55,18 @@
 		}
 	},
 	
+	listMousedownHandler : function(e) {
+		this.comboList.isList = true;
+	},
+	
+	fieldHandler : function() {
+		if (this.field.value == this.defaultMessage) {
+			this.field.value = "";
+		} else {
+			Richfaces.ComboBox.textboxSelect(this.field, 0, this.field.value.length);
+		}
+	},
+	
 	valueHandler : function(event) {
 		this.setValue(true);
 		
@@ -93,13 +109,27 @@
 		}
 	},
 	
+	/*doForce : function(){
+		if (this.el.dom.value.length > 0) {
+			this.el.dom.value = ((this.lastSelectionText === undefined) ? "" : this.lastSelectionText);
+			this.applyEmptyText();
+		}
+	},*/
+		
 	focusHandler : function(event) {
-		this.comboList.hide();
-		if (this.field.value == "") {
-			this.field.value = this.defaultMessage;
+		if (!this.comboList.isList) {
+			var value = this.field.value; 
+			if (value.length == 0) {
+				this.applyDefaultText();
+			}
+			this.comboList.hide();
 		}
 	},
 	
+	applyDefaultText : function() {
+		this.field.value = this.defaultMessage;
+	},
+	
 	dataUpdating : function(event) {
 		if (Richfaces.ComboBox.SPECIAL_KEYS.indexOf(event.keyCode) == -1) {
 			if (this.filterNewValue) {
@@ -139,6 +169,7 @@
 		}
 		
 		this.classes = classes;
+		this.isList = false;
 		
 		this.selectedItem = null;
 		
@@ -260,6 +291,7 @@
 			this.normalizeItem(this.selectedItem);			
 		}
 		this.selectedItem = null;
+		this.isList = false;
 	},
 	
 	dataFilter : function(text) {




More information about the richfaces-svn-commits mailing list