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.

330 lines
8.1 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

<PUBLIC:COMPONENT
    lightWeight = true
>
<PUBLIC:DEFAULTS
    contentEditable = false
    tabStop = true
/>
<PUBLIC:attach event="ondocumentready" onevent="initElement()" />
<PUBLIC:attach event="onmouseover" onevent="elementOnMouseOver()" />
<PUBLIC:attach event="onmouseout" onevent="elementOnMouseOut()" />
<PUBLIC:attach event="onmousedown" onevent="elementOnMouseDown()" />
<PUBLIC:attach event="onmouseup" onevent="elementOnMouseUp()" />
<PUBLIC:attach event="onpropertychange" onevent="elementPropertyChange()" />
<PUBLIC:attach event="onselectstart" onevent="elementOnSelect()" />
<PUBLIC:attach event="oncontextmenu" onevent="elementOnContextMenu()" />
<PUBLIC:attach event="ondetach" onevent="cleanupElement()" />
<PUBLIC:property name="enabled" value=true />
<PUBLIC:property name="menu" value="" />
<PUBLIC:property name="menuState" value=false />
<script language="jscript">
// ----------------------------------------------------
// 2k3Widgets: 2k3MenuButton
//
// Copyright ©2002-2004 Stedy Software and Systems
// Please see http://www.stedy.com for terms of use.
// ----------------------------------------------------
var onClickHolder = null ;
var vbLeftButton = 1 ;
var settingValueInternally = false ;
var menuShadowArray = new Array(null, null, null, null) ;
function initElement() {
settingValueInternally = true ;
element.enabled = makeBooleanOfAttribute("enabled") ;
element.menuState = makeBooleanOfAttribute("menuState") ;
if (!element.enabled) {
showDisabled(element) ;
}
settingValueInternally = false ;
for (var i = 3; i >= 0; i--) {
menuShadowArray[i] = window.document.createElement("SPAN") ;
menuShadowArray[i].className = "2k3ShadowElement" ;
element.parentElement.insertAdjacentElement("afterBegin", menuShadowArray[i]) ;
}
}
function cleanupElement() {
for (var i = 0; i <= 3; i++) {
if (menuShadowArray[i] != null) {
menuShadowArray[i].style.visibility = "hidden" ;
}
menuShadowArray[i].removeNode(true) ;
menuShadowArray[i] = null ;
}
}
function elementOnMouseOver() {
if (element.enabled) {
var fromElement = window.event.fromElement ;
if (fromElement != null) {
if (getRealItem(fromElement) == element) { return ; }
}
if (element.parentElement.parentElement.parentElement.parentElement.activeChild == null) {
if (!element.menuState) {
showOver(getRealItem(window.event.srcElement)) ;
element.parentElement.parentElement.parentElement.parentElement.activeChild = element ;
}
}
}
}
function elementOnMouseOut() {
if (element.enabled) {
var toElement = window.event.toElement ;
if (toElement != null) {
if (getRealItem(toElement) == element) { return ; }
}
if (element.parentElement.parentElement.parentElement.parentElement.activeChild == null
|| element.parentElement.parentElement.parentElement.parentElement.activeChild == element) {
if (!element.menuState) {
showNormal(getRealItem(window.event.srcElement)) ;
element.parentElement.parentElement.parentElement.parentElement.activeChild = null ;
}
}
}
}
function elementOnMouseDown() {
var el = getRealItem(window.event.srcElement) ;
if (element.parentElement.parentElement.parentElement.parentElement.activeChild == null
|| element.parentElement.parentElement.parentElement.parentElement.activeChild == element) {
if ((window.event.button == vbLeftButton) && element.enabled) {
if (el.className.indexOf("2k3MenuButton") == -1) {
return ;
}
if (!element.menuState) {
showActive(el) ;
showMenu() ;
}
}
}
}
function elementOnMouseUp() {
var el = getRealItem(window.event.srcElement) ;
if (element.parentElement.parentElement.parentElement.parentElement.activeChild == null
|| element.parentElement.parentElement.parentElement.parentElement.activeChild == element) {
if ((window.event.button == vbLeftButton) && element.enabled) {
if (el.className.indexOf("2k3MenuButton") == -1) {
return ;
}
if (element.menuState) {
hideMenu() ;
showOver(element) ;
}
else {
if (element.className == "2k3MenuButtonActive") {
element.menuState = true ;
}
}
}
}
}
function elementPropertyChange() {
if (window.event.propertyName == "enabled") {
if (element.enabled) {
showEnabled(element) ;
}
else {
showDisabled(element) ;
}
}
}
function elementOnSelect() {
with (window.event) {
cancelBubble = true ;
returnValue = false ;
}
return false ;
}
function elementOnContextMenu() {
with (window.event) {
cancelBubble = true ;
returnValue = false ;
}
return false ;
}
function showNormal(el) {
for (var i = 0; i <= 3; i++) {
if (menuShadowArray[i] != null) {
menuShadowArray[i].style.visibility = "hidden" ;
}
}
with (el) {
className = "2k3MenuButton" ;
}
}
function showOver(el) {
for (var i = 0; i <= 3; i++) {
if (menuShadowArray[i] != null) {
menuShadowArray[i].style.visibility = "hidden" ;
}
}
with (el) {
className = "2k3MenuButtonOver" ;
}
}
function showActive(el) {
for (var i = 3; i >= 0; i--) {
with (menuShadowArray[i].style) {
left = getRealLeft(el) + el.offsetWidth - 1 ;
top = (4 + i) ;
width = (i + 3) ;
height = el.offsetHeight - (i * 2) ;
zIndex = el.style.zIndex ;
overflow = "hidden" ;
visibility = "visible" ;
}
}
with (el) {
className = "2k3MenuButtonActive" ;
}
}
function showDisabled(el) {
with (el) {
var strClassName = className ;
if (strClassName.substring(0, 13) == "2k3MenuButton" && strClassName.indexOf("Disabled") == -1) {
className = "2k3MenuButtonDisabled" ;
if (onclick != null) {
onClickHolder = onclick ;
onclick = null ;
}
}
}
}
function showEnabled(el) {
with (el) {
if (className == "2k3MenuButtonDisabled") {
className = "2k3MenuButton" ;
if (onClickHolder != null) {
onclick = onClickHolder ;
onClickHolder = null ;
}
}
}
}
function showMenu() {
with (element) {
var x = offsetLeft + getRealLeft(element) ;
var y = offsetTop + offsetHeight + getRealTop(element) - 4 ;
var w = offsetWidth - 2 ;
}
with (window.document) {
attachEvent("onclick", hideMenuEx) ;
getElementById(element.menu).showMenu(x, y, w) ;
}
}
function hideMenu() {
var el = window.event.srcElement ;
var elParent = el.parentElement ;
if (elParent != null) {
switch (elParent.className) {
case "2k3MenuImageShadow":
elParent = elParent.parentElement ;
break ;
case "2k3MenuImage":
elParent = elParent.parentElement ;
break ;
case "2k3MenuItemOver":
el = elParent.parentElement.parentElement ;
if (el.subMenuState) {
elParent = null ;
el = null ;
return ;
}
break ;
}
}
with (window.document) {
detachEvent("onclick", hideMenuEx) ;
getElementById(element.menu).hideMenu() ;
}
showNormal(element) ;
element.menuState = false ;
element.parentElement.parentElement.parentElement.parentElement.activeChild = null ;
}
function hideMenuEx() {
var el = window.event.srcElement ;
if (el.tagName.toLowerCase() == "img") {
el = el.parentElement ;
}
if (el.className != "2k3MenuButtonActive" && el.className != "2k3MenuButtonCaption") {
hideMenu() ;
with (window.event) {
cancelBubble = true ;
returnValue = false ;
}
}
}
function getRealTop(el) {
var t = 0 ;
var tElement = el ;
while (tElement != null) {
t += tElement.offsetTop ;
tElement = tElement.offsetParent ;
}
return t ;
}
function getRealLeft(el) {
var l = 0 ;
var tElement = el ;
while (tElement != null) {
l += tElement.offsetLeft ;
tElement = tElement.offsetParent ;
}
return l ;
}
function getRealItem(el) {
var tmpElement = el ;
if (tmpElement == null) { return tmpElement ; }
if (tmpElement.tagName.toLowerCase() == "img") {
tmpElement = tmpElement.parentElement ;
}
if (tmpElement.className == "2k3MenuButtonCaption") {
tmpElement = tmpElement.parentElement ;
}
return tmpElement ;
}
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>