home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Joystick Magazine 2003 November
/
CD1_JOY_153.iso
/
demos
/
NHL2004Demo.exe
/
fe
/
nhl
/
htc
/
button
/
Button.htc
next >
Wrap
Text File
|
2003-08-20
|
5KB
|
179 lines
<!-- Copyright (c) 2002 Electronic Arts Inc. All rights reserved. -->
<PUBLIC:COMPONENT>
<PUBLIC:PROPERTY NAME="imgSrc" />
<PUBLIC:PROPERTY NAME="text" />
<ATTACH EVENT="ondocumentready" HANDLER="doInit" />
<ATTACH EVENT="onmousedown" HANDLER="doMouseDown" />
<ATTACH EVENT="onmouseenter" HANDLER="doMouseEnter" />
<ATTACH EVENT="onmouseleave" HANDLER="doMouseLeave" />
<ATTACH EVENT="onmouseup" HANDLER="doMouseUp" />
<ATTACH EVENT="onselectstart" HANDLER="cancelCursorSelect" />
<PUBLIC:METHOD NAME="setText" />
<script language="javascript">
var aButton = new Array();
var strImgSrc, strImgPath, strImgName, strText;
function doInit()
{
strImgSrc = (imgSrc != null) ? imgSrc : "../../NHL/images/button/controller_config_nml.gif";
strImgName = strImgSrc.split('/');
strImgName.reverse();
strImgName = strImgName[0];
strImgPath = strImgSrc.substr(0, strImgSrc.length - strImgName.length);
strText = (text !=null) ? text : "";
createImg( "normal" , strImgName );
createImg( "hover" , strImgName.replace(/nml/ , "hov" ));
createImg( "down" , strImgName.replace(/nml/ , "dwn"));
setDefaults();
createButton();
// defaults.viewLink = document;
}
function setDefaults()
{
NormalDefault("fontFamily", "Times New Roman", "Arial");
NormalDefault("fontSize", "12pt", "10pt");
NormalDefault("fontStyle", "normal", "italic");
NormalDefault("fontWeight", "400", "800");
NormalDefault("color", "black", "black");
NormalDefault("cursor", "auto", "hand");
NormalDefault("left", "0px", "0px");
NormalDefault("top", "0px", "0px");
CustomDefault('nml-text-color', 'nmlTextColor', 'black');
CustomDefault('dwn-text-color', 'dwnTextColor', 'white');
CustomDefault('hov-text-color', 'hovTextColor', 'white');
}
function NormalDefault(sCSSName, sIEDefault, sDefault)
{
if (currentStyle[sCSSName] == sIEDefault
&& (style[sCSSName] == "" || style[sCSSName] == null))
{
style[sCSSName] = sDefault;
}
else style[sCSSName] = currentStyle[sCSSName];
}
function CustomDefault(sCSSName, sScriptName, sDefault)
{
if (currentStyle[sCSSName] == null)
{
style[sCSSName] = sDefault;
}
else style[sCSSName] = currentStyle[sCSSName];
style[sScriptName] = style[sCSSName];
}
function createImg( sId , sImgName )
{
var oImg = new Image();
oImg.src = strImgPath + sImgName;
aButton[ sId ] = oImg;
}
function createButton()
{
var oImg = element.document.createElement("IMG");
oImg.id = element.id + "_img";
oImg.src = strImgPath + strImgName;
with(oImg.style)
{
position = 'absolute';
top = currentStyle.top;
left = currentStyle.left;
}
element.appendChild(oImg);
var oSpan = element.document.createElement("SPAN");
oSpan.id = element.id + "_text";
oSpan.innerText = strText;
with(oSpan.style)
{
position = 'absolute';
fontFamily = currentStyle.fontFamily;
color = currentStyle.color;
fontSize = currentStyle.fontSize;
fontStyle = currentStyle.fontStyle;
fontWeight = currentStyle.fontWeight;
height = String(oImg.clientHeight) + 'px';
width = String(oImg.clientWidth) + 'px';
overflowY = "hidden";
overflowX = "hidden";
top = currentStyle.top;
left = currentStyle.left;
textAlign = 'center';
paddingTop = String(oImg.clientHeight/ 5) + "px";
}
element.appendChild(oSpan);
}
function doMouseEnter()
{
doColorChange( 'hov' );
}
function doMouseLeave()
{
doColorChange( 'nml' );
}
function doMouseDown()
{
oAudioInterface.PlaySpinnerSFX();
doColorChange( 'dwn' );
}
function doMouseUp()
{
doColorChange('hov');
}
function setText( strText )
{
btnText = element.document.all[ srcEl.id + "_text" ];
btnText.innerText = strText;
}
function doColorChange( sState )
{
srcEl = event.srcElement;
if(srcEl.id.match(/_/)) srcEl = srcEl.parentElement;
btnText = element.document.all[ srcEl.id + "_text" ];
btnImg = element.document.all[ srcEl.id + "_img" ];
if(btnImg != null)
{
if(sState.match(/nml/))btnImg.src = aButton[ "normal" ].src;
if(sState.match(/hov/))btnImg.src = aButton[ "hover" ].src;
if(sState.match(/dwn/))btnImg.src = aButton[ "down" ].src;
}
switch( sState )
{
case "dwn":
if(btnText != null)
btnText.style.color = element.currentStyle.dwnTextColor;
break;
case "nml":
if(btnText != null)
btnText.style.color = element.currentStyle.nmlTextColor;
break;
case "hov":
if(btnText != null)
btnText.style.color = element.currentStyle.hovTextColor;
break;
}
}
function cancelCursorSelect()
{
event.cancelBubble = true;
event.returnValue = false;
}
</script>
</PUBLIC:COMPONENT>