123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- 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;
- }
-
-
- 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;
- }
-
-
- 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 = "";
- }
|