123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: ps
- //
- // (C) Copyright IBM Corp. 2005, 2014
- //
- // 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).
- function obj(sName) {
- return document.getElementById(sName);
- }
- var g_oTabWindow = document.getElementById('tabWindow');
- var g_oTabs = document.getElementById('tabs');
- var g_oBody = document.getElementsByTagName('body')[0];
- var g_sDirection = "";
- var oInterval = null;
- var g_bEndScroll = false;
- var g_iIncrument = null;
- var g_iDefualtIncrument = 5;
- var g_scrollDisabled = false;
-
- function tabControlMouseOver(obj) {
- if (obj.className != 'tabScrollButtonDisabled') {
- obj.className = 'tabScrollButtonOver';
- }
- }
- function tabControlMouseOut(obj) {
- if (obj.className != 'tabScrollButtonDisabled') {
- obj.className = 'tabScrollButton';
- }
- }
- function tabControlDisable() {
- obj('tabControlRight').src = g_sImageRoot + "action_scroll_right_disabled.gif";
- obj('tabControlRightContainer').className = 'tabScrollButtonDisabled';
- obj('tabControlLeft').src = g_sImageRoot + "action_scroll_left_disabled.gif";
- obj('tabControlLeftContainer').className = 'tabScrollButtonDisabled';
- g_scrollDisabled = true;
- }
- function tabControlEnable() {
- obj('tabControlRight').src = g_sImageRoot + "action_scroll_right.gif";
- obj('tabControlRightContainer').className = 'tabScrollButton';
- obj('tabControlLeft').src = g_sImageRoot + "action_scroll_left.gif";
- obj('tabControlLeftContainer').className = 'tabScrollButton';
- g_scrollDisabled = false;
- }
- function tabControlDBLClick(sDirection, evt) {
- var e = (evt) ? evt : (event) ? event : null;
- if (g_scrollDisabled) {
- return;
- }
- window.clearInterval(oInterval);
- oInterval = "";
- var inc = (e.shiftKey) ? (g_iDefualtIncrument * 2) : g_iDefualtIncrument;
- scrollTab(sDirection, inc, e.ctrlKey);
- }
-
- function tabControlPress(sDirection, evt) {
- var e = (evt) ? evt : (event) ? event : null;
- if (g_scrollDisabled || e === null) {
- return;
- }
- g_sDirection = sDirection;
- g_bEndScroll = e.ctrlKey;
- g_iIncrument = (e.shiftKey) ? (g_iDefualtIncrument * 2) : g_iDefualtIncrument;
- oInterval = window.setInterval("scrollTab(g_sDirection,g_iIncrument,g_bEndScroll);", 10);
- return true;
- }
- function tabControlRelease() {
- window.clearInterval(oInterval);
- oInterval = "";
- }
- function scrollTab(sDirection, iIncrument, bEnd) {
- var iMaxScroll = g_oTabs.clientWidth - g_oTabWindow.clientWidth;
- if (iMaxScroll < 0) {
- iMaxScroll = 0;
- }
-
- var iScrollIncrument = (iIncrument > 0) ? iIncrument : g_iDefualtIncrument;
- if (bEnd) {
- iScrollIncrument = iMaxScroll;
- }
- var iScrollWidth = 0;
- var iAvailableScroll;
-
- if (sDirection == 'right') {
- iAvailableScroll = iMaxScroll - g_oTabWindow.scrollLeft;
- if (iAvailableScroll <= iScrollIncrument) {
- iScrollWidth = iAvailableScroll;
- } else {
- iScrollWidth = iScrollIncrument;
- }
- } else {
- iAvailableScroll = g_oTabWindow.scrollLeft;
- if (iAvailableScroll <= iScrollIncrument) {
- iScrollWidth = iAvailableScroll;
- } else {
- iScrollWidth = iScrollIncrument;
- }
-
- iScrollWidth = -(iScrollWidth);
- }
- g_oTabWindow.scrollLeft = g_oTabWindow.scrollLeft + iScrollWidth;
- }
- function tabEvalScroll() {
- var bodySize = g_oBody.offsetWidth -48;
- var style = "overflow:hidden;width:" + bodySize + "px";
- g_oTabWindow.setAttribute("style",style);
-
- var iMaxScroll = g_oTabs.clientWidth - g_oTabWindow.clientWidth;
-
- if (iMaxScroll > 0) {
- tabControlEnable();
- } else {
- tabControlDisable();
- }
- }
- function tabControlInitialize() {
- g_oBody.setAttribute("onresize","tabEvalScroll()");
- var oSelectedTab = document.getElementById('selectedTab');
- tabEvalScroll();
- if (oSelectedTab) {
- // Scroll to the selected tab
- var iSTWidth = oSelectedTab.offsetWidth;
- var iSTLeft = oSelectedTab.offsetLeft;
- var iTWWidth = g_oTabWindow.offsetWidth;
- var iLeftScrollOffset = (iTWWidth - iSTWidth) / 2;
- var iScroll = iSTLeft - iLeftScrollOffset;
-
- if ((iSTWidth + iSTLeft) > iTWWidth) {
- scrollTab('right', iScroll, false);
- }
- }
- }
- function tabControlResize() {}
|