// Licensed Materials - Property of IBM // // IBM Cognos Products: cpscrn // // (C) Copyright IBM Corp. 2005, 2021 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // // // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated). if (window.dojo) { dojo.require("dijit.dijit"); } var maximizeBVToAvailableHeight = true; /** * ui_templates * Singleton to hold the current html templates. */ var ui_templates = { contentTemplate: '
' + '' + '' + '' + '' + '
' + '


' + '
' + '' + '
' + '' + PFM.JS.IDS_JS_TAB_WAIT + '' + '
' + '


' + '
' + '
', /** * get usage: * using param names in message string: * get(template, "name1", "value1", "name2", "value2", ...) * using indexes in message string: * get(msg, ["value1", "value2", ...]) */ get: function(sourceString) { var result = sourceString; var i, l=arguments.length; if (l == 2 && typeof arguments[1] == "object" && arguments[1].length > 0) { // second argument is an array of values args = arguments[1]; l = args.length; for (i = 0; i < l; i++) { result = result.replace(new RegExp("\\^" + i + "\\^"), args[i]); } } else { for (i = 1; (i + 1) < l; i += 2) { result = result.replace(new RegExp("\\^" + arguments[i] + "\\^"), arguments[i + 1]); } } return _F_Config.expandMacros(result); }, preload: function() { new Image().src = _F_Config.expandMacros("$WEB$/fragments/common/images/progress.gif"); } }; /** * ui_htabs * @param obj containing: "frag" a fragment object, "id" unique identifier, * "activeTabID" current active tab identifier and "tabs" array of ui_htab objects. */ function ui_htabs(obj, height) { this.parent = null; this.tabs = { }; for (var o in obj) { this[o] = obj[o]; } if (this.activeTabID === undefined) { for (var t in this.tabs) { this.activeTabID = t; break; } } this.pos = 0; this.scrollTimer = null; this.tableID = this.uniqueID() + "table"; this.tabCellID = this.uniqueID() + "tabscell"; this.buttons = { left: new ui_tabbutton({ id: this.frag.id + this.id + "leftbutton", type: "left" }), right: new ui_tabbutton({ id: this.frag.id + this.id + "rightbutton", type: "right" }) }; this.buttonsEnabled = false; } ui_htabs.prototype = { uniqueID: function() { return this.frag.id + this.id; }, attach: function(parent) { this.parent = parent; for (var t in this.tabs) { this.tabs[t].attach(this); } this.buttons.left.attach(this); this.buttons.right.attach(this); }, add: function(tab) { this.tabs[tab.id] = tab; tab.attach(this); }, remove: function(id) { if (this.tabs[id] != null) { if (this.active() == id) { for (var x in this.tabs) { if (x != id) { this.select(x); break; } } } delete this.tabs[id]; } }, select: function(id) { if (this.tabs[id] != null) { var cur = this.active(); if (cur != "") { this.tabs[cur].deselect(); } this.activeTabID = id; this.tabs[id].select(); } }, getTab: function(posIdx) { var x = 0; for (var tabId in this.tabs) { if (x++==posIdx) { return this.tabs[tabId]; } } }, active: function() { return this.activeTabID; }, getRoot: function() { var p = this; while (p.parent != null) { p = p.parent; } return p; }, isFixed: function() { return this.getRoot().fixed == true; }, onresize: function() { //ui_htabs var _self = this; window.setTimeout(function() { _self.adjustLayout(); }, 1); if (this.active() != "") { this.tabs[this.active()].onresize(); } }, scroll: function(dir) { if (!this.buttonsEnabled) { return; } var pos = this.pos + ((dir == "left") ? 5 : -5); this.setScrollPosition(pos); }, setScrollPosition: function(pos){ this.pos = pos; var table = $(this.tableID); if (this.pos >= 0) { this.pos = 0; } else { var td = xParent(xParent(table, true), true); var maxX = (xPageX(table) + xWidth(table)) - (xPageX(td) + xWidth(td)) - 5; if (maxX < 0) { this.pos -= maxX; } } table.style.marginLeft = this.pos + "px"; }, scrollTo: function(tab){ var node = $(tab.tabID) var tabPosition = xLeft(node); var tabWidth = xWidth(node); var clientWidth = xClientWidth(); if ((tabPosition + this.pos) > clientWidth) { this.setScrollPosition(clientWidth - tabPosition - tabWidth - 30); } }, startScroll: function(dir) { if (!this.buttonsEnabled) { return; } // If there is already an active timer, it should be stopped first to avoid it from being lost (i.e.: running) forever if (this.scrollTimer != null) { window.clearInterval(this.scrollTimer); this.scrollTimer = null; } var _self = this; this.scrollTimer = window.setInterval(function() { _self.scroll(dir); }, 10); }, stopScroll: function() { if (!this.buttonsEnabled) { return; } if (this.scrollTimer != null) { window.clearInterval(this.scrollTimer); this.scrollTimer = null; } }, adjustLayout: function() { var table = $(this.tableID); var tabsCell = $(this.tabCellID); if (table == null) { return; } if (tabsCell) { //Reflow the tabs cell, as the width can become confused if it is hidden and re-shown in IE tabsCell.style.width="0"; tabsCell.style.width=""; } var td = xParent(xParent(table, true), true); // test of a firefox bug if (xWidth(td) == 0) { xWidth(td, xWidth(table)); } var tabX = xPageX(td) + xWidth(td); if (this.pos < 0) { var maxX = (xPageX(table) + xWidth(table)) - tabX; if (maxX < 0) { this.pos -= maxX; } if (this.pos > 0) { this.pos = 0; } table.style.marginLeft = this.pos + "px"; } this.buttonsEnabled = (xPageX(table) + xWidth(table)) >= tabX; this.buttons.left.setEnable(this.buttonsEnabled); this.buttons.right.setEnable(this.buttonsEnabled); } }; /** * ui_htab * @param obj */ function ui_htab(obj) { this.id = null; this.parent = null; this.loaded = false; this.refreshRequired = false; this.href = null; this.subtabs = null; this.width = -1; this.height = -1; this.customProperties = null; for (var o in obj) { this[o] = obj[o]; } } ui_htab.prototype = { uniqueID: function() { if (this.parent != null) { return this.parent.uniqueID() + this.id; } return this.id; }, attach: function(parent) { this.parent = parent; var uniqueID = this.parent.uniqueID() + this.id; if (this.tabID == null) { this.tabID = uniqueID + "tab"; } if (this.pageID == null) { this.pageID = uniqueID + "page"; } if (this.contentID == null) { this.contentID = uniqueID + "content"; } if (this.subtabs != null) { this.subtabs.attach(this); } var elem = $(this.tabID); if (elem != null) { xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick")); xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress")); } }, createPage: function() { var tabContainer = $(this.parent.frag.id + "bvContainer"); var pageDiv = document.createElement("DIV"); pageDiv.id = this.pageID; pageDiv.style.display="none"; pageDiv.style.width="100%"; pageDiv.style.height="100%"; pageDiv.setAttribute("role", "tabpanel"); var tabAnchorId = this.tabID + "_anchor"; pageDiv.setAttribute("aria-labelledby", tabAnchorId); var tabEl = $(tabAnchorId); if (tabEl != null){ tabEl.setAttribute("aria-controls", this.pageID); } var contentDiv = ui_templates.get( ui_templates.contentTemplate, 'CONTENTID', this.contentID, 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-htabs-page-content-fixed" : "cogstyle-htabs-page-content") ); pageDiv.innerHTML = contentDiv; tabContainer.appendChild(pageDiv); }, isLoaded: function() { return this.loaded; }, select: function() { if (!this.isLoaded()) { if ($(this.pageID)) { this.loaded = true; this.refreshRequired = true; } else { this.createPage(); } } var frag = fragments[this.uniqueID()]; if (frag) { frag.lockUpdates(false); frag.raiseEvent("fragment.visibility.change",{"setVisibility":"visible"}, "params", false, false); } //RTC 200661 not using the 'alt' for now //var alt = (this.parent.parent != null) ? "-alt" : ""; var alt = ""; var td = $(this.tabID); var div = xFirstChild(td, "DIV"); div.className = "cogstyle-htabs" + alt + "-active-left-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-htabs" + alt + "-active-right-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-htabs" + alt + "-active"; if (this.subtabs != null) { $(this.pageID).style.display = "block"; this.subtabs.tabs[this.subtabs.active()].select(); } else { $(this.pageID).style.display = "block"; } // Get the tab title, which is the first anchor in the tab var label = xFirstChild(div, "A"); // Set the tabindex to 0 so it shows up in the tab order label.tabIndex=0; // Set the focus to the tab title label.focus(); label.setAttribute("aria-selected","true"); this.refresh(); this.parent.scrollTo(this); }, deselect: function() { var frag = fragments[this.uniqueID()]; if (frag) { frag.lockUpdates(true); frag.raiseEvent("fragment.visibility.change", {"setVisibility":"hidden"}, "params", false, false); } //var alt = (this.parent.parent != null) ? "-alt" : ""; var alt = ""; var td = $(this.tabID); var div = xFirstChild(td, "DIV"); div.className = "cogstyle-htabs" + alt + "-left-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-htabs" + alt + "-right-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-htabs" + alt; if (this.subtabs != null) { $(this.pageID).style.display = "none"; this.subtabs.tabs[this.subtabs.active()].deselect(); } else { var pageDIV = $(this.pageID); if (pageDIV != null) { pageDIV.style.display = "none"; } } var label = xFirstChild(div, "A"); label.setAttribute("aria-selected","false"); }, refresh: function(force) { if (this.href != null) { if (!this.isLoaded()) { this.loaded = true; var frag = new fragment(this.href, this.uniqueID()); frag.customProperties = this.customProperties; frag.retrieve(); } else if (force || this.refreshRequired) { this.refreshRequired = false; fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true); } } else if (this.subtabs != null) { this.subtabs.select(this.subtabs.active()); } var topLevel = this; while (topLevel.parent != null) { topLevel = topLevel.parent; } topLevel.onresize(); }, onclick: function(e, tag) { this.parent.select(this.id); }, onkeypress: function(evt) { evt = evt != null ? evt : window.event; var e = evt.srcElement ? evt.srcElement : evt.target; var activeTab; // Left or Up Arrow if (evt.keyCode == 37 || evt.keyCode == 38) { activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab"); // Get the previous tab var prevTab = activeTab.previousSibling; if (prevTab == null) { // or last child if you are on the first child. prevTab = activeTab.parentNode.lastChild; } // Extract the relevant part of the tab id var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3); // Select the tab this.parent.select(prevId); } // Right or Down arrow else if (evt.keyCode == 39 || evt.keyCode == 40) { activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab"); // Get the next tab var nextTab = activeTab.nextSibling; if (nextTab == null) { // or first child if you are on the last child. nextTab = activeTab.parentNode.firstChild; } // Extract the relevant part of the tab id var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3); // Select the tab this.parent.select(nextId); } xStopPropagation(evt); }, onresize: function() { //ui_htab if (!this.parent.isFixed()) { //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward if (this.subtabs != null) { this.subtabs.onresize(); } else { var objectType = this.target.targetType ? this.target.targetType : this.target.type; ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height); var list = _F_descendants(this.uniqueID(), null, true); _F_resize(list); } return; } var parentTab = this.parent.parent; // check if top level or sub-level? if (parentTab == null) { var page = $(this.pageID); this.height = xClientHeight() - ui_calcAvailableHeight(page, document.body,true); this.width = xClientWidth() - ui_calcAvailableWidth(page, document.body); if (maximizeBVToAvailableHeight) { this.height = ui_calcMaximumHeight(page, document.body, true); readjustParentHeight(this.contentID); } } else { this.height = parentTab.height - xHeight(this.parent.tableID) - 1; this.width = parentTab.width; } if (this.subtabs != null) { this.subtabs.onresize(); } else { var content = $(this.contentID); xHeight(content, this.height); // resize the fragments (and children) var dlist = _F_descendants(this.uniqueID(), null, true); _F_resize(dlist); } }, getVTabs: function() { return fragments[this.uniqueID()]; } }; /** * ui_tabbutton * @param obj */ function ui_tabbutton(obj) { this.id = null; this.parent = null; this.enabled = false; this.hovered = false; this.mouseUpHandler = null; this.selectStartHandler = function(e) {xPreventDefault(e);return false;}; for (var o in obj) { this[o] = obj[o]; } } ui_tabbutton.prototype = { attach: function(parent) { this.parent = parent; var elem = $(this.id); if (elem != null) { xAddEventListener(elem, "mousedown", _F_Document.associate(elem, this, "onmousedown")); xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover")); xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout")); xAddEventListener(elem, "keydown", _F_Document.associate(elem, this, "onkeydown")); xAddEventListener(elem, "touchstart", _F_Document.associate(elem, this, "ontouchstart")); xAddEventListener(elem, "touchend", _F_Document.associate(elem, this, "ontouchend")); } }, setEnable: function(enable) { if (this.enabled != enable) { this.enabled = enable; this.updateStyles(); } }, updateStyles: function() { var style = "cogstyle-htabs-scroll-button"; if (!this.enabled) { style += "-disabled"; } else if (this.hovered) { style += "-hover"; } style += " cogstyle-htabs-scroll-button-" + this.type; if (!this.enabled) { style += "-disabled"; } $(this.id).className = style; var scrollImg = $(this.id + "img"); if (this.enabled) { scrollImg.className = ""; } else { scrollImg.className = "cogstyle-img-faded"; } }, onkeydown: function(e, tag){ if (e.keyCode == 13 || e.keyCode == 32 || e.charCode==32){ this.parent.scroll(this.type); } }, onclick: function(e, tag) { this.parent.scroll(this.type); }, onmousedown: function(e, tag) { xPreventDefault(e); this.mouseUpHandler = _F_Document.associate(document, this, "onmouseup"); xAddEventListener(document, "mouseup", this.mouseUpHandler); xAddEventListener(document, "selectstart", this.selectStartHandler); xAddEventListener(document, "dragstart", this.selectStartHandler); this.parent.startScroll(this.type); }, onmouseup: function(e, tag) { xRemoveEventListener(document, "mouseup", this.mouseUpHandler); xRemoveEventListener(document, "selectstart", this.selectStartHandler); xRemoveEventListener(document, "dragstart", this.selectStartHandler); this.mouseUpHandler = null; this.parent.stopScroll(); }, ontouchstart: function(e, tag) { xPreventDefault(e); this.touchEndHandler = _F_Document.associate(document, this, "ontouchend"); xAddEventListener(document, "touchend", this.touchEndHandler); this.parent.startScroll(this.type); }, ontouchend: function(e, tag) { xRemoveEventListener(document, "touchend", this.touchEndHandler); this.touchEndHandler = null; this.parent.stopScroll(); }, onmouseover: function(e, tag) { if (this.enabled) { this.hovered = true; this.updateStyles(); if (this.mouseUpHandler != null) { this.parent.startScroll(this.type); } } }, onmouseout: function(e, tag) { if (this.enabled) { this.parent.stopScroll(); this.hovered = false; this.updateStyles(); } } }; /** * ui_vtabs * @param obj containing: "frag" the fragment object, "id" unique identifier, * "activeTabID" current active tab identifier and "tabs" array of ui_vtab objects. */ function ui_vtabs(obj) { this.parent = null; this.tabs = { }; for (var o in obj) { this[o] = obj[o]; } if (this.activeTabID === undefined) { for (var t in this.tabs) { this.activeTabID = t; break; } } } ui_vtabs.prototype = { uniqueID: function() { return this.frag.id + this.id; }, attach: function(parent) { this.parent = parent; this.bookletViewerContainerID = this.frag.id + "bvContainer"; if (parent == null) { this.toplevel = countLevels(this.frag.parent) == 1; this.tabsmainID = this.frag.id + "tabs_main"; this.tabsareaID = this.frag.id + "tabs_area"; this.tabsareadivID = this.frag.id + "tabs_area_div"; this.vtabsMinWidth = 0; } for (var t in this.tabs) { this.tabs[t].attach(this); } function countLevels(f) { var count = 0; while (f != null) { count++; f = f.parent; } return count; } }, select: function(id) { if (this.tabs[id] != null) { var cur = this.active(); if (cur != "") { this.tabs[cur].deselect(); } this.activeTabID = id; this.tabs[id].select(); } }, active: function() { return this.activeTabID; }, getTab: function(posIdx) { var x = 0; for (var tabId in this.tabs) { if (x++==posIdx) { return this.tabs[tabId]; } } }, getRoot: function() { var p = this; while (p.parent != null) { p = p.parent; } return p; }, isFixed: function() { return this.getRoot().fixed == true; }, getVTabsAreaWidth: function() { return this.getRoot().vtabsWidth; }, getVTabsAreaHeight: function() { return this.getRoot().vtabsHeight; }, setVTabsAreaWidth: function(vtabsWidth) { var o = this.getRoot(); if (o.vtabsWidth != vtabsWidth) { if (vtabsWidth < o.vtabsMinWidth) { o.vtabsWidth = o.vtabsMinWidth; } else { o.vtabsWidth = vtabsWidth; } o.onresize(); } }, onresize: function() { //ui_vtabs var tabsArea = $(this.tabsareaID); if (tabsArea != null) { if (this.parent == null) { var tabsAreaDiv = $(this.tabsareadivID); var tabsListDiv = tabsAreaDiv.childNodes[0]; var tabsFilterDiv = tabsAreaDiv.childNodes[1]; var tabsMainTable = $(this.tabsmainID); // check if top level or embeded in another htabs/vtabs? if (this.toplevel) { this.vtabsHeight = xClientHeight() - ui_calcAvailableHeight(tabsArea, document.body, true); } else { var div = $(this.frag.div); this.vtabsHeight = xHeight(div) - ui_calcAvailableHeight(tabsArea, div, true); } if (maximizeBVToAvailableHeight) { if (this.isFixed()) { this.vtabsHeight = ui_calcMaximumHeight(tabsArea, document.body, true); } } if (this.isFixed() || _F_Config.application.toLowerCase() == "/cogadmin") { if (tabsMainTable.style.height != "100%") { tabsMainTable.style.height = "100%"; } } xWidth(tabsFilterDiv, this.vtabsWidth); xWidth(tabsArea, this.vtabsWidth); if (!(xIE4Up)) { tabsListDiv.style.width = "auto"; } } } if (this.active() != "") { this.tabs[this.active()].onresize(); } } }; /** * ui_vtab * @param obj */ function ui_vtab(obj) { this.id = null; this.parent = null; this.loaded = false; this.refreshRequired = false; this.href = null; this.subtabs = null; this.width = -1; this.height = -1; this.customProperties = null; for (var o in obj) { this[o] = obj[o]; } } ui_vtab.prototype = { uniqueID: function() { if (this.parent != null) { return this.parent.uniqueID() + this.id; } return this.id; }, attach: function(parent) { this.parent = parent; var uniqueID = this.parent.uniqueID() + this.id; if (this.tabID == null) { this.tabID = uniqueID + "tab"; } if (this.pageID == null) { this.pageID = uniqueID + "page"; } if (this.filterID == null) { this.filterID = uniqueID + "filter"; } if (this.contentID == null) { this.contentID = uniqueID + "content"; } if (this.subtabs != null) { this.subtabs.attach(this); this.subtabsID = uniqueID + "subtabs"; } var elem = $(this.tabID); if (elem != null) { xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick")); xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover")); xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout")); xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress")); } }, createPage: function() { var tabContainer = $(this.parent.frag.id + "tabs_container"); var pageDiv = document.createElement("DIV"); pageDiv.id = this.pageID; pageDiv.style.width="100%"; pageDiv.style.height="100%"; pageDiv.style.display="none"; pageDiv.setAttribute("role", "tabpanel"); var tabAnchorId = this.tabID + "_anchor"; pageDiv.setAttribute("aria-labelledby", tabAnchorId); var tabEl = $(tabAnchorId); if (tabEl != null){ tabEl.setAttribute("aria-controls", this.pageID); } var contentDiv = ui_templates.get( ui_templates.contentTemplate, 'CONTENTID', this.contentID, 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-vtabs-page-content-fixed" : "cogstyle-vtabs-page-content") ); pageDiv.innerHTML = contentDiv; tabContainer.appendChild(pageDiv); }, createFilter: function() { var filterContainer = $(this.parent.frag.id + "filter_container"); var filterDiv = document.createElement("DIV"); filterDiv.id = this.filterID; filterDiv.style.display="none"; filterDiv.className = "cogstyle-filter"; filterContainer.appendChild(filterDiv); }, isLoaded: function() { return this.loaded; }, select: function() { if (!this.isLoaded()) { if ($(this.pageID)) { this.loaded = true; this.refreshRequired = true; } else { this.createPage(); this.createFilter(); } } var frag = fragments[this.uniqueID()]; if (frag) { frag.lockUpdates(false); frag.raiseEvent("fragment.visibility.change", { "setVisibility":"visible" }, "params", false, false); } var more = (this.parent.parent != null) ? "-alt" : ""; more += (this.subtabs) ? "-opened" : ""; var div = $(this.tabID); div.className = "cogstyle-vtabs-active-border"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more + "-active-left-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more + "-active-right-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more + "-active"; if (this.subtabs != null) { $(this.subtabsID).style.display = "block"; this.subtabs.tabs[this.subtabs.active()].select(); } else { $(this.pageID).style.display = "block"; var filterDIV = $(this.filterID); if (filterDIV != null && filterDIV.firstChild != null) { filterDIV.style.display = "block"; } } // Get the tab title, which is the first anchor in the tab var label = xFirstChild(div, "A"); // when you set the tabindex in IE, it shifts focus to the text inside it // if the tabsArea is smaller than the length of the text, it shifts over and hides the icon // setting the width of the label fixes this xWidth(label, xWidth(div)); // Set the tabindex to 0 so it shows up in the tab order label.tabIndex=0; // Set the focus to the tab title label.focus(); label.setAttribute("aria-selected","true"); this.refresh(); }, deselect: function() { var frag = fragments[this.uniqueID()]; if (frag) { frag.lockUpdates(true); frag.raiseEvent("fragment.visibility.change", { "setVisibility":"hidden" }, "params", false, false); } var more = (this.parent.parent != null) ? "-alt" : ""; more += (this.subtabs) ? "-opened" : ""; var div = $(this.tabID); div.className = ""; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more + "-left-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more + "-right-edge"; div = xFirstChild(div, "DIV"); div.className = "cogstyle-vtabs" + more; if (this.subtabs != null) { $(this.subtabsID).style.display = "none"; this.subtabs.tabs[this.subtabs.active()].deselect(); } else { var pageDIV = $(this.pageID); if (pageDIV != null) { pageDIV.style.display = "none"; } var filterDIV = $(this.filterID); if (filterDIV != null) { filterDIV.style.display = "none"; } } // Get the tab title, which is the first anchor in the tab var label = xFirstChild(div, "A"); label.setAttribute("aria-selected","false"); }, refresh: function(force) { if (this.href != null) { if (!this.isLoaded()) { this.loaded = true; var frag = new fragment(this.href, this.uniqueID()); frag.customProperties = this.customProperties; frag.retrieve(); } else if (force || this.refreshRequired) { this.refreshRequired = false; fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true); } } else if (this.subtabs != null) { this.subtabs.select(this.subtabs.active()); } var topLevel = this; while (topLevel.parent != null) { topLevel = topLevel.parent; } topLevel.onresize(); }, onclick: function(e, tag) { this.parent.select(this.id); }, onkeypress: function(evt) { evt = evt != null ? evt : window.event; var e = evt.srcElement ? evt.srcElement : evt.target; var activeTab; // Left or Up Arrow if (evt.keyCode == 37 || evt.keyCode == 38) { activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab"); // Get the previous tab var prevTab = activeTab.previousSibling; if (prevTab == null) { // or last child if you are on the first child. prevTab = activeTab.parentNode.lastChild; } // Extract the relevant part of the tab id var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3); // Select the tab this.parent.select(prevId); } // Right or Down arrow else if (evt.keyCode == 39 || evt.keyCode == 40) { activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab"); // Get the next tab var nextTab = activeTab.nextSibling; if (nextTab == null) { // or first child if you are on the last child. nextTab = activeTab.parentNode.firstChild; } // Extract the relevant part of the tab id var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3); // Select the tab this.parent.select(nextId); } }, onmouseover: function(e, tag) { var div = $(this.tabID); div = xFirstChild(div, "DIV"); var cur = div.className; if (cur.indexOf('-hover') == -1) { div.className = cur + "-hover"; } }, onmouseout: function(e, tag) { var div = $(this.tabID); div = xFirstChild(div, "DIV"); var cur = div.className; var i; if ((i = cur.indexOf('-hover')) != -1) { div.className = cur.substring(0, i); } }, onresize: function() { //ui_vtab if (!this.parent.isFixed()) { //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward if (this.subtabs != null) { this.subtabs.onresize(); } else { var objectType = this.target.targetType ? this.target.targetType : this.target.type; ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height); var list = _F_descendants(this.uniqueID(), null, true); _F_resize(list); } return; } // check if top level or sub-level? var parentTab = this.parent.parent; if (parentTab == null) { this.height = this.parent.getRoot().vtabsHeight; if (maximizeBVToAvailableHeight) { readjustParentHeight(this.contentID); } } else { // propagate down the size for all tabs this.height = parentTab.height; } if (this.subtabs != null) { this.subtabs.onresize(); } else { xHeight(this.contentID, this.height); xHeight(this.pageID, this.height); //keeps scrollbar from appearing off the side of the page in ie. // resize the fragments (and children) var dlist = _F_descendants(this.uniqueID(), null, true); _F_resize(dlist); } } }; /** * ui_splitter * @param obj */ function ui_splitter(obj) { this.id = null; this.splitterBar = null; this.startX = -1; for (var o in obj) { this[o] = obj[o]; } xAddEventListener($(this.id), "mousedown", _F_Document.associate(window, this, "start")); } ui_splitter.prototype = { start: function(e, tag) { var evt = new xEvent(e); xPreventDefault(e); var bar = $(this.id); var div = document.createElement('DIV'); div.appendChild(document.createElement('BR')); div.className="cogstyle-splitter-bar"; this.mousemove = _F_Document.associate(window, this, "move"); xAddEventListener(document, "mousemove", this.mousemove, true); this.mouseup = _F_Document.associate(window, this, "stop"); xAddEventListener(document, "mouseup", this.mouseup, true); this.width = xWidth(bar); xLeft(div, xPageX(bar)); xTop(div, xPageY(bar)); xWidth(div, this.width); xHeight(div, xHeight(bar)); xAppendChild(document.body, div); div.style.display = ""; this.splitterBar = div; this.startX = evt.pageX; var locker = ui_locker.get(); locker.show(true); }, move: function(e, tag) { if (this.startX > 0) { var evt = new xEvent(e); xPreventDefault(e); xLeft(this.splitterBar, evt.pageX - (this.width / 2)); } }, stop: function(e, tag) { if (this.startX > 0) { var evt = new xEvent(e); xPreventDefault(e); xHide(this.splitterBar); document.body.removeChild(this.splitterBar); this.splitterBar = null; xRemoveEventListener(document, "mousemove", this.mousemove, true); xRemoveEventListener(document, "mouseup", this.mouseup, true); this.resizing.setVTabsAreaWidth(this.resizing.getVTabsAreaWidth() + (evt.pageX - this.startX)); this.startX = -1; } var locker = ui_locker.get(); locker.hide(); } }; /** * ui_error * @param fragID the fragment unique identifier * @param contentID the identifier of the "content" div receiving the error bar. */ function ui_error(fragID, contentID) { this.fragID = fragID; this.contentID = contentID; this.code = null; this.message = null; this.details = null; } ui_error.prototype = { template: "
", setCode: function(code) { this.code = code; }, setMessage: function(msg) { this.message = msg||""; var div = $(this.fragID + "errormsg"); if (div != null) { div.innerHTML = _F_Strings.htmlEncode(this.message); } }, setDetails: function(details) { this.details = details; }, show: function() { var div = $(this.fragID + "error"); if (div == null) { var content = $(this.contentID); div = document.createElement("DIV"); div.className = "cogstyle-portlet-error-frame"; div.id = this.fragID + "error"; div.innerHTML = this.template.replace(/_THIS_/g, this.fragID); content.parentNode.insertBefore(div, content); var anchor = $(this.fragID + "error_showdetails"); if (anchor != null) { xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "showDetails")); anchor.href = "javascript:noop()"; } anchor = $(this.fragID + "error_retry"); if (anchor != null) { xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "retry")); anchor.href = "javascript:noop()"; } anchor = $(this.fragID + "error_hide"); if (anchor != null) { xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "hide")); anchor.href = "javascript:noop()"; } } $(this.fragID + "errormsg").innerHTML = _F_Strings.htmlEncode(this.message); div.style.display = ""; setTimeout(function(){div.setAttribute("role","alert");},1) this.hideLoading(); }, hide: function() { var div = $(this.fragID + "error"); if (div != null) { div.style.display = "none"; } return false; }, hideLoading: function() { // get div, get firstchild, check for removeonerror attribute, if there clear div content var viewport = $(this.contentID); if (viewport) { var ele = xFirstChild(viewport); if (ele) { if (ele.getAttribute("removeonerror") == "true") { viewport.innerHTML = ""; } } } }, showDetails: function() { var dlg = new ui_dialog(this.fragID + "errordetails", PFM.JS.IDS_JS_DETAILS, ui_dialog.style.ALERT | ui_dialog.style.BTN_CLOSE | ui_dialog.style.CENTER | ui_dialog.style.RESIZABLE, -1, -1, 500, 300, this.contentID); dlg.processCommand = function(cmd) { this.destroy(); return true; }; if (this.details != null) { var markup = ""; if (this.code != null) { markup += ""; } markup += "" + "" + "" + "" + "
" + this.code + "
" + "" + "" + _F_Strings.htmlEncode(this.message) + "
"; markup += "
" + _F_Strings.htmlEncode(this.details) + "
"; dlg.attachContent(markup); } dlg.show(); return false; }, retry: function() { this.hide(); // TODO: should call a retry instead of retrieve here fragments[this.fragID].retrieve(); return false; } }; function ui_fragment_help(frag) { if (frag) { var sURL = frag.baseURI(); // replace the macros sURL = _F_Config.expandMacros(sURL); sURL += ((sURL.indexOf('?') >= 0) ? "&" : "?") + "frag-mode=help"; var windowHelp = window.open(sURL, "cps_help", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500"); if (windowHelp != null) { windowHelp.focus(); } } } /** * ui_dialog * @param id unique identifier of dialog * @param caption text * @param styles bit field of STYLES_* * @param dx width * @param dy height * @param contentId Optional unique identifier of the content div for the invoking fragment. Used to set the proper font size. * @param srcHref Optional parameter, if passed the dialog system will use this as a url and create an iframe for it. */ function ui_dialog(id, caption, styles, x, y, dx, dy, contentId, srcHref) { this.id = id; this.caption = caption; this.styles = styles; this.x = x; this.y = y; this.dx = dx; this.dy = dy; this.dlg = null; this.backing = null; this.content = ""; this.results = null; this.contentId = contentId; this.srcHref = (srcHref !== undefined)? srcHref:null; this.minDialogWidth = 200; this.iframeName = (srcHref !== undefined)? "MODAL_IFRAME" + ( new Date() ).getTime():null; this.fragment = null; this.eventHandlers = []; this.triggerElement = document.activeElement; } ui_dialog.chain = []; ui_dialog.nextX = 0; ui_dialog.nextY = 0; ui_dialog.style = {}; ui_dialog.style.BTN_OK = 0; ui_dialog.style.BTN_OKCANCEL = 1; ui_dialog.style.BTN_OKCANCELAPPLY = 2; ui_dialog.style.BTN_CLOSE = 3; ui_dialog.style.BTN_CANCEL = 4; ui_dialog.style.BTN_YESNO = 5; ui_dialog.style.BTN_YESNOCANCEL = 6; ui_dialog.style.BTN_NOBUTTONS = 8; ui_dialog.style.RESIZABLE = 16; ui_dialog.style.MODELESS = 32; ui_dialog.style.CENTER = 64; ui_dialog.style.IFRAME = 128; ui_dialog.style.READONLY = 256; ui_dialog.style.ALERT = 512; ui_dialog.button = {}; ui_dialog.button.OK = "ok"; ui_dialog.button.CANCEL = "cancel"; ui_dialog.button.APPLY = "apply"; ui_dialog.button.YES = "yes"; ui_dialog.button.NO = "no"; ui_dialog.button.CLOSE = "close"; ui_dialog.button.CLOSEBOX = "closebox"; ui_dialog.button.HELPBOX = "helpbox"; ui_dialog.button._styles_ = [ [ui_dialog.button.OK], [ui_dialog.button.OK, ui_dialog.button.CANCEL], [ui_dialog.button.OK, ui_dialog.button.CANCEL, ui_dialog.button.APPLY], [ui_dialog.button.CLOSE], [ui_dialog.button.CANCEL], [ui_dialog.button.YES, ui_dialog.button.NO], [ui_dialog.button.YES, ui_dialog.button.NO, ui_dialog.button.CANCEL], null, [] ]; ui_dialog.prototype = { create: function() { var iframe = null; if (xIE4Up) { iframe = document.createElement("iframe"); iframe.id = this.id + "iframe"; iframe.style.display="none"; iframe.style.border="0px"; iframe.style.position="absolute"; iframe.src = _F_Config.webContent + "/fragments/common/images/space.gif"; this.backing = iframe; document.body.appendChild(iframe); } var div = document.createElement("DIV"); div.className = "cogstyle-dialog"; div.id = this.id; div.style.display = "none"; if ((this.styles & ui_dialog.style.ALERT) == ui_dialog.style.ALERT) { div.setAttribute("role", "alert"); } var markup = "" + "" + "" + "" + "" + "" + "" + "
" + "" + "" + ""; if (this.fragment != null && _F_Array.indexOf(this.fragment.modes, "help") > -1) { markup += ""; } markup += "" + "" + "
" + _F_Strings.htmlEncode(this.caption) + "" + "" + PFM.JS.IDS_JS_HELP_URL + "" + "" + "" + "
" + "
"; var tempMarkup = " id=\"" + this.id + "content\" class=\"cogstyle-dialog-content\" style=\"width:" + this.dx + "px;height:" + this.dy + "px"; if ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME) { markup += ""; } else { markup += ""; } markup += "
" + ""; } else { markup += "
"; } if (((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) && ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME)) { markup += ""; } markup += "" + "
" ; var buttons = ui_dialog.button._styles_[this.styles & 15]; var i, l = buttons.length; if (l > 0) { for (i=0; i"; } markup+="" + "\"\"" + "
" + "
" + "
"; div.innerHTML = markup; document.body.appendChild(div); this.attachContent(this.content); for (var b in ui_dialog.button) { var btn = $(this.id + "btn" + ui_dialog.button[b]); if (btn != null) { xAddEventListener(btn, "click", _F_Document.associate(btn, this, "oncommand")); } } var capDiv = $(this.id + "caption"); capDiv.xdlg = this; xAddEventListener(div, "mousedown", _F_Document.associate(div, this, "onactivate")); xEnableDrag(capDiv, this.onstartmove, this.onmove, null); if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) { var resizeBox = $(this.id + "resizebox"); resizeBox.xdlg = this; xEnableDrag(resizeBox, this.onstartresize, this.onresize, null); } if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) { if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) { _F_log("I", "Resize not currently available for dialogs displaying iframes."); } this.showLoadingIndicator(); this.postForm(this.srcHref); } return div; }, showLoadingIndicator: function () { // BUSY DIV var progressDiv = null; var dialogIframe; progressDiv = $(this.id + "progressDiv"); if (progressDiv == null) { progressDiv = xCreateElement("div"); progressDiv.id = this.id + "progressDiv"; var progressMarkup= ui_templates.get(ui_templates.contentTemplate, 'CONTENTID', progressDiv.id + "content"); dialogIframe = $(this.id + "content"); progressDiv.innerHTML = progressMarkup; progressDiv.style.height = this.dy; progressDiv.style.width = this.dx; dialogIframe.parentNode.insertBefore(progressDiv, dialogIframe); _F_Document.addEventListener(dialogIframe,"load", _F_Document.associate(dialogIframe.id,this,"onContentLoaded")); } dialogIframe.style.display = "none"; }, onContentLoaded : function(event) { var dialogIframe = $(this.id + "content"); var progressDiv = $(this.id + "progressDiv"); if ((dialogIframe) && (dialogIframe.style.display == "none")) { progressDiv.style.display = "none"; dialogIframe.style.display = ""; } }, postForm: function(url) { var iframe = $(this.id + "content"); var formElement = document.createElement("form"); formElement.setAttribute("name","_THIS_dlg_window_form"); formElement.setAttribute("method","POST"); formElement.setAttribute("target", iframe.name); var qm_index = url.indexOf("?"); var action = (qm_index==-1) ? url : url.substring(0, qm_index); formElement.setAttribute("action", action); if (qm_index != -1) { var paramString = url.substring(qm_index+1); var params = paramString.split("&"); var i; for (i=0; i < params.length; ++i) { if (params[i].length>0) { var hiddenElement = document.createElement("input"); hiddenElement.setAttribute("type","hidden"); var eq_index = params[i].indexOf("="); if (eq_index != -1) { hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index))); hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1))); } else { hiddenElement.setAttribute("name",unescape(params[i])); hiddenElement.setAttribute("value",""); } formElement.appendChild(hiddenElement); } } } document.body.appendChild(formElement); formElement.submit(); document.body.removeChild(formElement); formElement = null; }, destroy: function() { this.hide(); if (xIE4Up) { if ($(this.id + "caption")) { xDisableDrag(this.id + "caption"); } if ($(this.id + "resizebox")) { xDisableDrag(this.id + "resizebox"); } if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) { var iFrameObj = $(this.id + "content"); iFrameObj.parentNode.removeChild(iFrameObj); } } this.dlg.parentNode.removeChild(this.dlg); this.dlg = null; if (this.backing) { this.backing.parentNode.removeChild(this.backing); this.backing = null; } }, show: function() { if (this.dlg == null) { this.dlg = this.create(); } ui_dialog.chain.push(this); this.center(this.x, this.y, this.dx, this.dy); this.onactivate(); if (this.fragment) { this.fragment.raiseEvent("cognos.ui.dialog.show", null, null); } this.initTabStops(); }, initTabStops: function(skipFocus) { for (var i=0; i< this.eventHandlers.length;i++) { dojo.disconnect(this.eventHandlers[i]); } if ((this.styles & ui_dialog.style.MODELESS) == 0) { var buttons = ui_dialog.button._styles_[this.styles & 15]; var firstBtn = document.getElementById(this.id + "btn" + buttons[0]); var lastBtn = document.getElementById(this.id + "btn" + buttons[buttons.length-1]); var dialogContainer = document.getElementById(this.id + "content"); tabStops = []; if ((this.styles & ui_dialog.style.READONLY) == 0) { tabStops = ui_getNavigableElements(dialogContainer); this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){ for (var i=0;i 0) { this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){ dojo.stopEvent(e); setTimeout(function(){tabStops[tabIdx].focus()},1); }); } } for (var i=0; i < buttons.length;i++) { tabStops[tabStops.length] = document.getElementById(this.id + "btn" + buttons[i]); } for (var i=0; i < tabStops.length;i++) { tabStops[i].tabIndex=i+1; } if (tabStops.length > 0) { tabIdx = 0; var self = this; this.eventHandlers[this.eventHandlers.length] = dojo.connect(dojo.body(), "onkeypress", function(e){ if (e.charOrCode == dojo.keys.TAB) { if (e.shiftKey) { if (--tabIdx == -1) { dojo.stopEvent(e); tabIdx = tabStops.length-1; } } else if (++tabIdx == tabStops.length) { dojo.stopEvent(e); tabIdx = 0; } setTimeout(function(){tabStops[tabIdx].focus()},1); } else if (e.charOrCode == dojo.keys.ESCAPE){ dojo.stopEvent(e); self.processCommand(ui_dialog.button.CANCEL); } }); if (!skipFocus) { tabStops[0].focus(); } } } }, center: function(dialogX, dialogY, dialogW, dialogH) { if ((this.styles & ui_dialog.style.CENTER) != 0) { dialogX = ((xClientWidth() - dialogW ) / 2); if (dialogX < 0) {dialogX = 0;} dialogY = ((xClientHeight() - dialogH) / 2); if (dialogY < 0) {dialogY = 0;} } else { if (dialogX == -1) { ui_dialog.nextX += 20; if (ui_dialog.nextX > 200) {ui_dialog.nextX = 0;} dialogX = ui_dialog.nextX; } if (dialogY == -1) { ui_dialog.nextY += 20; if (ui_dialog.nextY > 200) {ui_dialog.nextY = 0;} dialogY = ui_dialog.nextY; } } if ((this.styles & ui_dialog.style.MODELESS) == 0) { var locker = ui_locker.get(); locker.show(); } if (this.contentId != null) { var content = $(this.contentId); this.dlg.style.fontSize = xGetComputedStyle(content, "font-size"); this.dlg.style.fontFamily = xGetComputedStyle(content, "font-family"); } this.dlg.style.left = dialogX + "px"; this.dlg.style.top = dialogY + "px"; this.dlg.style.display = ""; if (this.backing) { this.backing.style.left = dialogX + "px"; this.backing.style.top = dialogY + "px"; this.backing.style.display = ""; xResizeTo(this.backing, xWidth(this.dlg), xHeight(this.dlg)); } }, hide: function() { for (var i=0; i< this.eventHandlers.length;i++) { dojo.disconnect(this.eventHandlers[i]); } if (this.dlg != null) { this.dlg.style.display="none"; } if (this.backing) { this.backing.style.display="none"; } if (_F_Array.remove(ui_dialog.chain, this) != null) { var locker = ui_locker.get(); if ((this.styles & ui_dialog.style.MODELESS) == 0) { locker.hide(); } } var currentElement = document.activeElement; if (!ui_isTabNavigable(currentElement)) { if (this.triggerElement != null) { var self = this; setTimeout(function(){self.triggerElement.focus();},500); } } }, onactivate: function(e, tag) { // move this dialog to the end of the chain _F_Array.remove(ui_dialog.chain, this); ui_dialog.chain.push(this); // change Z order var i, l=ui_dialog.chain.length; for (i = 0; i < l; i++) { if (ui_dialog.chain[i].dlg != null) { $(ui_dialog.chain[i].id + "caption").className = "cogstyle-dialog-caption" + ((i < (l - 1)) ? "-inactive" : ""); ui_dialog.chain[i].dlg.style.zIndex = 9999 + (2*i); if (this.backing) { ui_dialog.chain[i].backing.style.zIndex = 9999 + ((2*i)-1); } } } }, onstartmove: function(e, dx, dy) { if (e.xdlg != null) { var _self = e.xdlg; if (_self != null) { var elm = _self.dlg; _self.startX = xPageX(elm); _self.startY = xPageY(elm); _self.lastX = e.xDPX; _self.lastY = e.xDPY; } } }, onmove: function(e, dx, dy) { if (e.xdlg != null) { var _self = e.xdlg; if (_self != null) { var elm = _self.dlg; var nx = _self.startX + (e.xDPX - _self.lastX); var ny = _self.startY + (e.xDPY - _self.lastY); var cx = xClientWidth(); if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;} var cy = xClientHeight(); if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;} var w = xWidth(elm); var h = xHeight(elm); if (nx < 0) {nx = 0;} if (ny < 0) {ny = 0;} if ((nx + w) > cx) {nx = cx - w;} if ((ny + h) > cy) {ny = cy - h;} _self.x = nx; _self.y = ny; xMoveTo(elm, nx, ny); if (_self.backing) { xMoveTo(_self.backing, nx, ny); } } } }, onstartresize: function(e, dx, dy) { if (e.xdlg != null) { var _self = e.xdlg; if (_self != null) { var elm = _self.dlg; } } }, onresize: function(e, dx, dy) { if (e.xdlg != null) { var _self = e.xdlg; if (_self != null) { var elm = $(_self.id + "content"); if ((xWidth(elm) + dx) > _self.minDialogWidth) { xResizeTo(elm, xWidth(elm) + dx, xHeight(elm) + dy); if (_self.backing) { xResizeTo(_self.backing, xWidth(_self.dlg), xHeight(_self.dlg)); } } } } }, onclose: function() { this.hide(); }, oncommand: function(e, tag) { try { if (false == this.processCommand(tag.id.substring((this.id + "btn").length))) { return; } } catch (err) { _F_log("E", err); } if (this.content && this.contentNativeParent) { //Detach the content node from the dialog and re-attach to the native parent this.content.parentNode.removeChild(this.content); this.contentNativeParent.appendChild(this.content); } this.hide(); }, processCommand: function(action) { if (this.fragment) { if ((action == ui_dialog.button.OK) || (action == ui_dialog.button.APPLY) || (action == ui_dialog.button.YES)) { return this.fragment.raiseEvent("cognos.ui.dialog.ok", null, null); } else if ((action == ui_dialog.button.CANCEL) || (action == ui_dialog.button.CLOSEBOX) || (action == ui_dialog.button.CLOSE) || (action == ui_dialog.button.NO)) { return this.fragment.raiseEvent("cognos.ui.dialog.cancel", null, null); } else if ((action == ui_dialog.button.HELPBOX)) { ui_fragment_help(this.fragment); return false; } else { _F_log("E", "Event " + evt.name + " not handled"); return false; } } return true; }, setCaption: function(text) { if (this.dlg != null) { $(this.id + "captiontext").innerHTML = _F_Strings.htmlEncode(text); } else { this.caption = text; } }, setContent: function(content) { this.content = content; if (this.dlg != null) { this.attachContent(content); } }, attachContent: function(content) { this.content = content; var contentParentDiv = $(this.id + "content"); if (contentParentDiv) { if (typeof content == "string") { var tempEl = document.createElement("div"); tempEl.innerHTML = content; contentParentDiv.appendChild(tempEl); } else { this.contentNativeParent = content.parentNode; if (this.contentNativeParent) { this.contentNativeParent.removeChild(content); } contentParentDiv.appendChild(content); content.style.display=''; } } }, getResults: function() { return this.results; } }; /** * ui_locker - creates a full screen DIV to lock events */ function ui_locker() { this.divID = "ui_locker"; this.backingID = "ui_lockerBacking"; var backing = $(this.backingID); if (backing == null) { backing = document.createElement("iframe"); backing.id = this.backingID; backing.name = this.backingID; backing.style.display= "none"; backing.style.position="absolute"; backing.style.backgroundColor="#dddddd"; backing.style.filter="alpha(opacity=0)"; backing.style.opacity="0.0"; backing.style.MozOpacity="0.0"; backing.src = _F_Config.webContent + "/fragments/common/images/space.gif"; backing.setAttribute("role","presentation"); document.body.appendChild(backing); } var div = $(this.divID); if (div == null) { div = document.createElement("DIV"); div.id = this.divID; div.style.display= "none"; div.style.position="absolute"; div.style.backgroundColor="#dddddd"; document.body.appendChild(div); } this.count = 0; } ui_locker.singleton = null; ui_locker.get = function() { if (ui_locker.singleton == null) { ui_locker.singleton = new ui_locker(); } return this.singleton; }; ui_locker.prototype = { show: function(bHidden) { var div = $(this.divID); var backing = $(this.backingID); if ((++this.count) == 1) { div.style.width = "0px"; div.style.height = "0px"; div.style.top = "0px"; div.style.left ="0px"; div.style.display = ""; backing.style.width = "0px"; backing.style.height = "0px"; backing.style.top = "0px"; backing.style.left ="0px"; backing.style.display = ""; if (bHidden && bHidden == true) { div.style.filter="alpha(opacity=0)"; div.style.opacity="0.0"; div.style.MozOpacity="0.0"; } else { div.style.filter="alpha(opacity=50)"; div.style.opacity="0.5"; div.style.MozOpacity="0.5"; } this.onresize(); } if (ui_dialog.chain != null && ui_dialog.chain.length > 0) { // move the glass before this dialog window var w = ui_dialog.chain[ui_dialog.chain.length - 1]; if (w.dlg != null) { w.dlg.parentNode.insertBefore(backing, w.dlg); w.dlg.parentNode.insertBefore(div, w.dlg); } } }, hide: function() { var div = $(this.divID); var backing = $(this.backingID); if (ui_dialog.chain != null && ui_dialog.chain.length > 0) { // move the glass before this dialog window var w = ui_dialog.chain[ui_dialog.chain.length - 1]; if (w.dlg != null) { w.dlg.parentNode.insertBefore(backing, w.dlg); w.dlg.parentNode.insertBefore(div, w.dlg); } } if ((--this.count) == 0) { xDisplay(this.divID, "none"); xDisplay(this.backingID, "none"); } }, isVisible: function() { return (ui_locker.singleton != null) && ("none" != xDisplay(this.divID)); }, onresize: function() { var div = $(this.divID); var backing = $(this.backingID); var cx = xClientWidth(); if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;} var cy = xClientHeight(); if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;} xResizeTo(div, cx, cy); xResizeTo(backing, cx, cy); } }; /** * toolbarButtonMouseOver * @deprecated */ function toolbarButtonMouseOver(e) { e.className = "cogstyle-btn-over"; } /** * toolbarButtonMouseOut * @deprecated */ function toolbarButtonMouseOut(e) { e.className = "cogstyle-btn-normal"; } var ui_curmenu = null; var ui_menuevt = false; /** * ui_menuShow * @param evt * @param menu */ function ui_menuShow(evt, menu) { ui_menuHide(); menu.show(evt); } /** * ui_menuUpdate * @param menu */ function ui_menuUpdate(menu) { menu.rebuild = true; } /** * ui_menuHide */ function ui_menuHide(menu) { if (!menu && ui_curmenu) { menu = ui_curmenu; if (menu.enabled) { menu.enabled = false; var currentElement = document.activeElement; if (!ui_isTabNavigable(currentElement)) { if (menu.originalControlElement != null) { menu.originalControlElement.focus(); } } } } if (menu != null) { if (menu.child) { for (var i in menu.child) { menu.child[i].enabled = false; ui_menuHide(menu.child[i]); } ui_curmenu = null; } if (menu.hide) { menu.hide(); } } } /** * ui_menuHideHook * @param evt */ function ui_menuHideHook(evt) { ui_menuHide(); } /** * ui_menuMouseOver * @param evt */ function ui_menuMouseOver(evt, menu) { evt = evt != null ? evt : window.event; var e = evt.srcElement ? evt.srcElement : evt.target; if (e.tagName == "TD") { e = e.parentNode; //get the TR rather than the TD } if (menu.menudef.items[menu.curitem] && menu.menudef.items[menu.curitem].items != null) { menu.child[menu.curitem].enabled = false; ui_menuHide(menu.child[menu.curitem]); } if (menu != null && menu.curitem !=null) { document.getElementById(menu.menudef.id + "TR" + menu.curitem).className = "cogstyle-menu-item"; menu.curitem = e.id.substring(e.id.lastIndexOf("TR")+2); } e.className = "cogstyle-menu-item-hilite"; e.focus(); } /** * ui_menuMouseOut */ function ui_menuMouseOut(evt) { evt = evt != null ? evt : window.event; var e = evt.srcElement ? evt.srcElement : evt.target; if (e.tagName == "TD") { e = e.parentNode; //get the TR rather than the TD } e.className = "cogstyle-menu-item"; } /** * ui_menu * @param menudef */ function ui_menu(menudef) { this.menu = null; this.backing = null; this.menudef = menudef; this.rebuild = true; this.child = null; this.enabled = false; this.fragment = null; this.curitem = null; this.selectedItem = null; this.originalControlElement = null; } ui_menu.prototype = { build: function() { // Remove the old menu if it already exists and is not this menu // This menu is taken care of later. var oldDiv = $(this.menudef.id + "mainDiv"); if (oldDiv && oldDiv != this.menu) { document.body.removeChild(oldDiv); } var oldBacking = $(this.menudef.id + "backing"); if (oldBacking && oldBacking != this.backing) { document.body.removeChild(oldBacking); } if (ui_menuevt == false) { //Attach global events used by ui_menus. ui_menuevt = true; _F_Document.addEventListener(document.body, "mouseup", ui_menuHideHook); _F_Document.addEventListener(window, "blur", ui_menuHideHook); } if (this.menu != null) { document.body.removeChild(this.menu); this.menu = null; } if (this.backing != null) { document.body.removeChild(this.backing); this.backing = null; } var pad = false; var selected = false; for (var i=0; i xClientHeight()) { y = y - dropDownHeight - e.offsetHeight; } // Add the body scroll position to the calculation y = y + getBodyScrollPosY(); x = x + getBodyScrollPosX(); if (y < 0) { y = 0; } this.menu.style.top = y + "px"; if ((x + this.menu.offsetWidth) > document.body.offsetWidth) { x += e.offsetWidth - this.menu.offsetWidth; } this.menu.style.left = x + "px"; this.backing.style.top = y + "px"; this.backing.style.height = xHeight(this.menu); this.backing.style.left = x + "px"; this.backing.style.width = xWidth(this.menu); this.backing.style.display = "block"; if (!this.menudef.parent) { ui_curmenu = this; this.menu.focus(); } if (this.curitem == null) { this.curitem = 0; } var newElem = document.getElementById(this.menudef.id + "TR" + this.curitem); newElem.className = "cogstyle-menu-item-hilite"; newElem.focus(); /* find iframes in page and hide menu when they are focused. IE does not trigger the window.onmouseup event when you click on an iframe */ for (var iframes = document.getElementsByTagName("iframe"), i = iframes.length; i--;) { if (iframes[i].getAttribute("menu-focus") == null) { _F_Document.addEventListener(iframes[i], "focus", ui_menuHideHook); iframes[i].setAttribute("menu-focus", "set"); } if (iframes[i].getAttribute("title") == null) { iframes[i].setAttribute("role", "presentation"); } } evt.cancelBubble = true; if (evt.stopPropagation) { evt.stopPropagation(); } this.enabled = true; }, hide: function() { if ((!this.enabled) && (this.menu != null)) { this.backing.style.display="none"; this.menu.style.display="none"; if (this.curitem != null) { document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; this.curitem = null; } } }, hideFocusOnControlElement: function(restoreTriggerFocus) { if (this.originalControlElement != null) { if (restoreTriggerFocus) { this.originalControlElement.focus(); } this.currentControlElement = null; } ui_menuHide(); }, findObject: function(evt) { var e=evt.srcElement ? evt.srcElement : evt.target; while (e != null) { if (typeof e.onclick !== "undefined" || typeof e.onmouseover !== "undefined") { return e; } e = e.parentNode; } return e; }, handleTab: function(evt){ this.keyIsUp = true; evt = evt != null ? evt : window.event; if (evt.keyCode == 9){ document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; this.curitem = null; this.hideFocusOnControlElement(true); } }, onkeypress: function(evt) { evt = evt != null ? evt : window.event; var e = evt.srcElement ? evt.srcElement : evt.target; // Enter: Act on the current menu var newElem; if (evt.keyCode == 13) { if (this.keyIsUp) { ui_curmenu.selectMenuItem(this.menudef.items[this.curitem].id); ui_menuHide(evt); if (this.fragment) { this.fragment.raiseEvent("cognos.ui.menu.select", context); } if (this.menudef.items[this.curitem].action) { setTimeout(this.menudef.items[this.curitem].action, 1); } if (this.menudef.items[this.curitem].items) { this.child[this.curitem].show(evt); document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; } else { this.curitem = null; this.hideFocusOnControlElement(); } } this.keyIsUp = false; } // Esc Key: Close menu else if (evt.keyCode == 27) { document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; this.curitem = null; this.hideFocusOnControlElement(true); this.keyIsUp = false; } // Up Arrow else if (evt.keyCode == 38) { if (this.curitem != null) { document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; if (this.curitem > 0) { this.curitem--; } newElem = document.getElementById(this.menudef.id + "TR" + this.curitem); newElem.className = "cogstyle-menu-item-hilite"; newElem.focus(); } } // Down arrow else if (evt.keyCode == 40) { if (this.curitem != null) { document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item"; if (this.menudef.items.length-1 > this.curitem) { this.curitem++; } newElem = document.getElementById(this.menudef.id + "TR" + this.curitem); newElem.className = "cogstyle-menu-item-hilite"; newElem.focus(); } else { this.curitem = 0; newElem = document.getElementById(this.menudef.id + "TR" + this.curitem); newElem.className = "cogstyle-menu-item-hilite"; newElem.focus(); } } //tab key else if (evt.keyCode == 9) { this.hideFocusOnControlElement(true); } xStopPropagation(evt); }, onmouseover: function(e, tag) { ui_menuMouseOver(e, this); this.enabled = true; }, onmouseoverParent: function(e, tag) { ui_menuMouseOver(e, this); this.child[tag.key].show(e != null ? e : window.event); }, onmouseout: function(e, tag) { this.child[tag.key].enabled = false; var self = this; window.setTimeout(function() { ui_menuHide(self.child[tag.key]); }, 100); }, getRootMenuItems: function() { return this.menudef.items; }, getSubMenuItems: function(item) { return item.items; }, getMenuItemAndGroup: function(id, group) { var itemAndGroup = null; var menuItemList; if (group) { menuItemList = group; } else { menuItemList = this.menudef.items; } for (var i=0; i'); } catch (e) { iFrame = null; } } if (iFrame == null) { iFrame = document.createElement("iframe"); } iFrame.id = "UI_MODAL_DIALOG_IFRAME"; iFrame.name = "UI_MODAL_DIALOG_IFRAME"; iFrame.src = _F_Config.webContent + "/fragments/common/images/space.gif"; iFrame.style.width = "100%"; iFrame.style.height = "100%"; iFrame.style.zIndex="9000"; iFrame.style.backgroundColor="white"; iFrame.style.borderRight="solid 1px black"; iFrame.style.borderLeft="solid 1px black"; iFrame.style.borderBottom="solid 1px black"; iFrame.border ="0"; iFrame.style.margin="0px"; iFrame.fragClientWidth = document.body.clientWidth - 80; iFrameDiv.appendChild(iFrame); _F_Document.addEventListener(iFrame,"load", function(event) { ui_modal_dialog.loaded(event);}); _F_Document.addEventListener(window,"resize", function(event) { ui_modal_dialog.resize(event);}); //need to create a dummy element in here so that we can trap the last tab and move the focus back to the top of the dialog var dummyEl2 = document.createElement("p"); dummyEl2.tabIndex = "-1"; dummyEl2.id="UI_MODAL_DIALOG_TABSTOP2"; dummyEl2.style.position="absolute"; iFrameDiv.appendChild(dummyEl2); var dummyEl = document.createElement("p"); dummyEl.tabIndex = "0"; dummyEl.id="UI_MODAL_DIALOG_TABSTOP"; dummyEl.style.position="absolute"; xAddEventListener(dummyEl, "onfocus", this.cycleFocus); iFrameDiv.appendChild(dummyEl); //also need to make sure that you can't back tab out of the dialog xAddEventListener(iFrameDiv, "keypress", this.cycleFocusBack); } //Show or hide the header. var winHeader = document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV"); var content = null; if (contentId != null) { content = $(contentId); winHeader.style.fontSize = xGetComputedStyle(content, "font-size"); } if (modalHideHeader == true) { //Display header winHeader.style.display = ""; } else { winHeader.style.display = "none"; } // Blur page pageBlurDiv.style.width = "100%"; pageBlurDiv.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px"; pageBlurDiv.style.top = "0"; pageBlurDiv.style.left ="0"; pageBlurDiv.style.display = ""; pageBlurBacking.style.width = "100%"; pageBlurBacking.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px"; pageBlurBacking.style.top = "0"; pageBlurBacking.style.left ="0"; pageBlurBacking.style.display = ""; // Show busy var iFrameBusyDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV"); iFrameBusyDiv.style.top =((document.body.clientHeight - 80 )/ 2) + "px"; iFrameBusyDiv.style.left =((document.body.clientWidth - 80 )/ 2) + "px"; if (contentId != null) { iFrameBusyDiv.style.fontSize = xGetComputedStyle(content, "font-size"); } iFrameBusyDiv.style.display=""; // invoke url var iFr = document.getElementById("UI_MODAL_DIALOG_IFRAME"); if (modalForceReload == true) { //Add a timestamp to create a unique URL. This prevents the iFrame from using a cached version of the page. url += (( url.indexOf('?') + 1 ) ? '&' : '?') + ( new Date() ).getTime(); } if (usePost != null && usePost == true) { this.postForm(url); } else { iFr.src = url; } }; ui_modal_dialog.cycleFocusBack = function(event) { if (event.keyCode == 9 && event.shiftKey) { document.getElementById("UI_MODAL_DIALOG_TABSTOP2").focus(); } }; ui_modal_dialog.cycleFocus = function() { document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV").focus(); }; ui_modal_dialog.postForm = function(url) { var formElement = document.createElement("form"); formElement.setAttribute("name","wsrp_rewrite_post_window_form"); formElement.setAttribute("method","POST"); formElement.setAttribute("target", "UI_MODAL_DIALOG_IFRAME"); var action =_F_config.gateway; //default var qm_index = url.indexOf("?"); if (qm_index!=0) { action = (qm_index==-1) ? url : url.substring(0, qm_index); } formElement.setAttribute("action", action); if (qm_index != -1) { var paramString = url.substring(qm_index+1); var params = paramString.split("&"); var i; for (i=0; i < params.length; ++i) { if (params[i].length>0) { var hiddenElement = document.createElement("input"); hiddenElement.setAttribute("type","hidden"); var eq_index = params[i].indexOf("="); if (eq_index != -1) { hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index))); hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1))); } else { hiddenElement.setAttribute("name",unescape(params[i])); hiddenElement.setAttribute("value",""); } formElement.appendChild(hiddenElement); } } } document.body.appendChild(formElement); formElement.submit(); document.body.removeChild(formElement); formElement = null; }; ui_modal_dialog.loaded = function(event) { var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR"); var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING"); var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV"); var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV"); var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME"); var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP"); var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP2"); if (iFrameDiv.style.display == "none" && iFrameBusy.style.display == "" && UI_MODAL_DIALOG_VISIBLE_DIALOG) { iFrameBusy.style.display="none"; iFrameDiv.style.width = (xClientWidth() - 80) + "px"; iFrameDiv.style.height = (xClientHeight() - 80) + "px"; iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px"; iFrameDiv.style.left = "30px"; dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px"; dummyEl.style.left = "30px"; dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px"; dummyEl2.style.left = "30px"; iFrameDiv.style.display = ""; iFrameDiv.focus(); return; } else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG)) { //if the page in the modal dialog is reloaded need to reset the width //for ie (it sometimes makes it a little teenie bit too small) iFrameBusy.style.display="none"; iFrameDiv.style.padding = "1px"; iFrameDiv.style.width = (xClientWidth() - 80) + "px"; iFrameDiv.style.display = ""; iFrameDiv.focus(); return; } }; ui_modal_dialog.resize = function(event) { var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV"); var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME"); var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP"); var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP"); if ( (!xIE4Up) && UI_MODAL_DIALOG_VISIBLE_DIALOG) { iFrameDiv.style.width = (xClientWidth() - 80) + "px"; iFrameDiv.style.height = (xClientHeight() - 80) + "px"; iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px"; iFrameDiv.style.left = "30px"; dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px"; dummyEl.style.left = "30px"; dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px"; dummyEl2.style.left = "30px"; iFrameDiv.style.display = ""; iFrameDiv.focus(); return; } else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG)) { //if the page in the modal dialog is reloaded need to reset the width //for ie (it sometimes makes it a little teenie bit too small) iFrameDiv.style.padding = "1px"; iFrameDiv.style.width = (xClientWidth() - 80) + "px"; iFrameDiv.style.height = (xClientHeight() - 80) + "px"; dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px"; dummyEl.style.left = "30px"; iFrameDiv.style.display = ""; iFrameDiv.focus(); return; } }; ui_modal_dialog.close = function() { UI_MODAL_DIALOG_VISIBLE_DIALOG = false; //Reset the visibility flag var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR"); var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING"); var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV"); var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV"); pageBlurDiv.style.display="none"; pageBlurBacking.style.display="none"; iFrameDiv.style.display="none"; iFrameBusy.style.display = "none"; var currentElement = document.activeElement; if (!ui_isTabNavigable(currentElement)) { if (UI_MODAL_DIALOG_TRIGGER_ELEMENT != null) { UI_MODAL_DIALOG_TRIGGER_ELEMENT.focus(); } } }; /** * getAbsolutePosX * @param e */ function getAbsolutePosX(e) { var xx=0 + e.offsetLeft; var p=e.offsetParent; while(p!=null) { xx+=(0 + p.offsetLeft); p=p.offsetParent; } return xx; } /** * getScrollPosX * @param e */ function getScrollPosX(e) { var xx = 0; var p=e; do { xx += p.scrollLeft || 0; p = p.parentNode; } while (p!=null); return xx; } /** * getBodyScrollPosX * */ function getBodyScrollPosX() { return document.body.scrollLeft; } /** * getAbsolutePosY * @param e */ function getAbsolutePosY(e) { var yy=0 + e.offsetTop; var p=e.offsetParent; while(p!=null) { yy+=(0 + p.offsetTop); p=p.offsetParent; } return yy; } /** * getScrollPosY * @param e */ function getScrollPosY(e) { var yy = 0; var p=e; do { yy += p.scrollTop || 0; p = p.parentNode; } while (p!=null); return yy; } /** * getBodyScrollPosY * */ function getBodyScrollPosY() { return document.body.scrollTop; } /** * EventUtils * @deprecated - use xAddEventListener */ function EventUtils() { throw 'RuntimeException: EventUtils is a static utility class and may not be instantiated'; } /** * addEventListener * @param target * @param type * @param callback * @param captures * @deprecated - use xAddEventListener instead. */ EventUtils.addEventListener = function (target, type, callback, capture) { _F_Document.addEventListener(target, type, callback, capture); }; /** * @deprecated: use _F_Document.associate() */ EventUtils.associate = function (target, obj, methodName) { return function(e) { e = e||window.event; return obj[methodName](e, target); }; }; /** * ui_init - must be called on load of the page */ function ui_init() { _F_Document.addEventListener(window, "resize", ui_onresize, true); fragment.prototype.onerror = function(msg, details, code) { if (this.error===undefined) { this.error = new ui_error(this.id, this.div); } this.error.setCode(code); this.error.setMessage(msg); this.error.setDetails(details); this.error.show(); }; fragment.prototype.clearerror = function() { if (this.error != null) { this.error.hide(); } }; if (window.pageInit) { pageInit(); } ui_templates.preload(); } /** * ui_onresize - handle the resizing event */ function ui_onresize(evt) { ui_menuHideHook(evt); var locker = ui_locker.get(); if (locker.isVisible()) { locker.onresize(); } } /** * ui_calcAvailableHeight - calculate how much height an HTML element can take * to maximize itself. * @param e the HTML DOM element */ function ui_calcAvailableHeight(e,p,n) { var y = 0, ey; var l = e; var ly = xHeight(l); while (e) { if (xDef(e.offsetHeight)) { ey = xHeight(e); y += (ey - ly); ly = ey; } else { ly = 0; } l = e; e = xParent(e, n); if (e != null && e === p) { if (document.body === p) { y += xOffsetTop(l); } e = l = null; } } y += xOffsetTop(l); return y; } /** * ui_calcMaximumHeight - calculates the height such that it takes up all browser height starting at 'e' */ function ui_calcMaximumHeight(e, p, n) { var y = 0; while (e) { y += xOffsetTop(e); e = e.offsetParent; if (e == p) { break; } } return xClientHeight() - y; } /** * readjustParentHeight - readjusts the height of the parents to elinimate scrollbars */ function readjustParentHeight(thisnodeid) { var t = document.getElementById(thisnodeid); while (t) { var parent = t.parentNode; if (parent) { if (parent.className == "cogstyle-htabs-page-content-fixed" || parent.className == "cogstyle-vtabs-page-content-fixed") { parent.style.height = "100%"; } } t = parent; } } /** * ui_calcAvailableWidth - calculate how much width an HTML element can take * to maximize itself. * @param e the HTML DOM element */ function ui_calcAvailableWidth(e,p,n) { var x = 0, ex; var l = e; var lx = xWidth(l); while (e) { if (xDef(e.offsetWidth)) { ex = xWidth(e); x += (ex - lx); lx = ex; } else { lx = 0; } l = e; e = xParent(e,n); if (e != null && e === p) { e = l = null; } } x += xOffsetLeft(l); return x; } // FIXME! Delete this function noop() { } function handleLogon(href, frag) { if (frag.mode == "edit") { alert(PFM.JS.IDS_JS_TIMEOUT_SETTINGS_LOST); } var href = window.location.href; var params = href.split("CAMNamespace="); if (params.length > 1) { var CAMNamespaceValue; var index = params[1].indexOf("&"); if (index != -1) { CAMNamespaceValue = params[1].substring(0, index); } else { CAMNamespaceValue = params[1]; } window.location.href = _F_Config.gateway + "?CAMNamespace=" + CAMNamespaceValue + "&b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href); } else { window.location.href = _F_Config.gateway + "?b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href); } } /** * ui_throbbers * @param id */ function ui_throbbers(id, imgSrc) { this.id = id; this.throbberURI = imgSrc; // preload image new Image().src = imgSrc; } ui_throbbers.prototype = { map: {}, getTabFragment: function(frag) { while (frag && frag.parent.id != this.id) { frag = frag.parent; } return frag; }, throb: function(id, bStart) { var img = $(id); if (img) { var item = this.map[id]; if (bStart) { if (item && item.count > 0) { item.count++; } else { this.map[id] = { count: 1, src: img.src }; img.src = this.throbberURI; } } else { if (item && item.count > 0) { item.count--; if (item.count == 0) { img.src = item.src; delete this.map[id]; } } } if (img.getAttribute("parent")) { this.throb(img.getAttribute("parent"), bStart); } } }, reset: function() { for (var id in this.map) { var item = this.map[id]; if (item) { if (item.count > 0) { var img = $(id); if (img) { img.src = item.src; } delete this.map[id]; } } } }, handler: function(evt) { var frag = this.getTabFragment(evt.target); if (frag) { this.throb(frag.id + "_throbber", evt.name == "fragment.retrieve.before"); } } }; // Helper methods used to determine the viewer height when displaying various Objects var ui_resizeHelper = { // Set a default height when the content uses an iframe with 100% height adjustHeightForFragmentContent: function(fragment, container, objectType, height) { if (container) { if (ui_resizeHelper.isIFrameBasedContent(objectType)) { var frame = ui_resizeHelper.getFirstVisibleIFrame(container); if (frame && (frame.height == "100%" || frame.style.height == "100%")) { var heightInPX = "365px"; if (height > 0) { heightInPX = height + "px"; } window.setTimeout(function() { container.originalHeight = container.style.height; container.style.height = heightInPX; }, 1); return; } } // Make sure to restore the original height, if any, when no resizing is required. if (container.originalHeight !== undefined){ container.style.height = container.originalHeight ; delete container.originalHeight; } } }, //Returns the first visible iframe getFirstVisibleIFrame: function(container) { var frame = null; if (container) { var nodeList = container.getElementsByTagName("iframe"); for (var i = 0; i < nodeList.length; i++) { if (nodeList[i].style.display != "none") { frame = nodeList[i]; break; } } } return frame; }, // Check if the type of the object that is being viewed might return an iframe based content.\ isIFrameBasedContent: function(type) { var iFrameBasedContent = ['query', 'analysis', 'report', 'reportView', 'output', 'powerPlayReport', 'powerPlay8Report', 'powerPlay8ReportView', 'powerPlayCube', 'document', 'documentContent', 'URL', 'dashboard']; return (_F_Array.indexOf(iFrameBasedContent, type) != -1); } }; /** * ui_getNavigableElements - return an ordererd list of child tab stops for a given parent element * @param containerElement * @returns array of ordered tabstops */ function ui_getNavigableElements(containerElement) { var tabStops = []; if (window.dojo) { var zeroTabStops = []; dojo.query("*", containerElement).forEach( function(ele) { if (ui_isTabNavigable(ele)) { if (ele.tabIndex == 0) { zeroTabStops[zeroTabStops.length] = ele; } else { tabStops[tabStops.length] = ele; } } }); tabStops.sort(function(obj1, obj2) { return obj1.tabIndex - obj2.tabIndex; }); tabStops = tabStops.concat(zeroTabStops); } return tabStops; } /** * ui_setFocus - set focus to the 1st focusable child tab stop for a given parent element * @param containerElement * @returns element with focus or null */ function ui_setFocus(containerElement) { var tabStops = ui_getNavigableElements(containerElement); for (var i=0; i < tabStops.length;i++) { tabStops[i].focus(); if (document.activeElement == tabStops[i]) { return tabStops[i]; } } return null; } function ui_isTabNavigable(ele) { if (ele) { try { return (dijit.isTabNavigable(ele) && (!ele.disabled)); } catch (e) { return false; } } return false; }