/*
*+------------------------------------------------------------------------+
*| Licensed Materials - Property of IBM
*| IBM Cognos Products: Viewer
*| (C) Copyright IBM Corp. 2001, 2011
*|
*| US Government Users Restricted Rights - Use, duplication or
*| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*|
*+------------------------------------------------------------------------+
*/
/*-----------------------------------------------------------------------------------------------------
Class : CMenuItem
Description :
-----------------------------------------------------------------------------------------------------*/
var theMenuCnt = 1;
function CMenuItem(parent, label, action, iconPath, style) {
this.m_label = label;
this.m_id = label + theMenuCnt++;
this.m_bVisible = true;
this.m_bEnabled = true;
this.m_action = action;
this.m_icon = new CIcon(iconPath);
this.m_parent = parent;
this.m_menu = null;
this.m_menuType='';
this.m_style = style;
this.m_observers = new CObserver(this);
//skin folder
this.m_sSkin = (typeof getPromptSkin != "undefined" ? getPromptSkin() : "../skins/corporate");
if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function") {
this.m_parent.add(this);
}
}
function CMenuItem_getId() {
return this.m_id;
}
function CMenuItem_getObservers() {
return this.m_observers;
}
function CMenuItem_setParent(parent) {
this.m_parent = parent;
}
function CMenuItem_getParent() {
return this.m_parent;
}
function CMenuItem_draw() {
var html = '
';
var bSiblingContainsIcon = false, siblingCount = null, siblingMenuItem = null, siblingIdx = 0;
if(this.m_menu == null || this.m_menuType=='dropDown') {
html += '
';
html += '';
if(bSiblingContainsIcon) {
html += ' ';
}
else {
html += this.m_icon.draw();
}
html += ' | ';
html += '';
html += this.m_label;
html += ' | ';
if(this.m_menuType=='dropDown')
{
html += '';
html += ' ';
html += ' | ';
}
html += '
';
} else {
html += '';
html += '';
} else {
html += ' width="1">';
}
html += this.m_icon.draw();
html += ' | ';
html += '';
html += this.m_label;
html += ' | ';
html += '';
html += ' ';
html += ' | ';
html += '
';
html += '';
}
return html;
}
function CMenuItem_onmouseover(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// get the menu item from the html element which is handling the event
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
return;
}
if(typeof menuItem.getStyle() == "object") {
this.className = menuItem.getStyle().getRolloverState();
}
var menu = menuItem.getMenu();
if(menu != null) {
var pageWidth = 0;
var pageHeight = 0;
if(typeof window.innerWidth != "undefined") {
pageWidth = window.innerWidth;
}
else {
pageWidth = document.body.clientWidth;
}
if(typeof window.innerHeight != "undefined") {
pageHeight = window.innerHeight;
}
else {
pageHeight = document.body.clientHeight;
}
if(menuItem.getMenuType() == 'cascaded') {
if(menu.isVisible() == false) {
menu.setHTMLContainer(document.all ? this.document.body : this.ownerDocument.body);
menu.draw();
menu.show();
}
} else if(menuItem.getMenuType() == 'dropDown') {
// check with the parent to see if there current are menus open. If there are, we'll automatically open this menu
var menuItemParent = menuItem.getParent();
var numOfItems = menuItemParent.getNumItems();
for(var i = 0; i < numOfItems; ++i) {
var currentItem = menuItemParent.get(i);
if(currentItem != menuItem && typeof currentItem.getMenu == "function") {
var oCurrentMenu = currentItem.getMenu();
if (oCurrentMenu && oCurrentMenu.isVisible()) {
// the user clicked on the menu
menu.setHTMLContainer(document.all ? this.document.body : this.ownerDocument.body);
menu.draw();
menu.show();
break;
}
}
}
}
}
// send the message up to our parent
var oMenuParent = menuItem.getParent();
if(oMenuParent && typeof oMenuParent.onmouseover == "function") {
oMenuParent.onmouseover(evt);
}
// notify our observers of this event
menuItem.getObservers().notify(CMenuItem_onmouseover);
}
function CMenuItem_onfocus(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// get the menu item from the html element which is handling the event
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
return;
}
if(typeof menuItem.getStyle() == "object") {
this.className = menuItem.getStyle().getRolloverState();
}
// send the message up to our parent (a fake mouseover)
var oParent = menuItem.getParent();
if(oParent && typeof oParent.onmouseover == "function") {
oParent.onmouseover(evt);
}
// notify our observers of this event
menuItem.getObservers().notify(CMenuItem_onfocus);
}
function CMenuItem_onmouseout(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
// get the menu item from the html element which is handling the event
if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
return;
}
if(typeof menuItem.getStyle() == "object") {
this.className = menuItem.getStyle().getNormalState();
}
// send the message up to our parent
var oParent = menuItem.getParent();
if(oParent && typeof oParent.onmouseout == "function") {
oParent.onmouseout(evt);
}
// notify our observers of this event
menuItem.getObservers().notify(CMenuItem_onmouseout);
}
function CMenuItem_onmouseup(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
if(menuItem != null && menuItem instanceof CMenuItem) {
if(!menuItem.isEnabled()) {
return;
}
if(menuItem.getMenu() != null) {
if(menuItem.getMenuType() == 'cascaded') {
// do nothing for now
} else if(menuItem.getMenuType() == 'dropDown')
{
var menu = menuItem.getMenu();
if(menu.isVisible() == false)
{
// the user clicked on the menu
menu.setHTMLContainer(document.all ? this.document.body : this.ownerDocument.body);
menu.draw();
menu.show();
} else {
menu.remove();
}
}
} else {
// handle the event
eval(menuItem.getAction());
}
if (typeof getReportFrame != "undefined") {
getReportFrame().clearTextSelection();
}
else if (typeof clearTextSelection != "undefined") {
clearTextSelection();
}
// send the message up to our parent
var oParent = menuItem.getParent();
if(oParent && typeof oParent.onmouseup == "function") {
oParent.onmouseup(evt);
}
// notify our observers of this event
if(menuItem.getMenuType() != 'cascaded') {
menuItem.getObservers().notify(CMenuItem_onmouseup);
}
if(typeof this.menuItem != 'undefined' && menuItem.getMenu()!=null && menuItem.getMenuType()=='cascaded' && menuItem.getAction() != '')
{
// handle the event
eval(menuItem.getAction());
}
}
if(evt != null) {
evt.cancelBubble = true;
}
return false;
}
function CMenuItem_onkeydown(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled() || typeof evt != "object" || evt == null) {
return;
}
//if a Shift-Tab is detected
var i = 0;
if (evt.keyCode == 9 && evt.shiftKey) {
for (i = 0; i < menuItem.getParent().getNumItems(); i++) {
if (menuItem.getParent().get(i) == menuItem) {
menuItem.getParent().hide();
if (document.all) {
evt.returnValue = false;
}
else {
evt.preventDefault();
}
break;
}
else if (menuItem.getParent().get(i).m_bEnabled == true) {
break;
}
}
}
//if a normal Tab is detected
else if (evt.keyCode == 9) {
for (i = (menuItem.getParent().getNumItems() - 1); i >= 0; i++) {
if (menuItem.getParent().get(i) == menuItem) {
menuItem.getParent().hide();
if (document.all) {
evt.returnValue = false;
}
else {
evt.preventDefault();
}
break;
}
else if (menuItem.getParent().get(i).m_bEnabled == true) {
break;
}
}
}
// send the message up to our parent
var oParent = menuItem.getParent();
if(oParent && typeof oParent.onmkeydown == "function") {
oParent.onkeydown(evt);
}
// notify our observers of this event
menuItem.getObservers().notify(CMenuItem_onkeydown);
}
function CMenuItem_onkeypress(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
var menuItem = null;
if(typeof this.menuItem != 'undefined') {
menuItem = this.menuItem;
}
else if (this instanceof CMenuItem) {
menuItem = this;
}
if(menuItem != null && menuItem instanceof CMenuItem && typeof evt == "object" && evt != null) {
//flag which determines if we notify observers of the event
var performNotification = true;
//check for the Enter key
if (evt.keyCode == 13) {
//menu item should always be enabled if you can tab to it, but just in case
if(!menuItem.isEnabled()) {
return;
}
if(menuItem.getMenu() != null) {
var menu = menuItem.getMenu();
if(menuItem.getMenuType() == 'cascaded') {
// stop notification so we do not hide the menu
performNotification = false;
// show the menu
if(menu.isVisible() == false) {
menu.setHTMLContainer(document.all ? this.document.body : this.ownerDocument.body);
menu.draw();
menu.show();
} else {
menu.remove();
}
} else if(menuItem.getMenuType() == 'dropDown') {
if(menu.isVisible() == false) {
// the user clicked on the menu
menu.setHTMLContainer(document.all ? this.document.body : this.ownerDocument.body);
menu.draw();
menu.show();
} else {
menu.remove();
}
}
} else {
// handle the event
eval(menuItem.getAction());
}
}
//check for Esc key
else if (evt.keyCode == 27) {
//close the menu
menuItem.getParent().hide();
//cancel event being bubbled up the hierarchy since only one level of menus needs to hide
return;
}
// send the message up to our parent
var oParent = menuItem.getParent();
if(oParent && typeof oParent.onkeypress == "function") {
oParent.onkeypress(evt);
}
if (performNotification) {
// notify our observers of this event
menuItem.getObservers().notify(CMenuItem_onkeypress);
}
}
if(evt != null) {
evt.cancelBubble = true;
}
return false;
}
function CMenuItem_createDropDownMenu(menuStyle) {
this.m_menu = new CMenu('dropDownMenu_'+this.getId(),menuStyle);
this.m_menu.setParent(this);
this.m_menuType = 'dropDown';
return this.m_menu;
}
function CMenuItem_createCascadedMenu(menuStyle) {
this.m_menu = new CMenu('cascadedMenu_'+this.getId(),menuStyle);
this.m_menu.setParent(this);
this.m_menuType = 'cascaded';
return this.m_menu;
}
function CMenuItem_addOwnerDrawControl(control, type) {
this.m_menu = control;
this.m_menuType = type;
if(typeof control.setParent != "undefined") {
this.m_menu.setParent(this);
}
}
function CMenuItem_attachEvents() {
if(typeof this.getParent().getHTMLContainer != "function") {
return; // this method must be implemented by the parent
}
var htmlContainer = this.getParent().getHTMLContainer();
if(htmlContainer == null) {
return;
}
var hMenuItem = eval(document.all ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId()));
if(hMenuItem == null) {
return; // just to be safe
}
hMenuItem.onmouseover = this.onmouseover;
hMenuItem.onmouseout = this.onmouseout;
hMenuItem.onmouseup = this.onmouseup;
hMenuItem.onkeypress = this.onkeypress;
hMenuItem.onfocus = this.onfocus;
hMenuItem.onblur = this.onblur;
hMenuItem.onkeydown = this.onkeydown;
hMenuItem.menuItem = eval(this);
}
function CMenuItem_remove() {
}
function CMenuItem_getMenu() {
return this.m_menu;
}
function CMenuItem_getMenuType() {
return this.m_menuType;
}
function CMenuItem_getStyle() {
return this.m_style;
}
function CMenuItem_setStyle(style) {
this.m_style = style;
}
function CMenuItem_hide() {
this.m_bVisible = false;
}
function CMenuItem_show() {
this.m_bVisible = true;
}
function CMenuItem_enable() {
if(typeof this.getStyle() == "object") {
if(typeof this.getParent().getHTMLContainer == "function") {
var htmlContainer = this.getParent().getHTMLContainer();
if(htmlContainer != null) {
var htmlElement = document.all ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
if(htmlElement != null) {
htmlElement.className = this.getStyle().getNormalState();
}
}
}
this.m_bEnabled = true;
this.getIcon().enable();
}
}
function CMenuItem_disable() {
if(typeof this.getStyle() == "object") {
if(typeof this.getParent().getHTMLContainer == "function") {
var htmlContainer = this.getParent().getHTMLContainer();
if(htmlContainer != null) {
var htmlElement = document.all ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
if(htmlElement != null) {
htmlElement.className = this.getStyle().getDisabledState();
}
}
}
this.m_bEnabled = false;
this.getIcon().disable();
}
}
function CMenuItem_isVisible() {
return this.m_bVisible;
}
function CMenuItem_isEnabled() {
return this.m_bEnabled;
}
function CMenuItem_getAction() {
return this.m_action;
}
function CMenuItem_getIcon() {
return this.m_icon;
}
function CMenuItem_getLabel() {
return this.m_label;
}
function CMenuItem_setFocus() {
document.getElementById(this.m_id).focus();
}
CMenuItem.prototype.draw = CMenuItem_draw;
CMenuItem.prototype.onmouseover = CMenuItem_onmouseover;
CMenuItem.prototype.onmouseout = CMenuItem_onmouseout;
CMenuItem.prototype.onmouseup = CMenuItem_onmouseup;
CMenuItem.prototype.onkeypress = CMenuItem_onkeypress;
CMenuItem.prototype.onkeydown = CMenuItem_onkeydown;
CMenuItem.prototype.onfocus = CMenuItem_onfocus;
CMenuItem.prototype.onblur = CMenuItem_onmouseout;
CMenuItem.prototype.attachEvents = CMenuItem_attachEvents;
CMenuItem.prototype.getMenu = CMenuItem_getMenu;
CMenuItem.prototype.getMenuType = CMenuItem_getMenuType;
CMenuItem.prototype.setParent = CMenuItem_setParent;
CMenuItem.prototype.getParent = CMenuItem_getParent;
CMenuItem.prototype.getObservers = CMenuItem_getObservers;
CMenuItem.prototype.getId = CMenuItem_getId;
CMenuItem.prototype.remove = CMenuItem_remove;
CMenuItem.prototype.setStyle = CMenuItem_setStyle;
CMenuItem.prototype.getStyle = CMenuItem_getStyle;
CMenuItem.prototype.createDropDownMenu = CMenuItem_createDropDownMenu;
CMenuItem.prototype.createCascadedMenu = CMenuItem_createCascadedMenu;
CMenuItem.prototype.addOwnerDrawControl = CMenuItem_addOwnerDrawControl;
CMenuItem.prototype.isVisible = CMenuItem_isVisible;
CMenuItem.prototype.hide = CMenuItem_hide;
CMenuItem.prototype.show = CMenuItem_show;
CMenuItem.prototype.isEnabled = CMenuItem_isEnabled;
CMenuItem.prototype.enable = CMenuItem_enable;
CMenuItem.prototype.disable = CMenuItem_disable;
CMenuItem.prototype.getAction = CMenuItem_getAction;
CMenuItem.prototype.getIcon = CMenuItem_getIcon;
CMenuItem.prototype.getLabel = CMenuItem_getLabel;
CMenuItem.prototype.setFocus = CMenuItem_setFocus;
CMenuItem.prototype.update = new Function("return true");
/*
Class CSeperator
todo : Add commments describing class....
*/
/*
CSeperator styles:
1. horizonal_blank
2. vertical_blank
3. vertical_line
4. horizonal_line
*/
function CSeperator(type, size, style) {
this.m_type=type;
this.m_size=size;
this.m_bVisible = true;
if(typeof style == "object") {
this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
}
else {
this.m_style = new CUIStyle('','','','','');
}
}
function CSeperator_draw() {
if(this.m_style == '') {
return;
}
var html='';
switch(this.m_type) {
case "horizonal_blank":
html += ' | ';
break;
case "horizontal_line":
html += '
';
break;
case "vertical_blank":
html += '';
html += ' |
';
break;
case "vertical_line":
html += '
| ';
break;
}
return html;
}
function CSeperator_getSize() {
return this.m_size;
}
function CSeperator_setSize(size) {
this.m_size = size;
}
function CSeperator_setStyle(style) {
this.m_style = style;
}
function CSeperator_getStyle() {
return this.m_style;
}
function CSeperator_setType(type) {
this.m_type = type;
}
function CSeperator_getType() {
return this.m_type;
}
function CSeperator_hide() {
this.m_bVisible = false;
}
function CSeperator_show() {
this.m_bVisible = true;
}
function CSeperator_isVisible() {
return this.m_bVisible;
}
CSeperator.prototype.draw = CSeperator_draw;
CSeperator.prototype.setSize = CSeperator_setSize;
CSeperator.prototype.getSize = CSeperator_getSize;
CSeperator.prototype.setStyle = CSeperator_setStyle;
CSeperator.prototype.getStyle = CSeperator_getStyle;
CSeperator.prototype.getType = CSeperator_getType;
CSeperator.prototype.setType = CSeperator_setType;
CSeperator.prototype.isVisible = CSeperator_isVisible;
CSeperator.prototype.show = CSeperator_show;
CSeperator.prototype.hide = CSeperator_hide;