[richfaces-svn-commits] JBoss Rich Faces SVN: r5333 - 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 Jan 12 11:48:13 EST 2008


Author: vmolotkov
Date: 2008-01-12 11:48:13 -0500 (Sat, 12 Jan 2008)
New Revision: 5333

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

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 16:27:49 UTC (rev 5332)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js	2008-01-12 16:48:13 UTC (rev 5333)
@@ -34,24 +34,7 @@
 		
 		this.classes = classes;
 		this.isDisabled = isDisabled;
-		this.initCombobox();
-	},
-	
-	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("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.buttonMousedownHandler(e);}.bindAsEventListener(this));
-		this.button.observe("mouseover", function(e){this.buttonMouseOverHandler(e);}.bindAsEventListener(this));
-		this.button.observe("mouseout", function(e){this.buttonMouseOutHandler(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));
-		this.comboList.listParent.observe("click", function(e){this.valueHandler(e);}.bindAsEventListener(this));
-		
 		if (this.onselected) {
 			this.combobox.observe("rich:onitemselected", this.onselected);
 		}
@@ -59,13 +42,28 @@
 		if (this.isDisabled) {
 			this.doDisable();
 		}
+		
+		this.initHandlers();
 	},
 	
-	getCurrentWidth : function() {
-		return this.combobox.firstChild.offsetWidth;	
+	initHandlers : function() {
+		this.button.observe("click", function(e){this.buttonClickHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mouseup", function(e){this.buttonMouseUpHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mousedown", function(e){this.buttonMousedownHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mouseover", function(e){this.buttonMouseOverHandler(e);}.bindAsEventListener(this));
+		this.button.observe("mouseout", function(e){this.buttonMouseOutHandler(e);}.bindAsEventListener(this));
+		
+		this.field.observe("keydown", function(e){this.fieldKeyDownHandler(e);}.bindAsEventListener(this));
+		this.field.observe("blur", function(e){this.fieldBlurHandler(e);}.bindAsEventListener(this));
+		this.field.observe("focus", function(e){this.fieldFocusHandler(e);}.bindAsEventListener(this));
+		this.field.observe("keyup", function(e){this.dataUpdating(e);}.bindAsEventListener(this));
+		
+		this.comboList.listParent.observe("mousedown", function(e){this.listMousedownHandler(e);}.bindAsEventListener(this));
+		this.comboList.listParent.observe("mousemove", function(e){this.listMouseMoveHandler(e)}.bindAsEventListener(this));
+		this.comboList.listParent.observe("click", function(e){this.listClickHandler(e);}.bindAsEventListener(this));
 	},
 	
-	clickHandler : function(event) {
+	buttonClickHandler : function(event) {
 		if (this.comboList.visible()) {
 			this.comboList.hide();
 		} else {
@@ -76,32 +74,12 @@
 			}
 			this.comboList.isList = false;
 		}
-		this.field.focus();
 	},
 	
-	listListener : function(event) {
-		//changes item's decoration
-		var item = this.comboList.getEventItem(event);
-		if (item) {
-			this.comboList.doActiveItem(this.comboList.getEventItem(event));			
-		}
+	buttonMouseUpHandler : function(e) {
+		this.field.focus();			
 	},
 	
-	listMousedownHandler : function(e) {
-		if (Prototype.Browser.IE) {
-			if (!this.comboList.getEventItem(e)) {
-				this.clickOnScroll = true;
-			}
-			this.comboList.isList = true;
-		} 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;
 	},
@@ -123,55 +101,37 @@
 		}	
 	},
 	
+	listMouseMoveHandler : function(event) {
+		//changes item's decoration
+		var item = this.comboList.getEventItem(event);
+		if (item) {
+			this.comboList.doActiveItem(this.comboList.getEventItem(event));			
+		}
+	},
 	
-	fieldHandler : function() {
-		this.doActive();
-		if (this.field.value == this.defaultMessage) {
-			this.field.value = "";
+	listMousedownHandler : function(e) {
+		if (Prototype.Browser.IE) {
+			if (!this.comboList.getEventItem(e)) {
+				this.clickOnScroll = true;
+			}
+			this.comboList.isList = true;
+		} else if (Prototype.Browser.Gecko) {
+			if (this.comboList.getEventItem(e)) {
+				this.comboList.isList = true;			
+			}
 		} else {
-			if (this.isSelection) {
-				Richfaces.ComboBox.textboxSelect(this.field, 0, this.field.value.length);
-			}
-			this.isSelection = true;
+			this.comboList.isList = true;
 		}
 	},
 	
-	valueHandler : function(event) {
+	listClickHandler : function(event) {
 		this.isSelection = false;
 		this.field.focus();
 		this.setValue(true);
 		this.comboList.hide();
 	},
 	
-	setValue : function(toSetOnly) {
-		if (!this.comboList.activeItem) {
-			return;
-		}
-		var value = this.comboList.activeItem.innerHTML;
-		if (toSetOnly) {
-			var oV = this.field.value; 
-			if (oV == value) {
-				if (Prototype.Browser.Gecko) {
-					this.field.value = "";
-				}
-			}
-			this.field.value = value;
-			this.comboList.doSelectItem(this.comboList.activeItem);
-			this.combobox.fire("rich:onitemselected", {});
-			/*if (oV != value) {
-				this.combobox.fire("rich:onchange", {});
-			}*/
-		} else {
-			if (this.directInputSuggestions) {
-				var startInd = this.field.value.length; 
-				var endInd = value.length;
-				this.field.value = value;
-				Richfaces.ComboBox.textboxSelect(this.field, startInd, endInd);
-			} 
-		}
-	},
-	
-	keyboardManager : function(event) {
+	fieldKeyDownHandler : function(event) {
 		switch (event.keyCode) {
 			case Event.KEY_RETURN : 
 				this.setValue(true);
@@ -192,7 +152,19 @@
 		}
 	},
 	
-	focusHandler : function(event) {
+	fieldFocusHandler : function() {
+		this.doActive();
+		if (this.field.value == this.defaultMessage) {
+			this.field.value = "";
+		} else {
+			if (this.isSelection) {
+				Richfaces.ComboBox.textboxSelect(this.field, 0, this.field.value.length);
+			}
+			this.isSelection = true;
+		}
+	},
+	
+	fieldBlurHandler : function(event) {
 		if (!this.comboList.isList) {
 			var value = this.field.value; 
 			if (value.length == 0) {
@@ -217,10 +189,6 @@
 		}
 	},
 	
-	applyDefaultText : function() {
-		this.field.value = this.defaultMessage;
-	},
-	
 	dataUpdating : function(event) {
 		if (Richfaces.ComboBox.SPECIAL_KEYS.indexOf(event.keyCode) == -1) {
 			this.comboList.hide();
@@ -246,6 +214,39 @@
 			}
 		}
 	},
+	
+	setValue : function(toSetOnly) {
+		if (!this.comboList.activeItem) {
+			return;
+		}
+		var value = this.comboList.activeItem.innerHTML;
+		if (toSetOnly) {
+			var oV = this.field.value; 
+			if (oV == value) {
+				if (Prototype.Browser.Gecko) {
+					this.field.value = "";
+				}
+			}
+			this.field.value = value;
+			this.comboList.doSelectItem(this.comboList.activeItem);
+			this.combobox.fire("rich:onitemselected", {});
+			/*if (oV != value) {
+				this.combobox.fire("rich:onchange", {});
+			}*/
+		} else {
+			if (this.directInputSuggestions) {
+				var startInd = this.field.value.length; 
+				var endInd = value.length;
+				this.field.value = value;
+				Richfaces.ComboBox.textboxSelect(this.field, startInd, endInd);
+			} 
+		}
+	},
+	
+	applyDefaultText : function() {
+		this.field.value = this.defaultMessage;
+	},
+	
 	isActive : function() {
 		return (this.field.className == this.classes.FIELD.ACTIVE); 
 		
@@ -277,6 +278,10 @@
 		this.button.disabled = false;
 		this.field.disabled = false;
 		this.isDisabled = false;
+	},
+	
+	getCurrentWidth : function() {
+		return this.combobox.firstChild.offsetWidth;	
 	}
 };
 




More information about the richfaces-svn-commits mailing list