// Licensed Materials - Property of IBM // // IBM Cognos Products: pps // // (C) Copyright IBM Corp. 2005, 2017 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. var COMBO_BOX_FLYOUT_SCROLL_PADDING = 30; var comboBoxes = new Array(); function initComboBox(container) { comboBoxes[container.id] = new comboBox(container); return comboBoxes[container.id]; } function displayCBOptions(event) { var eventM = new eventManager(event); eventM.cancelBubble(); var caller = eventM.getSrc().parentNode.parentNode.parentNode.parentNode; comboBoxes[caller.id].displayDropDown(); } function cbTextItem(text, action, isDefault) { this.text = text; this.action = action; this.itemType = "textItem"; this.isDefault = isDefault; } function cbTextImageItem(text, image, action, isDefault) { this.text = text; this.image = image; this.action = action; this.itemType = "textImageItem"; this.isDefault = isDefault; } function cbImageTextItem(text, image, action, isDefault) { this.text = text; this.image = image; this.action = action; this.itemType = "imageTextItem"; this.isDefault = isDefault; } function cbRepeatingImageItem(image, action, isDefault) { this.image = image; this.action = action; this.itemType = "repeatingImageItem"; this.isDefault = isDefault; } function comboBox(container) { this.container = container; var selectedItem = -1; this.getSelectedItem = function() { return selectedItem; } var items = new Array(); var flyout; this.addItem = function(item) { items[items.length] = item; if (item.isDefault || items.length == 1) setSelectedItem(items.length - 1); } this.getItem = function(item) { return items[item]; } this.numItems = function() { return items.length; } this.clearItems = function() { items = new Array(); selectedItem = -1; } function setSelectedItem(idx) { var text = container.firstChild.firstChild.firstChild; while(text.firstChild) text.removeChild(text.lastChild); createFlyoutItemContent(text, items[idx]); selectedItem = idx; } this.setSelectedItem = setSelectedItem; this.numItems = function() { return items.length; } this.displayDropDown = function() { if (selectedItem == -1) setSelectedItem(0); if (flyout != null) { document.body.removeChild(flyout); flyout = null; } flyout = document.createElement("DIV"); if (items.length <= 5) flyout.className = "comboBoxDropDown"; else flyout.className = "comboBoxDropDownLimited"; flyout.style.top = getPageOffsetTop(container) + container.offsetHeight; flyout.style.left = getPageOffsetLeft(container); flyout.style.width = container.offsetWidth; for (var i = 0; i < items.length; i++) populateFlyoutItem(i); document.body.appendChild(flyout); window.setTimeout("comboBoxes[\"" + container.id + "\"].sizeDropDown();",1); } this.sizeDropDown = function() { if (flyout.scrollWidth > flyout.offsetWidth) { flyout.style.width = flyout.scrollWidth + COMBO_BOX_FLYOUT_SCROLL_PADDING; } } function populateFlyoutItem(idx) { var fItem = document.createElement("DIV"); fItem.className = "comboBoxItem"; fItem.onmouseover = function() { this.className = "comboBoxItemOver"; } fItem.onmouseout = function() { this.className = "comboBoxItem"; } fItem.onclick = function() { setSelectedItem(idx); hideDropDown(); if (items[idx].action) eval(items[idx].action); } createFlyoutItemContent(fItem, items[idx]); flyout.appendChild(fItem); } function createFlyoutItemContent(cont, item) { if (item.itemType == "textItem") { cont.appendChild(document.createTextNode(item.text)); } else if (item.itemType == "textImageItem") { cont.appendChild(document.createTextNode(item.text + " (")); insertIMGNode(cont, item.image, "comboBoxItemImg", [new attrib("width","16"),new attrib("height","16")]); cont.appendChild(document.createTextNode(")")); } else if (item.itemType == "imageTextItem") { insertIMGNode(cont, item.image, "comboBoxItemImg", [new attrib("width","16"),new attrib("height","16")]); cont.appendChild(document.createTextNode(" " + item.text)); } else if (item.itemType == "repeatingImageItem") { insertIMGNode(cont, item.image, "comboBoxItemImg", [new attrib("height","16")]); } } function hideDropDown() { if (flyout != null) { for (var i = flyout.childNodes.length - 1; i >= 0; i--) { if (flyout.childNodes[i].onmouseover) flyout.childNodes[i].onmouseover = null; if (flyout.childNodes[i].onmouseout) flyout.childNodes[i].onmouseout = null; if (flyout.childNodes[i].onclick) flyout.childNodes[i].onclick = null; } document.body.removeChild(flyout); flyout = null; } } this.hideDropDown = function () {hideDropDown();} } function getPageOffsetLeft(obj) { var left = obj.offsetLeft; var oParent = obj.offsetParent; while (oParent) { left += oParent.offsetLeft; oParent = oParent.offsetParent; } //Now we have to remove any scrolling var scrollLeft = 0; oParent = obj; while (oParent && !oParent.body) { scrollLeft += oParent.scrollLeft; oParent = oParent.parentNode; } return left - scrollLeft; } function getPageOffsetTop(obj) { var top = obj.offsetTop; var oParent = obj.offsetParent; while (oParent) { top += oParent.offsetTop; oParent = oParent.offsetParent; } //Now we have to remove any scrolling var scrollTop = 0; oParent = obj; while (oParent && !oParent.body) { scrollTop += oParent.scrollTop; oParent = oParent.parentNode; } return top - scrollTop; } function hideChartDropdowns(event) { if (comboBoxRows) comboBoxRows.hideDropDown(); if (comboBoxColumns) comboBoxColumns.hideDropDown(); } function changeChartView() { var form = topparent.getXtabFrame().document.fhidden; var target = form.target; form.target = "Chart"; var command = ""; if (comboBoxRows && comboBoxRows.getSelectedItem() >= 0) command = 'RS:"' + CEncodingUtil.EncodeStrOperand(summaryRowCats[comboBoxRows.getSelectedItem()]) + '"'; if (comboBoxColumns && comboBoxColumns.getSelectedItem() >= 0) { if (command.length > 0) command += '\t\t'; command += 'RT:"' + CEncodingUtil.EncodeStrOperand(summaryColCats[comboBoxColumns.getSelectedItem()]) + '"'; } form.CO.value = command; form.RA.value = 999; form.CNCT.value = 20; parseAndSubmit(form); form.target = target; form.CO.value = ""; }