home *** CD-ROM | disk | FTP | other *** search
- /*
- * prefpane.js
- *
- * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved
- *
- * Preference panel utilities
- */
-
- var defaultWebtop = 0;
- var editing = 0;
- var applet = null;
- var propID;
- var propContainer;
- var propSelector;
- var previouslySelected = 0;
- var defaultContainer = null;
- var siteList = null;
- var channelArray = null;
- var layoutLoaded = false;
-
- function onLoad() {
- siteList = document.layers['channelList'].document.web_form;
- applet = opener.selectorWindow.titlebar.document.demo;
- propSelector = opener;
- fillOptionDialog(siteList, depth.getDefaultContainer(), applet);
- }
-
-
- /*
- * These methods initializes and populate the options dialog. It loops through the data
- * model storing pointers to the items, creating the list of channels.
- */
- function fillOptionDialog(form, category, applet) {
- var curOption;
- var channelArrayLength;
-
- channelArray = applet.getData(category);
-
- // prevent JavaScript from accessing a null item list
- if ( null == channelArray ) {
- channelArrayLength = 0;
-
- curOption = new Option("------------ none ------------");
- form.sitelist.options[0] = curOption;
-
- } else
- channelArrayLength = channelArray.length;
-
- // Lets loop through all the items storing pointers
- for (i = 0; i < channelArrayLength; i++)
- {
- // Fill in the channel selection box
- curOption = new Option(channelArray[i].getItemName());
- curOption.prototype = channelArray[i];
- form.sitelist.options[i] = curOption;
-
- }
-
- if (previouslySelected < channelArrayLength) {
- form.sitelist.selectedIndex = previouslySelected
- } else {
- // Mark the first channel as selected
- form.sitelist.selectedIndex = 0;
- }
-
- if (defaultContainer == null) {
- var containerName = depth.getDefaultContainer();
- defaultContainer = applet.findContainerByName(containerName);
- }
-
- adjustButtons();
- }
-
-
- function PropertiesCallback(propsWindow)
- {
- propsWindow.selector = propSelector;
- propsWindow.container = propContainer;
-
- if (editing == 1)
- propsWindow.editItem(propID);
-
- propsWindow.callback = self;
-
- }
-
- function EditCallback()
- {
- // Fix me, I should pass in a second arg, really I should
- fillOptionDialog(siteList, propContainer, applet);
- }
-
-
- function adjustButtons() {
- var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
- var online = applet.isOnline();
-
- if (defaultContainer.getCanAddItems()) {
- enableButton("new");
- } else {
- disableButton("new");
- }
-
- if ((item!= null) && (item.isDeletable())) {
- enableButton("delete");
- } else {
- disableButton("delete");
- }
-
- if ((item!= null) && (item.getStatus() == 1)) {
- document.layers['stopupdate'].visibility="inherit";
- document.layers['update'].visibility="hide";
- } else {
- document.layers['stopupdate'].visibility="hide";
- document.layers['update'].visibility="inherit";
-
- if (online) {
- enableButton("update");
- } else {
- disableButton("update");
- }
- }
- }
-
- function goDown(layer) {
- layer.background.src ="images/i_btnbg.gif";
- return false;
- }
-
- function goUp(layer) {
- layer.background.src ="images/o_btnbg.gif";
- return false;
- }
-
- function disableButton(buttonName) {
- document.layers[buttonName+'_d'].visibility="inherit";
- }
-
- function enableButton(buttonName) {
- document.layers[buttonName+'_d'].visibility="hide";
- }
-
- function handleAdd()
- {
- editing = 0;
-
- 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;
- propContainer = depth.getDefaultContainer();
- }
-
- function handleProperties()
- {
- previouslySelected = siteList.sitelist.selectedIndex;
- var item = siteList.sitelist.options[previouslySelected].prototype;
-
- 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');
-
- propID = item;
- propWin.depth = depth;
- propContainer = depth.getDefaultContainer();
- }
-
- }
-
- function stopSelectedUpdate()
- {
- var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
-
- if (null != item) {
- item.cancelUpdate();
- }
- }
-
- function deleteSelected()
- {
- var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
-
- if (null != item) {
- item.deleteMe();
-
- siteList.sitelist.options.length -= 1;
- fillOptionDialog(siteList, depth.getDefaultContainer(), applet);
- }
- }
-
- function startSelectedUpdate()
- {
- var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
-
- if ( null != item ) {
- item.update();
- }
- }
-
- function stopSelectedUpdate()
- {
- var item = siteList.sitelist.options[siteList.sitelist.selectedIndex].prototype;
-
- if ( null != item ) {
- item.cancelUpdate();
- }
- }
-
-
- void(0);
-