home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Joystick Magazine 2003 November
/
CD1_JOY_153.iso
/
demos
/
NHL2004Demo.exe
/
fe
/
COMMON
/
js
/
TopMenuBar.js
< prev
next >
Wrap
Text File
|
2003-08-20
|
17KB
|
422 lines
var TopMenuBar = function()
{
//function localizeMenus()
//{
var sFolder = "";
switch (window.external.GameInterface.ActiveLanguage)
{
case 1: sFolder = "local_SWED"; break;
case 2: sFolder = "local_GER"; break;
case 3: sFolder = "local_FINN"; break;
case 4: sFolder = "local_FR"; break;
}
//top.document.all.menu_1_toggler_img.src = "../../nhl/images2/common/" + sFolder + "/top_menu_gamemodes00.gif";
//top.document.all.menu_2_toggler_img.src = "../../nhl/images2/common/" + sFolder + "/top_menu_gamemodes00.gif";
//top.document.all.menu_3_toggler_img.src = "../../nhl/images2/common/" + sFolder + "/top_menu_gamemodes00.gif";
//}
var protect = this.createProtection(JAX_Object);
protect.imageCache = {};
protect.imageCache["tab_nml"] = new Image();
protect.imageCache["tab_nml"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_mynhl00.gif";
protect.imageCache["tab_hov"] = new Image();
protect.imageCache["tab_hov"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_mynhl01.gif";
protect.imageCache["tab_dwn"] = new Image();
protect.imageCache["tab_dwn"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_mynhl01.gif";
protect.imageCache["tab_arw_nml"] = new Image();
protect.imageCache["tab_arw_nml"].src = System.getInstallFolder(true) + "fe/nhl/images/background/transparent.gif";
protect.imageCache["tab_arw_hov"] = new Image();
protect.imageCache["tab_arw_hov"].src = System.getInstallFolder(true) + "fe/nhl/images/background/transparent.gif";
protect.imageCache["tab_arw_dwn"] = new Image();
protect.imageCache["tab_arw_dwn"].src = System.getInstallFolder(true) + "fe/nhl/images/background/transparent.gif";
protect.imageCache["menu_item_nml"] = new Image();
protect.imageCache["menu_item_nml"].src = System.getInstallFolder(true) + "fe/common/images/framework/menu_blank.gif";
protect.imageCache["menu_item_dwn"] = new Image();
protect.imageCache["menu_item_dwn"].src = System.getInstallFolder(true) + "fe/common/images/framework/menu_blank.gif";
protect.imageCache["menu_item_hov"] = new Image();
protect.imageCache["menu_item_hov"].src = System.getInstallFolder(true) + "fe/common/images/framework/menu_blank.gif";
protect.imageCache["tab_nml_easo"] = new Image();
protect.imageCache["tab_nml_easo"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_options00.gif";
protect.imageCache["tab_hov_easo"] = new Image();
protect.imageCache["tab_hov_easo"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_options01.gif";
protect.imageCache["tab_dwn_easo"] = new Image();
protect.imageCache["tab_dwn_easo"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_options01.gif";
protect.imageCache["tab_nml_nhl"] = new Image();
protect.imageCache["tab_nml_nhl"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_gamemodes00.gif";
protect.imageCache["tab_hov_nhl"] = new Image();
protect.imageCache["tab_hov_nhl"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_gamemodes01.gif";
protect.imageCache["tab_dwn_nhl"] = new Image();
protect.imageCache["tab_dwn_nhl"].src = System.getInstallFolder(true) + "fe/nhl/images2/common/" + sFolder + "/top_menu_gamemodes01.gif";
protect.instance = this;
protect.all = top.document.all;
protect.menuNamesOn = {};
protect.menusLoaded = "";
protect.menuOn = false;
protect.itemPressed = false;
protect.itemOver = false;
};
TopMenuBar.prototype = new JAX_Object;
TopMenuBar.prototype.loadMenu = function(menuObj, menuArrayName, toggleBtnName)
{
var protect = this.getProtection(TopMenuBar);
if (protect.all[menuArrayName]) {
protect.all[menuArrayName].tabIndex = -1;
protect.all[menuArrayName].hideFocus = true;
protect.all[menuArrayName].onblur = function()
{
if (System.GUI.isInCreatePlayer)
top.document.frames["Editorial_Frame"].oHWNDCtrl.style.left = "352px";
if (!protect.itemOver) {
this.releaseCapture();
protect.instance.hideMenu(this.id);
window.external.PumpMessages();
};
};
protect.menusLoaded += menuArrayName + "|" ;
var theID, expStr, exp, menu_name_match, overToggler;
function DoMenuDown()
{
if (System.GUI.isInCreatePlayer)
top.document.frames["Editorial_Frame"].oHWNDCtrl.style.left = "1341px";
if (System.GUI.isNavigating()) { return; };
if (event.srcElement.id) {
theID = event.srcElement.id;
expStr = protect.menusLoaded.substr(0, protect.menusLoaded.length -1);
exp = new RegExp("\(" + expStr + "\)", "gi");
if (theID.match(exp)) {
menu_name_match = theID.match(exp);
menu_name_match = menu_name_match.toString();
if (!protect.menuNamesOn[menu_name_match]) {
protect.instance.hideMenus();
protect.all[menu_name_match + "_toggler"].onmousedown();
window.external.PumpMessages();
} else {
if (!protect.itemOver) {
protect.instance.hideMenus();
protect.all[menu_name_match + "_toggler"].onmouseenter(true);
};
};
} else {
if (!protect.itemPressed) {
protect.instance.hideMenus();
window.external.PumpMessages();
protect.all[menu_name_match + "_toggler"].onmouseleave(true);
};
};
};
};
var bFired = false;
function DoMenuMove()
{
if (System.GUI.isNavigating()) { return; };
if (event.srcElement.id) {
theID = event.srcElement.id;
expStr = protect.menusLoaded.substr(0, protect.menusLoaded.length -1);
exp = new RegExp("\(" + expStr + "\)", "gi");
if (theID.match(exp)) {
menu_name_match = theID.match(exp);
menu_name_match = menu_name_match.toString();
if (!bFired) {
if (!protect.menuNamesOn[menu_name_match]) {
if ((overToggler) && (overToggler.id != (this.id + "_toggler"))) {
overToggler.onmouseleave(true);
overToggler = null;
};
if (!overToggler) {
overToggler = protect.all[menu_name_match + "_toggler"];
overToggler.onmouseenter(true);
bFired = true;
};
};
};
} else {
if ( (overToggler) && ((this.id + "_toggler") != overToggler.id) ) {
overToggler.onmouseleave(true);
overToggler = null;
bFired = false;
};
};
};
};
protect.all[menuArrayName].onmousedown = DoMenuDown;
protect.all[menuArrayName].onmousemove = DoMenuMove;
var selectedNavID;
function DoMenuItemEnter()
{
this.childNodes[0].src = protect.imageCache["menu_item_hov"].src;
this.childNodes[2].style.color = "#FFCB00";
this._isOver = true;
protect.itemOver = true;
};
function DoMenuItemLeave()
{
this.childNodes[0].src = protect.imageCache["menu_item_dwn"].src;
this.childNodes[2].style.color = "white";
this._isOver = false;
var ti = this;
setTimeout(function() { if (!ti._isOver) { ti.childNodes[0].src = protect.imageCache["menu_item_nml"].src; };ti = null; }, 400);
protect.itemOver = false;
};
function DoMenuItemDown()
{
if (System.GUI.isInCreatePlayer)
top.document.frames["Editorial_Frame"].oHWNDCtrl.style.left = "1341px";
this.childNodes[2].style.color = "gold";
protect.itemPressed = true;
selectedNavID = this.navID;
this.setCapture(false);
};
function DoMenuItemUp()
{
this.releaseCapture();
if (!protect.itemOver) { return; };
var ti = this;
function doIt()
{
protect.instance.hideMenus();
protect.itemPressed=false;
protect.itemOver=false;
protect.instance.onselect(selectedNavID);
ti.childNodes[2].style.color = "white";
ti.childNodes[2].style.fontWeight = "bold";
ti.childNodes[0].src = protect.imageCache["menu_item_nml"].src;
ti = null;
};
setTimeout(function() { doIt(); } , 200);
};
for (var idx = 0; idx < menuObj[menuArrayName].length; idx++)
{
var item_id = menuArrayName + "_btn_" + (idx + 1);
if (protect.all[item_id]) {
if (menuObj[menuArrayName][idx].text != "") {
protect.all[item_id].navID = menuObj[menuArrayName][idx].navID;
protect.all[item_id].onmouseenter = DoMenuItemEnter;
protect.all[item_id].onmouseleave = DoMenuItemLeave;
protect.all[item_id].onmousedown = DoMenuItemDown;
protect.all[item_id].onmouseup = DoMenuItemUp;
protect.all[item_id + "_txt"].style.pixelWidth = protect.all[menuArrayName].offsetWidth - (parseInt(protect.all[menuArrayName].style.borderWidth) * 2);
protect.all[item_id + "_txt"].innerText = menuObj[menuArrayName][idx].text;
} else {
protect.all[item_id].style.display = "none";
};
};
};
protect.all[menuArrayName + "_bg"].style.pixelHeight = protect.all[menuArrayName].offsetHeight-(parseInt(protect.all[menuArrayName].style.borderWidth) * 2);
protect.all[menuArrayName + "_bg"].style.pixelWidth = protect.all[menuArrayName].offsetWidth-(parseInt(protect.all[menuArrayName].style.borderWidth) * 2);
function GetRealLeft(el) {
var xPos = el.offsetLeft;
var tempEl = el.offsetParent;
while(tempEl != null) {
xPos += tempEl.offsetLeft;
if (tempEl.style) {
xPos += (isNaN(parseInt(tempEl.style.borderLeftWidth)) ) ? 0 : parseInt(tempEl.style.borderLeftWidth);
};
tempEl = tempEl.offsetParent;
};
return xPos;
};
function GetRealTop(el) {
var yPos = el.offsetTop;
var tempEl = el.offsetParent;
while (tempEl != null)
{
yPos += tempEl.offsetTop;
if (tempEl.style) {
yPos += (isNaN(parseInt(tempEl.style.borderTopWidth)) ) ? 0 : parseInt(tempEl.style.borderTopWidth);
};
tempEl = tempEl.offsetParent;
};
return yPos;
};
function DoMenuBtnEnter(bforce)
{
if (!bforce && System.GUI.isNavigating()) { return; };
if (bforce) {
this.childNodes[0].src =(this.isEASO) ? protect.imageCache["tab_hov_easo"].src : (this.isNHL) ? protect.imageCache["tab_hov_nhl"].src : protect.imageCache["tab_hov"].src;
if (this.isMyNHL) {
this.childNodes[4].src = protect.imageCache["tab_arw_hov"].src;
} else {
this.childNodes[3].src = protect.imageCache["tab_arw_hov"].src;
};
} else {
if (!protect.menuOn) {
this.childNodes[0].src =(this.isEASO) ? protect.imageCache["tab_hov_easo"].src : (this.isNHL) ? protect.imageCache["tab_hov_nhl"].src : protect.imageCache["tab_hov"].src;
if (this.isMyNHL) {
this.childNodes[4].src = protect.imageCache["tab_arw_hov"].src;
} else {
this.childNodes[3].src = protect.imageCache["tab_arw_hov"].src;
};
};
};
};
function DoMenuBtnLeave(bforce)
{
if (!bforce && System.GUI.isNavigating()) { return; };
if (bforce) {
this.childNodes[0].src = (this.isEASO) ? protect.imageCache["tab_nml_easo"].src : (this.isNHL) ? protect.imageCache["tab_nml_nhl"].src : protect.imageCache["tab_nml"].src;
if (this.isMyNHL) {
this.childNodes[4].src = protect.imageCache["tab_arw_nml"].src;
} else {
this.childNodes[3].src = protect.imageCache["tab_arw_nml"].src;
};
} else {
if (!protect.menuOn) {
this.childNodes[0].src = (this.isEASO) ? protect.imageCache["tab_nml_easo"].src : (this.isNHL) ? protect.imageCache["tab_nml_nhl"].src : protect.imageCache["tab_nml"].src;
if (this.isMyNHL) {
this.childNodes[4].src = protect.imageCache["tab_arw_nml"].src;
} else {
this.childNodes[3].src = protect.imageCache["tab_arw_nml"].src;
};
};
};
};
function DoMenuBtnDown()
{
if (System.GUI.isInCreatePlayer)
top.document.frames["Editorial_Frame"].oHWNDCtrl.style.left = "1341px";
if (System.GUI.isNavigating()) { return; };
if (!protect.menuOn) {
this.childNodes[0].src = (this.isEASO) ? protect.imageCache["tab_dwn_easo"].src : (this.isNHL) ? protect.imageCache["tab_dwn_nhl"].src : protect.imageCache["tab_dwn"].src;
if (this.isMyNHL) {
this.childNodes[4].src = protect.imageCache["tab_arw_dwn"].src;
} else {
this.childNodes[3].src = protect.imageCache["tab_arw_dwn"].src;
};
protect.instance.showMenu(menuArrayName, GetRealLeft(this), GetRealTop(this) + (this.offsetHeight - Math.floor(parseInt(protect.all[menuArrayName].style.borderWidth) )) );
window.external.PumpMessages();
};
};
if (protect.all[toggleBtnName]) {
protect.all[toggleBtnName].onmouseenter = DoMenuBtnEnter;
protect.all[toggleBtnName].onmouseleave = DoMenuBtnLeave;
protect.all[toggleBtnName].onmousedown = DoMenuBtnDown;
protect.all[toggleBtnName].style.pixelWidth = protect.all[toggleBtnName].childNodes[0].width;
protect.all[toggleBtnName].style.pixelHeight = protect.all[toggleBtnName].childNodes[0].height;
};
};
};
TopMenuBar.prototype.showMenu = function(menuName, nX, nY)
{
var protect = this.getProtection(TopMenuBar);
this.hideMenus();
if (nX) {
protect.all[menuName].style.pixelLeft = nX;
};
if (nY) {
protect.all[menuName].style.pixelTop = nY;
};
protect.all[menuName].setCapture(false);
protect.menuOn = true;
protect.all[menuName].style.visibility = "visible";
protect.all[menuName].focus();
protect.menuNamesOn[menuName] = menuName;
oAudioInterface.PlaySFX(1095);
};
TopMenuBar.prototype.hideMenu = function(menuName)
{
var protect = this.getProtection(TopMenuBar);
protect.all[menuName].style.visibility = "hidden";
protect.all[menuName].releaseCapture(false);
protect.menuOn = false;
protect.all[menuName + "_toggler"].onmouseleave();
delete protect.menuNamesOn[menuName];
oAudioInterface.PlaySFX(1096);
};
TopMenuBar.prototype.hideMenus = function()
{
var protect = this.getProtection(TopMenuBar);
protect.itemPressed = false;
for (var menu in protect.menuNamesOn)
{
this.hideMenu(menu);
};
oAudioInterface.PlaySFX(1096);
};
TopMenuBar.prototype.onselect = function(selectedItemID)
{
oAudioInterface.PlaySFX(1064);
if (System.GUI.isNavigating()) { return; };
//EASO CHECK
if (oGameFace.LeagueServerInterface.LeagueType!=2 || selectedItemID==1124 ||
selectedItemID==1123 || selectedItemID==1122 || selectedItemID==1121 || selectedItemID==1102)
{
//reset ticker if game modes or my nhl & dynasty skin
if (selectedItemID==100 || selectedItemID==101 || selectedItemID==891 || selectedItemID==108 ||
selectedItemID==102 || selectedItemID==104 || selectedItemID==111 || selectedItemID==886)
{
resetTicker();
//set back to skin...
oBrowserSkinObject = new BrowserSkinObject();
oGameFace.LoadBrowserSkin(oBrowserSkinObject);
System.GUI.setTeamSkin(oBrowserSkinObject.TeamID, false);
}
System.GUI.navigate(selectedItemID);
}
else
{
oAudioInterface.PlayWarningSFX();
System.GUI.dialog.innerHTML = nhlMsg("EASO_EXIT_CONFIRMATION");
System.GUI.dialog.setSize( 500, 200 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton( "okay_button" , nhlMsg("OKAY", true), function(){ exitEASO(selectedItemID); } );
System.GUI.dialog.addButton( "cancel_button" , nhlMsg("CANCEL", true), function(){ return false; } );
System.GUI.dialog.show( true );
}
function exitEASO( selectedItemID )
{
oGameFace.CommInterface.ReportNoStart();
oGameFace.CommInterface.PurgeGameReporter();
System.GUI.navigate(selectedItemID);
}
};
function TopNavMenuItem(navID, sText)
{
this.navID = navID;
this.text = sText;
};
function resetTicker()
{
var sTxt = nhlMsg("TICKER1") + "XXXXXXX" +
nhlMsg("TICKER2") + "XXXXXXX" +
nhlMsg("TICKER3") + "XXXXXXX" +
nhlMsg("TICKER4") + "XXXXXXX" +
nhlMsg("TICKER5") + "XXXXXXX" +
nhlMsg("TICKER6") + "XXXXXXX" +
nhlMsg("TICKER7");
var str = '<div id="tickercontainer">\n'+
'<div id="tickerTest">\n'+
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER1") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER2") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER3") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER4") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER5") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER6") + '</A>       ' +
'<A HREF="" onclick="return false;">' + nhlMsg("TICKER7") + '</A>       ' +
'</div>\n'+
'</div>';
top.document.all.tickerHTMLContainer.innerHTML = str;
top.document.all.tickerHTMLContainer.nEnd = sTxt.length;
}
function BrowserSkinObject()
{
this.TeamID = "-1";
}