Author: amarkhel
Date: 2010-07-11 08:16:01 -0400 (Sun, 11 Jul 2010)
New Revision: 17915
Added:
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
root/ui-sandbox/panels2/trunk/ui/src/test/resources/popupPanelText.xhtml
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPanel.java
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPopupPanel.java
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/popupPanel.ecss
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanel.js
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelBorders.js
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelSizer.js
root/ui-sandbox/panels2/trunk/ui/src/main/templates/popupPanel.template.xml
Log:
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPanel.java
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-07-11
12:16:01 UTC (rev 17915)
@@ -25,17 +25,17 @@
/**
* JSF component class
- *
+ *
*/
-public class UIPanel extends UIComponentBase
-{
- public boolean getRendersChildren() {
- return true;
- }
+public class UIPanel extends UIComponentBase {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
- @Override
- public String getFamily() {
- // TODO Auto-generated method stub
- return "org.richfaces.Panel";
- }
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
}
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPopupPanel.java
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPopupPanel.java 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPopupPanel.java 2010-07-11
12:16:01 UTC (rev 17915)
@@ -24,8 +24,6 @@
import java.util.HashMap;
import java.util.Map;
-import javax.el.ELException;
-import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.UIComponentBase;
@@ -34,163 +32,172 @@
/**
* JSF component class
- *
+ *
*/
-public class UIPopupPanel extends UIComponentBase{
-
- public static final String COMPONENT_TYPE = "org.richfaces.PopupPanel";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.PopupPanel";
-
- private Map<String, Object> visualOptions;
-
- protected enum PropertyKeys {
- selectBehaviour, width, height, zIndex, minHeight, minWidth, maxHeight, maxWidth,
top, left, moveable, autosized, modal, domElementAttachment, controlsClass, show,
headerClass, keepVisualState, label, overlapEmbedObjects, resizeable, shadowDepth,
shadowOpacity, trimOverlayedElements, style, styleClass, visualOptions, scrollerClass
+public class UIPopupPanel extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.PopupPanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.PopupPanel";
+
+ protected enum PropertyKeys {
+ width, height, zIndex, minHeight, minWidth, maxHeight, maxWidth, top, left,
moveable, autosized, modal, domElementAttachment, controlsClass, show, headerClass,
keepVisualState, overlapEmbedObjects, resizeable, shadowDepth, shadowOpacity, style,
styleClass, visualOptions
}
-
- public int getZIndex() {
+
+ public Map<String, Object> getHandledVisualOptions() {
+ String options = (String) getStateHelper().eval(PropertyKeys.visualOptions);
+ Map<String, Object> result;
+ result = prepareVisualOptions(options);
+
+ if (null == result) {
+ result = new HashMap<String, Object>();
+ }
+ return result;
+ }
+
+ public String getVisualOptions() {
+ return (String) getStateHelper().eval(PropertyKeys.visualOptions);
+ }
+
+ public void setVisualOptions(String visualOptions) {
+ getStateHelper().put(PropertyKeys.visualOptions, visualOptions);
+ }
+
+ public int getZIndex() {
return (Integer) getStateHelper().eval(PropertyKeys.zIndex, 100);
}
public void setZIndex(int zIndex) {
getStateHelper().put(PropertyKeys.zIndex, zIndex);
}
-
- public int getHeight() {
- return (Integer) getStateHelper().eval(PropertyKeys.height, 400);
+
+ public int getHeight() {
+ return (Integer) getStateHelper().eval(PropertyKeys.height, -1);
}
public void setHeight(int height) {
getStateHelper().put(PropertyKeys.height, height);
}
-
+
public int getWidth() {
- return (Integer) getStateHelper().eval(PropertyKeys.width, 600);
+ return (Integer) getStateHelper().eval(PropertyKeys.width, -1);
}
public void setWidth(int width) {
getStateHelper().put(PropertyKeys.width, width);
}
-
- public int getMinHeight() {
- return (Integer) getStateHelper().eval(PropertyKeys.minHeight, 10);
+
+ public int getMinHeight() {
+ return (Integer) getStateHelper().eval(PropertyKeys.minHeight, -1);
}
public void setMinHeight(int minheight) {
getStateHelper().put(PropertyKeys.minHeight, minheight);
}
-
+
public int getMinWidth() {
- return (Integer) getStateHelper().eval(PropertyKeys.minWidth, 10);
+ return (Integer) getStateHelper().eval(PropertyKeys.minWidth, -1);
}
public void setMinWidth(int minWidth) {
getStateHelper().put(PropertyKeys.minWidth, minWidth);
}
-
+
public int getMaxHeight() {
- return (Integer) getStateHelper().eval(PropertyKeys.maxHeight, 0);
+ return (Integer) getStateHelper().eval(PropertyKeys.maxHeight,
Integer.MAX_VALUE);
}
public void setMaxHeight(int maxheight) {
getStateHelper().put(PropertyKeys.maxHeight, maxheight);
}
-
+
public int getMaxWidth() {
- return (Integer) getStateHelper().eval(PropertyKeys.maxWidth, 0);
+ return (Integer) getStateHelper().eval(PropertyKeys.maxWidth,
Integer.MAX_VALUE);
}
public void setMaxWidth(int maxWidth) {
getStateHelper().put(PropertyKeys.maxWidth, maxWidth);
}
-
- public String getSelectBehaviour() {
- return (String) getStateHelper().eval(PropertyKeys.selectBehaviour);
- }
-
- public void setSelectBehaviour(String selectBehaviour) {
- getStateHelper().put(PropertyKeys.selectBehaviour, selectBehaviour);
- }
-
+
public String getTop() {
- return (String) getStateHelper().eval(PropertyKeys.top);
+ return (String) getStateHelper().eval(PropertyKeys.top, "auto");
}
public void setTop(String top) {
getStateHelper().put(PropertyKeys.top, top);
}
-
+
public String getLeft() {
- return (String) getStateHelper().eval(PropertyKeys.left);
+ return (String) getStateHelper().eval(PropertyKeys.left, "auto");
}
public void setLeft(String left) {
getStateHelper().put(PropertyKeys.left, left);
}
-
- public boolean isShow() {
+
+ public boolean isShow() {
return (Boolean) getStateHelper().eval(PropertyKeys.show, false);
}
- public void setShow(Boolean show) {
+ public void setShow(boolean show) {
getStateHelper().put(PropertyKeys.show, show);
}
-
- public boolean isMoveable() {
+
+ public boolean isMoveable() {
return (Boolean) getStateHelper().eval(PropertyKeys.moveable, true);
}
- public void setMoveable(Boolean moveable) {
+ public void setMoveable(boolean moveable) {
getStateHelper().put(PropertyKeys.moveable, moveable);
}
-
+
public boolean isAutosized() {
return (Boolean) getStateHelper().eval(PropertyKeys.autosized, false);
}
- public void setAutosized(Boolean autosized) {
+ public void setAutosized(boolean autosized) {
getStateHelper().put(PropertyKeys.autosized, autosized);
}
-
+
public boolean isModal() {
return (Boolean) getStateHelper().eval(PropertyKeys.modal, true);
}
- public void setModal(Boolean modal) {
+ public void setModal(boolean modal) {
getStateHelper().put(PropertyKeys.modal, modal);
}
-
+
public boolean isKeepVisualState() {
return (Boolean) getStateHelper().eval(PropertyKeys.keepVisualState, false);
}
- public void setKeepVisualState(Boolean keepVisualState) {
+ public void setKeepVisualState(boolean keepVisualState) {
getStateHelper().put(PropertyKeys.keepVisualState, keepVisualState);
}
-
+
public boolean isOverlapEmbedObjects() {
return (Boolean) getStateHelper().eval(PropertyKeys.overlapEmbedObjects, false);
}
- public void setOverlapEmbedObjects(Boolean overlapEmbedObjects) {
+ public void setOverlapEmbedObjects(boolean overlapEmbedObjects) {
getStateHelper().put(PropertyKeys.overlapEmbedObjects, overlapEmbedObjects);
}
-
+
public boolean isResizeable() {
return (Boolean) getStateHelper().eval(PropertyKeys.resizeable, true);
}
- public void setResizeable(Boolean resizeable) {
+ public void setResizeable(boolean resizeable) {
getStateHelper().put(PropertyKeys.resizeable, resizeable);
}
-
- public boolean isTrimOverlayedElements() {
- return (Boolean) getStateHelper().eval(PropertyKeys.trimOverlayedElements,
false);
- }
- public void setTrimOverlayedElements(Boolean trimOverlayedElements) {
- getStateHelper().put(PropertyKeys.trimOverlayedElements, trimOverlayedElements);
- }
+ /*
+ * public boolean isTrimOverlayedElements() { return (Boolean)
+ * getStateHelper().eval(PropertyKeys.trimOverlayedElements, false); }
+ *
+ * public void setTrimOverlayedElements(boolean trimOverlayedElements) {
+ * getStateHelper().put(PropertyKeys.trimOverlayedElements, trimOverlayedElements);
}
+ */
public String getDomElementAttachment() {
return (String) getStateHelper().eval(PropertyKeys.domElementAttachment);
@@ -208,14 +215,12 @@
getStateHelper().put(PropertyKeys.controlsClass, controlsClass);
}
- public String getLabel() {
- return (String) getStateHelper().eval(PropertyKeys.label);
- }
+ /*
+ * public String getLabel() { return (String)
getStateHelper().eval(PropertyKeys.label); }
+ *
+ * public void setLabel(String label) { getStateHelper().put(PropertyKeys.label,
label); }
+ */
- public void setLabel(String label) {
- getStateHelper().put(PropertyKeys.label, label);
- }
-
public String getHeaderClass() {
return (String) getStateHelper().eval(PropertyKeys.headerClass);
}
@@ -223,15 +228,14 @@
public void setHeaderClass(String headerClass) {
getStateHelper().put(PropertyKeys.headerClass, headerClass);
}
-
- public String getScrollerClass() {
- return (String) getStateHelper().eval(PropertyKeys.scrollerClass);
- }
- public void setScrollerClass(String scrollerClass) {
- getStateHelper().put(PropertyKeys.scrollerClass, scrollerClass);
- }
-
+ /*
+ * public String getScrollerClass() { return (String)
getStateHelper().eval(PropertyKeys.scrollerClass); }
+ *
+ * public void setScrollerClass(String scrollerClass) {
getStateHelper().put(PropertyKeys.scrollerClass,
+ * scrollerClass); }
+ */
+
public String getShadowDepth() {
return (String) getStateHelper().eval(PropertyKeys.shadowDepth);
}
@@ -239,7 +243,7 @@
public void setShadowDepth(String shadowDepth) {
getStateHelper().put(PropertyKeys.shadowDepth, shadowDepth);
}
-
+
public String getShadowOpacity() {
return (String) getStateHelper().eval(PropertyKeys.shadowOpacity);
}
@@ -247,82 +251,30 @@
public void setShadowOpacity(String shadowOpacity) {
getStateHelper().put(PropertyKeys.shadowOpacity, shadowOpacity);
}
-
- public String getShadowStyle() {
- String shadow = getShadowDepth();
- String shadowStyle ="";
- if (shadow != null) {
- shadowStyle = "top: " + shadow + "px; left: " + shadow +
"px;";
- }
-
- String opacity = getShadowOpacity();
- String filterOpacity;
- if (opacity != null) {
- try {
- Double op = Double.valueOf(opacity);
- filterOpacity = Integer.toString(op.intValue() * 10);
- opacity = Double.toString(op.doubleValue() / 10);
- } catch (Exception e) {
- // illegal opacity
- return "";
- }
- shadowStyle += " opacity:" + opacity
- + "; filter:alpha(opacity=" + filterOpacity +
");";
- }
- return shadowStyle;
- }
-
- public Object getVisualOptions() {
- if (null != this.visualOptions) {
- return this.visualOptions;
- }
-
- ValueExpression ve = getValueExpression("visualOptions");
- if (null != ve) {
- try {
- Object value = ve.getValue(getFacesContext().getELContext());
- this.visualOptions = prepareVisualOptions(value);
- return this.visualOptions;
- } catch (ELException e) {
- throw new FacesException(e);
- }
- }
-
- if (null == this.visualOptions) {
- this.visualOptions = new HashMap<String, Object>();
- }
- return this.visualOptions;
- }
- public void setVisualOptions(Object visualOptions) {
- this.visualOptions = prepareVisualOptions(visualOptions);
- }
+ private Map<String, Object> prepareVisualOptions(Object value) {
+ if (null == value) {
+ return new HashMap<String, Object>();
+ } else if (value instanceof Map) {
+ return (Map<String, Object>) value;
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (!s.startsWith("{")) {
+ s = "{" + s + "}";
+ }
+ try {
+ return new HashMap<String, Object>(new JSONMap(s));
+ } catch (JSONException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ throw new FacesException("Attribute visualOptions of component [" +
this.getClientId(getFacesContext())
+ + "] must be instance of Map or String, but its type is " +
value.getClass().getSimpleName());
+ }
+ }
- private Map<String, Object> prepareVisualOptions(Object value) {
- if (null == value) {
- return new HashMap<String, Object>();
- } else if (value instanceof Map) {
- return (Map<String, Object>) value;
- } else if (value instanceof String) {
- String s = (String) value;
- if (!s.startsWith("{")) {
- s = "{" + s + "}";
- }
- try {
- return new HashMap<String, Object>(new JSONMap(s));
- } catch (JSONException e) {
- throw new FacesException(e);
- }
- } else {
- throw new FacesException("Attribute visualOptions of component [" +
- this.getClientId(getFacesContext()) + "] must be instance of Map or String, but
its type is " +
- value.getClass().getSimpleName());
- }
- }
-
- @Override
- public String getFamily() {
- // TODO Auto-generated method stub
- return COMPONENT_FAMILY;
- }
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
}
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-07-11
12:16:01 UTC (rev 17915)
@@ -17,224 +17,193 @@
import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UIPopupPanel;
-
-@ResourceDependencies( {
- @ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js"),
+@ResourceDependencies( { @ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "richfaces-base-component.js"),
@ResourceDependency(name = "script/popupPanel.js"),
- @ResourceDependency(name = "script/popupPanelBorders.js"),
- @ResourceDependency(name = "script/popupPanelSizer.js"),
+ @ResourceDependency(name = "script/popupPanelBorders.js"),
@ResourceDependency(name = "script/popupPanelSizer.js"),
@ResourceDependency(name = "css/popupPanel.ecss")
})
-public class PopupPanelBaseRenderer extends RendererBase{
+public class PopupPanelBaseRenderer extends RendererBase {
- private static final String CONTROLS_FACET = "controls";
- private static final String HEADER_FACET = "header";
- private static final int sizeA = 10;
- private static final String STATE_OPTION_SUFFIX = "StateOption_";
-
- public String getShadowStyle(FacesContext context, UIComponent component) {
- UIPopupPanel panel = (UIPopupPanel)component;
- return panel.getShadowStyle();
- }
- public void renderHeaderFacet(FacesContext context, UIComponent component) throws
IOException {
- renderFacet(context, component, HEADER_FACET);
+ private static final String CONTROLS_FACET = "controls";
+ private static final String HEADER_FACET = "header";
+ private static final int SIZE = 10;
+ private static final String STATE_OPTION_SUFFIX = "StateOption_";
+ private static final Set<String> ALLOWED_ATTACHMENT_OPTIONS = new
HashSet<String>();
+ static {
+ ALLOWED_ATTACHMENT_OPTIONS.add("body");
+ ALLOWED_ATTACHMENT_OPTIONS.add("parent");
+ ALLOWED_ATTACHMENT_OPTIONS.add("form");
}
-
- public void renderControlsFacet(FacesContext context, UIComponent component) throws
IOException {
- renderFacet(context, component, CONTROLS_FACET);
+
+ public void renderHeaderFacet(FacesContext context, UIComponent component) throws
IOException {
+ renderFacet(context, component, HEADER_FACET);
}
-
- private void renderFacet(FacesContext context, UIComponent component, String facet)
throws IOException{
- UIComponent headerFacet = component.getFacet(facet);
- headerFacet.encodeAll(context);
- }
-
- @SuppressWarnings("unchecked")
- protected void doDecode(FacesContext context, UIComponent component) {
- super.doDecode(context, component);
-
- UIPopupPanel panel = (UIPopupPanel)component;
- ExternalContext exCtx = context.getExternalContext();
- Map<String, String> rqMap = exCtx.getRequestParameterMap();
- Object panelOpenState = rqMap.get(panel.getClientId(context) +
"OpenedState");
-
- if (panel.isKeepVisualState()) {
- if (null != panelOpenState) {
- // Bug
https://jira.jboss.org/jira/browse/RF-2466
- // Incorrect old:
- // panel.setShowWhenRendered(Boolean.parseBoolean((String) clnId));
- // ShowWhenRendered can be settled separately with modal panel
"showWhenRendered" attribute
- // so we should combine ShowWhenRendered || KeepVisualState &&
(OpenedState==TRUE) against rewriting
- boolean show = panel.isShow() || Boolean.parseBoolean((String)
panelOpenState);
- panel.setShow(show);
-
- Map<String, Object> visualOptions = (Map<String, Object>)
panel.getVisualOptions();
- Iterator<Entry<String, String>> it = rqMap.entrySet().iterator();
- while ( it.hasNext()) {
- Map.Entry<String, String> entry = it.next();
- int suffixPos = entry.getKey().toString().indexOf(STATE_OPTION_SUFFIX);
- if (-1 != suffixPos) {
- String key = entry.getKey().toString().substring(suffixPos +
STATE_OPTION_SUFFIX.length());
- visualOptions.put(key, entry.getValue());
- }
- }
- }
- }
- }
-
- protected Class getComponentClass() {
- return UIPopupPanel.class;
- }
- private static final Set<String> ALLOWED_ATTACHMENT_OPTIONS = new
HashSet<String>();
- static {
- ALLOWED_ATTACHMENT_OPTIONS.add("body");
- ALLOWED_ATTACHMENT_OPTIONS.add("parent");
- ALLOWED_ATTACHMENT_OPTIONS.add("form");
- }
-
- //TODO nick - add messages
- public void checkOptions(FacesContext context, UIComponent component) {
- UIPopupPanel panel = (UIPopupPanel)component;
- if (panel.isAutosized() && panel.isResizeable()) {
- throw new IllegalArgumentException("Autosized modal panel can't be
resizeable.");
- }
-
- String domElementAttachment = panel.getDomElementAttachment();
- if (domElementAttachment != null && domElementAttachment.trim().length() != 0)
{
- if (!ALLOWED_ATTACHMENT_OPTIONS.contains(domElementAttachment)) {
- throw new IllegalArgumentException("Value '" + domElementAttachment +
"' of domElementAttachment attribute is illegal. " +
- "Allowed values are: " + ALLOWED_ATTACHMENT_OPTIONS);
- }
- }
-
- if (panel.getMinHeight() != -1) {
- if (panel.getMinHeight() < sizeA) {
- throw new IllegalArgumentException();
- }
-
-// if (panel.getHeight() < panel.getMinHeight()) {
-// panel.setHeight(panel.getMinHeight());
-// }
- }
+ public void renderControlsFacet(FacesContext context, UIComponent component) throws
IOException {
+ renderFacet(context, component, CONTROLS_FACET);
+ }
- if (panel.getMinWidth() != -1) {
- if (panel.getMinWidth() < sizeA) {
- throw new IllegalArgumentException();
- }
+ private void renderFacet(FacesContext context, UIComponent component, String facet)
throws IOException {
+ UIComponent headerFacet = component.getFacet(facet);
+ headerFacet.encodeAll(context);
+ }
-// if (panel.getWidth() < panel.getMinWidth()) {
-// panel.setWidth(panel.getMinWidth());
-// }
- }
- }
-
-// protected String buildOptions(FacesContext context, UIModalPanel panel) {
-// return getOptions(context, panel, getUtils());
-// }
-
- public boolean getRendersChildren() {
- return true;
- }
-
- @SuppressWarnings("unchecked")
- public String buildShowScript(FacesContext context, UIComponent component) {
- UIPopupPanel panel = (UIPopupPanel)component;
- StringBuilder result = new StringBuilder();
-
- // Bug
https://jira.jboss.org/jira/browse/RF-2466
- // We are already processed KeepVisualState and current open state in
- // doDecode, so no need to check panel.isKeepVisualState() here.
- if (/*panel.isKeepVisualState() || */panel.isShow()) {
- result.append("RichFaces.ui.PopupPanel.showPopupPanel('" +
panel.getClientId(context) + "', {");
-
- Iterator<Map.Entry<String, Object>> it = ((Map<String, Object>)
panel.getVisualOptions()).entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<String, Object> entry = it.next();
-
- result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
- if (it.hasNext()) {
- result.append(", ");
- }
- }
-
- result.append("});");
- }
- return result.toString();
- }
-
- public String buildScript(FacesContext context, UIComponent component) throws
IOException {
- UIPopupPanel panel = (UIPopupPanel)component;
- StringBuilder result = new StringBuilder();
- result.append("new RichFaces.ui.PopupPanel('");
- result.append(panel.getClientId());
- result.append("',{");
- result.append("width:");
- result.append(panel.getWidth());
- result.append(",");
- result.append("height:");
- result.append(panel.getHeight());
- result.append(",");
- result.append("minWidth:");
- result.append(panel.getMinWidth());
- result.append(",");
- result.append("minHeight:");
- result.append(panel.getMinHeight());
- result.append(",");
- result.append("maxWidth:");
- result.append(panel.getMaxWidth());
- result.append(",");
- result.append("maxHeight:");
- result.append(panel.getMaxHeight());
- result.append(",");
- result.append("resizeable:");
- result.append(panel.isResizeable());
- result.append(",");
- result.append("moveable:");
- result.append(panel.isMoveable());
- result.append(",");
- result.append("left:");
- result.append(panel.getLeft());
- result.append(",");
- result.append("top:");
- result.append(panel.getTop());
- result.append(",");
- result.append("zIndex:");
- result.append(panel.getZIndex());
- result.append(",");
- result.append(writeEventHandlerFunction(context, panel,"onresize"));
- result.append(writeEventHandlerFunction(context, panel,"onmove"));
- result.append(writeEventHandlerFunction(context, panel,"onshow"));
- result.append(writeEventHandlerFunction(context, panel,"onhide"));
- result.append(writeEventHandlerFunction(context, panel,"onbeforeshow"));
- result.append(writeEventHandlerFunction(context, panel,"onbeforehide"));
- result.append("domElementAttachment:");
- result.append(panel.getDomElementAttachment());
- result.append(",");
- result.append("keepVisualState:");
- result.append(panel.isKeepVisualState());
- result.append(",");
- result.append("show:");
- result.append(panel.isShow());
- result.append(",");
- result.append("selectBehaviour:");
- result.append(panel.getSelectBehaviour());
- result.append(",");
- result.append("autosized:");
- result.append(panel.isAutosized());
- result.append(",");
- result.append("overlapEmbedObjects:");
- result.append(panel.isOverlapEmbedObjects());
- //result.append(",");
- //result.append(writeVisualOptions(context, panel));
- result.append("});");
- return result.toString();
- }
-
- public String writeEventHandlerFunction(FacesContext context, UIComponent component,
String eventName) throws IOException{
- String event = (String) component.getAttributes().get(eventName);
+ @SuppressWarnings("unchecked")
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+ UIPopupPanel panel = (UIPopupPanel) component;
+ ExternalContext exCtx = context.getExternalContext();
+ Map<String, String> rqMap = exCtx.getRequestParameterMap();
+ Object panelOpenState = rqMap.get(panel.getClientId(context) +
"OpenedState");
+
+ if (panel.isKeepVisualState()) {
+ if (null != panelOpenState) {
+ // Bug
https://jira.jboss.org/jira/browse/RF-2466
+ // Incorrect old:
+ // panel.setShowWhenRendered(Boolean.parseBoolean((String) clnId));
+ // ShowWhenRendered can be settled separately with modal panel
"showWhenRendered" attribute
+ // so we should combine ShowWhenRendered || KeepVisualState &&
(OpenedState==TRUE) against rewriting
+ boolean show = panel.isShow() || Boolean.parseBoolean((String)
panelOpenState);
+ panel.setShow(show);
+
+ Map<String, Object> visualOptions = (Map<String, Object>)
panel.getHandledVisualOptions();
+ Iterator<Entry<String, String>> it =
rqMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, String> entry = it.next();
+ int suffixPos =
entry.getKey().toString().indexOf(STATE_OPTION_SUFFIX);
+ if (-1 != suffixPos) {
+ String key = entry.getKey().toString().substring(suffixPos +
STATE_OPTION_SUFFIX.length());
+ visualOptions.put(key, entry.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ protected Class getComponentClass() {
+ return UIPopupPanel.class;
+ }
+
+ public void checkOptions(FacesContext context, UIComponent component) {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ if (panel.isAutosized() && panel.isResizeable()) {
+ throw new IllegalArgumentException("Autosized modal panel can't be
resizeable.");
+ }
+
+ String domElementAttachment = panel.getDomElementAttachment();
+ if (domElementAttachment != null && domElementAttachment.trim().length()
!= 0) {
+ if (!ALLOWED_ATTACHMENT_OPTIONS.contains(domElementAttachment)) {
+ throw new IllegalArgumentException("Value '" +
domElementAttachment
+ + "' of domElementAttachment attribute is illegal. " +
"Allowed values are: "
+ + ALLOWED_ATTACHMENT_OPTIONS);
+ }
+ }
+
+ if (panel.getMinHeight() != -1) {
+ if (panel.getMinHeight() < SIZE) {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ if (panel.getMinWidth() != -1) {
+ if (panel.getMinWidth() < SIZE) {
+ throw new IllegalArgumentException();
+ }
+
+ }
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String buildShowScript(FacesContext context, UIComponent component) {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ StringBuilder result = new StringBuilder();
+
+ // Bug
https://jira.jboss.org/jira/browse/RF-2466
+ // We are already processed KeepVisualState and current open state in
+ // doDecode, so no need to check panel.isKeepVisualState() here.
+ if (panel.isShow()) {
+ result.append("RichFaces.ui.PopupPanel.showPopupPanel('" +
panel.getClientId(context) + "', {");
+
+ Iterator<Map.Entry<String, Object>> it = ((Map<String,
Object>) panel.getHandledVisualOptions()).entrySet()
+ .iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, Object> entry = it.next();
+
+ result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
+ if (it.hasNext()) {
+ result.append(", ");
+ }
+ }
+
+ result.append("});");
+ }
+ return result.toString();
+ }
+
+ private void writeOption(StringBuilder builder, String attribbute, Object value,
UIComponent component,
+ boolean isString) {
+ if (component.getAttributes().get(attribbute) != null) {
+ builder.append(attribbute + ":");
+ if (isString) {
+ builder.append("'");
+ }
+ builder.append(value);
+ if (isString) {
+ builder.append("'");
+ }
+ builder.append(",");
+ }
+ }
+
+ public String buildScript(FacesContext context, UIComponent component) throws
IOException {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ StringBuilder result = new StringBuilder();
+ result.append("new RichFaces.ui.PopupPanel('");
+ result.append(panel.getClientId());
+ result.append("',{");
+ writeOption(result, "width", panel.getWidth(), component, false);
+ writeOption(result, "height", panel.getHeight(), component, false);
+ writeOption(result, "minWidth", panel.getMinWidth(), component,
false);
+ writeOption(result, "minHeight", panel.getMinHeight(), component,
false);
+ writeOption(result, "maxWidth", panel.getMaxWidth(), component,
false);
+ writeOption(result, "maxHeight", panel.getMaxHeight(), component,
false);
+ writeOption(result, "resizeable", panel.isResizeable(), component,
false);
+ writeOption(result, "moveable", panel.isMoveable(), component, false);
+ writeOption(result, "left", panel.getLeft(), component, true);
+ writeOption(result, "top", panel.getTop(), component, true);
+ writeOption(result, "zIndex", panel.getZIndex(), component, false);
+ writeOption(result, "onresize", writeEventHandlerFunction(context,
panel, "onresize"), component, false);
+ writeOption(result, "onmove", writeEventHandlerFunction(context, panel,
"onmove"), component, false);
+ writeOption(result, "onshow", writeEventHandlerFunction(context, panel,
"onshow"), component, false);
+ writeOption(result, "onhide", writeEventHandlerFunction(context, panel,
"onhide"), component, false);
+ writeOption(result, "onbeforeshow", writeEventHandlerFunction(context,
panel, "onbeforeshow"), component, false);
+ writeOption(result, "onbeforehide", writeEventHandlerFunction(context,
panel, "onbeforehide"), component, false);
+ writeOption(result, "shadowDepth", panel.getShadowDepth(), component,
true);
+ writeOption(result, "shadowOpacity", panel.getShadowOpacity(),
component, true);
+ writeOption(result, "domElementAttachment",
panel.getDomElementAttachment(), component, true);
+ writeOption(result, "keepVisualState", panel.isKeepVisualState(),
component, false);
+ writeOption(result, "show", panel.isShow(), component, false);
+ writeOption(result, "autosized", panel.isAutosized(), component,
false);
+ writeOption(result, "overlapEmbedObjects",
panel.isOverlapEmbedObjects(), component, false);
+ result.delete(result.length() - 1, result.length());
+ if (component.getAttributes().get("visualOptions") != null) {
+ result.append(writeVisualOptions(context, panel));
+ }
+ result.append("});");
+ return result.toString();
+ }
+
+ public String writeEventHandlerFunction(FacesContext context, UIComponent component,
String eventName)
+ throws IOException {
+ String event = (String) component.getAttributes().get(eventName);
+
if (event != null) {
event = event.trim();
@@ -249,24 +218,24 @@
}
return "";
- }
-
- private String writeVisualOptions(FacesContext context, UIPopupPanel panel)
- throws IOException {
- StringBuffer result = new StringBuffer();
-
- Iterator<Map.Entry<String, Object>> it = ((Map<String, Object>)
panel.getVisualOptions()).entrySet().iterator();
- if (it.hasNext()) {
- result.append(",\n");
- }
- while (it.hasNext()) {
- Map.Entry<String, Object> entry = it.next();
-
- result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
- if (it.hasNext()) {
- result.append(",\n");
- }
- }
- return result.toString();
- }
+ }
+
+ private String writeVisualOptions(FacesContext context, UIPopupPanel panel) throws
IOException {
+ StringBuffer result = new StringBuffer();
+
+ Iterator<Map.Entry<String, Object>> it = ((Map<String, Object>)
panel.getHandledVisualOptions()).entrySet()
+ .iterator();
+ if (it.hasNext()) {
+ result.append(",\n");
+ }
+ while (it.hasNext()) {
+ Map.Entry<String, Object> entry = it.next();
+
+ result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
+ if (it.hasNext()) {
+ result.append(",");
+ }
+ }
+ return result.toString();
+ }
}
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/popupPanel.ecss
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/popupPanel.ecss 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/popupPanel.ecss 2010-07-11
12:16:01 UTC (rev 17915)
@@ -8,6 +8,7 @@
top: 0px;
z-index: -300;
opacity:0.1;
+ filter : 'alpha(opacity=10)';
}
.mp_shade {
@@ -18,6 +19,7 @@
left : 0px;
background : #D0D0D0;
opacity:0.5;
+ filter : 'alpha(opacity=50)';
}
.mp_iframe {
position : absolute;
@@ -26,26 +28,16 @@
top:0px;
left : 0px;
opacity:0.3;
+ filter : 'alpha(opacity=30)';
}
.mp_shadow {
position : fixed;
- top : 50%;
- left : 50%;
- width : 602px;
- height : 402px ;
background-color : #000000;
- margin-top : -197px;
- margin-left : -297px;
opacity:0.1;
+ filter : 'alpha(opacity=10)';
}
.mp_container {
position : fixed;
- top : 50%;
- left : 50%;
- width : 600px;
- height : 400px;
- margin-top : -200px;
- margin-left : -300px;
border : '1px solid #{richSkin.panelBorderColor}';
background : '#{richSkin.generalBackgroundColor}';
z-index:100;
@@ -53,22 +45,21 @@
.mp_header {
background :
"url(#{resource['org.richfaces.renderkit.html.GradientA']})";
repeat-x : 'top left #{richSkin.headerBackgroundColor}';
- height : 30px;
position : relative;
- padding-right : 60px;
padding-left : 10px;
cursor : move;
+ padding : 2px;
}
.mp_header_content {
overflow : hidden;
- width : 100%;
white-space : nowrap;
- padding-top : 8px;
text-overflow: ellipsis;
font-weight : '#{richSkin.headerWeightFont}';
color : '#{richSkin.headerTextColor}';
font-family : '#{richSkin.headerFamilyFont}';
font-size : '#{richSkin.headerSizeFont}';
+ padding : 2px;
+ padding-left : 10px;
}
.mp_header_controls {
background : "url(#{resource['images/close_act.gif']}) no-repeat
center";
@@ -90,13 +81,10 @@
text-align : middle;
}
.mp_content_scroller {
- width : 600px ;
- height : 370px ;
position : relative;
top : 0px;
left : 0px;
overflow : auto;
- overflow-x : hidden;
}
.mp_content {
position : relative;
@@ -127,6 +115,16 @@
right : 0px;
cursor : w-resize;
}
+
+.mp-iframe {
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ background-color: white;
+ overflow-y: hidden;
+ z-index: -1;
+}
+
.mp_handler_top {
width : 100%;
height : 7px;
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanel.js
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanel.js 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanel.js 2010-07-11
12:16:01 UTC (rev 17915)
@@ -1,21 +1,20 @@
(function ($, richfaces) {
richfaces.ui = richfaces.ui || {};
- var selectionEventHandler=function(event){event.stopPropagation();};
+ var selectionEventHandler = function(event){
+ event.stopPropagation();
+ event.preventDefault();
+ };
var disableSelection = function (element)
{
if (typeof element.onselectstart!="undefined") //IE
{
- jQuery(element).bind( 'selectstart', this.selectionEventHandler);
+ jQuery(element).bind( 'selectstart', selectionEventHandler);
}
- else if (typeof element.style.MozUserSelect!="undefined") //Firefox
- {
- jQuery(element).css('MozUserSelect','none');
- }
else //All other (ie: Opera)
{
- jQuery(element).bind( 'mousedown', this.selectionEventHandler);
+ jQuery(element).bind( 'mousedown', selectionEventHandler);
}
}
@@ -23,7 +22,7 @@
{
if (typeof element.onselectstart!="undefined") //IE
{
- jQuery(element).unbind( 'selectstart', this.selectionEventHandler);
+ jQuery(element).unbind( 'selectstart', selectionEventHandler);
}
else if (typeof element.style.MozUserSelect!="undefined") //Firefox
{
@@ -31,44 +30,32 @@
}
else //All other (ie: Opera)
{
- jQuery(element).unbind( 'mousedown', this.selectionEventHandler);
+ jQuery(element).unbind( 'mousedown', selectionEventHandler);
}
}
-
- PANELS = new Array();
- ACTIVEPANELS = new Array();
- var getSizeElements = function() {
- return document.body;
- }
-
- var getMinimumSize = function(size) {
- return Math.max(size, 2*richfaces.ui.PopupPanel.Sizer.INITIAL_MIN + 2);//TODO
- };
richfaces.ui.PopupPanel = function(id, options) {
$super.constructor.call(this,id);
-
+ this.markerId = id;
$p.attachToDom.call(this, id);
id = "#" + id;
this.options = options;
- this.firstOutside = null;
- this.lastOutside = null;
- this.markerId = $(id);
this.id = $(id);
-
+ this.minWidth = this.getMinimumSize(this.options.minWidth);
+ this.minHeight = this.getMinimumSize(this.options.minHeight);
+ this.maxWidth = this.options.maxWidth;
+ this.maxHeight = this.options.maxHeight;
this.options = options;
this.baseZIndex = this.options.zindex ? this.options.zindex : 100;
-
- this.minWidth = getMinimumSize(this.options.minWidth);
- this.minHeight = getMinimumSize(this.options.minHeight);
this.div = id;
- this.cdiv = id + "_container";//TODO remove one
+ this.cdiv = id + "_container";
this.contentDiv = id + "_content";
this.shadowDiv = id + "_shadow";
+ this.scrollerDiv = id + "_content_scroller"
this.borders = new Array();
@@ -86,21 +73,15 @@
if (this.options.moveable && $(id + "_header")) {
this.header = new richfaces.ui.PopupPanel.Border(id + "_header", this,
"move", richfaces.ui.PopupPanel.Sizer.Header);
+ } else{
+ $(id + "_header").css('cursor', 'default');
}
- this.markerId.component = this;
-
- PANELS.push(this);
-
- this.firstHref = id + "FirstHref";
- this.lastHref = id + "LastHref";
- this.selectBehavior = options.selectBehavior;
};
var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.PopupPanel);
var $p =
richfaces.BaseComponent.extend(richfaces.BaseComponent,richfaces.ui.PopupPanel, {});
var $super = richfaces.ui.PopupPanel.$super;
-
$.extend(richfaces.ui.PopupPanel.prototype, (function (options) {
return {
@@ -116,46 +97,48 @@
},
width: function() {
- return this.getSizedElement().clientWidth;
+ return this.getContentElement()[0].clientWidth;//TODO
},
height: function() {
- return this.getSizedElement().clientHeight;
+ return this.getContentElement()[0].clientHeight;//TODO
},
-
- getSizedElement: function() {
- if (!this._sizedElement) {
- this._sizedElement = $(this.cdiv);
+
+ getLeft : function (){
+ return $(this.cdiv).css('left');
+ },
+
+ getTop : function (){
+ return $(this.cdiv).css('top');
+ },
+
+ getInitialSize : function(){
+ if(this.options.autosized){
+ return $(this.div+"_headerSpan").height();
+ } else{
+ return $(this.div + "_header_content").height();
}
-
- return this._sizedElement;
},
-
+
getContentElement: function() {
if (!this._contentElement) {
- this._contentElement = $(this.contentDiv);
+ this._contentElement = $(this.cdiv);
}
return this._contentElement;
},
-
+ getSizeElement : function() {
+ return document.body;
+ },
+
+ getMinimumSize : function(size) {
+ return Math.max(size, 2*this.getInitialSize() + 2);
+ },
destroy: function() {
-
- if (this.observerSize) {
- window.clearInterval(this.observerSize);
- this.observerSize = null;
- }
this._contentElement = null;
- this._sizedElement = null;
-
- //PANELS = PANELS.without(this);
-
- //ACTIVEPANELS = ACTIVEPANELS.without(this);
this.parent = null;
- this.firstOutside = null;
- this.lastOutside = null;
if (this.header) {
this.header.destroy();
this.header=null;
@@ -170,12 +153,9 @@
var element = this.id;
var parent = $(element).parent();
if (parent) {
- parent.removeChild(element);
+ parent.remove(element);
}
}
-
- this.markerId.component = null;
- this.markerId = null;
},
initIframe : function() {
@@ -187,97 +167,31 @@
}
if("transparent" == $(document.body).css("background-color")) {
- this.style.filter = "alpha(opacity=0)";
- this.style.opacity = "0";
+ $(this).css('filter', "alpha(opacity=0)");
+ $(this).css('opacity', "0");
}
},
setLeft: function(pos) {
- $(this.cdiv).css('left', pos + "px");
+ if(!isNaN(pos)){
+ $(this.cdiv).css('left', pos + "px");
+ var depth = this.options.shadowDepth ? this.options.shadowDepth : 2;
+ $(this.shadowDiv).css('left', pos + depth + "px");
+ }
},
setTop: function(pos) {
- $(this.cdiv).css('top', pos + "px");
- },
-
- firstOnfocus: function(event) {
- var e = $(this.firstHref)
- //if (e && (ACTIVEPANELS.last() == this)) {
- e.focus();
- //}
- },
-
- lastOnfocus: function(event) {
- var e = $(this.lastHref);
- //if (e && (ACTIVEPANELS.last() == this)) {
- e.focus();
- //}
- },
-
- processAllFocusElements: function(root, callback) {
-
- var popup = this;
- $('a, input, select, button, textarea',
root).not(':disabled').not(':hidden').each(function(index) {
- callback.call($(this), popup);
- });
- },
-
- processTabindexes: function(popup) {
- if (!popup.firstOutside ) {
- popup.firstOutside = this;
+ if(!isNaN(pos)){
+ $(this.cdiv).css('top', pos + "px");
+ var depth = this.options.shadowDepth ? this.options.shadowDepth : 2;
+ $(this.shadowDiv).css('top', pos + depth +"px");
}
- popup.lastOutside = this;
- if (this.tabIndex && !this.prevTabIndex) {
- this.prevTabIndex = this.tabIndex;
- }
- this.tabIndex = undefined;
- if (this.accesskey && !this.prevAccesskey) {
- this.prevAccesskey = this.accesskey;
- }
- this.accesskey = undefined;
},
- restoreTabindexes: function(popup) {
- if (this.prevTabIndex) {
- this.tabIndex = this.prevTabIndex;
- this.prevTabIndex = undefined;
- }
- if (this.prevAccesskey) {
- this.accesskey = this.prevAccesskey;
- this.prevAccesskey = undefined;
- }
- },
-
- preventFocus: function() {
- this.processAllFocusElements(document, this.processTabindexes);
-
- if (this.firstOutside) {
- $(this.firstOutside).bind( "focus", this.firstOnfocus);
- }
- if (this.lastOutside && this.lastOutside != this.firstOutside) {
- $(this.lastOutside).bind( "focus", this.lastOnfocus);
- }
- },
-
- restoreFocus: function() {
- this.processAllFocusElements(document, this.restoreTabindexes);
-
- if (this.firstOutside) {
- $(this.firstOutside).unbind("focus", this.eventFirstOnfocus);
- this.firstOutside = null;
- }
- if (this.lastOutside) {
- $(this.lastOutside).unbind("focus", this.eventLastOnfocus);
- this.lastOutside = null;
- }
- },
-
show: function(event, opts) {
if(!this.shown &&
this.invokeEvent("beforeshow",event,null,element)) {
var element = this.id;
-
- this.preventFocus();
if (!this.domReattached) {
this.parent = $(element).parent();
@@ -303,38 +217,27 @@
if (newParent != this.parent) {
this.saveInputValues(element);
- element.insertBefore(newParent);
+ element.insertBefore(newParent.firstChild);
this.domReattached = true;
} else {
$(this.parent).show();
}
}
- var eCdiv = $(this.cdiv);
- var forms = $("form", eCdiv);
+ var forms = $("form", element);
if (this.options.keepVisualState && forms) {
for (var i = 0; i < forms.length; i++) {
- $(forms[i]).bind( "submit", this.setStateInput);
+ var popup = this;
+ $(forms[i]).bind( "submit", {popup:popup}, this.setStateInput);
}
}
- var eIframe;
- if (this.options.overlapEmbedObjects && !this.iframe) {
- this.iframe = this.id + "IFrame";
- $("<iframe src=\"javascript:''\"
frameborder=\"0\" scrolling=\"no\" id=\"" + this.iframe +
"\" " +
- "class=\"rich-mpnl-iframe\" style=\"width: 1px; height:
1px;\">" +
- "</iframe>").insertBefore($(':first-child', eCdiv));
-
- eIframe = jQery(this.iframe);
+
- $(eIframe).bind('load', this.initIframe);
- }
-
var options = {};
this.userOptions = {};
-
- if (!eCdiv.mpSet) {
+ if (!element.mpSet) {
$.extend(options, this.options);
}
@@ -343,44 +246,64 @@
$.extend(this.userOptions, opts);
}
- this.currentMinHeight = getMinimumSize((options.minHeight || options.minHeight == 0)
? options.minHeight : this.minHeight);
- this.currentMinWidth = getMinimumSize((options.minWidth || options.minWidth == 0) ?
options.minWidth : this.minWidth);
+ this.currentMinHeight = this.getMinimumSize((options.minHeight || options.minHeight
== 0) ? options.minHeight : this.minHeight);
+ this.currentMinWidth = this.getMinimumSize((options.minWidth || options.minWidth ==
0) ? options.minWidth : this.minWidth);
var eContentElt = this.getContentElement();
if (!this.options.autosized) {
if (options.width && options.width == -1)
- options.width = 300;
+ options.width = 600;
if (options.height && options.height == -1)
- options.height = 200;
+ options.height = 400;
+ } else{
+ options.width = $(this.div+"_headerSpan").width() +20;
}
if (options.width && options.width != -1) {
if (this.currentMinWidth > options.width) {
options.width = this.currentMinWidth;
}
-
+ if (options.width > this.maxWidth) {
+ options.width = this.maxWidth;
+ }
$(eContentElt).css('width', options.width + (/px/.test(options.width) ?
'' : 'px'));
+ $(this.shadowDiv).css('width', options.width + 4 +
(/px/.test(options.width) ? '' : 'px'));
+ $(this.scrollerDiv).css('width', options.width + (/px/.test(options.width)
? '' : 'px'));
+
+
}
if (options.height && options.height != -1) {
if (this.currentMinHeight > options.height) {
options.height = this.currentMinHeight;
}
-
+ if (options.height > this.maxHeight) {
+ options.height = this.maxHeight;
+ }
$(eContentElt).css('height', options.height + (/px/.test(options.height) ?
'' : 'px'));
+ $(this.shadowDiv).css('height', options.height + 4 +
(/px/.test(options.height) ? '' : 'px'));
+ var headerHeight = $(this.div +"_header")[0].clientHeight;
+ $(this.scrollerDiv).css('height', options.height - headerHeight +
(/px/.test(options.height) ? '' : 'px'));
+
+
}
+ var eIframe;
+ if (this.options.overlapEmbedObjects && !this.iframe) {
+ this.iframe = this.markerId + "IFrame";
+ $("<iframe src=\"javascript:''\"
frameborder=\"0\" scrolling=\"no\" id=\"" + this.iframe +
"\" " +
+ "class=\"mp-iframe\" style=\"width:" +this.options.width +
"px; height:" + this.options.height + "px;\">" +
+ "</iframe>").insertBefore($(':first-child',
$(this.cdiv))[0]);
+
+ eIframe = jQuery("#"+this.iframe);
- eCdiv.mpSet = true;
+ $(eIframe).bind('load', this.initIframe);
+ this.eIframe = eIframe;
+ }
+ element.mpSet = true;
- //ACTIVEPANELS = ACTIVEPANELS.without(this);
- ACTIVEPANELS.push(this);
-
var eDiv = $(this.div);
- $(element).css('visibility', '');
- this.correctShadowSize();
-
if (options.left) {
var _left;
if (options.left != "auto") {
@@ -414,28 +337,12 @@
this.setTop(Math.round(_top));
}
-
- if (this.options.autosized) {
- this.observerSize =
- window.setInterval(this.correctShadowSize.bindAsEventListener(this), 500);
- }
-
- this.doResizeOrMove(richfaces.ui.PopupPanel.Sizer.Diff.EMPTY);//TODO
-
- for (var k = 0; k < this.borders.length; k++ ) {
- this.borders[k].doPosition();
- }
-
- if (this.header) {
- this.header.doPosition();
- }
-
- $(eCdiv).hide().css('visibility', '');
-
- this.lastOnfocus();
-
- $(eCdiv).show();
-
+
+ var opacity = options.shadowOpacity ? options.shadowOpacity : 0.1;
+ $(this.shadowDiv).css('opacity', opacity);
+ $(this.shadowDiv).css('filter ', 'alpha(opacity='+opacity*100
+');');
+ $(element).css('visibility', '');
+ $(element).css('display', 'block');
var event = {};
event.parameters = opts || {};
this.shown = true;
@@ -459,27 +366,19 @@
},
hide: function(event, opts) {
+ var element = this.id;
if (this.shown &&
this.invokeEvent("beforehide",event,null,element)) {
this.currentMinHeight = undefined;
- this.currentMinWidth = undefined;
-
- this.restoreFocus();
-
- this.enableSelects();
+ this.currentMinWidth = undefined;
- //ACTIVEPANELS = ACTIVEPANELS.without(this);
-
- var eDiv = $(this.div);
- var eCdiv = $(this.cdiv);
-
$(this.id).hide();
if (this.parent) {
if (this.domReattached) {
this.saveInputValues(element);
- this.parent.appendChild(element);
+ this.parent.append(element);
this.domReattached = false;
} else {
@@ -493,7 +392,7 @@
this.options.onhide(event);
}
- var forms = $("form", eCdiv);
+ var forms = $("form", element);
if (this.options.keepVisualState && forms) {
for (var i = 0; i < forms.length; i++) {
$(forms[i]).unbind( "submit", this.setStateInput);
@@ -502,14 +401,6 @@
this.shown = false;
- if (this.observerSize) {
- window.clearInterval(this.observerSize);
- this.observerSize = null;
- }
-
- if (ACTIVEPANELS.length > 0) {
- ACTIVEPANELS.last().preventFocus();
- }
}
},
@@ -519,12 +410,18 @@
doResizeOrMove: function(diff) {
var vetoes = {};
+ var shadowHash = {};
var cssHash = {};
var cssHashWH = {};
+ var shadowHashWH = {};
+ var contentHashWH = {};
+ var scrollerHashWH = {};
var vetoeChange = false;
var newSize;
-
+ var shadowDepth = this.options.shadowDepth? this.options.shadowDepth: 4;
+ var scrollerHeight = 22;
+ var scrollerWidth = 0;
var eContentElt = this.getContentElement();
newSize = this.getStyle(eContentElt, "width");
@@ -532,20 +429,39 @@
var oldSize = newSize;
newSize += diff.deltaWidth || 0;
+
+
if (newSize >= this.currentMinWidth || this.options.autosized) {
if (diff.deltaWidth) {
cssHashWH.width = newSize + 'px';
+ shadowHashWH.width = newSize + shadowDepth + 'px';
+ contentHashWH.width = newSize - scrollerWidth + 'px';
+ scrollerHashWH.width = newSize - scrollerWidth + 'px';
}
} else {
if (diff.deltaWidth) {
cssHashWH.width = this.currentMinWidth + 'px';
-
+ shadowHashWH.width = this.currentMinWidth + shadowDepth + 'px';
+ contentHashWH.width = this.currentMinWidth - scrollerWidth + 'px';
+ scrollerHashWH.width = this.currentMinWidth - scrollerWidth + 'px';
vetoes.vx = oldSize - this.currentMinWidth;
}
vetoes.x = true;
}
+
+ if (newSize >= this.options.maxWidth) {
+ if (diff.deltaWidth) {
+ cssHashWH.width = this.currentMaxWidth + 'px';
+ shadowHashWH.width = this.currentMaxWidth + shadowDepth + 'px';
+ contentHashWH.width = this.currentMaxWidth - scrollerWidth + 'px';
+ scrollerHashWH.width = this.currentMaxWidth - scrollerWidth + 'px';
+ vetoes.vx = oldSize - this.currentMaxWidth;
+ }
+ vetoes.x = true;
+ }
+
if (vetoes.vx && diff.deltaX) {
diff.deltaX = -vetoes.vx;
}
@@ -561,6 +477,8 @@
newPos = this.getStyle(eCdiv, "left");
newPos += diff.deltaX;
cssHash.left = newPos + 'px';
+
+ shadowHash.left = newPos + shadowDepth + "px";
}
newSize = this.getStyle(eContentElt, "height")
@@ -571,17 +489,31 @@
if (newSize >= this.currentMinHeight || this.options.autosized) {
if (diff.deltaHeight) {
cssHashWH.height = newSize + 'px';
+ shadowHashWH.height = newSize + shadowDepth + 'px';
+ scrollerHashWH.height = newSize - scrollerHeight + 'px';
}
} else {
if (diff.deltaHeight) {
cssHashWH.height = this.currentMinHeight + 'px';
-
+ shadowHashWH.height = this.currentMinHeight + shadowDepth + 'px';
+ scrollerHashWH.height = this.currentMinHeight - scrollerHeight + 'px';
vetoes.vy = oldSize - this.currentMinHeight;
}
vetoes.y = true;
}
+
+ if (newSize >= this.options.maxHeight) {
+ if (diff.deltaHeight) {
+ cssHashWH.height = this.currentMaxHeight + 'px';
+ shadowHashWH.height = this.currentMaxHeight + shadowDepth + 'px';
+ scrollerHashWH.height = this.currentMaxHeight - scrollerHeight + 'px';
+ vetoes.vy = oldSize - this.currentMaxHeight;
+ }
+ vetoes.y = true;
+ }
+
if (vetoes.vy && diff.deltaY) {
diff.deltaY = -vetoes.vy;
}
@@ -592,27 +524,38 @@
}
}
-
+ if (diff.deltaY && (vetoes.vy || !vetoes.y)) {
+ if (vetoes.vy) {
+ diff.deltaY = vetoes.vy;
+ }
+ var newPos;
+
+ newPos = this.getStyle(eCdiv, "top");
+ newPos += diff.deltaY;
+ cssHash.top = newPos + 'px';
+ shadowHash.top = newPos + shadowDepth + "px";
+ }
$(eContentElt).css(cssHashWH);
+ $(this.scrollerDiv).css(scrollerHashWH);
+ if(this.eIframe)$(this.eIframe).css(scrollerHashWH);
+ $(this.shadowDiv).css(shadowHashWH);
$(eCdiv).css(cssHash);
-
- this.correctShadowSize();
-
+ $(this.shadowDiv).css(shadowHash);
+ //if(this.eIframe)$(this.eIframe).css(cssHash);
$.extend(this.userOptions, cssHash);
$.extend(this.userOptions, cssHashWH);
-
var w = this.width();
var h = this.height();
this.reductionData = null;
- if (w <= 2*richfaces.ui.PopupPanel.Sizer.INITIAL_MAX) {//todo
+ if (w <= 2*this.getInitialSize()) {
this.reductionData = {};
this.reductionData.w = w;
}
- if (h <= 2*richfaces.ui.PopupPanel.Sizer.INITIAL_MAX) {//todo
+ if (h <= 2*this.getInitialSize()) {
if (!this.reductionData) {
this.reductionData = {};
}
@@ -626,6 +569,31 @@
return vetoes;
},
+
+ setSize : function (width, height){
+ var w = width - this.width() ;
+ var h = height -this.height();
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(0,0, w, h);
+ this.doResizeOrMove(diff);
+ },
+
+ moveTo : function (top, left){
+ var shadowDepth = this.options.shadowDepth? this.options.shadowDepth: 4;
+ $(this.cdiv).css('top', top);
+ $(this.cdiv).css('left', left);
+ $(this.shadowDiv).css('top', top + shadowDepth);
+ $(this.shadowDiv).css('left', left + shadowDepth);
+ },
+
+ move : function (dx, dy){
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(dx,dy, 0, 0);
+ this.doResizeOrMove(diff);
+ },
+
+ resize : function (dx, dy){
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(0,0, dx, dy);
+ this.doResizeOrMove(diff);
+ },
findForm: function(elt) {
var target = elt;
@@ -642,54 +610,30 @@
return target;
},
- setStateInput: function(target) {
+ setStateInput: function(event) {
// Concret input but not entire form is a target element for onsubmit in FF
- target = this.findForm(target);
+ var popup = event.data.popup;
+ target = $(popup.findForm(event.currentTarget));
var input = document.createElement("input");
input.type = "hidden";
- input.id = this.markerId.id + "OpenedState";
- input.name = this.markerId.id + "OpenedState";
- input.value = this.shown ? "true" : "false";
- target.appendChild(input);
+ input.id = popup.markerId + "OpenedState";
+ input.name = popup.markerId + "OpenedState";
+ input.value = popup.shown ? "true" : "false";
+ target.append(input);
- $.each(userOptions, function(key, value) {
+ $.each(popup.userOptions, function(key, value) {
input = document.createElement("input");
input.type = "hidden";
- input.id = this.id.id + "StateOption_" + key;
- input.name = this.id.id + "StateOption_" + key;
+ input.id = popup.markerId + "StateOption_" + key;
+ input.name = popup.markerId + "StateOption_" + key;
input.value = value;
- target.appendChild(input);
+ target.append(input);
});
return true;
},
- correctShadowSize: function() {
- var eShadowDiv = $(this.shadowDiv);
- if (!eShadowDiv) {
- return;
- }
- var eIframe = $(this.iframe);
-
- var dx = 0;
- var dy = 0;
- if (!$.browser.msie)
- {
- dx = eShadowDiv.offsetWidth-eShadowDiv.clientWidth;
- dy = eShadowDiv.offsetHeight-eShadowDiv.clientHeight;
- }
- var w = this.width();
- var h = this.height();
- $(eShadowDiv).css('width ', (w-dx)+"px");
- $(eShadowDiv).css('height' , (h-dy)+"px");
-
- if (eIframe) {
- $(eIframe).css('width',w+"px");
- $(eIframe).css('height',h+"px");
- }
- },
-
invokeEvent: function(eventName, event, value, element) {
var eventFunction = this.options['on'+eventName];
@@ -721,69 +665,22 @@
result = true;
}
return result;
- },
- showModalPanel : function (id, opts, event) {
-
- var invoke =
- ($.browser.msie || $.browser.safari) ?
- function(f) {
- if (document.readyState != "complete") {
- var args = arguments;
- var dis = this;
- window.setTimeout(
- function() {
- args.callee.apply(dis,args );
- }, 50);
- } else {
- f();
- }
- } :
- function(f) {
- f();
- };
-
- var panel = $(id);
- if (!panel) {
- panel = findModalPanel(id);
}
- invoke(function() {
- $(panel.component).show(opts);
- });
- },
-
- hideModalPanel : function (id, opts, event) {
- var panel = $(id);
- if (!panel) {
- panel = findModalPanel(id);
- }
- $(panel.component).hide(opts);
- },
-
- findModalPanel : function (id) {
- if (id) {
- var prefId = (id.charAt(0) == ':' ? id : ':' + id);
-
- for (var i = 0; i < PANELS.length; i++ ) {
- var pnl = PANELS[i];
- if (pnl && pnl.markerId) {
- var pnlId = pnl.markerId.id;
-
- if (pnlId) {
- //try to match ids
- if (pnlId.length >= prefId.length) {
- var substr = pnlId.substring(pnlId.length - prefId.length, pnlId.length);
- if (substr == prefId) {
- return pnl.markerId;
- }
- }
- }
- }
- }
- }
- }
+
}
})());
+ $.extend(richfaces.ui.PopupPanel, {
+
+ showPopupPanel : function (id, opts, event) {
+
+ $(document).ready(richfaces.$(id).show());
+ },
+ hidePopupPanel : function (id, opts, event) {
+ $(document).ready(richfaces.$(id).hide());
+ }
+ });
+
})(jQuery, window.RichFaces);
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelBorders.js
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelBorders.js 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelBorders.js 2010-07-11
12:16:01 UTC (rev 17915)
@@ -8,14 +8,11 @@
var element = jQuery(id);
jQuery(element).css('cursor',cursor);
+ var border = this;
+ jQuery(this.id).bind( 'mousedown', {border:border},this.startDrag);
- jQuery(this.id).bind( 'mousedown', this.startDrag, new Date());
-
this.modalPanel = modalPanel;
this.sizer = sizer;
-
- //this.boundDoDrag = this.doDrag.bindAsEventListener(this);
- //this.boundEndDrag = this.endDrag.bindAsEventListener(this);
};
var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.PopupPanel.Border);
@@ -48,21 +45,21 @@
},
startDrag: function(event) {
- this.doingDrag = true;
+ var border = event.data.border;
+ border.doingDrag = true;
- this.dragX = event.clientX;
- this.dragY = event.clientY;
-
- jQuery(document).bind( 'mousemove', this.doDrag);
- jQuery(document).bind( 'mouseup', this.endDrag);
+ border.dragX = event.clientX;
+ border.dragY = event.clientY;
+ jQuery(document).bind( 'mousemove',{border:border}, border.doDrag);
+ jQuery(document).bind( 'mouseup',{border:border}, border.endDrag);
- var eCursorDiv = jQuery(this.modalPanel.cDiv);
- jQuery(eCursorDiv).css('cursor', jQuery(this.id).css('cursor'));
- jQuery(eCursorDiv).css('zIndex', 10);
+ //var eCursorDiv = jQuery(border.modalPanel.cDiv);
+ //jQuery(eCursorDiv).css('cursor', jQuery(border.id).css('cursor'));
+ //jQuery(eCursorDiv).css('zIndex', 10);
- this.modalPanel.startDrag(this);
+ border.modalPanel.startDrag(border);
- this.onselectStartHandler = document.onselectstart;
+ border.onselectStartHandler = document.onselectstart;
document.onselectstart = function() { return false; }
},
@@ -82,16 +79,15 @@
},
doDrag: function(event) {
- if (!this.doingDrag) {
+ var border = event.data.border;
+ if (!border.doingDrag) {
return ;
}
var evtX = event.clientX;
var evtY = event.clientY;
- var winSize = this.getWindowSize();
-
- //window.status = "" + evtX + " " + evtY;
+ var winSize = border.getWindowSize();
if (evtX < 0) {
evtX = 0;
@@ -105,48 +101,48 @@
evtY = winSize.height - 1;
}
- var dx = evtX - this.dragX;
- var dy = evtY - this.dragY;
+ var dx = evtX - border.dragX;
+ var dy = evtY - border.dragY;
if (dx != 0 || dy != 0) {
- var id = this.id;
+ var id = border.id;
- var diff = this.sizer.doDiff(dx, dy);
+ var diff = border.sizer.prototype.doDiff(dx, dy);//TODO
var doResize;
- var element = jQuery(this.modalPanel.cdiv);
+ var element = jQuery(border.modalPanel.cdiv);
if (diff.deltaWidth || diff.deltaHeight) {
- doResize = this.modalPanel.invokeEvent("resize",event,null,element);
+ doResize = border.modalPanel.invokeEvent("resize",event,null,element);
} else if (diff.deltaX || diff.deltaY) {
- doResize = this.modalPanel.invokeEvent("move",event,null,element);
+ doResize = border.modalPanel.invokeEvent("move",event,null,element);
}
var vetoes;
if (doResize) {
- vetoes = this.modalPanel.doResizeOrMove(diff);
+ vetoes = border.modalPanel.doResizeOrMove(diff);
}
if(vetoes){
if (!vetoes.x) {
- this.dragX = evtX;
+ border.dragX = evtX;
} else {
if (!diff.deltaX) {
- this.dragX -= vetoes.vx || 0;
+ border.dragX -= vetoes.vx || 0;
} else {
- this.dragX += vetoes.vx || 0;
+ border.dragX += vetoes.vx || 0;
}
}
if (!vetoes.y) {
- this.dragY = evtY;
+ border.dragY = evtY;
} else {
if (!diff.deltaY) {
- this.dragY -= vetoes.vy || 0;
+ border.dragY -= vetoes.vy || 0;
} else {
- this.dragY += vetoes.vy || 0;
+ border.dragY += vetoes.vy || 0;
}
}
}
@@ -154,20 +150,18 @@
},
endDrag: function(event) {
- this.doingDrag = undefined;
+ var border = event.data.border;
+ border.doingDrag = undefined;
- jQuery(document).unbind( 'mousemove', this.doDrag);
- jQuery(document).unbind( 'mouseup', this.endDrag);
+ jQuery(document).unbind( 'mousemove', border.doDrag);
+ jQuery(document).unbind( 'mouseup', border.endDrag);
- this.modalPanel.endDrag(this);
+ border.modalPanel.endDrag(border);
- this.modalPanel.doResizeOrMove(richfaces.ui.PopupPanel.Sizer.Diff.EMPTY);
- jQuery(this.modalPanel.cursorDiv).css('zIndex ', -200);
+ border.modalPanel.doResizeOrMove(richfaces.ui.PopupPanel.Sizer.Diff.EMPTY);
- document.onselectstart = this.onselectStartHandler;
- this.onselectStartHandler = null;
-
- var id = this.id;
+ document.onselectstart = border.onselectStartHandler;
+ border.onselectStartHandler = null;
},
doPosition: function() {
Modified:
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelSizer.js
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelSizer.js 2010-07-11
00:06:08 UTC (rev 17914)
+++
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelSizer.js 2010-07-11
12:16:01 UTC (rev 17915)
@@ -14,6 +14,7 @@
return {
name: "richfaces.ui.PopupPanel.Sizer",
+
doSetupSize: function (modalPanel, elt) {
var width = 0;
var height = 0;
@@ -33,15 +34,15 @@
if (width > 0) {
if (elt.clientWidth > width) {
if (!elt.reducedWidth) {
- elt.reducedWidth = elt.style.width;
+ elt.reducedWidth = jQuery(elt).css('width');
}
- elt.style.width = width + 'px';
- } else if (width < ModalPanel.Sizer.INITIAL_MAX && /* TODO fix the dirty
code */elt.reducedWidth == ModalPanel.Sizer.INITIAL_MAX + 'px') {
- elt.style.width = width + 'px';
+ jQuery(elt).css('width', width + 'px');
+ } else if (width < 4 && elt.reducedWidth == 4 + 'px') {
+ jQuery(elt).css('width', width + 'px');
}
} else {
if (elt.reducedWidth) {
- elt.style.width = elt.reducedWidth;
+ jQuery(elt).css('width', elt.reducedWidth);
elt.reducedWidth = undefined;
}
}
@@ -49,23 +50,25 @@
if (height > 0) {
if (elt.clientHeight > height) {
if (!elt.reducedHeight) {
- elt.reducedHeight = elt.style.height;
+ elt.reducedHeight = jQuery(elt).css('height');
}
elt.style.height = height + 'px';
- } else if (height < ModalPanel.Sizer.INITIAL_MAX && /* TODO fix the dirty
code */elt.reducedHeight == ModalPanel.Sizer.INITIAL_MAX + 'px') {
- elt.style.height = height + 'px';
+ } else if (height < 4 && elt.reducedHeight == 4 + 'px') {
+ jQuery(elt).css('height', height + 'px');
}
} else {
if (elt.reducedHeight) {
- elt.style.height = elt.reducedHeight;
+ jQuery(elt).css('height', elt.reducedHeight);
elt.reducedHeight = undefined;
}
}
},
doSetupPosition: function (modalPanel, elt, left, top) {
- elt.style.left = left + 'px';
- elt.style.top = top + 'px';
+ if(!isNaN(left) && !isNaN(top)){
+ jQuery(elt).css('left', left + 'px');
+ jQuery(elt).css('top', top + 'px');
+ }
},
doPosition: function (modalPanel, elt) {
@@ -95,10 +98,10 @@
richfaces.ui.PopupPanel.Sizer.N = function(){
}
- richfaces.ui.PopupPanel.Sizer.N.prototype = richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.N.prototype, (function (options) {
+
+ $.extend(richfaces.ui.PopupPanel.Sizer.N.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.N.prototype, {
- return {
name: "richfaces.ui.PopupPanel.Sizer.N",
@@ -111,16 +114,13 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(0, dy, 0, -dy);
},
- }
- })());
+ });
richfaces.ui.PopupPanel.Sizer.NW = function(){
}
- richfaces.ui.PopupPanel.Sizer.NW.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.NW.prototype, (function (options) {
-
- return {
+ $.extend(richfaces.ui.PopupPanel.Sizer.NW.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.NW.prototype, {
name: "richfaces.ui.PopupPanel.Sizer.NW",
@@ -133,16 +133,13 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(dx, dy, -dx, -dy);
}
- }
- })());
+ });
richfaces.ui.PopupPanel.Sizer.NE = function(){
}
- richfaces.ui.PopupPanel.Sizer.NE.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.NE.prototype, (function (options) {
-
- return {
+ $.extend(richfaces.ui.PopupPanel.Sizer.NE.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.NE.prototype, {
name: "richfaces.ui.PopupPanel.Sizer.NE",
@@ -155,43 +152,18 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(0, dy, dx, -dy);
}
- }
- })());
+ });
- richfaces.ui.PopupPanel.Sizer.NEL = function(){
-
- }
- richfaces.ui.PopupPanel.Sizer.NEL.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.NEL.prototype, (function (options) {
-
- return {
-
- name: "richfaces.ui.PopupPanel.Sizer.NEL",
-
- doPosition : function (popupPanel, elt) {
- this.doSetupSize(popupPanel, elt);
- this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0);
- },
-
- doDiff : function(dx, dy) {
- return new richfaces.ui.PopupPanel.Sizer.Diff(0, dy, dx, -dy);
- }
-
- }
- })());
-
richfaces.ui.PopupPanel.Sizer.E = function(){
}
- richfaces.ui.PopupPanel.Sizer.E.prototype = richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.E.prototype, (function (options) {
-
- return {
+ $.extend(richfaces.ui.PopupPanel.Sizer.E.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.E.prototype, {
name: "richfaces.ui.PopupPanel.Sizer.E",
doPosition : function (popupPanel, elt) {
- jQuery(elt)/css('height', popupPanel.height() + 'px');
+ jQuery(elt).css('height', popupPanel.height() + 'px');
this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0);
},
@@ -199,16 +171,13 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, dx, 0);
}
- }
- })());
+ });
richfaces.ui.PopupPanel.Sizer.SE = function(){
}
- richfaces.ui.PopupPanel.Sizer.SE.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.prototype.SE, (function (options) {
-
- return {
+ $.extend(richfaces.ui.PopupPanel.Sizer.SE.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.prototype.SE, {
name: "richfaces.ui.PopupPanel.Sizer.SE",
@@ -222,39 +191,13 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, dx, dy);
}
- }
- })());
+ });
- richfaces.ui.PopupPanel.Sizer.SEL = function(){
-
- }
- richfaces.ui.PopupPanel.Sizer.SEL.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.SEL.prototype, (function (options) {
-
- return {
-
- name: "richfaces.ui.PopupPanel.Sizer.SEL",
-
- doPosition : function (popupPanel, elt) {
- this.doSetupSize(PopupPanel, elt);
- this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth,
- popupPanel.height() - elt.clientHeight);
- },
-
- doDiff : function(dx, dy) {
- return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, dx, dy);
- }
-
- }
- })());
-
richfaces.ui.PopupPanel.Sizer.S = function(){
}
- richfaces.ui.PopupPanel.Sizer.S.prototype = richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.S.prototype, (function (options) {
-
- return {
+ $.extend(richfaces.ui.PopupPanel.Sizer.S.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.S.prototype,{
name: "richfaces.ui.PopupPanel.Sizer.S",
@@ -267,39 +210,16 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, 0, dy);
}
- }
- })());
+ });
- richfaces.ui.PopupPanel.Sizer.SWL = function(){
-
- }
- richfaces.ui.PopupPanel.Sizer.SWL.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.SWL.prototype, (function (options) {
-
- return {
-
- name: "richfaces.ui.PopupPanel.Sizer.SWL",
-
- doPosition : function (popupPanel, elt) {
- this.doSetupSize(popupPanel, elt);
- this.doSetupPosition(popupPanel, elt, 0, popupPanel.height() - elt.clientHeight);
- },
-
- doDiff : function(dx, dy) {
- return new richfaces.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, dy);
- }
-
- }
- })());
richfaces.ui.PopupPanel.Sizer.SW = function(){
}
- richfaces.ui.PopupPanel.Sizer.SW.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.SW.prototype, (function (options) {
+ $.extend(richfaces.ui.PopupPanel.Sizer.SW.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.SW.prototype,{
- return {
-
+
name: "richfaces.ui.PopupPanel.Sizer.SW",
doPosition : function (popupPanel, elt) {
@@ -311,17 +231,15 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, dy);
}
- }
- })());
+ });
richfaces.ui.PopupPanel.Sizer.W = function(){
}
- richfaces.ui.PopupPanel.Sizer.W.prototype = richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.W.prototype, (function (options) {
+ $.extend(richfaces.ui.PopupPanel.Sizer.W.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.W.prototype,{
- return {
-
+
name: "richfaces.ui.PopupPanel.Sizer.W",
doPosition : function (popupPanel, elt) {
@@ -333,39 +251,17 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, 0);
}
- }
- })());
-
- richfaces.ui.PopupPanel.Sizer.NWL = function(){
- }
- richfaces.ui.PopupPanel.Sizer.NWL.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.NWL.prototype, (function (options) {
-
- return {
-
- name: "richfaces.ui.PopupPanel.Sizer.NWL",
-
- doPosition : function (popupPanel, elt) {
- this.doSetupSize(popupPanel, elt);
- this.doSetupPosition(popupPanel, elt, 0, 0);
- },
-
- doDiff : function(dx, dy) {
- return new richfaces.ui.PopupPanel.Sizer.Diff(dx, dy, -dx, -dy);
- }
-
- }
- })());
+ });
+
richfaces.ui.PopupPanel.Sizer.Header = function(){
}
- richfaces.ui.PopupPanel.Sizer.Header.prototype =
richfaces.ui.PopupPanel.Sizer.prototype;
- $.extend(richfaces.ui.PopupPanel.Sizer.Header.prototype, (function (options) {
+ $.extend(richfaces.ui.PopupPanel.Sizer.Header.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.Header.prototype, {
- return {
-
+
name: "richfaces.ui.PopupPanel.Sizer.Header",
doPosition : function (popupPanel, elt) {
@@ -376,8 +272,8 @@
return new richfaces.ui.PopupPanel.Sizer.Diff(dx, dy, 0, 0);
}
- }
- })());
+
+ });
})(jQuery, window.RichFaces);
\ No newline at end of file
Modified: root/ui-sandbox/panels2/trunk/ui/src/main/templates/popupPanel.template.xml
===================================================================
--- root/ui-sandbox/panels2/trunk/ui/src/main/templates/popupPanel.template.xml 2010-07-11
00:06:08 UTC (rev 17914)
+++ root/ui-sandbox/panels2/trunk/ui/src/main/templates/popupPanel.template.xml 2010-07-11
12:16:01 UTC (rev 17915)
@@ -28,20 +28,21 @@
onmouseout="#{component.attributes['onmaskmouseout']}"
class="mp_shade"/>
</c:if>
-<cdk:object type="java.lang.String" name="shadowStyle"
value="#{getShadowStyle(facesContext,component)}" />
- <div id="#{clientId}_shadow" style="#{shadowStyle}"
class="mp_shadow"/>
+ <div id="#{clientId}_shadow" class="mp_shadow"/>
<div id="#{clientId}_container"
cdk:passThruWithExclusions="id,style,class,styleClass" class="mp_container
#{component.attributes['styleClass']}">
<div id="#{clientId}_header" class="mp_header
#{component.attributes['headerClass']}" >
<c:if test="#{component.getFacet('header')!=null and
component.getFacet('header').rendered}">
<div id="#{clientId}_header_content"
class="mp_header_content">
+ <c:if test="#{component.attributes['autosized']}">
+ <span id="#{clientId}_headerSpan">
<cdk:call expression="renderHeaderFacet(facesContext, component)"/>
+ </span>
+ </c:if>
+ <c:if test="#{!component.attributes['autosized']}">
+ <cdk:call expression="renderHeaderFacet(facesContext, component)"/>
+ </c:if>
</div>
</c:if>
- <c:if test="#{component.getFacet('header')==null and
component.getFacet('header').rendered}">
- <div id="#{clientId}_header_content"
class="mp_header_content">
- <div id="#{clientId}_header_icon"
class="mp_header_icon"></div>Modal panel header name
- </div>
- </c:if>
<c:if test="#{component.getFacet('controls')!=null and
component.getFacet('controls').rendered}">
<div id="#{clientId}_header_controls" class="mp_header_controls
#{component.attributes['controlsClass']}">
<cdk:call expression="renderControlsFacet(facesContext,
component)"/>
@@ -66,7 +67,12 @@
</c:if>
</div>
- <cdk:object type="java.lang.String" name="script"
value="#{buildScript(facesContext, component)}" />
+
+
+
+<button class="mp-button"
id="#{clientId}LastHref"></button>
+</div>
+<cdk:object type="java.lang.String" name="script"
value="#{buildScript(facesContext, component)}" />
<cdk:object type="java.lang.String" name="showScript"
value="#{buildShowScript(facesContext, component)}" />
<script type="text/javascript">
#{script}
@@ -78,9 +84,5 @@
</c:if>
-<button class="mp-button"
id="#{clientId}LastHref"></button>
-</div>
-
-
</cc:implementation>
</cdk:root>
\ No newline at end of file
Added:
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
===================================================================
---
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
(rev 0)
+++
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java 2010-07-11
12:16:01 UTC (rev 17915)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+
+import org.jboss.test.faces.FacesEnvironment.FacesRequest;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.component.UIPanel;
+import org.richfaces.component.UIPopupPanel;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Andrey Markhel
+ *
+ */
+public class PopupRendererTest {
+
+ private HtmlUnitEnvironment environment;
+
+ @Before
+ public void setUp() {
+ environment = new HtmlUnitEnvironment();
+ environment.withWebRoot(new File("src/test/resources"));
+ environment.start();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+ }
+
+ private FacesRequest startFacesRequest() throws IOException {
+ FacesRequest facesRequest =
environment.createFacesRequest("http://localhost/popupPanelTest.jsf");
+ facesRequest.withViewId("/popupPanelTest.jsf");
+ facesRequest.start();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ViewHandler vh = facesContext.getApplication().getViewHandler();
+ ViewDeclarationLanguage vdl = vh.getViewDeclarationLanguage(facesContext,
facesContext.getViewRoot()
+ .getViewId());
+ vdl.buildView(facesContext, facesContext.getViewRoot());
+ return facesRequest;
+ }
+ /**
+ * Test method for {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#getComponentClass()}.
+ *
+ * @throws IOException
+ */
+ @Test
+ public final void testGetComponentClass() throws IOException {
+ /*FacesRequest facesRequest = startFacesRequest();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIPopupPanel component = (UIPopupPanel)
facesContext.getViewRoot().findComponent("panel");
+ PopupPanelRenderer renderer = (PopupPanelRenderer)
FacesContext.getCurrentInstance()
+ .getRenderKit().getRenderer(component.getFamily(),
component.getRendererType());
+ assertEquals(UIPopupPanel.class, renderer.getComponentClass());
+ facesRequest.release();*/
+ return ;
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)}.
+ *
+ * @throws IOException
+ */
+ /*@Test
+ public final void testDoEncode() throws IOException {
+ HtmlPage page = environment.getPage("/panelTest.jsf");
+ HtmlElement panelWithFacet = page.getElementById("panelWithFacet");
+ assertEquals("rf-panel panel",
panelWithFacet.getAttribute("class"));
+ assertEquals("Write your own custom rich components with built-in AJAX
support",
panelWithFacet.getElementById("panelWithFacet_header").getTextContent().trim());
+ assertEquals("The CDK includes",
panelWithFacet.getElementById("panelWithFacet_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanel = page.getElementById("simplePanel");
+ assertEquals("rf-panel ",
simplePanel.getAttribute("class"));
+ try{
+ simplePanel.getElementById("simplePanel_header");
+ }catch(Exception e){
+ assertTrue(true);
+ }
+ assertEquals("RichFaces is a l", simplePanel
+ .getElementById("simplePanel_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanelBody = page.getElementById("simplePanel_body");
+ assertEquals("rf-panel-body rich-laguna-panel-no-header",
simplePanelBody.getAttribute("class"));
+ HtmlElement simplePanel2 =
page.getElementById("simplePanelWithTextHeader");
+ assertEquals("rf-panel ",
simplePanel2.getAttribute("class"));
+
assertNotNull(simplePanel2.getElementById("simplePanelWithTextHeader_header"));
+ assertEquals("rich-laguna-panel-no-header",
simplePanel2.getElementById("simplePanelWithTextHeader_header").getTextContent().trim());
+ assertEquals("RichFaces is a l", simplePanel2
+ .getElementById("simplePanelWithTextHeader_body")
+ .getTextContent().trim().substring(0, 16));
+
+ HtmlElement nestedPanelContainer =
page.getElementById("nestedPanelContainer");
+ assertEquals("rf-panel ",
nestedPanelContainer.getAttribute("class"));
+
assertNotNull(nestedPanelContainer.getElementById("nestedPanelContainer_header"));
+ assertEquals("||||",
nestedPanelContainer.getElementById("nestedPanelContainer_header").getTextContent().trim());
+ HtmlElement nestedPanelContainerHeader =
page.getElementById("nestedPanelContainer_header");
+ assertEquals("rf-panel-header outpanelHeader",
nestedPanelContainerHeader.getAttribute("class"));
+ assertEquals("Benefits of Usin", nestedPanelContainer
+ .getElementById("nestedPanelContainer_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel1 =
nestedPanelContainer.getElementById("nestedPanel1");
+ assertEquals("rf-panel ",
nestedPanel1.getAttribute("class"));
+ HtmlElement nestedPanel1Body =
page.getElementById("nestedPanel1_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel1Body.getAttribute("class"));
+ assertNotNull(nestedPanel1.getElementById("nestedPanel1_header"));
+ assertEquals("For Application Developers",
nestedPanel1.getElementById("nestedPanel1_header").getTextContent().trim());
+ assertEquals("Production quali", nestedPanel1
+ .getElementById("nestedPanel1_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel2 =
nestedPanelContainer.getElementById("nestedPanel2");
+ assertEquals("rf-panel ",
nestedPanel2.getAttribute("class"));
+ HtmlElement nestedPanel2Body =
page.getElementById("nestedPanel2_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel2Body.getAttribute("class"));
+ assertNotNull(nestedPanel2.getElementById("nestedPanel2_header"));
+ assertEquals("For Component Developers",
nestedPanel2.getElementById("nestedPanel2_header").getTextContent().trim());
+ assertEquals("Ajax4jsf is Open", nestedPanel2
+ .getElementById("nestedPanel2_body")
+ .getTextContent().trim().substring(0, 16));
+ }*/
+
+}
\ No newline at end of file
Added: root/ui-sandbox/panels2/trunk/ui/src/test/resources/popupPanelText.xhtml
===================================================================
--- root/ui-sandbox/panels2/trunk/ui/src/test/resources/popupPanelText.xhtml
(rev 0)
+++ root/ui-sandbox/panels2/trunk/ui/src/test/resources/popupPanelText.xhtml 2010-07-11
12:16:01 UTC (rev 17915)
@@ -0,0 +1,82 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:panel="http://richfaces.org/panels"
+
xmlns:rich="http://richfaces.org/rich">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+ <h:head>
+ <title>Richfaces ExtendedDataTable Test</title>
+ </h:head>
+
+ <h:body>
+
+ <panel:popupPanel domElementAttachment="body"
visualOptions="{left:400px;}" moveable="true"
overlapEmbedObjects="true" keepVisualState="true"
onmaskclick="alert('1')" width="600" height="400"
id="panel" left="500px" top="300px">
+ <f:facet name="header">
+ Write your own custom rich components with built-in AJAX
+ </f:facet>
+ <h:form>
+ <h:panelGroup layout="block"
style="width:500px,height:400px;">
+ The CDK includes a code-generation facility and a
+ templating facility using a JSP-like syntax. These capabilities help
+ to avoid a routine process of a component creation. The component factory
+ works like a well-oiled machine allowing the creation of first-class
+ rich components with built-in Ajax functionality even more easily than
+ the creation of simpler components by means of the traditional coding
+ approach.
+
+ <a4j:commandLink value="Hide">
+
+ <rich:componentControl target="panel" operation="hide"
event="click">
+ </rich:componentControl>
+ </a4j:commandLink>
+
+<h:inputText value="aaa"/>
+<a href="#" onclick="RichFaces.$('panel').setSize(500,
300)" tabindex="0">setSize
+ </a>
+ <a href="#" onclick="RichFaces.$('panel').resize(20,
50)" tabindex="0">resize
+ </a>
+ <a href="#" onclick="RichFaces.$('panel').move(20,
50)" tabindex="0">move
+ </a>
+
+ <a href="#" onclick="RichFaces.$('panel').moveTo(20,
50)" tabindex="0">moveTo
+ </a>
+ </h:panelGroup>
+ </h:form>
+ </panel:popupPanel>
+
+ <a4j:commandLink value="Show">
+
+ <rich:componentControl target="panel" operation="show"
event="click">
+ </rich:componentControl>
+ </a4j:commandLink>
+
+ </h:body>
+</html>
\ No newline at end of file