/* @todo The NOF_NS init needs to be moved out to a shared JS that gets loaded prior to all its clients using it. Right now is just Flash but will likely add more in the future. For instances DB could inject in the same name space. It simply uses now NOF_xxxx @todo: refine it further by moving the navbar specifics to a subclass @see http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701 for OBJECT/EMBED attributes */ if(typeof NOF == "undefined") { function NOF_NS() { this.__proto__ = NOF_NS.prototype; } } var NOF = new NOF_NS(); if(typeof NOF.ProgramVersion == "undefined") { function NOF_ProgramVersion (majorNumber, minorNumber, revisionNumber) { this.__proto__ = NOF_ProgramVersion.prototype; if (arguments.length != 3) throw "Illegal arguments exception"; this.majorNumber = majorNumber; this.minorNumber = minorNumber; this.revisionNumber = revisionNumber; } { var method = NOF_ProgramVersion.prototype; method.getMajorNumber = function () { return this.majorNumber; } method.getMinorNumber = function () { return this.minorNumber; } method.getRevisionNumber = function () { return this.revisionNumber; } method.eq = function (programVersion) { return this.majorNumber == programVersion.getMajorNumber() && this.minorNumber == programVersion.getMinorNumber() && this.revisionNumber == programVersion.getRevisionNumber(); } method.lt = function (programVersion) { var retValue = false; if (this.majorNumber < programVersion.getMajorNumber() ) { retValue = true; } else if (this.majorNumber == programVersion.getMajorNumber()) { if (this.minorNumber < programVersion.getMinorNumber()) { retValue = true; } else if (this.minorNumber == programVersion.getMinorNumber()) { if (this.revisionNumber < programVersion.getRevisionNumber()) { retValue = true; } } } return retValue; } method.lte = function (programVersion) { return this.lt(programVersion) && this.eq(programVersion); } method.gt = function (programVersion) { return !this.lte(programVersion); } method.gte = function (programVersion) { return !this.lt(programVersion); } method.toString = function () { return this.majorNumber + "." + this.minorNumber + "." + this.revisionNumber; } } NOF.__proto__.ProgramVersion = NOF_ProgramVersion; } if (typeof NOF.Util == "undefined") { function NOF_Util() { this.__proto__ = NOF_Util.prototype; } NOF.Util = new NOF_Util(); function NOF_Util_FramesIterator (wnd) { this.__proto__ = NOF_Util_FramesIterator.prototype; this.currentIndex = 0; this.array = wnd.frames; NOF_Util_FramesIterator.prototype.next = function () { return (this.currentIndex < this.array.length ) ? this.array[this.currentIndex++] : null; } } NOF.Util.__proto__.FramesIterator = NOF_Util_FramesIterator; NOF.Util.GetFrameWndByName = function GetFrameWndByName(name) { var stack = new Array(); stack[0] = new NOF.Util.FramesIterator(window); var wnd = null; var found = false; while (stack.length > 0 && !found) { if ((wnd = stack[stack.length -1].next()) != null) { if (wnd.name == name) { found = true; break; } else if (wnd.frames.length > 0) { stack[stack.length] = new NOF.Util.FramesIterator(wnd); } } else { stack[stack.length-1] = null; stack.length--; } } return wnd; } } if(typeof NOF.Event == "undefined") { function NOF_Event(source, type, state) { this.__proto__ = NOF_Event.prototype; this.source = source; this.type = type; this.state = state; } var member = NOF_Event.prototype; member.MOUSEDOWN_EVENT = 0x001; member.MOUSEUP_EVENT = 0x002; member.MOUSEMOVE_EVENT = 0x004; member.MOVIE_INITIALIZED_EVENT = 0x008; var method = NOF_Event.prototype; method.getSource = function() { return this.source; }; method.getType = function() { return this.type; }; method.getState = function() { return this.state; }; NOF.Event = new NOF_Event(); NOF.EventObject = NOF_Event; } if(typeof NOF.Flash == "undefined") { function NOF_Flash() { this.__proto__ = NOF_Flash.prototype; } NOF.Flash = new NOF_Flash(); } if(typeof NOF.Flash.HtmlCtrl == "undefined") { function NOF_Flash_HtmlCtrl_Base() { this.__proto__ = NOF_Flash_HtmlCtrl_Base.prototype; } { var member = NOF_Flash_HtmlCtrl_Base.prototype; //add static members here member.MOVIE_LISTENER = 0x001; member.MOUSE_LISTENER = 0x002; member.NETSCAPE_PLUGIN_NAME = "Shockwave Flash"; member.IE_PLUGIN_NAME = "ShockwaveFlash.ShockwaveFlash"; member.FOOTPRINT_SUFFIX = "_footprint"; member.CONTAINER_SUFFIX = "_container"; member.LAYER_SUFFIX = "LYR"; member.PARAM_ALLOWSCRIPTACCESS = "allowScriptAccess"; member.PARAM_QUALITY = "quality"; member.PARAM_WMODE = "wmode"; member.DEFAULT_QUALITY_VALUE = "high"; member.DEFAULT_WMODE_VALUE = "transparent"; member.cDELTA = 5; //compensantion delta for dimensions variations member.DEFAULT_HIGHEST_ZINDEX = 2000; var method = NOF_Flash_HtmlCtrl_Base.prototype; method.ctr = function ( id, movieSrc, width, height, align, htmlDocument) { //verify preconditions in case this is not the default constructor call if (arguments.length > 0) { if (id == undefined || id.length <=0 ) { throw "IllegalArgumentException: id cannot be empty"; } if (movieSrc == undefined || movieSrc.length <=0 ) { throw "IllegalArgumentException: movieSrc cannot be null"; } } this.movieListeners= new Array(); this.mouseListeners= new Array(); this.params = new Array(); this.variables = new Array(); this.id = id; this.movieSrc = movieSrc; this.width = (width != null) ? width : null; this.height = (height != null) ? height : null; this.align = (align != null) ? align : null; this.htmlDocument = (htmlDocument != undefined) ? htmlDocument : document; this.position = {left : -1, top: -1}; this.isFSCEventsSupportEnabled = true; this.areFSCEventsEnabled = true; //enable scripts access within the same domain by default so getURL and fsCommands succeed this.setParam(this.PARAM_ALLOWSCRIPTACCESS, "sameDomain"); //set default params value this.setParam(this.PARAM_QUALITY, this.DEFAULT_QUALITY_VALUE); this.setParam(this.PARAM_WMODE, this.DEFAULT_WMODE_VALUE); this.requiredPlayerVersion = "7,0,0,0"; this.closedMenuSize = {width : 0, height: 0}; this.foHtmlInstance = null; this.foContainer = null; this.foFootprint = null; this.foParentLYR = null; this.isWritten = false; this.bReady = false; this.capturedEventsMask = 0; this.owner = null; } /* * Gets the readiness state. * * @return true if PostInit event was received and processed succesfully. false otherwise */ method.isReady = function () { return this.bReady;}; /* *Gets/sets the movie owner */ method.getOwner = function () { return this.owner;}; method.setOwner = function (owner) { this.owner = owner;}; /* *Gets/sets the movie width */ method.getWidth = function () { return this.width;}; method.setWidth = function (width) { this.width = width;}; /* * Gets/sets the movie height */ method.getHeight = function () { return this.height;}; method.setHeight = function (height) { this.height = height;}; /* * Gets/sets the movie Position */ method.getPosition = function () { return this.position;}; method.setPosition = function (position) { this.position = position;}; /* * Gets/sets the movie source. URLs are expected */ method.getMovieSrc = function () { return this.movieSrc;}; method.setMovieSrc = function (movieSrc) { this.movieSrc = movieSrc;}; /* * Gets/sets the html element alignment. */ method.getAlign = function () { return this.align;}; method.setAlign = function (align) { this.align = align;}; method.getId = function () {return this.id;}; /* * Player Parameters getter/setter * * @note: the names are case insensitive */ method.getParam = function(name) { return this.params[name.toLowerCase()];}; method.setParam = function(name, value) { this.params[name.toLowerCase()] = value;}; method.getParams = function() { return this.params; }; /* * Variables getter/setter */ method.getVariable = function(name) {return this.variables[name];}; method.setVariable = function(name, value) { this.variables[name] = value;}; method.getVariables = function() { return this.variables;}; /* * Footprint getter */ method.getFootprint = function() { if (!this.foFootprint) { this.foFootprint = this.findObject(this.id + this.FOOTPRINT_SUFFIX); } return this.foFootprint; }; /* * Searches the document's objects collection for a name match. Handles the * particular case for NN4 compat generation mode where a collection of two * is returned instead of the actual object due to duplicate IDs (
args) handler
*
* @param command the event name
* @param args the arguments event state
*/
method.processFSCEvent = function (eventName, args) {
this.log("processFSCEvent -> " + eventName + "[" + args + "]");
var auxStr = "";
for (var i=0; iarg argument
*
* @param methodName
* @param arg
*/
method.callFlashMethod = function (methodName, arg) {
try {
this.getHtmlInstance().SetVariable("hostEventsMonitor", methodName + ":" + arg);
} catch (e) {}
};
/*
* Returns the highest index of all elements on current page + 1
*
* @return highestIndex + 1
*
* @note currently returns a constant high value considered safe to be the highest
*/
method.getNextHighestIndex = function() {
return this.DEFAULT_HIGHEST_ZINDEX;
}
method.adjustZIndexOnSizeChange = function (width, height) {
if (Math.abs(this.closedMenuSize.width - width) > this.cDELTA
|| Math.abs(this.closedMenuSize.height - height) > this.cDELTA)
{
//find parent layer. set the zIndex to something really high
var parentLYR = this.getParentLYR();
if (parentLYR) {
this.log("setting high Z-Index on flyouts");
this.setStyle("zIndex", this.getNextHighestIndex(), parentLYR);
}
}
else
{
//reset the z-index to normal value
if (this.parentZIndex != null) {
var parentLYR = this.getParentLYR();
if (parentLYR) {
this.log("setting Z-Index on original size to " + this.parentZIndex);
this.setStyle("zIndex", this.parentZIndex, parentLYR);
}
}
}
}
}
function NOF_Flash_HtmlCtrl_IE(id, movieSrc, width, height, align, htmlDocument){
this.__proto__ = NOF_Flash_HtmlCtrl_IE.prototype;
this.ctr(id, movieSrc, width, height, align, htmlDocument);
}
NOF_Flash_HtmlCtrl_IE.prototype = new NOF_Flash_HtmlCtrl_Base;
//@todo: define the generators for IE
{
var method = NOF_Flash_HtmlCtrl_IE.prototype;
/*
Returns an HTML string that has the FSCommand scripting hooks
*/
method.getFSCommandHandlerDef = function() {
var str = "";
str += "\n";
}
//@todo: check for the current plugin version and replace w/ an upgrade text message
htmlStr += '';
return htmlStr;
};
}
function isHostNetscapeCompatible() {return navigator.mimeTypes.length ? true : false;};
function isHostActiveXCompatible() { return window.ActiveXObject ? true : false; };
if (isHostActiveXCompatible()) {
NOF.Flash.HtmlCtrl = NOF_Flash_HtmlCtrl_IE;
} else {
NOF.Flash.HtmlCtrl = NOF_Flash_HtmlCtrl_NetscapeGeneric;
}
//Static methods go here
NOF.Flash.HtmlCtrl.PLATFORM_WINDOWS = "Windows";
NOF.Flash.HtmlCtrl.PLATFORM_MAC = "Mac";
NOF.Flash.HtmlCtrl.PLATFORM_UNKNOWN = "Unknown";
/*
* Not entirely reliable. Navigator.platform is not always populated. Need to guess it from appVersion or userAgent
*/
NOF.Flash.HtmlCtrl.getPlatform = function () {
if ((navigator.platform && navigator.platform.substring(0,3) == "Win")
|| navigator.appVersion.indexOf("Windows") != -1 ) {
return NOF.Flash.HtmlCtrl.PLATFORM_WINDOWS;
} else if ((navigator.platform && navigator.platform.substring(0,3) == "Mac")
|| navigator.appVersion.indexOf("Macintosh") != -1 ) {
return NOF.Flash.HtmlCtrl.PLATFORM_MAC;
}
return NOF.Flash.HtmlCtrl.PLATFORM_UNKNOWN;
};
/*
Returns true if browser support Netscape Plugin Architecture
*/
NOF.Flash.HtmlCtrl.isHostNetscapeCompatible = isHostNetscapeCompatible;
/*
Returns true if browser supports ActiveXObject method. Currently IE only
*/
NOF.Flash.HtmlCtrl.isHostActiveXCompatible = isHostActiveXCompatible;
/*
* Queries the host browser for version information (major, minor, revision)
*
* @return a ProgramVersion reference
* @see ProgramVersion
*/
NOF.Flash.HtmlCtrl.getCurrentPlayerVersion = function () {
if (NOF.Flash.HtmlCtrl.playerVersion == null) {
var playerVer = new NOF.ProgramVersion(0,0,0);
if(NOF.Flash.HtmlCtrl.isHostNetscapeCompatible() ) {
var plugin = navigator.plugins[member.NETSCAPE_PLUGIN_NAME];
if (plugin && plugin.description) {
var parts = plugin.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")
playerVer = new NOF.ProgramVersion(parts[0], parts[1], parts[2]);
}
} else if (NOF.Flash.HtmlCtrl.isHostActiveXCompatible()) {
try {
var player = new ActiveXObject(member.IE_PLUGIN_NAME);
var parts = player.GetVariable("$version").split(" ")[1].split(",");
playerVer = new NOF_ProgramVersion(parts[0], parts[1], parts[2]);
} catch (e) {}
}
NOF.Flash.HtmlCtrl.playerVersion = playerVer;
}
return NOF.Flash.HtmlCtrl.playerVersion;
};
/*
* Takes current page to url if targetWindow is empty or _self
* Otherwise opens a new window at url
*
* @param url
* @param targetName
*/
NOF.Flash.HtmlCtrl.launchURL = function (args) {
var url = args[0];
var targetName = args[1];
var windowRef = null;
if (targetName == undefined || targetName == null || targetName == "") {
if ( document.getElementsByTagName )
{
var coll = document.getElementsByTagName('BASE');
if ( coll && coll.length && coll.length > 0 )
targetName = coll[0].target;
if ( targetName == undefined || targetName == "" )
windowRef = window;
}
}
if (windowRef == null) {
switch (targetName)
{
case undefined:
case null:
case "":
if ( document.getElementsByTagName )
{
var coll = document.getElementsByTagName('BASE');
if ( coll && coll.length && coll.length > 0 )
targetName = coll[0].target;
if ( targetName == undefined || targetName == "" )
windowRef = window;
}
if (windowRef != null) //stop if we found our window. otherwise keep searching
break;
case "_self" :
windowRef = window;
break;
case "_parent" :
windowRef = parent;
break;
case "_top" :
windowRef = top;
break;
case "_blank" :
break;
default:
windowRef = NOF.Util.GetFrameWndByName(targetName);
break;
}
}
if (windowRef != null) {
windowRef.location.href = url;
} else {
window.open(url, targetName);
}
};
}
if(typeof NOF.Flash.MovieCollectionMgr == "undefined")
{
function NOF_Flash_MovieCollectionMgr() {
this.__proto__ = NOF_Flash_MovieCollectionMgr.prototype;
this.collections = new Array();
}
var method = NOF_Flash_MovieCollectionMgr.prototype;
method.createCollection = function() {
var coll = new NOF.Flash.MovieCollection(this.collections.length);
this.collections[this.collections.length] = coll;
return coll;
};
method.getCollection = function(index) {
return (index>=0 && index