home *** CD-ROM | disk | FTP | other *** search
- var thisMultibar;
-
- function initDialog() {
- thisMultibar = window.arguments[0];
- thisMultibar.fromEditDialog = true;
- populateList();
- }
-
- function closeDialog() {
- thisMultibar.fromEditDialog = false;
- }
-
- function populateList() {
- // arguments[0] is the multibar object
-
- // populate the tray list
- var trayList = document.getElementById('trayList');
- var listItem = trayList.firstChild;
- while (listItem) {
- listItem.parentNode.removeChild(listItem);
- listItem = trayList.firstChild;
- }
-
- var orderSplit = thisMultibar.currentSet.split(";");
- for (var i=0; i < orderSplit.length; i++) {
- var trayCSet = orderSplit[i];
- var trayName = trayCSet.split(":").shift();
- dump ("Trying to find the tray called : " + trayName + "\n\n");
- var thisTray = thisMultibar.getTrayByName(trayName);
- var listElem = document.createElement('listitem');
- var trayIndex = thisMultibar.getIndexOfTray(thisTray)
- listElem.setAttribute('id', 'trayIndex' + trayIndex);
- listElem.setAttribute('label', thisTray.getAttribute('toolbarname'));
- trayList.appendChild(listElem);
- }
-
- updateSelectedTray();
- // grab value of showTrayTitle for checkbox
- var showTrayTitleCheckBox = document.getElementById('showTrayTitleCheckBox');
- if(thisMultibar.showTrayTitle)
- {
- showTrayTitleCheckBox.setAttribute('checked', 'true');
- }
- else
- {
- showTrayTitleCheckBox.setAttribute('checked', 'false');
- }
- }
-
- function updateSelectedTray()
- {
- // Get the
- var currentListItem = document.getElementById('trayIndex' + window.arguments[0].currentTrayIndex);
- var trayList = document.getElementById('trayList');
- trayList.selectItem(currentListItem);
- }
-
- function changeSelectedTray()
- {
- var trayList = document.getElementById('trayList');
- var trayItem = trayList.selectedItem;
- if (trayItem)
- {
- var trayIndex = trayItem.id.substring('trayIndex'.length);
- thisMultibar.showTray(trayIndex);
- }
-
- }
-
- function selectedTray()
- {
- return thisMultibar.getTrayByName(document.getElementById('trayList').selectedItem.getAttribute('label'));
- }
-
- function addTray() {
- // we set this value so tray will get added to listbox as well
- window.openDialog("chrome://global/content/addRenameTrayDialog.xul", "addRenameTrayDialog",
- "centerscreen,modal=yes", 'add', window.arguments[0]);
- }
-
- function renameTray() {
- // we set this value so tray will get renamed in listbox as well
- window.openDialog("chrome://global/content/addRenameTrayDialog.xul", "addRenameTrayDialog",
- "centerscreen,modal=yes", 'rename', thisMultibar);
- }
-
- function deleteTray() {
- var trayList = document.getElementById('trayList');
-
- // get selected list item
- // var idx = trayList.selectedIndex;
- var item = trayList.selectedItem;
- var selectedTray = thisMultibar.getTrayByName(item.getAttribute('label'));
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- var promptTitle = "Confirm Delete Tray";
- var promptMsg = "You are about to delete the tray '" + item.label + "' permanently. Are you sure you wish to proceed?";
-
- // if Cancel on confirm dialog, do nothing
- if(!promptService.confirm(window, promptTitle, promptMsg)) return;
-
- // delete from multibar
- thisMultibar.deleteTrayByObj(selectedTray);
-
- populateList();
- }
- function moveTrayUp() {
- thisMultibar.moveTrayUp(thisMultibar.currentTray);
- populateList();
- }
- function moveTrayDown() {
- thisMultibar.moveTrayDown(thisMultibar.currentTray);
- populateList();
- }
-
- // disables dialog buttons according the the following rules
- // 1) if top item selected, disable Move Up
- // 2) if bottom item selected, disable Move Down
- // 3) if one element in list, disable Delete
- function disableButtons()
- {
- var trayList = document.getElementById('trayList');
-
- // must have at least 1 tray
- if(trayList.childNodes.length == 1)
- {
- document.getElementById('removeTrayButton').setAttribute('disabled', 'true');
- }
- else
- {
- document.getElementById('removeTrayButton').removeAttribute('disabled');
- }
-
- // maximum of 10 trays
- if(trayList.childNodes.length == 10)
- {
- document.getElementById('addTrayButton').setAttribute('disabled', 'true');
- }
- else
- {
- document.getElementById('addTrayButton').removeAttribute('disabled');
- }
-
- // if top elem selected disable Move Up
- if(trayList.selectedItem == trayList.firstChild)
- {
- document.getElementById('moveUpTrayButton').setAttribute('disabled', 'true');
- }
- else
- {
- document.getElementById('moveUpTrayButton').removeAttribute('disabled');
- }
-
- // if bottom elem selected disable Move Down
- if(trayList.selectedItem == trayList.lastChild)
- {
- document.getElementById('moveDownTrayButton').setAttribute('disabled', 'true');
- }
- else
- {
- document.getElementById('moveDownTrayButton').removeAttribute('disabled');
- }
- }
-
- function toggleShowTrayTitle()
- {
- thisMultibar.showTrayTitle = !thisMultibar.showTrayTitle;
- }
-
-