home *** CD-ROM | disk | FTP | other *** search
Wrap
/* * tab.js * * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved * * Tab functions */ // utils.js must have been previously included // Calculate the correct selector height for this platform. function calcSelectorHeight() { var h=screen.availHeight; // AIX (or maybe Dogbert for AIX) has trouble showing a window // greater than 1000 pixels high. No, I don't know why 1000. // -- francis. if ( (h>1000) && (navigator.platform.indexOf('AIX4')==0) ) h=1000; return h; } var selectorVisible = 0; var selectorWidth = 200; var selectorHeight = calcSelectorHeight(); var tabVPos = screen.availHeight - 250; var tabWidth = 20; var animateSteps = 200; var selectorTab = this; var splashScreen = null; var drawer = null; var selectorDock; var focusToggle = 0; var componentVersion = "unknown"; var componentName = "Netscape Netcaster"; // This window is already open, we just need to get a handle to it. function ShowSplash() { splashScreen = window.open('ncsplash.htm', 'Netcaster_Splash','top=100,width=450,height=150,hotkeys=no'); } function setSplashText(textIndex) { if ((splashScreen != null) && (splashScreen.closed == false)) { if (splashScreen.changeSplashText) { splashScreen.changeSplashText(textIndex); } } } function removeSplash() { if ((splashScreen != null) && (splashScreen.closed == false)) { splashScreen.close(); splashScreen = null; } } /********************************************************************** * PositionSelector * * positionSelector moves the selector tab and drawer depending on the * available screen size and docking preference(s). * */ function PositionSelector() { selectorDock = GetNetscapePref("netcaster.drawer.dock", "right", false); if (selectorDock == "left") { // if the container is open, move it first if (drawer != null) { if (selectorVisible) { SecureMoveWindow(drawer, screen.availLeft, screen.availTop); } else { SecureMoveWindow(drawer, screen.availLeft-selectorWidth, screen.availTop); } } if (selectorTab != null) { tabVPos = GetNetscapePref("netcaster.tabPosition", tabVPos, false); // make sure that the arrow is showing the right directionality if (selectorVisible) { SecureMoveWindow(selectorTab, screen.availLeft + selectorWidth, tabVPos); document.layers["right"].visibility = "hide"; document.layers["left"].visibility = "show"; } else { SecureMoveWindow(selectorTab, screen.availLeft, tabVPos); document.layers["right"].visibility = "show"; document.layers["left"].visibility = "hide"; } } } else { // the default is right var selectorPos = screen.availLeft + screen.availWidth - selectorWidth; if (drawer != null) { if (selectorVisible) { SecureMoveWindow(drawer, selectorPos, screen.availTop); } else { var availRight = screen.availLeft + screen.availWidth SecureMoveWindow(drawer, availRight, screen.availTop); } } if (selectorTab != null) { tabVPos = GetNetscapePref("netcaster.tabPosition", tabVPos, false); // make sure that the arrow is showing the right directionality if (selectorVisible) { SecureMoveWindow(selectorTab, selectorPos - tabWidth, tabVPos); document.layers["right"].visibility = "show"; document.layers["left"].visibility = "hide"; } else { SecureMoveWindow(selectorTab, screen.availLeft + screen.availWidth - tabWidth, tabVPos); document.layers["right"].visibility = "hide"; document.layers["left"].visibility = "show"; } } } // then, resize the drawer if (drawer != null) { selectorHeight = calcSelectorHeight(); drawer.resizeTo(selectorWidth, selectorHeight, true); } return; } /********************************************************************** * CreateSelector * * The selector gets created offscreen initially, then moved by PositionSelector(); * * Only one selector can be active at a time, so if another one exits, there's something * wrong. Rather than simply trust the other one (which might be a spoof), we explicitly * close the other one, then create our own. Therefore, THIS FUNCTION MUST BE CALLED * EXACTLY ONCE DURING THE EXECUTION OF THE PROGRAM * */ function CreateSelector() { setSplashText(2); // Yes, the enablePrivilege below asks for far more than it needs, but we want // the user to accept the Netcaster privilege now so we have all of the // component pieces which the macro target references later on. netscape.security.PrivilegeManager.enablePrivilege("Netcaster"); var loadImages = GetNetscapePrefBool("general.always_load_images", true, false); if (!loadImages) { if (!confirm("Because Netcaster and Netcaster channels are graphically intensive, Netscape recommends you " + "leave checked the Automatically Load Images item in the Advanced preferences pane. If you continue " + "without doing so, Netcaster will load, but some graphical elements may be missing or incomplete. Continue?")) { components["netcaster"].forceCloseNetcaster(); return false; } } if (drawer != null) { drawer.close(); } var options = "left=-15000,top=-15000,width="+selectorWidth+",height="+selectorHeight+",titlebar=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,dependent=yes,hotkeys=no"; if ("true" == GetNetscapePref("netcaster.alwaysTop", "true", false)) { options = options + ',alwaysRaised=yes,z-lock=yes' } drawer = SecureWindowOpen(self,'netcast.htm', 'Netscape_Netcaster_Drawer', options); return true; } /********************************************************************** * ToggleSelector, ShowSelector, HideSelector * * The selector gets created offscreen initially, then moved by PositionSelector(); * * Only one selector can be active at a time, so if another one exits, there's something * wrong. Rather than simply trust the other one (which might be a spoof), we explicitly * close the other one, then create our own. Therefore, THIS FUNCTION MUST BE CALLED * EXACTLY ONCE DURING THE EXECUTION OF THE PROGRAM * */ /* Functions that toggle the state of the drawer */ function ToggleSelector() { if (selectorVisible == 0) { ShowSelector(); } else { if (focusToggle == 0) HideSelector(); else focusToggle = 0; } } function ShowSelector() { if (selectorVisible) { return; } if (selectorDock == "left") { if (drawer != null) { for (i = (screen.availLeft - selectorWidth); i < screen.availLeft; i += animateSteps) { SecureMoveWindow(drawer, i, screen.availTop); } SecureMoveWindow(drawer, screen.availLeft, screen.availTop); } SecureMoveWindow(selectorTab, screen.availLeft + selectorWidth, tabVPos); document.layers["right"].visibility = "show"; document.layers["left"].visibility = "hide"; } else { /* if (selectorDock == "right") */ var availRight = screen.availLeft + screen.availWidth var selectorPos = availRight - selectorWidth; if (drawer != null) { for (i = availRight; i > selectorPos; i -= animateSteps) { SecureMoveWindow(drawer, i, screen.availTop); } SecureMoveWindow(drawer, selectorPos, screen.availTop); } SecureMoveWindow(selectorTab, selectorPos - tabWidth, tabVPos); document.layers["right"].visibility = "hide"; document.layers["left"].visibility = "show"; } selectorVisible = 1; } function HideSelector() { if (selectorVisible == 0) return; if (drawer.fullyLoaded == 1) { drawer.selector.hideMenu(); } if (selectorDock == "left") { SecureMoveWindow(selectorTab, screen.availLeft, tabVPos); if (drawer != null) { for (i = screen.availLeft; i > screen.availLeft-selectorWidth; i -= animateSteps) SecureMoveWindow(drawer, i, screen.availTop); SecureMoveWindow(drawer, screen.availLeft-selectorWidth, screen.availTop); } document.layers["right"].visibility = "hide"; document.layers["left"].visibility = "show"; } else { /* if (selectorDock == "right") */ var availRight = screen.availLeft + screen.availWidth var selectorPos = availRight - selectorWidth; SecureMoveWindow(selectorTab, availRight - tabWidth, tabVPos); if (drawer != null) { for (i = (availRight - selectorWidth); i < availRight; i += animateSteps) SecureMoveWindow(drawer, i, screen.availTop); SecureMoveWindow(drawer, availRight, screen.availTop); } document.layers["right"].visibility = "show"; document.layers["left"].visibility = "hide"; } selectorVisible = 0; } function FocusTimeout() { //The only real way we can differentiate between a focus event //due to switching tasks to the window and clicking on the window //is whether the focus event is followed quickly by a click. focusToggle = 0; } /* Slide selector out when tab window gains focus */ function onfocus() { if ( (drawer != null && selectorVisible == 0) && ((drawer.fullyLoaded == 1) && (drawer.titlebar.getFinishedLoading() == 1))) { ShowSelector(); // Bool to indicate if window toggle was by focus event to prevent // second toggle command from click event. focusToggle = 1; } setTimeout(FocusTimeout, 500); } /* This is the global quit us method */ function closeNetCast() { removeSplash(); netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); // nettop.close(); drawer.close(); selectorTab.close(); } function forceCloseNetcaster() { removeSplash(); if (drawer) { drawer.close(); } if (selectorTab) { selectorTab.close(); } } function closeNetCast() { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); drawer.close(); selectorTab.close(); } // These functions are called from public APIs function getChannelObject() { return new ChannelObject(); } function addChannel(chanObj) { drawer.titlebar.document.demo.AddChannel(chanObj); } function addInfoblock(infoblockObj) { drawer.titlebar.document.demo.AddInfoblock(infoblockObj); } function setVersion() { componentVersion = drawer.titlebar.document.demo.getNetcasterVersion(); } // Compatibility functions var GetChannelObject = getChannelObject; var AddChannelObject = addChannel; export GetChannelObject; export getChannelObject; export AddChannelObject; export addChannel; export addInfoblock; export componentVersion; export componentName; // Perform all initial operations which do not require us to be fully loaded. compromisePrincipals(); window.onMouseDown = SupressRightMouse; window.onerror = SupressError; window.onDragDrop = SupressDrag; window.captureEvents(Event.MOUSEDOWN | Event.ERROR | Event.DRAGDROP); // The last thing we do is to create the selector ShowSplash(); if (CreateSelector()) { PositionSelector(); } void(0);