Author: A.Skokov
Date: 2007-05-03 12:04:52 -0400 (Thu, 03 May 2007)
New Revision: 639
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-146 fixed
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-05-03
15:57:15 UTC (rev 638)
+++
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-05-03
16:04:52 UTC (rev 639)
@@ -18,13 +18,13 @@
if (idx != -1) {
var versIdx = agent.indexOf(";", idx);
var versString;
-
+
if (versIdx != -1) {
versString = agent.substring(idx + searchString.length, versIdx);
} else {
versString = agent.substring(idx + searchString.length);
}
-
+
if (parseFloat(versString) < 7) {
ModalPanel.disableSelects = true;
}
@@ -43,7 +43,7 @@
if (!Richfaces.isNodeInDOMTree(elt)) {
panel.destroy();
-
+
ModalPanel.panels.splice(i, 1);
//check all panels again. maybe we've removed parent of any panel just now
i = 0;
@@ -60,19 +60,19 @@
this.cdiv = modalPanel.contentDiv;
this.isPositionFixed = Richfaces.getComputedStyle(this.cdiv, "position") ==
"fixed";
},
-
+
left: function(offset) {
return offset;
- },
+ },
top: function(offset) {
return offset;
},
-
+
width: function() {
return this.cdiv.offsetWidth;
},
-
+
height: function() {
return this.cdiv.offsetHeight;
}
@@ -83,7 +83,7 @@
if (document.compatMode=='CSS1Compat') {
element = document.documentElement;
} else {
- element = document.body;
+ element = document.body;
}
return element;
@@ -93,23 +93,23 @@
ModalPanel.prototype = {
initialize: function(id, options) {
this.markerId = $(id);
-
+
this.id = $(id + "Container");
-
+
this.options = options;
-
+
this.baseZIndex = this.options.zindex ? this.options.zindex : 100;
-
- this.minWidth = Math.max(this.options.minWidth, 2*sizeA + 2);
- this.minHeight = Math.max(this.options.minHeight, 2*sizeA + 2);
-
+
+ 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.context = new ModalPanel.Context(this);
-
+
this.borders = new Array();
if (this.options.resizeable) {
@@ -126,16 +126,16 @@
this.borders.push(new ModalPanel.Border(id + "ResizerW", this,
"W-resize", ModalPanel.Sizer.W));
this.borders.push(new ModalPanel.Border(id + "ResizerNWL", this,
"NW-resize", ModalPanel.Sizer.NWL));
}
-
+
if (this.options.moveable && $(id + "Header")) {
this.header = new ModalPanel.Border(id + "Header", this, "move",
ModalPanel.Header);
}
-
+
this.id.modalPanel = this;
- if (this.div.style.setExpression)
+ 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";
@@ -155,8 +155,9 @@
},
destroy: function() {
- this.traverseSelects(true);
-
+
+ this.traverseSelects(true);
+
if (this.floatedToBody) {
var parent = this.id.parentNode;
if (parent) {
@@ -166,13 +167,13 @@
},
initIframe : function() {
- if (this.contentWindow) {
+ if (this.contentWindow) {
Element.setStyle(this.contentWindow.document.body, { "margin" : "0px
0px 0px 0px" });
} else {
//TODO opera etc.
-
+
}
-
+
if("transparent" == Element.getStyle(document.body,
"background-color")) {
this.allowTransparency = true;
}
@@ -185,33 +186,33 @@
//iframeBodyStyle.opacity = "0.5";
//iframeBodyStyle.zIndex = "99";
},
-
+
traverseSelects: function(enable) {
if (!ModalPanel.disableSelects) {
return ;
}
-
+
var children = document.body.childNodes;
for (var k = 0; k < children.length; k++) {
var child = children[k];
if (child != this.id && child.getElementsByTagName) {
-
+
var selects = child.getElementsByTagName("SELECT");
-
+
for (var i = 0; i < selects.length; i++) {
var elt = selects[i];
-
+
if (enable) {
if (elt._mdwCount) {
elt._mdwCount -= 1;
-
+
if (elt._mdwCount == 0) {
if (elt._mdwDisabled) {
elt._mdwDisabled = undefined;
} else {
- elt.disabled = false;
+ elt.disabled = false;
}
-
+
elt._mdwCount = undefined;
}
}
@@ -224,7 +225,7 @@
} else {
elt.disabled = true;
}
-
+
elt._mdwCount = 1;
}
}
@@ -240,7 +241,7 @@
this.cdiv.style.left = pos + "px";
}
},
-
+
setTop: function(pos) {
if (this.cdiv.mpUseExpr) {
this.cdiv.mpTop = pos;
@@ -250,34 +251,38 @@
},
show: function(opts) {
- if (!this.floatedToBody) {
+ this.onSelectStartHandler = document.onselectstart;
+
+ document.onselectstart = function () { return false; };
+
+ if (!this.floatedToBody) {
document.body.appendChild(this.id.parentNode.removeChild(this.id));
this.floatedToBody = true;
}
-
+
if (ModalPanel.disableSelects && !this.iframe) {
new Insertion.Top(this.cdiv,
- "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.markerId.id + "IFrame\""
+
+ "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.markerId.id + "IFrame\""
+
"style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
"</iframe>");
-
+
this.iframe = $(this.markerId.id + "IFrame");
-
+
//alert("IFrame:" + this.iframe + "created!");
-
+
this.iframe.onload = this.initIframe.bind(this.iframe);
}
-
+
var options = {};
-
+
if (!this.cdiv.mpSet) {
Object.extend(options, this.options);
}
if (opts) {
Object.extend(options, opts);
- }
-
+ }
+
if (options.width) {
if (this.minWidth > options.width) {
options.width = this.minWidth;
@@ -291,7 +296,7 @@
if (options.height) {
if (this.minHeight > options.height) {
- options.height = this.minHeight;
+ options.height = this.minHeight;
}
if (this.iframe) {
@@ -315,7 +320,7 @@
this.setLeft(_left);
}
-
+
if (options.top) {
var _top;
if (options.top != "auto") {
@@ -324,23 +329,23 @@
var cw = getSizeElement().clientHeight;
_top = (cw - Richfaces.getComputedStyleSize(this.contentDiv, "height")) /
2;
}
-
+
this.setTop(_top);
}
this.cdiv.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;
//}
-
+
this.traverseSelects();
//this.shape.init(this.cdiv, this.options);
- if (this.div.style.position == "absolute")
+ if (this.div.style.position == "absolute")
{
var we = "getSizeElement().clientWidth + \"px\"";
var he = "getSizeElement().clientHeight + \"px\"";
@@ -352,7 +357,7 @@
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);
@@ -366,7 +371,7 @@
this.cdiv.style.setExpression("left", leftExpr);
this.cdiv.style.setExpression("top", topExpr);
-
+
/* That's how we output debug info - DOM inspector rulez */
/*
document.body.setExpression("_clientLeft",
"getSizeElement().clientLeft");
@@ -386,14 +391,14 @@
for (var k = 0; k < this.borders.length; k++ ) {
this.borders[k].doPosition();
}
-
+
if (this.header) {
this.header.doPosition();
}
-
+
this.id.style.visibility = "";
},
-
+
startDrag: function(border) {
for (var k = 0; k < this.borders.length; k++ ) {
//this.borders[k].hide();
@@ -406,9 +411,11 @@
this.borders[k].doPosition();
}
},
-
+
hide: function() {
- this.traverseSelects(true);
+ document.onselectstart = this.onSelectStartHandler;
+
+ this.traverseSelects(true);
if (this.div.style.removeExpression) {
this.div.style.removeExpression("width");
@@ -429,14 +436,14 @@
Element.hide(this.id);
},
-
+
doResizeOrMove: function(diff) {
var vetoes = {};
var cssHash = {};
var cssHashWH = {};
var winSize = Richfaces.getWindowSize();
-
+
var vetoeChange = false;
var newSize;
// Avoid currentStyle bug in opera
@@ -444,10 +451,10 @@
newSize = Richfaces.getComputedStyleSize(this.contentDiv, "width");
else
newSize = parseInt(this.contentDiv.style.width.replace("px", ""),
10);
-
+
var oldSize = newSize;
newSize += diff.deltaWidth || 0;
-
+
if (newSize >= this.minWidth) {
if (diff.deltaWidth) {
cssHashWH.width = newSize + 'px';
@@ -456,17 +463,17 @@
} else {
if (diff.deltaWidth) {
cssHashWH.width = this.minWidth + 'px';
-
+
vetoes.vx = oldSize - this.minWidth;
}
-
+
vetoes.x = true;
}
if (vetoes.vx && diff.deltaX) {
diff.deltaX = -vetoes.vx;
}
-
+
if (diff.deltaX && (vetoes.vx || !vetoes.x)) {
if (vetoes.vx) {
diff.deltaX = vetoes.vx;
@@ -475,19 +482,19 @@
if (this.cdiv.mpUseExpr) {
newPos = this.cdiv.mpLeft || 0;
newPos += diff.deltaX;
-
+
this.cdiv.mpLeft = newPos;
} else {
newPos = Richfaces.getComputedStyleSize(this.cdiv, "left");
newPos += diff.deltaX;
cssHash.left = newPos + 'px';
}
- }
+ }
var newSize = Richfaces.getComputedStyleSize(this.contentDiv, "height");
var oldSize = newSize;
newSize += diff.deltaHeight || 0;
-
+
if (newSize >= this.minHeight) {
if (diff.deltaHeight) {
cssHashWH.height = newSize + 'px';
@@ -498,14 +505,14 @@
vetoes.vy = oldSize - this.minHeight;
}
-
+
vetoes.y = true;
}
if (vetoes.vy && diff.deltaY) {
diff.deltaY = -vetoes.vy;
}
-
+
if (diff.deltaY && (vetoes.vy || !vetoes.y)) {
if (vetoes.vy) {
diff.deltaY = vetoes.vy;
@@ -515,20 +522,20 @@
if (this.cdiv.mpUseExpr) {
newPos = this.cdiv.mpTop || 0;
newPos += diff.deltaY;
-
+
this.cdiv.mpTop = newPos;
} else {
newPos = Richfaces.getComputedStyleSize(this.cdiv, "top");
newPos += diff.deltaY;
cssHash.top = newPos + 'px';
}
- }
+ }
- Element.setStyle(this.cdiv, cssHash);
-
- Element.setStyle(this.contentDiv, cssHashWH);
+ Element.setStyle(this.cdiv, cssHash);
+
+ Element.setStyle(this.contentDiv, cssHashWH);
if (this.iframe) {
- Element.setStyle(this.iframe, cssHashWH);
+ Element.setStyle(this.iframe, cssHashWH);
}
var w = this.context.width();
@@ -545,7 +552,7 @@
if (!this.context.reduced) {
this.context.reduced = {};
}
-
+
this.context.reduced.h = h;
}
@@ -560,12 +567,12 @@
Richfaces.findModalPanel = function (id) {
if (id) {
var prefId = (id.charAt(0) == ':' ? id : ':' + id);
-
+
for (var i = 0; i < ModalPanel.panels.length; i++ ) {
var pnl = ModalPanel.panels[i];
if (pnl && pnl.markerId) {
var pnlId = pnl.markerId.id;
-
+
if (pnlId) {
//try to match ids
if (pnlId.length >= prefId.length) {