Author: pyaschenko
Date: 2007-10-04 12:17:32 -0400 (Thu, 04 Oct 2007)
New Revision: 3258
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
RF-1035
+ positioning improved (auto center didn't work in opera)
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-10-04
14:47:33 UTC (rev 3257)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-10-04
16:17:32 UTC (rev 3258)
@@ -149,6 +149,7 @@
}
Richfaces.browser= {
+ isIE: (!window.opera && /MSIE/.test(navigator.userAgent)),
isIE6: (!window.opera && /MSIE\s*[6][\d,\.]+;/.test(navigator.userAgent)),
isSafari: /Safari/.test(navigator.userAgent)
};
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-10-04
14:47:33 UTC (rev 3257)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-10-04
16:17:32 UTC (rev 3258)
@@ -104,7 +104,7 @@
ModalPanel.Context = Class.create();
ModalPanel.Context.prototype = {
initialize: function(modalPanel) {
- this.cdiv = modalPanel.contentDiv;
+ this.cdiv = modalPanel.contentTable;
this.isPositionFixed = Richfaces.getComputedStyle(this.cdiv, "position") ==
"fixed";
},
@@ -155,6 +155,7 @@
this.cursorDiv = id + "CursorDiv";
this.cdiv = id + "CDiv";
this.contentDiv = id + "ContentDiv";
+ this.contentTable = id + "ContentTable";
this.shadowDiv = id + "ShadowDiv";
this.context = new ModalPanel.Context(this);
@@ -504,10 +505,14 @@
}
var eContentDiv = $(this.contentDiv);
- var eShadowDiv = $(this.shadowDiv);
if (this.options.autosized) {
eContentDiv.style.overflow = "";
+ options.width = -1;
+ options.height = -1;
+ eContentDiv.style.width="100%";
+ eContentDiv.style.height="100%";
+
} else {
if (options.width && options.width == -1)
options.width = 300;
@@ -520,11 +525,7 @@
options.width = this.minWidth;
}
- if (eIframe) {
- eIframe.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
- }
eContentDiv.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
- eShadowDiv.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
}
if (options.height && options.height != -1) {
@@ -532,13 +533,9 @@
options.height = this.minHeight;
}
- if (eIframe) {
- eIframe.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
- }
eContentDiv.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
- eShadowDiv.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
}
-
+
eCdiv.mpSet = true;
//Element.setStyle(this.dialogWindow.document.body, { "margin" : "0px
0px 0px 0px" });
@@ -593,7 +590,8 @@
element.style.visibility = "hidden";
Element.show(element);
-
+ this.correctShadowSizeEx(eContentDiv);
+
if (options.left) {
var _left;
if (options.left != "auto") {
@@ -601,11 +599,13 @@
} else {
var cw = getSizeElement().clientWidth;
if (RichFaces.navigatorType() == "OPERA")
- _left = (cw - eContentDiv.style.width.replace("px", "")) / 2;
+ {
+ _left = (cw - eContentDiv.parentNode.getWidth()) / 2;
+ }
else {
- var _width = Richfaces.getComputedStyleSize(eContentDiv, "width");
+ var _width = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"width");
if (isNaN(_width))
- _width = eContentDiv.clientWidth;
+ _width = eContentDiv.parentNode.clientWidth;
_left = (cw - _width) / 2;
}
@@ -622,12 +622,12 @@
var cw = getSizeElement().clientHeight;
if (RichFaces.navigatorType() == "OPERA")
{
- _top = (cw - eContentDiv.style.height.replace("px", "")) / 2;
+ _top = (cw - eContentDiv.parentNode.getHeight()) / 2;
}
else {
- var _height = Richfaces.getComputedStyleSize(eContentDiv, "height");
+ var _height = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"height");
if (isNaN(_height))
- _height = eContentDiv.clientHeight;
+ _height = eContentDiv.parentNode.clientHeight;
_top = (cw - _height) / 2;
}
}
@@ -739,11 +739,12 @@
var newSize;
var eContentDiv = $(this.contentDiv);
- var eShadowDiv = $(this.shadowDiv);
// Avoid currentStyle bug in opera
if (RichFaces.navigatorType() != "OPERA")
+ {
newSize = Richfaces.getComputedStyleSize(eContentDiv, "width");
+ }
else
newSize = parseInt(eContentDiv.style.width.replace("px", ""),
10);
@@ -790,7 +791,9 @@
// Avoid currentStyle bug in opera
if (RichFaces.navigatorType() != "OPERA")
+ {
newSize = Richfaces.getComputedStyleSize(eContentDiv, "height");
+ }
else
newSize = parseInt(eContentDiv.style.height.replace("px", ""),
10);
@@ -837,10 +840,7 @@
Element.setStyle(eCdiv, cssHash);
Element.setStyle(eContentDiv, cssHashWH);
- Element.setStyle(eShadowDiv, cssHashWH);
- if (this.iframe) {
- Element.setStyle($(this.iframe), cssHashWH);
- }
+ this.correctShadowSizeEx(eContentDiv);
Object.extend(this.userOptions, cssHash);
Object.extend(this.userOptions, cssHashWH);
@@ -899,17 +899,27 @@
correctShadowSize: function(event) {
var eContentDiv = $(this.contentDiv);
+ this.correctShadowSizeEx($(this.contentDiv));
+ },
+
+ correctShadowSizeEx: function(eContentDiv) {
var eShadowDiv = $(this.shadowDiv);
var eIframe = $(this.iframe);
- var cWidth = eContentDiv.clientWidth;
- var cHeight = eContentDiv.clientHeight;
-
- eShadowDiv.style.width = cWidth+"px";
- eShadowDiv.style.height = cHeight+"px";
+ var dx = 0;
+ var dy = 0;
+ if (!Richfaces.browser.isIE)
+ {
+ dx = eShadowDiv.offsetWidth-eShadowDiv.clientWidth;
+ dy = eShadowDiv.offsetHeight-eShadowDiv.clientHeight;
+ }
+ var w = eContentDiv.parentNode.offsetWidth;
+ var h = eContentDiv.parentNode.offsetHeight;
+ eShadowDiv.style.width = (w-dx)+"px";
+ eShadowDiv.style.height = (h-dy)+"px";
if (eIframe) {
- eIframe.style.width = cWidth+"px";
- eIframe.style.height = cHeight+"px";
+ eIframe.style.width = w+"px";
+ eIframe.style.height = h+"px";
}
}
}
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-10-04
14:47:33 UTC (rev 3257)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-10-04
16:17:32 UTC (rev 3258)
@@ -72,9 +72,8 @@
<div id="#{clientId}ShadowDiv" class="dr-mpnl-shadow
rich-mpnl-shadow"
style="#{component.shadowStyle}" >
</div>
-
- <div style="position: absolute; overflow: hidden; z-index: 2;
#{component.attributes['style']}"
- class="dr-mpnl-pnl" id="#{clientId}ContentDiv">
+ <table id="#{clientId}ContentTable" cellpadding="0"
cellspacing="0" border="0" style="position: absolute; z-index:
2;"><tbody><tr><td class="dr-mpnl-pnl">
+ <div id="#{clientId}ContentDiv" style="overflow: hidden;
#{component.attributes['style']}">
<a href="#" class="dr-mpnl-pnl-a"
id="#{clientId}FirstHref" >_</a>
<table style="height: 100%; width: 100%;" border="0"
cellpadding="0" cellspacing="0">
@@ -113,6 +112,7 @@
</tr>
</table>
</div>
+ </td></tr></tbody></table>
</div>
<script type="text/javascript">