Author: pyaschenko
Date: 2007-08-01 09:34:04 -0400 (Wed, 01 Aug 2007)
New Revision: 1979
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/modalPanelBorders.js
Log:
Bug RF-483 fixed
(
http://jira.jboss.com/jira/browse/RF-483)
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-08-01
13:32:38 UTC (rev 1978)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-08-01
13:34:04 UTC (rev 1979)
@@ -39,7 +39,7 @@
while (i < ModalPanel.panels.length) {
var panel = ModalPanel.panels[i];
- var elt = panel.markerId;
+ var elt = $(panel.markerId);
if (!Richfaces.isNodeInDOMTree(elt)) {
panel.destroy();
@@ -70,11 +70,11 @@
},
width: function() {
- return this.cdiv.offsetWidth;
+ return $(this.cdiv).offsetWidth;
},
height: function() {
- return this.cdiv.offsetHeight;
+ return $(this.cdiv).offsetHeight;
}
}
@@ -92,9 +92,9 @@
ModalPanel.prototype = {
initialize: function(id, options) {
- this.markerId = $(id);
+ this.markerId = id;
- this.id = $(id + "Container");
+ this.id = id + "Container";
this.options = options;
@@ -103,11 +103,11 @@
this.minWidth = Math.max(this.options.minWidth, 2*sizeA + 2);
this.minHeight = Math.max(this.options.minHeight, 2*sizeA + 2);
- this.div = $(id + "Div");
- this.cursorDiv = $(id + "CursorDiv");
- this.cdiv = $(id + "CDiv");
- this.contentDiv = $(id + "ContentDiv");
- this.shadowDiv = $(id + "ShadowDiv");
+ this.div = id + "Div";
+ this.cursorDiv = id + "CursorDiv";
+ this.cdiv = id + "CDiv";
+ this.contentDiv = id + "ContentDiv";
+ this.shadowDiv = id + "ShadowDiv";
this.context = new ModalPanel.Context(this);
@@ -132,24 +132,28 @@
this.header = new ModalPanel.Border(id + "Header", this, "move",
ModalPanel.Header);
}
- this.id.modalPanel = this;
+ $(this.id).modalPanel = this;
+
+ var eDiv = $(this.div);
+ if (eDiv.style.setExpression)
+ if (ModalPanel.disableSelects /* IE 6 */ || Richfaces.getComputedStyle(eDiv,
"position") != "fixed" /* IE again, not in strict mode*/)
- if (this.div.style.setExpression)
- if (ModalPanel.disableSelects /* IE 6 */ || Richfaces.getComputedStyle(this.div,
"position") != "fixed" /* IE again, not in strict mode*/)
-
{
- this.div.style.position = "absolute";
- this.cursorDiv.style.position = "absolute";
+ eDiv.style.position = "absolute";
+
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.position = "absolute";
//that is to apply filter
- this.div.style.width = "1px";
- this.div.style.height = "1px";
- this.cursorDiv.style.width = "1px";
- this.cursorDiv.style.height = "1px";
+ eDiv.style.width = "1px";
+ eDiv.style.height = "1px";
+ eCursorDiv.style.width = "1px";
+ eCursorDiv.style.height = "1px";
- this.cdiv.style.position = "absolute";
+ var eCdiv = $(this.cdiv);
+ eCdiv.style.position = "absolute";
- this.cdiv.mpUseExpr = true;
+ eCdiv.mpUseExpr = true;
}
if (this.options.onshow && this.options.onshow != ""){
@@ -165,8 +169,8 @@
this.eventFirstOnfocus = this.firstOnfocus.bindAsEventListener(this);
this.eventLastOnfocus = this.lastOnfocus.bindAsEventListener(this);
- this.firstHref = $(this.markerId.id + "FirstHref");
- this.lastHref = $(this.markerId.id + "LastHref");
+ this.firstHref = this.markerId + "FirstHref";
+ this.lastHref = this.markerId + "LastHref";
},
destroy: function() {
@@ -174,9 +178,10 @@
this.traverseSelects(true);
if (this.floatedToBody) {
- var parent = this.id.parentNode;
+ var element = $(this.id);
+ var parent = element.parentNode;
if (parent) {
- parent.removeChild(this.id);
+ parent.removeChild(element);
}
}
},
@@ -208,9 +213,10 @@
}
var children = document.body.childNodes;
+ var element = $(this.id);
for (var k = 0; k < children.length; k++) {
var child = children[k];
- if (child != this.id && child.getElementsByTagName) {
+ if (child != element && child.getElementsByTagName) {
var selects = child.getElementsByTagName("SELECT");
@@ -250,30 +256,34 @@
},
setLeft: function(pos) {
- if (this.cdiv.mpUseExpr) {
- this.cdiv.mpLeft = pos;
+ var eCdiv = $(this.cdiv);
+ if (eCdiv.mpUseExpr) {
+ eCdiv.mpLeft = pos;
} else {
- this.cdiv.style.left = pos + "px";
+ eCdiv.style.left = pos + "px";
}
},
setTop: function(pos) {
- if (this.cdiv.mpUseExpr) {
- this.cdiv.mpTop = pos;
+ var eCdiv = $(this.cdiv);
+ if (eCdiv.mpUseExpr) {
+ eCdiv.mpTop = pos;
} else {
- this.cdiv.style.top = pos + "px";
+ eCdiv.style.top = pos + "px";
}
},
firstOnfocus: function(event) {
- if (this.firstHref) {
- this.firstHref.focus();
+ var e = $(this.firstHref)
+ if (e) {
+ e.focus();
}
},
lastOnfocus: function(event) {
- if (this.lastHref) {
- this.lastHref.focus();
+ var e = $(this.lastHref);
+ if (e) {
+ e.focus();
}
},
@@ -285,14 +295,14 @@
!/^none$/.test(root.style.display)) {
this.execute(root);
} else {
- if (root == this.cdiv)
+ if (root.id && root.id==this.cdiv)
this.inModalPanel = true;
var child = root.firstChild;
while (child) {
this.processAllFocusElements(child);
child = child.nextSibling;
}
- if (root == this.cdiv)
+ if (root.id && root.id==this.cdiv)
this.inModalPanel = false;
}
},
@@ -351,13 +361,15 @@
show: function(opts) {
this.preventFocus();
+ var element = $(this.id);
if (!this.floatedToBody) {
- this.parent = this.id.parentNode;
- document.body.insertBefore(this.parent.removeChild(this.id), null);
+ this.parent = element.parentNode;
+ document.body.insertBefore(this.parent.removeChild(element), null);
this.floatedToBody = true;
}
- var forms = this.cdiv.getElementsByTagName("form");
+ var eCdiv = $(this.cdiv);
+ var forms = eCdiv.getElementsByTagName("form");
if (this.options.keepVisualState && forms) {
this.formOnsubmit = this.setStateInput.bindAsEventListener(this);
@@ -366,23 +378,26 @@
}
}
+ var eIframe;
if (ModalPanel.disableSelects && !this.iframe) {
- new Insertion.Top(this.cdiv,
- "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.markerId.id + "IFrame\""
+
+ new Insertion.Top(eCdiv,
+ "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.markerId + "IFrame\"" +
"style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
"</iframe>");
- this.iframe = $(this.markerId.id + "IFrame");
+ this.iframe = this.markerId + "IFrame";
+
+ eIframe = $(this.iframe);
- //alert("IFrame:" + this.iframe + "created!");
+ //alert("IFrame:" + eIframe + "created!");
- this.iframe.onload = this.initIframe.bind(this.iframe);
+ eIframe.onload = this.initIframe.bind(eIframe);
}
var options = {};
this.userOptions = {};
- if (!this.cdiv.mpSet) {
+ if (!eCdiv.mpSet) {
Object.extend(options, this.options);
}
@@ -390,17 +405,20 @@
Object.extend(options, opts);
Object.extend(this.userOptions, opts);
}
+
+ var eContentDiv = $(this.contentDiv);
+ var eShadowDiv = $(this.shadowDiv);
if (options.width) {
if (this.minWidth > options.width) {
options.width = this.minWidth;
}
- if (this.iframe) {
- this.iframe.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
+ if (eIframe) {
+ eIframe.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
}
- this.contentDiv.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
- this.shadowDiv.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) {
@@ -408,11 +426,11 @@
options.height = this.minHeight;
}
- if (this.iframe) {
- this.iframe.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
+ if (eIframe) {
+ eIframe.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
}
- this.contentDiv.style.height = options.height + (/px/.test(options.height) ?
'' : 'px');
- this.shadowDiv.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');
}
if (options.left) {
@@ -422,9 +440,9 @@
} else {
var cw = getSizeElement().clientWidth;
if (RichFaces.navigatorType() == "OPERA")
- _left = (cw - this.contentDiv.style.width.replace("px", "")) /
2;
+ _left = (cw - eContentDiv.style.width.replace("px", "")) / 2;
else
- _left = (cw - Richfaces.getComputedStyleSize(this.contentDiv, "width")) /
2;
+ _left = (cw - Richfaces.getComputedStyleSize(eContentDiv, "width")) / 2;
}
@@ -437,49 +455,51 @@
_top = parseInt(options.top, 10);
} else {
var cw = getSizeElement().clientHeight;
- _top = (cw - Richfaces.getComputedStyleSize(this.contentDiv, "height")) /
2;
+ _top = (cw - Richfaces.getComputedStyleSize(eContentDiv, "height")) / 2;
}
this.setTop(_top);
}
- this.cdiv.mpSet = true;
+ eCdiv.mpSet = true;
//Element.setStyle(this.dialogWindow.document.body, { "margin" : "0px
0px 0px 0px" });
//if("transparent" == Element.getStyle(document.body,
"background-color")) {
- // this.iframe.allowTransparency = true;
+ // eIframe.allowTransparency = true;
//}
this.traverseSelects();
- //this.shape.init(this.cdiv, this.options);
+ //this.shape.init(eCdiv, this.options);
- if (this.div.style.position == "absolute")
+ var eDiv = $(this.div);
+ if (eDiv.style.position == "absolute")
{
var we = "getSizeElement().clientWidth + \"px\"";
var he = "getSizeElement().clientHeight + \"px\"";
- this.div.style.setExpression("width", we);
- this.div.style.setExpression("height", he);
+ eDiv.style.setExpression("width", we);
+ eDiv.style.setExpression("height", he);
- this.cursorDiv.style.setExpression("width", we);
- this.cursorDiv.style.setExpression("height", he);
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.setExpression("width", we);
+ eCursorDiv.style.setExpression("height", he);
var le = "-Position.cumulativeOffset(this.parentNode)[0] +
getSizeElement().scrollLeft + \"px\"";
var te = "-Position.cumulativeOffset(this.parentNode)[1] +
getSizeElement().scrollTop + \"px\"";
- this.div.style.setExpression("left", le);
- this.div.style.setExpression("top", te);
+ eDiv.style.setExpression("left", le);
+ eDiv.style.setExpression("top", te);
- this.cursorDiv.style.setExpression("left", le);
- this.cursorDiv.style.setExpression("top", te);
+ eCursorDiv.style.setExpression("left", le);
+ eCursorDiv.style.setExpression("top", te);
var leftExpr = "(this.mpLeft || 0) +
-Position.cumulativeOffset(this.parentNode)[0] + getSizeElement().scrollLeft +
\"px\"";
var topExpr = "(this.mpTop || 0) + -Position.cumulativeOffset(this.parentNode)[1]
+ getSizeElement().scrollTop + \"px\"";
- this.cdiv.style.setExpression("left", leftExpr);
- this.cdiv.style.setExpression("top", topExpr);
+ eCdiv.style.setExpression("left", leftExpr);
+ eCdiv.style.setExpression("top", topExpr);
/* That's how we output debug info - DOM inspector rulez */
@@ -492,9 +512,9 @@
/* */
}
- this.id.style.visibility = "hidden";
+ element.style.visibility = "hidden";
- Element.show(this.id);
+ Element.show(element);
this.doResizeOrMove(ModalPanel.Sizer.Diff.EMPTY);
@@ -506,7 +526,7 @@
this.header.doPosition();
}
- this.id.style.visibility = "";
+ element.style.visibility = "";
var event = {};
event.parameters = opts || {};
@@ -535,28 +555,34 @@
this.traverseSelects(true);
- if (this.div.style.removeExpression) {
- this.div.style.removeExpression("width");
- this.div.style.removeExpression("height");
+ var eDiv = $(this.div);
+ var eCdiv = $(this.cdiv);
- this.div.style.removeExpression("left");
- this.div.style.removeExpression("top");
+ if (eDiv.style.removeExpression) {
+ eDiv.style.removeExpression("width");
+ eDiv.style.removeExpression("height");
- this.cursorDiv.style.removeExpression("width");
- this.cursorDiv.style.removeExpression("height");
+ eDiv.style.removeExpression("left");
+ eDiv.style.removeExpression("top");
- this.cursorDiv.style.removeExpression("left");
- this.cursorDiv.style.removeExpression("top");
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.removeExpression("width");
+ eCursorDiv.style.removeExpression("height");
- this.cdiv.style.removeExpression("left");
- this.cdiv.style.removeExpression("top");
+ eCursorDiv.style.removeExpression("left");
+ eCursorDiv.style.removeExpression("top");
+
+ eCdiv.style.removeExpression("left");
+ eCdiv.style.removeExpression("top");
}
- Element.hide(this.id);
+ var element = $(this.id);
+ Element.hide(element);
if (this.floatedToBody && this.parent) {
- document.body.removeChild(this.id);
- this.parent.appendChild(this.id);
+
+ document.body.removeChild(element);
+ this.parent.appendChild(element);
this.floatedToBody = false;
}
@@ -564,7 +590,7 @@
event.parameters = opts || {};
if (this.eventOnHide) this.eventOnHide(event);
- var forms = this.cdiv.getElementsByTagName("form");
+ var forms = eCdiv.getElementsByTagName("form");
if (this.options.keepVisualState && forms) {
for (var i = 0; i < forms.length; i++) {
Event.stopObserving(forms[i], "submit", this.formOnsubmit);
@@ -581,11 +607,15 @@
var vetoeChange = false;
var newSize;
+
+ var eContentDiv = $(this.contentDiv);
+ var eShadowDiv = $(this.shadowDiv);
+
// Avoid currentStyle bug in opera
if (RichFaces.navigatorType() != "OPERA")
- newSize = Richfaces.getComputedStyleSize(this.contentDiv, "width");
+ newSize = Richfaces.getComputedStyleSize(eContentDiv, "width");
else
- newSize = parseInt(this.contentDiv.style.width.replace("px", ""),
10);
+ newSize = parseInt(eContentDiv.style.width.replace("px", ""),
10);
var oldSize = newSize;
newSize += diff.deltaWidth || 0;
@@ -607,26 +637,28 @@
if (vetoes.vx && diff.deltaX) {
diff.deltaX = -vetoes.vx;
}
+
+ var eCdiv = $(this.cdiv);
if (diff.deltaX && (vetoes.vx || !vetoes.x)) {
if (vetoes.vx) {
diff.deltaX = vetoes.vx;
}
var newPos;
- if (this.cdiv.mpUseExpr) {
- newPos = this.cdiv.mpLeft || 0;
+ if (eCdiv.mpUseExpr) {
+ newPos = eCdiv.mpLeft || 0;
newPos += diff.deltaX;
- this.cdiv.mpLeft = newPos;
+ eCdiv.mpLeft = newPos;
cssHash.left = newPos + 'px';
} else {
- newPos = Richfaces.getComputedStyleSize(this.cdiv, "left");
+ newPos = Richfaces.getComputedStyleSize(eCdiv, "left");
newPos += diff.deltaX;
cssHash.left = newPos + 'px';
}
}
- var newSize = Richfaces.getComputedStyleSize(this.contentDiv, "height");
+ var newSize = Richfaces.getComputedStyleSize(eContentDiv, "height");
var oldSize = newSize;
newSize += diff.deltaHeight || 0;
@@ -654,25 +686,25 @@
}
var newPos;
- if (this.cdiv.mpUseExpr) {
- newPos = this.cdiv.mpTop || 0;
+ if (eCdiv.mpUseExpr) {
+ newPos = eCdiv.mpTop || 0;
newPos += diff.deltaY;
- this.cdiv.mpTop = newPos;
+ eCdiv.mpTop = newPos;
cssHash.top = newPos + 'px';
} else {
- newPos = Richfaces.getComputedStyleSize(this.cdiv, "top");
+ newPos = Richfaces.getComputedStyleSize(eCdiv, "top");
newPos += diff.deltaY;
cssHash.top = newPos + 'px';
}
}
- Element.setStyle(this.cdiv, cssHash);
+ Element.setStyle(eCdiv, cssHash);
- Element.setStyle(this.contentDiv, cssHashWH);
- Element.setStyle(this.shadowDiv, cssHashWH);
+ Element.setStyle(eContentDiv, cssHashWH);
+ Element.setStyle(eShadowDiv, cssHashWH);
if (this.iframe) {
- Element.setStyle(this.iframe, cssHashWH);
+ Element.setStyle($(this.iframe), cssHashWH);
}
Object.extend(this.userOptions, cssHash);
@@ -708,8 +740,8 @@
if (e && target) {
var input = document.createElement("input");
input.type = "hidden";
- input.id = this.markerId.id + "OpenedState";
- input.name = this.markerId.id + "OpenedState";
+ input.id = this.markerId + "OpenedState";
+ input.name = this.markerId + "OpenedState";
input.value = this.shown ? "true" : "false";
target.appendChild(input);
@@ -718,8 +750,8 @@
for (var i = 0; i < keys.length; i++) {
input = document.createElement("input");
input.type = "hidden";
- input.id = this.markerId.id + "StateOption_" + keys[i];
- input.name = this.markerId.id + "StateOption_" + keys[i];
+ input.id = this.markerId + "StateOption_" + keys[i];
+ input.name = this.markerId + "StateOption_" + keys[i];
input.value = this.userOptions[keys[i]];
target.appendChild(input);
@@ -738,7 +770,7 @@
for (var i = 0; i < ModalPanel.panels.length; i++ ) {
var pnl = ModalPanel.panels[i];
if (pnl && pnl.markerId) {
- var pnlId = pnl.markerId.id;
+ var pnlId = pnl.markerId;
if (pnlId) {
//try to match ids
@@ -757,7 +789,7 @@
Richfaces.showModalPanel = function (id, opts) {
var panel = $(id + "Container");
if (!panel) {
- panel = Richfaces.findModalPanel(id);
+ panel = $(Richfaces.findModalPanel(id));
}
panel.modalPanel.show(opts);
}
@@ -765,7 +797,7 @@
Richfaces.hideModalPanel = function (id, opts) {
var panel = $(id + "Container");
if (!panel) {
- panel = Richfaces.findModalPanel(id);
+ panel = $(Richfaces.findModalPanel(id));
}
panel.modalPanel.hide(opts);
}
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js 2007-08-01
13:32:38 UTC (rev 1978)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js 2007-08-01
13:34:04 UTC (rev 1979)
@@ -2,10 +2,11 @@
ModalPanel.Border.prototype = {
initialize: function(id, modalPanel, cursor, sizer) {
- this.id = $(id);
- this.id.style.cursor = cursor;
+ this.id = id;
+ var element = $(id);
+ element.style.cursor = cursor;
- this.id.onmousedown = this.startDrag.bindAsEventListener(this);
+ $(id).onmousedown = this.startDrag.bindAsEventListener(this);
this.modalPanel = modalPanel;
this.sizer = sizer;
@@ -31,8 +32,9 @@
Event.observe(document, 'mousemove', this.boundDoDrag);
Event.observe(document, 'mouseup', this.boundEndDrag);
- this.modalPanel.cursorDiv.style.cursor = this.id.style.cursor;
- this.modalPanel.cursorDiv.style.zIndex = 8;
+ var eCursorDiv = $(this.modalPanel.cursorDiv);
+ eCursorDiv.style.cursor = $(this.id).style.cursor;
+ eCursorDiv.style.zIndex = 8;
this.modalPanel.startDrag(this);
@@ -102,13 +104,13 @@
this.modalPanel.endDrag(this);
this.modalPanel.doResizeOrMove(ModalPanel.Sizer.Diff.EMPTY);
- this.modalPanel.cursorDiv.style.zIndex = -200;
+ $(this.modalPanel.cursorDiv).style.zIndex = -200;
document.onselectstart = this.onselectStartHandler;
},
doPosition: function() {
- this.sizer.doPosition(this.modalPanel, this.id);
+ this.sizer.doPosition(this.modalPanel, $(this.id));
}
};