home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 December
/
PCWorld_2005-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-0.exe
/
chrome
/
toolkit.jar
/
content
/
global
/
addRenameTrayDialog.js
< prev
next >
Wrap
Text File
|
2005-09-26
|
3KB
|
80 lines
var thisMultibar;
var thisOpener;
var action;
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
function initDialog() {
// arguments[0] is either 'add' or 'rename'
action = window.arguments[0];
thisOpener = window.opener;
thisMultibar= window.arguments[1];
var dialog = document.getElementById('addRenameTrayDialog');
if(action == "add") {
// set the dialog title
dialog.setAttribute('title', 'Add Tray');
} else { // == 'rename'
// set the dialog title
dialog.setAttribute('title', 'Rename Tray');
var currentTrayNameText;
if(thisMultibar.fromEditDialog) {
// get the selected tray item text
var trayList = thisOpener.document.getElementById('trayList');
currentTrayNameText = trayList.selectedItem.getAttribute('label');
} else {
// dump ("Context rename from Multibar : \n");
currentTrayNameText = thisMultibar.currentTray.getAttribute('toolbarname');
}
var trayNameText = document.getElementById('trayName');
trayNameText.value = currentTrayNameText;
trayNameText.focus();
}
}
function onOK() {
// get the new tray name
var trayName = document.getElementById('trayName').value;
var toolbar;
if(action == "add") {
// if dialog was opened from Edit Dialog, we need to add new tray to the listbox as well
toolbar = thisMultibar.addNewTray(trayName);
if (!toolbar) // Bad name
return false;
// toolbar.setAttribute("currentSet", "spring");
toolbar.parentNode.parentNode.reorderToolbars();
if(thisMultibar.fromEditDialog) {
// dump('** opened from Edit Dialog\n');
// window.opener.addTrayToList(trayName);
thisOpener.populateList();
} else {
if (thisOpener.BrowserCustomizeToolbar)
thisOpener.BrowserCustomizeToolbar();
return true;
}
} else { // == 'rename'
// if dialog was opened from Edit Dialog, we need to add new tray to the listbox as well
var idx;
if(thisMultibar.fromEditDialog) {
dump('** opened from Edit Dialog\n');
idx = thisMultibar.getIndexOfTray(opener.selectedTray());
} else {
// rename the current multibar tray
idx = thisMultibar.currentTrayIndex;
}
var success = thisMultibar.renameTray(idx, trayName);
if (!success) // bad name
return false;
if (thisMultibar.fromEditDialog) {
thisOpener.populateList();
}
}
return true;
}