home *** CD-ROM | disk | FTP | other *** search
- // (c) Copyright 1997 Netscape Communications, Corp.
-
- var gNumLayers = document.layers.length;
- var layerLevel = null;
- var statusLocked = false;
- var enablePopups = 0;
- var propID = null;
-
- var expandedLayer = null;
- var numContainers = 0;
- var currentHeight = 0;
-
- var currentItem = null;
-
- var newWorld = 1;
-
- function onload()
- {
- var startup=1;
-
- new LayerManager(window);
-
- captureEvents (Event.CLICK);
- window.onClick = itemPopupMenu;
-
- depth.onmousedown = itemPopupMenu;
- }
-
- function onblur()
- {
- hideMenu();
- }
-
- function finishLoading()
- {
- var ready = parent.titlebar.document.demo.isSelectorReady();
-
- if (!ready) {
- setTimeout(finishLoading, 750);
- return;
- }
-
- var lastOpened = "" + depth.GetNetscapePref("netcaster.drawer.lastOpen", "finder", false);
-
- toggleContainer(lastOpened);
-
-
- }
-
- function setFocusedItem(dataItem)
- {
- currentItem = dataItem;
- }
-
- function layerLoaded(layerObj, parameter)
- {
- layerObj.fontFace = "arial,geneva,helvetica";
- layerObj.fontSize = "+0";
- layerObj.y = currentHeight;
- layerObj.type = parameter.getType();
- layerObj.itemName = parameter.getItemName();
- layerObj.descName = parameter.getDescription();
- layerObj.url = parameter.getURL();
- layerObj.dataItem = parameter;
- layerObj.clip.height = 30;
- layerObj.clip.width = 200;
-
- parameter.setItemView(layerObj);
-
- currentHeight += 30;
- layerObj.visibility = "show";
-
- }
-
- function createCategoryLayer(dataItem)
- {
- var newLoadObj = new LayerLoadObject(null, "headtmpl.htm",
- window, this, dataItem, false);
-
- window.layerManager.layerLoad(newLoadObj);
- window.numContainers++;
-
- return;
- }
-
- function contextCreateItemLayer(dataItem)
- {
- setTimeout(createItemLayer, 10, dataItem);
- }
-
- function createItemLayer(dataItem)
- {
- var itemParent = dataItem.getParent();
- var parentLayer = itemParent.getItemView();
-
- if (!parentLayer || (parentLayer == null) || parentLayer.container == null) {
- setTimeout(createItemLayer, 200, dataItem);
- return;
- }
-
- var newLoadObj = new LayerLoadObject(null, "itemtmpl.htm",
- parentLayer.container, parentLayer.container, dataItem, false);
-
- window.layerManager.layerLoad(newLoadObj);
-
- parentLayer.container.itemCount++;
- return;
- }
-
- function createPageLayer(dataItem, url)
- {
- var itemParent = dataItem.getParent();
- var parentLayer = itemParent.getItemView();
-
- if (!parentLayer || (parentLayer == null) || parentLayer.container == null) {
- setTimeout(createPageLayer, 200, dataItem, url);
- return;
- }
-
- var newLoadObj = new LayerLoadObject(null, url,
- parentLayer.container, parentLayer.container, dataItem, true);
-
- window.layerManager.layerLoad(newLoadObj);
-
- parentLayer.container.itemCount++;
- return;
- }
-
- function refreshItemLayer(dataItem, layer)
- {
- layer.type = dataItem.getType();
- layer.itemName = dataItem.getItemName();
- layer.descName = dataItem.getDescription();
- layer.url = dataItem.getURL();
-
- layer.refreshChannelInfo();
- }
-
-
-
- function contextDeleteItemLayer(dataItem, layer)
- {
- setTimeout(deleteItemLayer, 10, dataItem, layer);
- }
-
- function deleteItemLayer(dataItem, layer)
- {
- var itemHeight = 30;
- var parentArray = layer.parentLayer.document.layers;
-
- layer.visibility = "hide";
-
- for (var i=0; i < parentArray.length; i++) {
- if (parentArray[i].top > layer.top) {
-
- parentArray[i].top -= itemHeight;
- }
- }
-
- layer.parentLayer.topPos -= itemHeight;
- }
-
- function openWebtopURL(siteURL, dataItem)
- {
- parent.titlebar.OpenWebtop(siteURL, dataItem, true);
- }
-
- function openSiteURL(fullscreen, siteURL)
- {
- parent.titlebar.OpenSite(fullscreen, siteURL, true);
- }
-
- function openCastanetURL(siteURL)
- {
- parent.titlebar.document.demo.openCastanetURL(siteURL);
- }
-
- function toggleContainer(containerName)
- {
- var container = null;
- var containerLayer = null;
-
- if (containerName == null || containerName == "")
- return;
-
- container = parent.titlebar.document.demo.findContainerByName(containerName)
- if (container != null) {
- containerLayer = container.getItemView()
- }
-
- if (containerLayer == null) {
- return;
- }
-
- var parentArray = containerLayer.parentLayer.document.layers;
-
- if (expandedLayer == null) {
- expandedLayer = containerLayer;
- expandedLayer.clip.height = containerGetHeight() + 30;
- expandedLayer.showContainer();
-
- for (var i=0; i < parentArray.length; i++) {
- if (parentArray[i].top > expandedLayer.top) {
- parentArray[i].top += containerGetHeight();
- }
-
- if (parentArray[i] != expandedLayer) {
- parentArray[i].clip.bottom = 30;
- }
- }
- }
-
- else if (expandedLayer.top < containerLayer.top) {
- var moveArray = new Array();
- var itemCount = 0;
-
- for (var i=0; i < parentArray.length; i++) {
- if ((parentArray[i].top > expandedLayer.top) &&
- (parentArray[i].top <= containerLayer.top)) {
- moveArray[itemCount++] = parentArray[i];
- }
- }
-
- repositionContainers(-250, moveArray, expandedLayer, 30, containerLayer);
-
- expandedLayer.hiding();
- expandedLayer = containerLayer;
- containerLayer.showing();
- }
-
- else if (expandedLayer.top > containerLayer.top) {
- var moveArray = new Array;
- var itemCount = 0;
- var parentArray = containerLayer.parentLayer.document.layers;
-
- for (var i=0; i < parentArray.length; i++) {
- if ((parentArray[i].top > containerLayer.top) &&
- (parentArray[i].top <= expandedLayer.top)) {
- moveArray[itemCount++] = parentArray[i];
- }
- }
-
- var newBottom = containerGetHeight() + 30;
- repositionContainers(250, moveArray, containerLayer, newBottom, expandedLayer);
-
- expandedLayer.hiding();
- expandedLayer = containerLayer;
- containerLayer.showing();
- }
-
- }
-
- function repositionContainers(delta, moveArray, sourceLayer, sourceClip, destLayer)
- {
- var bottom = sourceLayer.clip.height;
-
- if (((delta > 0) && (bottom < sourceClip)) ||
- ((delta < 0) && (bottom > sourceClip))) {
-
- var pinnedDelta = Math.abs(bottom - sourceClip);
-
- if (Math.abs(delta) > pinnedDelta) {
-
- if (delta < 0) {
- pinnedDelta *= -1;
- }
-
- delta = pinnedDelta;
- }
-
-
- for (var i=0; i < moveArray.length; i++) {
- moveArray[i].top += delta;
- }
-
- if (delta < 0) {
- sourceLayer.clip.height += delta;
- } else {
- sourceLayer.clip.bottom += delta;
- }
-
- destLayer.clip.height -= delta;
-
- if (sourceLayer.clip.height != sourceClip) {
- setTimeout(repositionContainers, 40, delta, moveArray, sourceLayer, sourceClip, destLayer);
- }
-
- }
-
- return;
- }
-
- function handleProperties(item)
- {
- if ( null != item )
- {
- editing = 1;
- var propWin = depth.SecureWindowOpen (window, 'addc.htm',
- 'prefs',
- 'left=150,top=200,width=427,height=247,titlebar=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,modal=yes,alwaysRaised=yes,z-lock=no,dependent=yes,hotkeys=no');
-
- propWin.depth = depth;
- propID = item;
- }
- }
-
- function PropertiesCallback(propsWindow)
- {
- propsWindow.selector = this;
- propsWindow.container = depth.getDefaultContainer();
-
- if (editing == 1)
- propsWindow.editItem(propID);
-
- propsWindow.callback = self;
-
- }
-
- function hiliteMenuItem(e) {
- e.target.bgColor="#808080";
- }
-
- function showMenu(dataItem, menuLeft, menuTop)
- {
- var menu = window.document.layers['menu'];
- var menuCommands = dataItem.getMenuItems();
- var currentDoc = menu.layers['item_name'].document;
-
- menu.clip.height = ((menuCommands.length + 1) * 25) + 3; // leave a 3 pixel margin
- currentDoc.open("text/html");
- currentDoc.write("<center><font size=-1 face='arial,helvetica'><b>");
- currentDoc.write("" + dataItem.getItemName() + "</b></font></center>");
- currentDoc.close();
-
- for (var i=0; i < menuCommands.length; i++) {
- var currentDoc = menu.layers["item"+i].document;
- currentDoc.open("text/html");
- currentDoc.write("<font size=-1 face='arial,helvetica'>");
- if (("" + menuCommands[i][0]) == "-") {
- menu.layers["item"+i].onmouseover=null;
- currentDoc.write("<hr width=80%></font>");
- } else {
- menu.layers["item"+i].onmouseover=hiliteMenuItem;
- currentDoc.write("<spacer type=block height=2 width=200><spacer type=block height=1 width=5>");
- currentDoc.write(menuCommands[i][0] + "</font>");
- currentDoc.write("<layer top=0 left=0 clip=150,25>");
- currentDoc.write("<a href='about:blank' " +
- "onclick='parentLayer.doMenuItem(\"" + menuCommands[i][1] + "\");return false;'>" +
- "<img src='images/blank.gif' border=none width=150 height=25>" +
- "</a></layer>");
- }
- currentDoc.close();
- }
-
- menu.layers["item"+menuCommands.length].onmouseover=null;
-
- // the selector is 200 pixels wide
- var overflow = menuLeft + menu.clip.width- 200;
-
- if (overflow > 0) {
- menu.left = menuLeft - overflow;
- } else {
- menu.left = menuLeft;
- }
-
- var overflow = menuTop + menu.clip.height - (containerGetHeight() + 30);
- if (overflow > 0) {
- menu.top = menuTop - overflow;
- } else {
- menu.top = menuTop;
- }
-
- menu.visibility = "show";
- menu.menuTarget = dataItem;
- menu.zIndex=1000;
-
- }
-
- function hideMenu()
- {
- var menu = window.document.layers['menu'];
-
- if (menu.visibility = "show") {
- menu.visibility="hide";
- }
- }
-
- function itemPopupMenu(e)
- {
- var menu = window.document.layers['menu'];
-
- if (e.which > 1 || (depth.isMac() && (e.modifiers & Event.CONTROL_MASK)))
- {
- if (currentItem == null) {
- menu.visibility = "hide";
- } else {
- setTimeout(showMenu, 10, currentItem, e.pageX, e.pageY);
- }
-
- return false;
- }
- else
- {
- if (menu.visibility == "show") {
-
- if ((e.pageX >= menu.left) && (e.pageX <= (menu.left + menu.clip.width))
- && (e.pageY >= menu.top) && (e.pageY <= (menu.top + menu.clip.height))) {
-
- menu.visibility = "hide";
- return routeEvent(e);
- }
-
- menu.visibility = "hide";
- return false;
- }
-
- return routeEvent(e);
- }
- }
-
- function showError(error) {
- if (error != null)
- alert(error);
- }
-
- function winOpen(url, name, options) {
- return window.open(url, name, options);
- }
-
- function winAlert(string) {
- return window.alert(string);
- }
-
- function winConfirm(string) {
- return window.confirm(string);
- }
-
- function winEscape(string) {
- return window.escape(string);
- }
-
- function winUnescape(string) {
- return window.unescape(string);
- }
-
- function containerIsOpen(containerName) {
- return expandedContainer == containerName;
- }
-
- function containerGetHeight() {
- return window.innerHeight - (window.numContainers * 30);
- }
-
- function containerGetParameter(containerName) {
- container = parent.titlebar.document.demo.findContainerByName(containerName)
-
- if (container != null) {
- return "" + container.getUserData();
- }
-
- return "";
- }
-
- function containerSetParameter(containerName, data) {
- container = parent.titlebar.document.demo.findContainerByName(containerName)
- if (container != null) {
- container.setUserData(data);
- }
-
- return;
- }
-
- function selectorOpen() {
- parent.selectorTab.ShowSelector();
- return;
- }
-
- function selectorClose() {
- parent.selectorTab.HideSelector();
- return;
- }
-
- function containerPrintln(outputString) {
- java.lang.System.out.println(outputString);
- return;
- }
-
- export winOpen;
- export winAlert;
- export winConfirm;
- export winEscape;
- export winUnescape;
- export containerIsOpen;
- export containerGetHeight;
- export containerGetParameter;
- export containerSetParameter;
- export selectorClose;
- export selectorOpen;
- export containerPrintln;
-
- void(0);
-