suggested impl:
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java (working copy)
@@ -100,8 +100,40 @@
- The current modal state.
*/
private Boolean modal = null;
+ /**
+ * The current autoCentre state.
+ */
+ private Boolean autoCentre = null;
- /**
+ public boolean isAutoCentre()
Unknown macro: {+ if (autoCentre != null) {
+ return autoCentre.booleanValue();
+ }+ ValueBinding vb = getValueBinding("autoCentre");+ Boolean boolVal =+ vb != null ? (Boolean) vb.getValue(getFacesContext()) }
+
+ public void setAutoCentre(boolean autoCentre)
{
+ this.autoCentre = Boolean.valueOf(autoCentre);
+ }
+
+ private String autoPosition = null;
+
+ public String getAutoPosition()
Unknown macro: {+ if (autoPosition != null) {
+ return autoPosition;
+ }+ ValueBinding vb = getValueBinding("autoPosition");+ return vb != null ? (String) vb.getValue(getFacesContext()) }
+
+ public void setAutoPosition(String val)
{
+ this.autoPosition = val;
+ }
+
+ /**
- Creates an instance and sets renderer type to "com.icesoft.faces.PanelPopup".
*/
public PanelPopup()
{
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java
===================================================================
--- D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java (working copy)
@@ -223,6 +223,32 @@
String call = addJavascriptCalls(uiComponent, "DRAG", handleId, facesContext);
JavascriptContext.addJavascriptCall(facesContext, call);
}
+
+ //autoPosition handling
+ String autoPositionJS = null;
+ if( panelPopup.getAutoPosition() != null )
{
+ String positions = panelPopup.getAutoPosition();
+ String x = positions.substring(0,positions.indexOf(','));
+ String y = positions.substring(positions.indexOf(',')+1);
+ autoPositionJS = "Ice.autoPosition.start('" + clientId + "'," + x + "," + y +");";
+ }
+ else
{
+ autoPositionJS = "Ice.autoPosition.stop('" + clientId + "');";
+ }
+ JavascriptContext.addJavascriptCall(facesContext, autoPositionJS);
+
+ //autoCentre handling
+ boolean autoCentre = panelPopup.isAutoCentre();
+ String centreJS;
+ if( autoCentre )
{
+ centreJS = "Ice.autoCentre.start('" + clientId + "');";
+
+ }
+ else
{
+ centreJS = "Ice.autoCentre.stop('" + clientId + "');";
+ }
+ JavascriptContext.addJavascriptCall(facesContext, centreJS);
+
}
private String modalJavascript(Boolean modal, Boolean visible,
@@ -230,7 +256,8 @@
String call = null;
if (modal != null) {
if (modal.booleanValue() && visible.booleanValue()) {
- call = "Ice.modal.start('" + clientId + "');";
+ call = "Ice.modal.start('" + clientId + "');";
+
if (log.isTraceEnabled())
{
log.trace("Starting Modal Function");
}
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml (working copy)
@@ -111,4 +111,24 @@
<property-extension>
<category>ICE_LAYOUT</category>
</property-extension>
+</property>
+<property>
+ <description>Used to keep the popup centred on the screen through
+ scrolling and window resizing events.
+ </description>
+ <property-name>autoCentre</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <category>ICE_LAYOUT</category>
+ </property-extension>
+</property>
+<property>
+ <description>Used to keep the popup positioned on the screen through
+ scrolling events. Use a string of x and y px values (e.g. autoPostion="35,200").
+ </description>
+ <property-name>autoPosition</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <category>ICE_LAYOUT</category>
+ </property-extension>
</property>
\ No newline at end of file
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js (working copy)
@@ -139,9 +139,11 @@
}
var modal = document.getElementById(target);
-
+
+
modal.style.zIndex = parseInt(iframe.style.zIndex) + 1;
Ice.modal.target = modal;
+
Ice.modal.id = target;
Ice.modal.running = true;
modal.style.visibility = 'visible';
@@ -155,6 +157,7 @@
logger.debug('removed modal iframe for : ' + target);
}
Ice.modal.running = false;
+
}
},
keypress:function(event)
{
@@ -200,3 +203,73 @@
}
;
+Ice.autoCentre = Class.create();
+Ice.autoCentre = {
+ id:null,
+ keepCentred:function(){
+ var scrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
+ var scrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
+ var div = document.getElementById(Ice.autoCentre.id);
+ if( div ){
+ var x = Math.round( (Element.getWidth(document.body) - Element.getWidth(div)) / 2 + scrollX );
+ if( x < 0 ) x = 0;
+ var y = Math.round( ((window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - Element.getHeight(div)) / 2 + scrollY );
+ if( y < 0 ) y = 0;
+ x = x + "px"; y = y + "px";
+ Element.setStyle(div,
{position:'absolute'}
);
+ Element.setStyle(div,
{left: x}
);
+ Element.setStyle(div,
{top:y}
);
+ }
+
+
+ },
+ start:function(target)
{
+ Ice.autoCentre.id = target;
+ Ice.autoCentre.keepCentred();
+ Event.observe(window, 'resize', Ice.autoCentre.keepCentred);
+ Event.observe(window, 'scroll', Ice.autoCentre.keepCentred);
+ }
,
+ stop:function(target) {
+ if (Ice.autoCentre.id == target)
{
+ Event.stopObserving(window, 'resize', Ice.autoCentre.keepCentred);
+ Event.stopObserving(window, 'scroll', Ice.autoCentre.keepCentred);
+ }
+ }
+};
+
+
+Ice.autoPosition = Class.create();
+Ice.autoPosition = {
+ id:null,
+ xPos:null,
+ yPos:null,
+ keepPositioned:function(){
+ var scrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
+ var scrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
+ var div = document.getElementById(Ice.autoPosition.id);
+ if( div ){
+ var x = Math.round( Ice.autoPosition.xPos + scrollX ) + "px";
+ var y = Math.round( Ice.autoPosition.yPos + scrollY ) + "px";
+ Element.setStyle(div,
{position:'absolute'}
);
+ Element.setStyle(div,
{left: x}
);
+ Element.setStyle(div,
{top:y}
);
+ }
+
+
+ },
+ start:function(target,x,y)
{
+ Ice.autoPosition.id = target;
+ Ice.autoPosition.xPos = x;
+ Ice.autoPosition.yPos = y;
+ Ice.autoPosition.keepPositioned();
+ Event.observe(window, 'scroll', Ice.autoPosition.keepPositioned);
+ }
,
+ stop:function(target) {
+ if (Ice.autoPosition.id == target)
{
+ Event.stopObserving(window, 'scroll', Ice.autoPosition.keepPositioned);
+ }
+ }
+};
+
+
+
suggested impl:
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopup.java (working copy)
@@ -100,8 +100,40 @@
*/
private Boolean modal = null;
+ /**
+ * The current autoCentre state.
+ */
+ private Boolean autoCentre = null;
+ public boolean isAutoCentre()
+
{ + this.autoCentre = Boolean.valueOf(autoCentre); + }+ public void setAutoCentre(boolean autoCentre)
+
+ private String autoPosition = null;
+
+ public String getAutoPosition()
+
{ + this.autoPosition = val; + }+ public void setAutoPosition(String val)
+
+ /**
*/
public PanelPopup() { Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java =================================================================== --- D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java (revision 15197) +++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/panelpopup/PanelPopupRenderer.java (working copy) @@ -223,6 +223,32 @@ String call = addJavascriptCalls(uiComponent, "DRAG", handleId, facesContext); JavascriptContext.addJavascriptCall(facesContext, call); }
+
{ + String positions = panelPopup.getAutoPosition(); + String x = positions.substring(0,positions.indexOf(',')); + String y = positions.substring(positions.indexOf(',')+1); + autoPositionJS = "Ice.autoPosition.start('" + clientId + "'," + x + "," + y +");"; + }+ //autoPosition handling
+ String autoPositionJS = null;
+ if( panelPopup.getAutoPosition() != null )
+ else
{ + autoPositionJS = "Ice.autoPosition.stop('" + clientId + "');"; + }+ JavascriptContext.addJavascriptCall(facesContext, autoPositionJS);
{ + centreJS = "Ice.autoCentre.start('" + clientId + "');"; + + }+
+ //autoCentre handling
+ boolean autoCentre = panelPopup.isAutoCentre();
+ String centreJS;
+ if( autoCentre )
+ else
{ + centreJS = "Ice.autoCentre.stop('" + clientId + "');"; + }+ JavascriptContext.addJavascriptCall(facesContext, centreJS);
+
}
private String modalJavascript(Boolean modal, Boolean visible,
@@ -230,7 +256,8 @@
String call = null;
if (modal != null) {
if (modal.booleanValue() && visible.booleanValue()) {
+ call = "Ice.modal.start('" + clientId + "');";
+
if (log.isTraceEnabled()) { log.trace("Starting Modal Function"); }
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component-metadata/src/main/resources/conf/ice_cust_properties/cust-panelpopup-props.xml (working copy)
@@ -111,4 +111,24 @@
<property-extension>
<category>ICE_LAYOUT</category>
</property-extension>
+</property>
+<property>
+ <description>Used to keep the popup centred on the screen through
+ scrolling and window resizing events.
+ </description>
+ <property-name>autoCentre</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <category>ICE_LAYOUT</category>
+ </property-extension>
+</property>
+<property>
+ <description>Used to keep the popup positioned on the screen through
+ scrolling events. Use a string of x and y px values (e.g. autoPostion="35,200").
+ </description>
+ <property-name>autoPosition</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <category>ICE_LAYOUT</category>
+ </property-extension>
</property>
\ No newline at end of file
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/bridge/lib/extras/style.js (working copy)
@@ -139,9 +139,11 @@
}
var modal = document.getElementById(target);
{ @@ -200,3 +203,73 @@ }-
+
+
modal.style.zIndex = parseInt(iframe.style.zIndex) + 1;
Ice.modal.target = modal;
+
Ice.modal.id = target;
Ice.modal.running = true;
modal.style.visibility = 'visible';
@@ -155,6 +157,7 @@
logger.debug('removed modal iframe for : ' + target);
}
Ice.modal.running = false;
+
}
},
keypress:function(event)
;
+Ice.autoCentre = Class.create();
{position:'absolute'}+Ice.autoCentre = {
+ id:null,
+ keepCentred:function(){
+ var scrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
+ var scrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
+ var div = document.getElementById(Ice.autoCentre.id);
+ if( div ){
+ var x = Math.round( (Element.getWidth(document.body) - Element.getWidth(div)) / 2 + scrollX );
+ if( x < 0 ) x = 0;
+ var y = Math.round( ((window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - Element.getHeight(div)) / 2 + scrollY );
+ if( y < 0 ) y = 0;
+ x = x + "px"; y = y + "px";
+ Element.setStyle(div,
);
{left: x}+ Element.setStyle(div,
);
{top:y}+ Element.setStyle(div,
);
{ + Ice.autoCentre.id = target; + Ice.autoCentre.keepCentred(); + Event.observe(window, 'resize', Ice.autoCentre.keepCentred); + Event.observe(window, 'scroll', Ice.autoCentre.keepCentred); + }+ }
+
+
+ },
+ start:function(target)
,
{ + Event.stopObserving(window, 'resize', Ice.autoCentre.keepCentred); + Event.stopObserving(window, 'scroll', Ice.autoCentre.keepCentred); + }+ stop:function(target) {
+ if (Ice.autoCentre.id == target)
+ }
{position:'absolute'}+};
+
+
+Ice.autoPosition = Class.create();
+Ice.autoPosition = {
+ id:null,
+ xPos:null,
+ yPos:null,
+ keepPositioned:function(){
+ var scrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
+ var scrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
+ var div = document.getElementById(Ice.autoPosition.id);
+ if( div ){
+ var x = Math.round( Ice.autoPosition.xPos + scrollX ) + "px";
+ var y = Math.round( Ice.autoPosition.yPos + scrollY ) + "px";
+ Element.setStyle(div,
);
{left: x}+ Element.setStyle(div,
);
{top:y}+ Element.setStyle(div,
);
{ + Ice.autoPosition.id = target; + Ice.autoPosition.xPos = x; + Ice.autoPosition.yPos = y; + Ice.autoPosition.keepPositioned(); + Event.observe(window, 'scroll', Ice.autoPosition.keepPositioned); + }+ }
+
+
+ },
+ start:function(target,x,y)
,
{ + Event.stopObserving(window, 'scroll', Ice.autoPosition.keepPositioned); + }+ stop:function(target) {
+ if (Ice.autoPosition.id == target)
+ }
+};
+
+
+