You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhky/web/js/2k3Dialog.htc

456 lines
11 KiB

1 year ago
<PUBLIC:COMPONENT
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>lightWeight<EFBFBD>=<3D>true
>
<PUBLIC:DEFAULTS
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>contentEditable<EFBFBD>=<3D>false
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>tabStop<EFBFBD>=<3D>true
/>
<PUBLIC:attach event="ondocumentready" onevent="initElement()" />
<PUBLIC:attach event="ondetach" onevent="cleanupElement()" />
<PUBLIC:attach event="oncontextmenu" onevent="elementOnContextMenu()" />
<PUBLIC:attach event="onpropertychange" onevent="elementOnPropertyChange()" />
<PUBLIC:property name="left" value=0 />
<PUBLIC:property name="top" value=0 />
<PUBLIC:property name="height" value=200 />
<PUBLIC:property name="width" value=250 />
<PUBLIC:property name="src" value="" />
<PUBLIC:property name="caption" value="" />
<PUBLIC:property name="resizable" value=true />
<script language="jscript">
// ----------------------------------------------------
// 2k3Widgets: 2k3Dialog
//
// Copyright <20>2002-2004 Stedy Software and Systems
// Please see http://www.stedy.com for terms of use.
// ----------------------------------------------------
var isIE6 = ((window.navigator.appVersion).indexOf("MSIE 6.") != -1) ;
var inDrag = false ;
var inSize = false ;
var orgX ;
var orgY ;
var orgTop ;
var orgLeft ;
var orgHeight ;
var orgWidth ;
var orgDirection ;
var objWindowCaption = null ;
var objCaptionImage = null ;
var objCloseButton = null ;
var objContentWindow = null ;
var objCurrentButton = null ;
internalSettingProperties = false ;
// ----------------------------------------------------
// initialize/terminate functions
// ----------------------------------------------------
function initElement() {
with (element) {
resizable = makeBooleanOfAttribute("resizable") ;
attachEvent("onselectstart", elementOnSelect)
attachEvent("onmousedown", elementOnMouseDown)
attachEvent("onmouseup", elementOnMouseUp)
attachEvent("onmousemove", elementOnMouseMove)
for (var i = 0; i < children.length; i++) {
switch (element.children[i].className) {
case "windowCaption":
objWindowCaption = children[i] ;
objWindowCaption.attachEvent("onmousedown", captionOnMouseDown)
element.caption = objWindowCaption.innerHTML ;
break ;
case "captionImage":
objCaptionImage = children[i] ;
break ;
case "windowButtonClose":
objCloseButton = children[i] ;
objCloseButton.title = "Close"
objCloseButton.children[0].setAttribute("src", currentStyle.closeImageUrl)
objCloseButton.attachEvent("onmousedown", buttonOnMouseDown)
objCloseButton.attachEvent("onmouseup", buttonOnMouseUp)
break ;
case "windowContent":
objContentWindow = children[i] ;
objContentWindow.attachEvent("onload", contentOnLoad)
objContentWindow.setAttribute("src", src)
break ;
}
}
}
}
function cleanupElement() {
with (element) {
detachEvent("onselectstart", elementOnSelect)
detachEvent("onmousedown", elementOnMouseDown)
detachEvent("onmouseup", elementOnMouseUp)
detachEvent("onmousemove", elementOnMouseMove)
}
with (objWindowCaption) {
detachEvent("onmousedown", captionOnMouseDown)
objWindowCaption = null ;
}
with (objCloseButton) {
detachEvent("onmousedown", buttonOnMouseDown)
detachEvent("onmouseup", buttonOnMouseUp)
objCloseButton = null ;
}
with (objContentWindow) {
detachEvent("onload", contentOnLoad)
objContentWindow = null ;
}
}
// ----------------------------------------------------
// element functions
// ----------------------------------------------------
function elementOnMouseDown() {
var ev = window.event ;
if (ev.srcElement == element) {
if (ev.button == 1 && orgDirection != "" && element.resizable) {
inSize = true
orgX = ev.clientX ;
orgY = ev.clientY ;
orgTop = element.offsetTop ;
orgLeft = element.offsetLeft ;
orgHeight = element.offsetHeight ;
orgWidth = element.offsetWidth ;
element.setCapture() ;
with (ev) {
returnValue = false ;
cancelBubble = true ;
}
}
}
}
function elementOnMouseUp() {
if (inSize) {
inSize = false ;
element.releaseCapture() ;
}
}
function elementOnMouseMove() {
if (inDrag) {
return ;
}
if (inSize) {
var btnWidth = objCloseButton.offsetWidth ;
with (window.event) {
var cliX = clientX ;
var cliY = clientY ;
returnValue = false ;
cancelBubble = true ;
}
if (orgDirection.indexOf("e") != -1) {
var intX = orgWidth + cliX - orgX ;
if (intX < 60) {
intX = 60 ;
}
element.style.width = intX ;
intX -= 8 ;
objCloseButton.style.left = intX - btnWidth ;
objContentWindow.style.width = intX ;
}
if (orgDirection.indexOf("s") != -1) {
var intY = orgHeight + cliY - orgY ;
if (intY < 60) {
intY = 60 ;
}
element.style.height = intY ;
objContentWindow.style.height = intY - objWindowCaption.offsetHeight - 10 ;
}
if (orgDirection.indexOf("w") != -1) {
var intX = orgWidth - cliX + orgX ;
var intL = orgLeft + cliX - orgX ;
if (intX < 60) {
intX = 60 ;
intL = orgLeft + orgWidth - 60 ;
}
element.style.left = intL ;
element.style.width = intX ;
intX -= 8 ;
objCloseButton.style.left = intX - btnWidth ;
objContentWindow.style.width = intX ;
}
if (orgDirection.indexOf("n") != -1) {
var intY = orgHeight - cliY + orgY ;
var intT = orgTop + cliY - orgY ;
if (intY < 60) {
intY = 60 ;
intT = orgTop + orgHeight - 60 ;
}
with (element.style) {
top = intT ;
height = intY ;
}
objContentWindow.style.height = intY - objWindowCaption.offsetHeight - 10 ;
}
}
else {
if (window.event.srcElement == element && element.resizable) {
orgDirection = getResizeDirection() ;
if (orgDirection == "") {
var strCursor = "default" ;
}
else {
var strCursor = orgDirection + "-resize" ;
}
element.style.cursor = strCursor ;
}
}
return false ;
}
function elementOnSelect() {
with (window.event) {
cancelBubble = true ;
returnValue = false ;
}
return false ;
}
function elementOnContextMenu() {
with (window.event) {
cancelBubble = true ;
returnValue = false ;
}
return false ;
}
function elementOnPropertyChange() {
if (internalSettingProperties) {
return ;
}
switch (window.event.propertyName) {
case "caption":
objWindowCaption.innerHTML = element.caption ;
break ;
case "src":
objContentWindow.setAttribute("src", element.src) ;
break ;
case "left":
case "top":
case "width":
case "height":
if (inDrag || inSize) {
return ;
}
with (element) {
style.left = left ;
style.top = top ;
style.width = width ;
style.height = height ;
}
with (objWindowCaption) {
var capWidth = offsetWidth ;
var capHeight = offsetHeight ;
var capTop = offsetTop ;
}
with (objCloseButton) {
var btnWidth = offsetWidth ;
var btnHeight = offsetHeight ;
style.top = (capHeight / 2) - (btnHeight / 2) + capTop ;
style.left = capWidth - btnWidth + 1 ;
}
with (objCaptionImage) {
var imgHeight = objCaptionImage.offsetHeight ;
style.top = (capHeight / 2) - (imgHeight / 2) + capTop + 1 ;
}
with (objContentWindow) {
style.width = capWidth ;
style.height = element.offsetHeight - capHeight - 10 ;
}
break ;
}
}
// ----------------------------------------------------
// caption functions
// ----------------------------------------------------
function captionOnMouseDown() {
with (window.event) {
if (button != 1) {
return ;
}
inDrag = true ;
orgX = clientX - element.style.pixelLeft ;
orgY = clientY - element.style.pixelTop ;
cancelBubble = true ;
returnValue = false ;
}
element.setCapture() ;
with (window.document) {
attachEvent("onmouseup", captionOnMouseUp) ;
attachEvent("onmousemove", captionOnMouseMove) ;
}
}
function captionOnMouseUp() {
inDrag = false ;
element.releaseCapture() ;
with (window.document) {
detachEvent("onmouseup", captionOnMouseUp) ;
detachEvent("onmousemove", captionOnMouseMove) ;
}
}
function captionOnMouseMove() {
if (inDrag) {
with (window.event) {
if (clientX > 0 && clientX < element.parentElement.offsetWidth) {
element.style.left = clientX - orgX ;
}
if (clientY > 0 && clientY < element.parentElement.offsetHeight) {
element.style.top = clientY - orgY ;
}
returnValue = false ;
cancelBubble = true ;
}
}
}
// ----------------------------------------------------
// close button functions
// ----------------------------------------------------
function buttonOnMouseDown() {
with (window.event) {
if (button != 1) {
return ;
}
var el = srcElement ;
}
if (el.tagName == "IMG") {
el = el.parentElement ;
}
showPressed(el, el.children[0]) ;
el.setCapture() ;
objCurrentButton = el ;
}
function buttonOnMouseUp() {
with (window.event) {
if (button != 1) {
return ;
}
var el = srcElement ;
}
if (el.tagName == "IMG") {
el = el.parentElement ;
}
showRaised(objCurrentButton, objCurrentButton.children[0]) ;
objCurrentButton.releaseCapture() ;
if (el == objCurrentButton) {
element.style.visibility = "hidden" ;
}
objCurrentButton = null ;
}
// ----------------------------------------------------
// iframe functions
// ----------------------------------------------------
function contentOnLoad() {
try {
if (window.event.srcElement.contentWindow.document.title != "") {
element.caption = window.event.srcElement.contentWindow.document.title ;
}
}
catch(e) { return ; }
}
// ----------------------------------------------------
// internal functions
// ----------------------------------------------------
function showRaised(el, elImage) {
with (el.style) {
borderLeft = "1px solid buttonhighlight" ;
borderRight = "1px solid threeddarkshadow" ;
borderTop = "1px solid buttonhighlight" ;
borderBottom = "1px solid threeddarkshadow" ;
}
with (elImage.style) {
borderLeft = "" ;
borderRight = "1px solid buttonshadow" ;
borderTop = "" ;
borderBottom = "1px solid buttonshadow" ;
}
}
function showPressed(el, elImage) {
with (el.style) {
borderLeft = "1px solid threeddarkshadow" ;
borderRight = "1px solid buttonhighlight" ;
borderTop = "1px solid threeddarkshadow" ;
borderBottom = "1px solid buttonhighlight" ;
}
with (elImage.style) {
borderLeft = "1px solid buttonshadow" ;
borderRight = "" ;
borderTop = "1px solid buttonshadow" ;
borderBottom = "" ;
}
}
function getResizeDirection() {
var sResult = "" ;
var offSet = 8 ;
with (window.event) {
var xPos = offsetX ;
var yPos = offsetY ;
}
if (yPos < offSet) {
sResult += "n" ;
}
if (yPos > element.offsetHeight - offSet) {
sResult += "s" ;
}
if (xPos < offSet) {
sResult += "w" ;
}
if (xPos > element.offsetWidth - offSet) {
sResult += "e" ;
}
return sResult ;
}
function makeBooleanOfAttribute(attName) {
a = element.getAttribute(attName) ;
if (typeof(a) == "boolean") {
return a ;
}
else if (a == null) {
a = false ;
}
else if (typeof(a) == "string") {
a = a.toLowerCase() ;
a = (a == "true" || a == "1" || a == "yes") ;
}
else {
a = new Boolean(a) ;
}
return a ;
}
</script>
</PUBLIC:COMPONENT>