[richfaces-svn-commits] JBoss Rich Faces SVN: r2349 - in trunk/ui/modal-panel/src/main: java/org/richfaces/component and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 20 11:09:39 EDT 2007


Author: a.izobov
Date: 2007-08-20 11:09:38 -0400 (Mon, 20 Aug 2007)
New Revision: 2349

Modified:
   trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
   trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java
   trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
   trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
   trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-80 fixed

Modified: trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
===================================================================
--- trunk/ui/modal-panel/src/main/config/component/modalPanel.xml	2007-08-20 14:59:35 UTC (rev 2348)
+++ trunk/ui/modal-panel/src/main/config/component/modalPanel.xml	2007-08-20 15:09:38 UTC (rev 2349)
@@ -63,14 +63,14 @@
 			<description>
 				Attribute defines width of component
 			</description>
-			<defaultvalue>300</defaultvalue>
+			<defaultvalue>-1</defaultvalue>
 		</property>
 		<property>
 			<name>height</name>
 			<classname>int</classname>
 			<description>Attribute defines height of component
 			</description>
-			<defaultvalue>200</defaultvalue>
+			<defaultvalue>-1</defaultvalue>
 		</property>
 		
         <property>
@@ -208,6 +208,14 @@
             </description>
             <defaultvalue><![CDATA["disable"]]></defaultvalue>
         </property>
+       <property>
+			<name>autosized</name>
+			<classname>boolean</classname>
+			<description>
+				If 'true' modalPanel should be autosizeable
+			</description>
+			<defaultvalue>false</defaultvalue>
+		</property>
 		
 	</component>
 </components>

Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java
===================================================================
--- trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java	2007-08-20 14:59:35 UTC (rev 2348)
+++ trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java	2007-08-20 15:09:38 UTC (rev 2349)
@@ -61,9 +61,11 @@
 
 	public abstract boolean isResizeable();
 	public abstract boolean isMoveable();
+	public abstract boolean isAutosized();
 
 	public abstract void setResizeable(boolean resizeable);
 	public abstract void setMoveable(boolean moveable);
+	public abstract void setAutosized(boolean autosized);
 
 	public abstract String getLeft();
 	public abstract String getTop();
@@ -93,7 +95,7 @@
 	            shadow = Integer.toString(SHADOW_DEPTH);
 	        }
 
-	        String shadowStyle = "top: " + shadow + "; left: " + shadow + ";";
+	        String shadowStyle = "top: " + shadow + "px; left: " + shadow + "px;";
 	        
 	        FacesContext context = FacesContext.getCurrentInstance();
 	        if (null == context)

Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
--- trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java	2007-08-20 14:59:35 UTC (rev 2348)
+++ trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java	2007-08-20 15:09:38 UTC (rev 2349)
@@ -45,6 +45,8 @@
 
 	//TODO nick - set sizeA to actual min value
 	private static final int sizeA = 10;
+	private static final int DEFAULT_WIDTH = 300;
+	private static final int DEFAULT_HEIGHT = 200;
 	
 	private static final String STATE_OPTION_SUFFIX = "StateOption_";
 	
@@ -85,14 +87,17 @@
 
 	//TODO nick - add messages
 	public void checkOptions(FacesContext context, UIModalPanel panel) {
+		if (panel.isAutosized() && panel.isResizeable()) {
+			throw new IllegalArgumentException();
+		}
 		if (panel.getMinHeight() != -1) {
 			if (panel.getMinHeight() < sizeA) {
 				throw new IllegalArgumentException();
 			}
 			
-			if (panel.getHeight() < panel.getMinHeight()) {
-			    panel.setHeight(panel.getMinHeight());
-			}
+//			if (panel.getHeight() < panel.getMinHeight()) {
+//			    panel.setHeight(panel.getMinHeight());
+//			}
 		}
 
 		if (panel.getMinWidth() != -1) {
@@ -100,10 +105,10 @@
 				throw new IllegalArgumentException();
 			}
 
-			if (panel.getWidth() < panel.getMinWidth()) {
-			    panel.setWidth(panel.getMinWidth());
-			}
-		}
+//			if (panel.getWidth() < panel.getMinWidth()) {
+//			    panel.setWidth(panel.getMinWidth());
+//			}
+		} 
 	}
 
     public void initializeResources(FacesContext context, UIModalPanel panel)

Modified: trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2007-08-20 14:59:35 UTC (rev 2348)
+++ trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2007-08-20 15:09:38 UTC (rev 2349)
@@ -471,7 +471,16 @@
 		var eContentDiv = $(this.contentDiv);
 		var eShadowDiv = $(this.shadowDiv);
 
-		if (options.width) {
+		if (this.options.autosized) {
+			eContentDiv.style.overflow = "";
+		} else {
+			if (options.width && options.width == -1) 
+				options.width = 300;
+			if (options.height && options.height == -1) 
+				options.height = 200;
+		}
+			
+		if (options.width && options.width != -1) {
 			if (this.minWidth > options.width) {
 				options.width = this.minWidth;
 			}
@@ -483,7 +492,7 @@
 			eShadowDiv.style.width = options.width + (/px/.test(options.width) ? '' : 'px');
 		}
 
-		if (options.height) {
+		if (options.height && options.height != -1) {
 			if (this.minHeight > options.height) {
 				options.height = this.minHeight;
 			}
@@ -495,34 +504,6 @@
 			eShadowDiv.style.height = options.height + (/px/.test(options.height) ? '' : 'px');
 		}
 
-		if (options.left) {
-			var _left;
-			if (options.left != "auto") {
-				_left = parseInt(options.left, 10);
-			} else {
-				var cw = getSizeElement().clientWidth;
-				if (RichFaces.navigatorType() == "OPERA")
-				 	_left = (cw - eContentDiv.style.width.replace("px", "")) / 2;
-				 else
-					_left = (cw - Richfaces.getComputedStyleSize(eContentDiv, "width")) / 2;
-
-			}
-
-			this.setLeft(_left);
-		}
-
-		if (options.top) {
-			var _top;
-			if (options.top != "auto") {
-				_top = parseInt(options.top, 10);
-			} else {
-				var cw = getSizeElement().clientHeight;
-				_top = (cw - Richfaces.getComputedStyleSize(eContentDiv, "height")) / 2;
-			}
-
-			this.setTop(_top);
-		}
-
 		eCdiv.mpSet = true;
 
 		//Element.setStyle(this.dialogWindow.document.body, { "margin" : "0px 0px 0px 0px" });
@@ -578,6 +559,53 @@
 
 		Element.show(element);
 
+		if (options.left) {
+			var _left;
+			if (options.left != "auto") {
+				_left = parseInt(options.left, 10);
+			} else {
+				var cw = getSizeElement().clientWidth;
+				if (RichFaces.navigatorType() == "OPERA")
+				 	_left = (cw - eContentDiv.style.width.replace("px", "")) / 2;
+				 else {
+				 	var _width = Richfaces.getComputedStyleSize(eContentDiv, "width");
+				 	if (isNaN(_width))
+				 		_width = eContentDiv.clientWidth;
+					_left = (cw - _width) / 2;
+				 }
+
+			}
+
+			this.setLeft(_left);
+		}
+
+		if (options.top) {
+			var _top;
+			if (options.top != "auto") {
+				_top = parseInt(options.top, 10);
+			} else {
+				var cw = getSizeElement().clientHeight;
+				var _height = Richfaces.getComputedStyleSize(eContentDiv, "height");
+				if (isNaN(_height))
+					_height = eContentDiv.clientHeight;
+				_top = (cw - _height) / 2;
+			}
+
+			this.setTop(_top);
+		}
+
+		if (this.options.autosized) {
+			var cWidth = eContentDiv.clientWidth;
+			var cHeight = eContentDiv.clientHeight;
+			
+			eShadowDiv.style.width = cWidth+"px";
+			eShadowDiv.style.height = cHeight+"px";
+			if (eIframe) {
+				eIframe.style.width = cWidth+"px";
+				eIframe.style.height = cHeight+"px";
+			}
+		}
+
 		this.doResizeOrMove(ModalPanel.Sizer.Diff.EMPTY);
 
 		for (var k = 0; k < this.borders.length; k++ ) {

Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx	2007-08-20 14:59:35 UTC (rev 2348)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx	2007-08-20 15:09:38 UTC (rev 2349)
@@ -136,7 +136,9 @@
 					
 					keepVisualState: #{component.keepVisualState},
 					showWhenRendered: #{component.showWhenRendered},
-					selectBehavior: "#{component.tridentIVEngineSelectBehavior}"
+					selectBehavior: "#{component.tridentIVEngineSelectBehavior}",
+
+					autosized: #{component.autosized}
 				});
 			</script>
 		</div>




More information about the richfaces-svn-commits mailing list