home *** CD-ROM | disk | FTP | other *** search
HTML Component | 2003-08-20 | 10.4 KB | 293 lines |
- <PUBLIC:COMPONENT tagName='DialogWindow' lightweight="true">
- <PUBLIC:PROPERTY NAME="dialog_width" />
- <PUBLIC:PROPERTY NAME="dialog_height" />
- <PUBLIC:PROPERTY NAME="document_src" />
- <PUBLIC:PROPERTY NAME="innerHTML" />
- <PUBLIC:PROPERTY NAME="align" />
- <PUBLIC:PROPERTY NAME="opacity" />
- <PUBLIC:ATTACH EVENT="onpropertychange" ONEVENT="doPropChange();" />
- <PUBLIC:METHOD NAME="isOn" />
- <PUBLIC:METHOD NAME="getElement" />
- <PUBLIC:METHOD NAME="show" />
- <PUBLIC:METHOD NAME="hide" />
- <PUBLIC:METHOD NAME="setSize" />
- <PUBLIC:METHOD NAME="allowResize" />
- <PUBLIC:METHOD NAME="addButton" />
- <PUBLIC:METHOD NAME="clearButtons" />
- <PUBLIC:METHOD NAME="setBackgroundImage" />
- <PUBLIC:METHOD NAME="setStyle" />
- <PUBLIC:METHOD NAME="setButtonWidth" />
- <PUBLIC:EVENT NAME="onhide" ID="OnDialogHide" />
- <PUBLIC:EVENT NAME="onshow" ID="OnDialogShow" />
-
- <PUBLIC:DEFAULTS
- contentEditable = "false"
- viewInheritStyle = "false"
- viewLinkContent = "true"
- viewMasterTab = "false"
- />
- </PUBLIC:COMPONENT>
- <script>
- element.dialog_width = 600;
- element.dialog_height = 500;
-
- var dialogMode = 0;
- var cachedDialogWidth = element.dialog_width;
- var cachedDialogHeight = element.dialog_height;
- var dontListenToPropChange = false;
- var sCurrentStyle = "";
-
- function doPropChange()
- {
- switch (event.propertyName)
- {
- case "dialog_width":
- case "dialog_height":
- if (cachedDialogHeight != element.dialog_height || cachedDialogWidth != element.dialog_width ) {
- element.document.all.sys_dialog_tblFrame.height = dialog_height;
- element.document.all.divDialogBG.style.pixelHeight = (dialog_height - 10);
- element.document.all.divDialogHeader.style.pixelHeight = 26;
- element.document.all.divDialogBody.style.pixelHeight = (dialog_height - 10 - 26 - 1 );
- element.document.all.divTextPopup.style.pixelHeight = (dialog_height - 19);
- element.document.all.ifrmPopup.style.pixelHeight = (dialog_height - 19);
- element.document.all.divBtnBox.style.pixelTop = (element.document.all.sys_dialog_tblFrame.height - 50);
- cachedDialogHeight = element.dialog_height;
-
- element.document.all.sys_dialog_tblFrame.width = dialog_width;
- element.document.all.divDialogBG.style.pixelWidth = (dialog_width - 10);
- element.document.all.divDialogHeader.style.pixelWidth = (dialog_width - 10);
- element.document.all.divDialogBody.style.pixelWidth = (dialog_width - 10);
- element.document.all.divTextPopup.style.pixelWidth = (dialog_width - 35);
- element.document.all.ifrmPopup.style.pixelWidth = (dialog_width-18);
- element.document.all.divBtnBox.style.pixelWidth = (dialog_width-45);
- cachedDialogWidth = element.dialog_width;
- };
- break;
- case "document_src":
- if (!dontListenToPropChange) {
- setSize(500, 400);
- dialogMode = 0;
- element.document.all.ifrmPopup.src = System.getInstallFolder(true) + element.document_src;
- element.document.all.divTextPopup.innerHTML = "";
- clearButtons();
- dontListenToPropChange = true;
- element.innerHTML = "";
- dontListenToPropChange = false;
- };
- break;
- case "innerHTML":
- if (!dontListenToPropChange) {
- setSize(350, 147);
- dialogMode = 1;
- element.document.all.divTextPopup.style.backgroundColor="transparent";
- element.document.all.divTextPopup.style.color = "white";
- element.document.all.divTextPopup.innerHTML = element.innerHTML;
-
- clearButtons();
- element.document.all.divTextPopup.style.textAlign = "left";
- element.document.all.divTextPopup.noWrap = false;
- dontListenToPropChange = true;
- element.document_src = "";
- dontListenToPropChange = false;
- };
- break;
- case "align":
- element.document.all.divTextPopup.style.textAlign = element.align;
- break;
- };
- };
- function allowResize(bWrap, suggestedWidth)
- {
- if (!bWrap)
- {
- element.document.all.divTextPopup.noWrap = true;
- if (element.document.all.divTextPopup.scrollWidth > element.document.all.divTextPopup.offsetWidth)
- {
- diff = element.document.all.divTextPopup.scrollWidth - element.document.all.divTextPopup.offsetWidth;
- newWidth = diff + element.dialog_width;
- if (newWidth > 800) { newWidth = 800; }
- element.dialog_width = newWidth;
- };
- } else {
- if (!suggestedWidth) { return; };
- if (suggestedWidth > 800) { suggestedWidth = 800; };
- element.dialog_width = suggestedWidth;
- element.document.all.divTextPopup.noWrap = false;
- if ((element.document.all.divTextPopup.scrollHeight + 30 /*buffer for buttons*/) > element.document.all.divTextPopup.offsetHeight)
- {
- diff =(element.document.all.divTextPopup.scrollHeight + 30) - element.document.all.divTextPopup.offsetHeight;
- newHeight = diff + element.dialog_height;
- if (newHeight > 600) { newHeight = 600; };
- element.dialog_height = newHeight;
- };
- };
- };
- function setSize (width, height)
- {
- if (width < 159) width = 159;
- if (width > 800) width = 800;
- if (height < 87) height = 87;
- if (height > 600) height = 600;
-
- element.dialog_height = height;
- if (element.document.all.divTextPopup.innerHTML) {
- allowResize(true, width);
- } else {
- element.dialog_width = width;
- };
- };
- function isOn() { return (element.document.all.divDialogBox.style.visibility == "visible"); };
- function getElement(id)
- {
- if (element.document.all[id]) { return element.document.all[id]; };
- if (element.document.all.ifrmPopup.contentWindow.document.all[id]) { return element.document.all.ifrmPopup.contentWindow.document.all[id]; };
- };
- function show()
- {
- try { top.document.frames["Editorial_Frame"].focus(); } catch (e) { }
-
- setStyle(sCurrentStyle);
-
- if (top.document.frames["Editorial_Frame"].showDialogCallback) {
- top.document.frames["Editorial_Frame"].showDialogCallback();
- };
- var screenCenterX = 400;
- var screenCenterY = 300;
- var elCenterX = Math.round(element.dialog_width/2);
- var elCenterY = Math.round(element.dialog_height/2);
- if (elCenterX <= screenCenterX) {
- element.document.all.sys_dialog_box.style.pixelLeft = screenCenterX - elCenterX;
- } else {
- element.document.all.sys_dialog_box.style.pixelLeft = elCenterX - screenCenterX;
- };
- if (elCenterY <= screenCenterY) {
- element.document.all.sys_dialog_box.style.pixelTop = screenCenterY - elCenterY;
- } else {
- element.document.all.sys_dialog_box.style.pixelTop = elCenterY - screenCenterY;
- };
- if (dialogMode) {
- element.document.all.divTextPopup.style.visibility = 'visible';
- element.document.all.ifrmPopup.style.visibility = 'hidden';
- } else {
- element.document.all.divTextPopup.style.visibility = 'hidden';
- element.document.all.ifrmPopup.style.visibility = 'visible';
- };
- element.document.all.divDialogBox.style.visibility = "visible";
- element.document.all.divDialogHeader.style.visibility = "visible";
- element.document.all.divDialogBody.style.visibility = "visible";
-
- element.document.all.divDialogBox.focus();
- screenCenterX = screenCenterY = elCenterX = elCenterY = null;
- window.external.PumpMessages();
-
- var eventObject = createEventObject();
- eventObject.dialogOn = true;
- OnDialogShow.fire(eventObject);
- };
- function hide()
- {
- setBackgroundImage("fe/nhl/images2/common/1x1_wht.gif");
- sCurrentStyle = nhlMsg("ALERT") + "!";
-
- element.document.all.divDialogHeader.style.visibility = "hidden";
- element.document.all.divDialogBody.style.visibility = "hidden";
-
- if (top.document.frames["Editorial_Frame"].hideDialogCallback) {
- top.document.frames["Editorial_Frame"].hideDialogCallback();
- };
- element.document.all.divDialogBox.style.visibility = "hidden";
- element.document.all.divTextPopup.style.visibility = 'hidden';
- element.document.all.ifrmPopup.style.visibility = 'hidden';
-
- // var eventObject = createEventObject();
- // eventObject.dialogOn = false;
- // OnDialogHide.fire(eventObject);
- };
- var btnOnCount = 0;
- var btn1Handler, btn2Handler, btn3Handler;
- function addButton(sID, sText, fHandler, bDontClose)
- {
- if (btnOnCount < 3) {
- switch (btnOnCount +1) {
- case 1:
- btn1Handler = fHandler;
- break;
- case 2:
- btn2Handler = fHandler;
- break;
- case 3:
- btn3Handler = fHandler;
- break;
- };
- element.document.all["btn" + (btnOnCount +1)].enable();
- element.document.all["btn" + (btnOnCount + 1)].style.display = '';
- element.document.all["btn" + (btnOnCount + 1)].btnEvent = function()
- {
- switch (this.id) {
- case "btn1":
- if (btn1Handler) {
- btn1Handler();
- };
- break;
- case "btn2":
- if (btn2Handler) {
- btn2Handler();
- };
- break;
- case "btn3":
- if (btn3Handler) {
- btn3Handler();
- };
- break;
- };
- if (!bDontClose) { hide(); };
- };
- element.document.all["btn" + (btnOnCount + 1)].btnText = sText;
- };
- btnOnCount++;
- };
- function clearButtons()
- {
- element.document.all.btn1.style.display = 'none';
- btn1Handler = null;
- element.document.all.btn2.style.display = 'none';
- btn2Handler = null;
- element.document.all.btn3.style.display = 'none';
- btn3Handler = null;
- btnOnCount = 0;
- };
-
- function setBackgroundImage(imgPath, pixelTop)
- {
- sCurrentStyle = "NONE";
-
- element.document.all.divDialogHeader.style.visibility = "hidden";
- element.document.all.divDialogBody.style.visibility = "hidden";
-
- element.document.all.divDialogBG.src = System.getInstallFolder(true) + imgPath;
-
- if (pixelTop != null)
- {
- element.document.all.divBtnBox.style.pixelTop = (element.document.all.sys_dialog_tblFrame.height - 50 + pixelTop);
- }
- };
- function setStyle(strStyle)
- {
- sCurrentStyle = strStyle;
-
- switch (strStyle)
- {
- case "NONE":
- element.document.all.divTextPopup.innerHTML = element.innerHTML;
- break;
- default:
- element.document.all.divTextPopup.innerHTML = strStyle + "<BR><BR>" + element.innerHTML;
- setSize(element.dialog_width,element.dialog_height+32);
- break;
- }
- };
- function setButtonWidth(nWidth)
- {
- element.document.all.btn1.style.pixelWidth = nWidth;
- };
- </script>