// Controller baseline established 10/9/2007
//
// The Nav interface still has a lot of ActionScript on the fla that we should try to purge
// in favor of handling evrything dynamically from .as files.
//
// NavInterfaceBase is a base class. Currently the only subclass in NavInterfaceObj which
// over-rides very little of the logic here. The Controller only instantiates NavInterfaceObj
// so that is a particular course whats to customize the nav interface functionality it can rewrite
// NavInterfaceObj, leaving the Controller and NavInterfaceBase as is for other courses.
//
function NavInterfaceBase() {
this.navBarCntrls = new Object();
this.lvlRef = null;
this.suspendedLbl = "suspended";
this.normalLbl = "normal";
this.pausedLbl = "paused";
this.hiddenLbl = "intro";
this.transitionLbl = "transition";
this.toggleRMAOn = true;
this.pageLocation = undefined;
this.nextBtn = undefined;
this.prevBtn = undefined;
}
NavInterfaceBase.prototype.createNavButtons = function(navBtnsNode) {
var idx = NAV_INTERFACE_BASE_TAB_IDX;
for (var i = 0; i < navBtnsNode.childNodes.length; i++) {
var childNode = navBtnsNode.childNodes[i];
if (childNode.nodeType == 1) {
if (childNode.nodeName == "NavBtn") {
var navBtn = new NavBarControl(childNode, idx++);
this.navBarCntrls[navBtn.name] = navBtn;
if (navBtn.isNextBtn) {
this.nextBtn = navBtn;
}
if (navBtn.isPrevBtn) {
this.prevBtn = navBtn;
}
}
}
}
}
NavInterfaceBase.prototype.initialize = function() {
this.lvlRef = eval("_level" + NAV_LVL);
if ((this.lvlRef == null) || (this.lvlRef == undefined)) {
debugLog("WARNING: Unable to get a reference to the nav interface movie.");
}
for (var navBtnName in this.navBarCntrls) {
this.navBarCntrls[navBtnName].initialize();
}
var toggleNavBarCntrl = this.navBarCntrls["toggleNavRMABtn"];
toggleNavBarCntrl.objRef._alpha = 0;
this.setInterfaceToNormal();
this.PageChanged(pageIdx);
this.setTitleGraphic();
}
NavInterfaceBase.prototype.PageChanged = function(pageIdx) {
if (this.lvlRef == null) {
this.lvlRef = eval("_level" + NAV_LVL);
}
if (this.pageLocation == undefined) {
this.pageLocation = eval("_level" + NAV_LVL + ".pageLocation");
this.pageLocation._accProps = new Object();
this.pageLocation._accProps.silent = false;
this.pageLocation._accProps.forceSimple = true;
this.pageLocation._accProps.name = "";
this.pageLocation.tabIndex = PAGE_LOC_TAB_IDX;
this.pageLocation._width = 0;
}
var pgNbr = getCurrentPageNbr();
var pgCount = currentModule.getPageCount();
if (currentModule.pageCountType == "ByTopic") {
var currentTopic = currentModule.getTopic(topicIdx);
pgCount = currentTopic.getPageCount();
}
this.lvlRef.pageNbr.text = pgNbr;
this.lvlRef.pageCount.text = pgCount;
this.pageLocation.text = "Page " + pgNbr + " of " + pgCount;
this.setTopicTitle();
this.setModuleTitle();
}
NavInterfaceBase.prototype.hideInterface = function() {
for (var navBtnName in this.navBarCntrls) {
var navBarCntrl = this.navBarCntrls[navBtnName];
navBarCntrl.setVisible(false);
navBarCntrl.makeRMASilent(true, this.toggleRMAOn);
}
this.lvlRef.gotoAndStop(this.hiddenLbl);
Accessibility.updateProperties();
}
NavInterfaceBase.prototype.suspendInterface = function() {
debugLog("suspendInterface");
for (var navBtnName in this.navBarCntrls) {
var navBarCntrl = this.navBarCntrls[navBtnName];
if (navBtnName == "resumeBtn") {
navBarCntrl.setVisible(false);
navBarCntrl.setEnabled(false);
}
else {
navBarCntrl.setVisible(true);
navBarCntrl.setEnabled(false);
// navBarCntrl.makeRMASilent(true, this.toggleRMAOn);
}
}
this.lvlRef.gotoAndStop(this.suspendedLbl);
Accessibility.updateProperties();
}
NavInterfaceBase.prototype.setInterfaceToNormal = function() {
debugLog("setInterfaceToNormal");
for (var navBtnName in this.navBarCntrls) {
var navBarCntrl = this.navBarCntrls[navBtnName];
if (navBtnName == "resumeBtn") {
navBarCntrl.setVisible(false);
navBarCntrl.setEnabled(false);
navBarCntrl.makeRMASilent(true, this.toggleRMAOn);
}
else {
navBarCntrl.setVisible(true);
navBarCntrl.setEnabled(true);
navBarCntrl.makeRMASilent(false, this.toggleRMAOn);
}
}
this.lvlRef.gotoAndStop(this.normalLbl);
Accessibility.updateProperties();
}
NavInterfaceBase.prototype.setInterfaceToPaused = function() {
debugLog("setInterfaceToPaused");
for (var navBtnName in this.navBarCntrls) {
var navBarCntrl = this.navBarCntrls[navBtnName];
if (navBtnName == "pauseBtn") {
navBarCntrl.setVisible(false);
navBarCntrl.setEnabled(false);
}
else if (navBtnName == "resumeBtn") {
navBarCntrl.setVisible(true);
navBarCntrl.setEnabled(true);
navBarCntrl.makeRMASilent(false, this.toggleRMAOn);
}
else {
navBarCntrl.setEnabled(false);
navBarCntrl.makeRMASilent(true, this.toggleRMAOn);
}
}
this.lvlRef.gotoAndStop(this.pausedLbl);
Accessibility.updateProperties();
}
NavInterfaceBase.prototype.transitionInterface = function () {
this.lvlRef.gotoAndPlay(ths.transitionLbl);
}
//
// This function is provided to make it easy to enable/disable and change the
// appearance of the "Next" and "Prev" navigation buttons.
// For example see ControllerBehvavior.xml calls such as:
//
NavInterfaceBase.prototype.setButton = function(btnName, btnEnabled, btnState) {
var navBarCntrl = undefined;
//
// Sample lines from controllerbehavior.xml:
//
//
//
//
var obj = new Object();
if (btnName == "Next") {
navBarCntrl = this.nextBtn;
}
else if (btnName == "Previous") {
navBarCntrl = this.prevBtn;
}
else {
navBarCntrl = this.navBarCntrls[btnName];
}
if (navBarCntrl == undefined) {
return;
}
var rmaSilent = (!btnEnabled || !navBarCntrl.visible);
navBarCntrl.makeRMASilent(rmaSilent, this.toggleRMAOn);
navBarCntrl.setEnabled(btnEnabled);
navBarCntrl.setVisualState(btnState);
}
NavInterfaceBase.prototype.setButton_COMPONENT_VERSION = function(btnName, btnEnabled, btnState) {
var navBarCntrl = undefined;
//
// Sample lines from controllerbehavior.xml:
//
//
//
//
var obj = new Object();
if (btnName == "Next") {
navBarCntrl = this.nextBtn;
if (btnState == "blink") {
obj.falseUpSkin = "NextBlinkingActiveSkin";
obj.falseDownSkin = "NextDownSkin";
obj.falseOverSkin = "NextRollSkin";
obj.falseDisabledSkin = "NextDownSkin";
navBarCntrl.setSkin(obj);
}
else {
obj.falseUpSkin = "NextActiveSkin";
obj.falseDownSkin = "NextDownSkin";
obj.falseOverSkin = "NextRollSkin";
obj.falseDisabledSkin = "NextDownSkin";
navBarCntrl.setSkin(obj);
}
}
else if (btnName == "Previous") {
navBarCntrl = this.prevBtn;
}
else {
navBarCntrl = this.navBarCntrls[btnName];
}
if (navBarCntrl == undefined) {
return;
}
//navBarCntrl.setVisible(true);
navBarCntrl.setEnabled(btnEnabled);
//navBarCntrl.makeRMASilent(false, this.toggleRMAOn);
}
////////////////////////////////
//REVISIT: SPECIFY THESE PARAMETERS IN THE DATA.XML
NavInterfaceBase.prototype.setTopicTitle = function() {
if (this.lvlRef == null) {
this.lvlRef = eval("_level" + NAV_LVL);
}
//// this.lvlRef.topicTitle._x = 950;
// this.lvlRef.topicTitle._x = 732;
// this.lvlRef.topicTitle._width = 0;
// this.lvlRef.topicTitle.autoSize = "right";
//debugLog("SETTING TOPIC TITLE: (" + topicIdx + ") " + topic[topicIdx].title);
this.lvlRef.topicTitle.text = topic[topicIdx].title;
}
NavInterfaceBase.prototype.setModuleTitle = function() {
if (this.lvlRef == null) {
this.lvlRef = eval("_level" + NAV_LVL);
}
// this.lvlRef.moduleTitle._x = 950;
// this.lvlRef.moduleTitle._width = 0;
// this.lvlRef.moduleTitle.autoSize = "right";
this.lvlRef.moduleTitle.text = currentModule.moduleTitle;
}
NavInterfaceBase.prototype.toggleRMA = function() {
this.toggleRMAOn = !this.toggleRMAOn;
for (var navBtnName in this.navBarCntrls) {
var navBarCntrl = this.navBarCntrls[navBtnName];
// REVISIT. NOT SURE THIS IS STRICTLY CORRECT.
// INSTEAD OF FALSE, WE SHOULD BE USING THE CURRENT STATE
navBarCntrl.makeRMASilent(false, this.toggleRMAOn);
}
}
NavInterfaceBase.prototype.resetFocus = function() {
this.lvlRef.focusManager.setFocus(this.pageLocation);
//Selection.setFocus("_level" + this.parent.openOnLevel + ".fbBox.fbText");
}
//REVISIT: MOVE TO XMLActions.as
var ToggleNavBtnsRMA = function() {
navInterface.toggleRMA();
}
//REVISIT: NOT CURRENTLY USED
//NavInterfaceBase.prototype.restoreAllButtons = function() {
// //REVISIT. NOT SURE WHEN/WHY THIS METHOD IS CALLED.
//// this.lvlRef.restoreAllButtons();
//
// var nextBtn = this.navBarCntrls["Next"];
// this.setButton("Next", nextBtn.btnEnabled, nextBtn.state);
// var prevBtn = this.navBarCntrls["Previous"];
// this.setButton("Previous", prevBtn.btnEnabled, prevBtn.state);
//}
//REVISIT: NOT CURRENTLY USED
//NavInterfaceBase.prototype.synchAccessibility = function() {
// debugLog("NavInterfaceBase: nav synchAccessibility");
// this.makeNotSilent();
//
//// for (var navBtnName in this.navBarCntrls) {
//// this.navBarCntrls[navBtnName].synchAccessibilityObj();
//// }
//// this.lvlRef.gotoAndPlay(this.normalLbl);
//debugLog("NavInterfaceBase: Acc.updateProperties()");
// Accessibility.updateProperties();
//}
//REVISIT: NOT CURRENTLY USED
//NavInterfaceBase.prototype.makeSilent = function() {
//debugLog("NavInterfaceBase: in makeSilent");
// _level21._accProps = new Object();
// _level21._accProps.silent = true;
// _level21._accProps.forceSimple = true;
// Accessibility.updateProperties();
//}
//REVISIT: NOT CURRENTLY USED
//NavInterfaceBase.prototype.makeNotSilent = function() {
//debugLog("NavInterfaceBase: in makeNotSilent");
// _level21._accProps = new Object();
// _level21._accProps.silent = false;
// _level21._accProps.forceSimple = false;
// Accessibility.updateProperties();
//}
//REVISIT: NOT CURRENTLY USED
//NavInterfaceBase.prototype.setRMA = function(silent) {
//debugLog("NavInterfaceBase: navInterface setRMA, silnet = " + silent);
////return;
//
// if (silent) {
// this.hideNavButtons();
// }
// else {
// this.synchAccessibility();
// }
//}