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

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Feb 26 04:41:32 EST 2008


Author: andrei_exadel
Date: 2008-02-26 04:41:32 -0500 (Tue, 26 Feb 2008)
New Revision: 6338

Modified:
   trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
   trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
disable functionality refactoring

Modified: trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
--- trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js	2008-02-25 19:31:49 UTC (rev 6337)
+++ trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js	2008-02-26 09:41:32 UTC (rev 6338)
@@ -577,9 +577,9 @@
 	},
 
 	processButtons: function () {
-		this.disableAddButton(this.disabled || this.maxFileBatchSize && this.entries.length >= this.maxFileBatchSize);
-		this.disableCleanButton(this.disabled || this.cleanAllDisabled());
-		this.disableUploadButton(this.disabled || this.uploadAllDisabled());
+		this.disableAddButton();
+		this.disableCleanButton();
+		this.disableUploadButton();
 		this.switchUploadButton();
 	},
 
@@ -625,43 +625,60 @@
 		}
 	},
 
-	disableCleanButton: function(disabled) {
-		if (disabled)
-			Element.hide($(this.id + ":clean1"));
-		else 
-			Element.show($(this.id + ":clean1"));
-	  	if(disabled) {
-    		$(this.id + ":clean1").onclick = function() {return false;};
+	disableCleanButton: function() {
+		var disabled = this.cleanAllDisabled();
+		var d1 = $(this.id + ":clean1");
+		var d2 = $(this.id + ":clean2");
+		if (disabled) {
+			Element.hide(d1);
+			return;
+		} else { 
+			Element.show(d1);
+		}
+		
+	  	if(this.disabled) {
+    		d1.onclick = function() {return false;};
     	} else {
-    		$(this.id + ":clean1").onclick = function() {return this.clear();}.bind(this);
+    		d1.onclick = function() {return this.clear();}.bind(this);
     	}
 
-    	$(this.id+":clean1").className = (disabled? this.classes.CLEAN.DISABLED : this.classes.CLEAN.ENABLED);
-    	$(this.id+":clean2").className = (disabled? this.classes.CLEAN_CONTENT.DISABLED : this.classes.CLEAN_CONTENT.ENABLED);
+    	d1.className = (this.disabled ? this.classes.CLEAN.DISABLED : this.classes.CLEAN.ENABLED);
+    	d2.className = (this.disabled ? this.classes.CLEAN_CONTENT.DISABLED : this.classes.CLEAN_CONTENT.ENABLED);
     	
     },
 
-    disableAddButton: function(disabled) {
-    	this.currentInput.disabled = disabled;
-    	if (disabled)
-    		Element.hide($(this.id+":add1"));
-    	else 
-    		Element.show($(this.id+":add1"));
-    	$(this.id+":add1").className = (disabled? this.classes.ADD.DISABLED : this.classes.ADD.ENABLED);
-    	$(this.id+":add2").className = (disabled? this.classes.ADD_CONTENT.DISABLED : this.classes.ADD_CONTENT.ENABLED);
+    disableAddButton: function() {
+    	var disabled = (this.maxFileBatchSize && this.entries.length >= this.maxFileBatchSize);
+    	this.currentInput.disabled = disabled || this.disabled;
+    	var d1 = $(this.id+":add1");
+    	var d2 = $(this.id+":add2");
+    	if (disabled) {
+    		Element.hide(d1);
+    		return;
+    	} else {
+    		Element.show(d1);
+    	}
+    	d1.className = (this.disabled ? this.classes.ADD.DISABLED : this.classes.ADD.ENABLED);
+    	d2.className = (this.disabled ? this.classes.ADD_CONTENT.DISABLED : this.classes.ADD_CONTENT.ENABLED);
     },
 
-    disableUploadButton: function (disabled) {
+    disableUploadButton: function () {
+    	var disabled = this.uploadAllDisabled();
+    	var d1 = $(this.id + ":upload1");
+    	var d2 = $(this.id + ":upload2");
     	if(disabled) {
-    		Element.hide($(this.id + ":upload1"));
-    		$(this.id + ":upload1").onclick = function() {return false;};
+    		Element.hide(d1);
     	} else {
-    		Element.show($(this.id + ":upload1"));
-    		$(this.id + ":upload1").onclick = function() {return this.upload();}.bind(this);
+    		Element.show(d1);
     	}
+    	if (this.disabled) {
+    		d1.onclick = function() {return false;};
+    	}else {
+    		d1.onclick = function() {return this.upload();}.bind(this);
+    	}
 
-    	$(this.id + ":upload1").className = (disabled? this.classes.UPDATE.DISABLED : this.classes.UPDATE.ENABLED);
-    	$(this.id + ":upload2").className = (disabled? this.classes.UPDATE_CONTENT.DISABLED : this.classes.UPDATE_CONTENT.ENABLED);
+    	d1.className = (this.disabled ? this.classes.UPDATE.DISABLED : this.classes.UPDATE.ENABLED);
+    	d2.className = (this.disabled ? this.classes.UPDATE_CONTENT.DISABLED : this.classes.UPDATE_CONTENT.ENABLED);
     },
     
     disable: function () {

Modified: trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx	2008-02-25 19:31:49 UTC (rev 6337)
+++ trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx	2008-02-26 09:41:32 UTC (rev 6338)
@@ -92,7 +92,7 @@
 						 style="display: none">
 						<a href="#" class="upload_button_selection">
 							<div class="upload_button_content upload_font upload_ico upload_ico_clear_dis #{component.attributes['cleanButtonClassDisabled']}"
-								 id="#{clientId}:clean2">Clean All</div>
+								 id="#{clientId}:clean2">Clear All</div>
 						</a>
 					</div>
 				</div>




More information about the richfaces-svn-commits mailing list