// xFenster, Copyright 2004-2007 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xFenster(eleId, iniX, iniY, barId, resBtnId, maxBtnId) // object prototype { // Private Properties var me = this; var ele = xGetElementById(eleId); var rBtn = xGetElementById(resBtnId); var mBtn = xGetElementById(maxBtnId); var x, y, w, h, maximized = false; this.savePos = function() { document.globalform.posX.value = xLeft(ele); document.globalform.posY.value = xTop(ele); } // Public Methods this.onunload = function() { if (!window.opera) { // clear cir refs xDisableDrag(barId); xDisableDrag(rBtn); mBtn.onclick = ele.onmousedown = null; me = ele = rBtn = mBtn = null; } }; this.paint = function() { xMoveTo(rBtn, xWidth(ele) - xWidth(rBtn), xHeight(ele) - xHeight(rBtn)); xMoveTo(mBtn, xWidth(ele) - xWidth(mBtn), 0); }; // Private Event Listeners function barOnDrag(e, mdx, mdy) { // Thanks to Jen for this feature: var x = xLeft(ele) + mdx; var y = xTop(ele) + mdy; if (x < 0) x = 0; if (y < 0) y = 0; xMoveTo(ele, x, y); } function resOnDrag(e, mdx, mdy) { xResizeTo(ele, xWidth(ele) + mdx, xHeight(ele) + mdy); me.paint(); } function fenOnMousedown() { xZIndex(ele, xFenster.z++); } function maxOnClick() { if (maximized) { maximized = false; xResizeTo(ele, w, h); xMoveTo(ele, x, y); } else { w = xWidth(ele); h = xHeight(ele); x = xLeft(ele); y = xTop(ele); xMoveTo(ele, xScrollLeft(), xScrollTop()); maximized = true; xResizeTo(ele, xClientWidth(), xClientHeight()); } me.paint(); } // Constructor Code xFenster.z++; xMoveTo(ele, iniX, iniY); this.paint(); xEnableDrag(barId, null, barOnDrag, null); xEnableDrag(rBtn, null, resOnDrag, null); // mBtn.onclick = maxOnClick; if (ele != null) { ele.onmousedown = fenOnMousedown; xShow(ele); } } // end xFenster object prototype xFenster.z = 0; // xFenster static property