Post-bookmarksliner cleanup. r=ben sr=hewitt

This commit is contained in:
blakeross%telocity.com 2001-12-06 03:11:06 +00:00
Родитель b79467d92f
Коммит 16f42a6bac
4 изменённых файлов: 78 добавлений и 78 удалений

Просмотреть файл

@ -80,11 +80,11 @@ BookmarksToolbar.prototype = {
xulElement.setAttribute("command", cmd);
switch (aCommandName) {
case NC_NS_CMD + "open":
case NC_NS_CMD + "bm_open":
xulElement.setAttribute("label", aDisplayName);
xulElement.setAttribute("default", "true");
break;
case NC_NS_CMD + "openfolder":
case NC_NS_CMD + "bm_openfolder":
xulElement.setAttribute("default", "true");
if (aItemNode.localName == "hbox")
// Don't show an "Open Folder" item for clicks on the toolbar itself.
@ -362,8 +362,8 @@ BookmarksToolbar.prototype = {
supportsCommand: function (aCommand)
{
switch(aCommand) {
case "cmd_undo":
case "cmd_redo":
case "cmd_bm_undo":
case "cmd_bm_redo":
return false;
case "cmd_bm_cut":
case "cmd_bm_copy":
@ -371,20 +371,20 @@ BookmarksToolbar.prototype = {
case "cmd_bm_delete":
case "cmd_bm_selectAll":
return true;
case "cmd_open":
case "cmd_openfolder":
case "cmd_openfolderinnewwindow":
case "cmd_newbookmark":
case "cmd_newfolder":
case "cmd_newseparator":
case "cmd_find":
case "cmd_properties":
case "cmd_rename":
case "cmd_setnewbookmarkfolder":
case "cmd_setpersonaltoolbarfolder":
case "cmd_setnewsearchfolder":
case "cmd_import":
case "cmd_export":
case "cmd_bm_open":
case "cmd_bm_openfolder":
case "cmd_bm_openfolderinnewwindow":
case "cmd_bm_newbookmark":
case "cmd_bm_newfolder":
case "cmd_bm_newseparator":
case "cmd_bm_find":
case "cmd_bm_properties":
case "cmd_bm_rename":
case "cmd_bm_setnewbookmarkfolder":
case "cmd_bm_setpersonaltoolbarfolder":
case "cmd_bm_setnewsearchfolder":
case "cmd_bm_import":
case "cmd_bm_export":
case "cmd_bm_fileBookmark":
return true;
default:
@ -395,8 +395,8 @@ BookmarksToolbar.prototype = {
isCommandEnabled: function (aCommand)
{
switch(aCommand) {
case "cmd_undo":
case "cmd_redo":
case "cmd_bm_undo":
case "cmd_bm_redo":
return false;
case "cmd_bm_paste":
var cp = gBookmarksShell.canPaste();
@ -407,7 +407,7 @@ BookmarksToolbar.prototype = {
return (document.popupNode != null) && (NODE_ID(document.popupNode) != "NC:PersonalToolbarFolder");
case "cmd_bm_selectAll":
return false;
case "cmd_open":
case "cmd_bm_open":
var seln = gBookmarksShell.getSelection();
return document.popupNode != null && seln[0].getAttributeNS(RDF_NS, "type") == NC_NS + "Bookmark";
case "cmd_openfolder":
@ -421,20 +421,20 @@ BookmarksToolbar.prototype = {
case "cmd_import":
case "cmd_export":
return true;
case "cmd_properties":
case "cmd_rename":
case "cmd_bm_properties":
case "cmd_bm_rename":
return document.popupNode != null;
case "cmd_setnewbookmarkfolder":
case "cmd_bm_setnewbookmarkfolder":
seln = gBookmarksShell.getSelection();
if (!seln.length) return false;
var folderType = seln[0].getAttributeNS(RDF_NS, "type") == (NC_NS + "Folder");
return document.popupNode != null && !(NODE_ID(seln[0]) == "NC:NewBookmarkFolder") && folderType;
case "cmd_setpersonaltoolbarfolder":
case "cmd_bm_setpersonaltoolbarfolder":
seln = gBookmarksShell.getSelection();
if (!seln.length) return false;
folderType = seln[0].getAttributeNS(RDF_NS, "type") == (NC_NS + "Folder");
return document.popupNode != null && !(NODE_ID(seln[0]) == "NC:PersonalToolbarFolder") && folderType;
case "cmd_setnewsearchfolder":
case "cmd_bm_setnewsearchfolder":
seln = gBookmarksShell.getSelection();
if (!seln.length) return false;
folderType = seln[0].getAttributeNS(RDF_NS, "type") == (NC_NS + "Folder");
@ -450,29 +450,29 @@ BookmarksToolbar.prototype = {
doCommand: function (aCommand)
{
switch(aCommand) {
case "cmd_undo":
case "cmd_redo":
case "cmd_bm_undo":
case "cmd_bm_redo":
break;
case "cmd_bm_paste":
case "cmd_bm_copy":
case "cmd_bm_cut":
case "cmd_bm_delete":
case "cmd_newbookmark":
case "cmd_newfolder":
case "cmd_newseparator":
case "cmd_properties":
case "cmd_rename":
case "cmd_open":
case "cmd_openfolder":
case "cmd_openfolderinnewwindow":
case "cmd_setnewbookmarkfolder":
case "cmd_setpersonaltoolbarfolder":
case "cmd_setnewsearchfolder":
case "cmd_find":
case "cmd_import":
case "cmd_export":
case "cmd_bm_newbookmark":
case "cmd_bm_newfolder":
case "cmd_bm_newseparator":
case "cmd_bm_properties":
case "cmd_bm_rename":
case "cmd_bm_open":
case "cmd_bm_openfolder":
case "cmd_bm_openfolderinnewwindow":
case "cmd_bm_setnewbookmarkfolder":
case "cmd_bm_setpersonaltoolbarfolder":
case "cmd_bm_setnewsearchfolder":
case "cmd_bm_find":
case "cmd_bm_import":
case "cmd_bm_export":
case "cmd_bm_fileBookmark":
gBookmarksShell.execCommand(aCommand.substring("cmd_".length));
gBookmarksShell.execCommand(aCommand.substring("cmd_bm_".length));
break;
case "cmd_bm_selectAll":
break;
@ -512,8 +512,8 @@ function checkBookmarksMenuTemplateBuilder()
{
var lastStaticSeparator = document.getElementById("lastStaticSeparator");
if (!lastStaticSeparator.nextSibling) {
var button = document.getElementById("bookmarks-button");
button.builder.rebuild();
var button = document.getElementById("bookmarks-button");
button.builder.rebuild();
}
}

Просмотреть файл

@ -65,7 +65,7 @@ function Startup()
}
bookmarksView.outlinerBoxObject.selection.select(0);
bookmarksView.focus();
bookmarksView.outliner.focus();
}
function Shutdown ()

Просмотреть файл

@ -116,7 +116,6 @@ BookmarksUIElement.prototype = {
createContextMenu: function (aEvent)
{
var popup = aEvent.target;
// clear out the old context menu contents (if any)
while (popup.hasChildNodes())
popup.removeChild(popup.firstChild);
@ -130,7 +129,6 @@ BookmarksUIElement.prototype = {
aEvent.preventDefault();
return;
}
if (!("getContextSelection" in this))
throw "Clients must implement getContextSelection!";
var selection = this.getContextSelection (itemNode);
@ -217,31 +215,31 @@ BookmarksUIElement.prototype = {
var commands = [];
switch (type) {
case "http://home.netscape.com/NC-rdf#BookmarkSeparator":
commands = ["find", "separator", "bm_cut", "bm_copy", "bm_paste",
commands = ["bm_find", "separator", "bm_cut", "bm_copy", "bm_paste",
"bm_delete", "separator", "bm_fileBookmark", "separator",
"newfolder"];
"bm_newfolder"];
break;
case "http://home.netscape.com/NC-rdf#Bookmark":
commands = ["open", "find", "separator", "bm_cut",
"bm_copy", "bm_paste", "bm_delete", "separator", "rename",
"separator", "bm_fileBookmark", "separator", "newfolder",
"separator", "properties"];
commands = ["bm_open", "bm_find", "separator", "bm_cut",
"bm_copy", "bm_paste", "bm_delete", "separator", "bm_rename",
"separator", "bm_fileBookmark", "separator", "bm_newfolder",
"separator", "bm_properties"];
break;
case "http://home.netscape.com/NC-rdf#Folder":
commands = ["openfolder", "openfolderinnewwindow", "find", "separator",
"bm_cut", "bm_copy", "bm_paste", "bm_delete", "separator", "rename",
commands = ["bm_openfolder", "bm_openfolderinnewwindow", "bm_find", "separator",
"bm_cut", "bm_copy", "bm_paste", "bm_delete", "separator", "bm_rename",
"separator", "bm_fileBookmark", "separator",
"newfolder", "separator", "properties"];
"bm_newfolder", "separator", "bm_properties"];
break;
case "http://home.netscape.com/NC-rdf#IEFavoriteFolder":
commands = ["open", "find", "separator", "bm_copy", "bm_delete", "separator", "rename", "separator",
"bm_fileBookmark", "separator", "separator", "properties"];
commands = ["bm_open", "bm_find", "separator", "bm_copy", "bm_delete", "separator", "bm_rename", "separator",
"bm_fileBookmark", "separator", "separator", "bm_properties"];
break;
case "http://home.netscape.com/NC-rdf#IEFavorite":
commands = ["open", "find", "separator", "bm_copy"];
commands = ["bm_open", "bm_find", "separator", "bm_copy"];
break;
case "http://home.netscape.com/NC-rdf#FileSystemObject":
commands = ["open", "find", "separator", "bm_copy"];
commands = ["bm_open", "bm_find", "separator", "bm_copy"];
break;
default:
var source = this.RDF.GetResource(aNodeID);
@ -290,35 +288,35 @@ BookmarksUIElement.prototype = {
if (selection.length >= 1)
var selectedItem = selection[0];
switch (aCommandID) {
case "open":
case "bm_open":
this.open(null, selectedItem);
break;
case "openfolder":
case "bm_openfolder":
this.commands.openFolder(selectedItem);
break;
case "openfolderinnewwindow":
case "bm_openfolderinnewwindow":
this.openFolderInNewWindow(selectedItem);
break;
case "rename":
case "bm_rename":
// XXX - this is SO going to break if we ever do column re-ordering.
this.commands.editCell(selectedItem, 0);
break;
case "editurl":
case "bm_editurl":
this.commands.editCell(selectedItem, 1);
break;
case "setnewbookmarkfolder":
case "setpersonaltoolbarfolder":
case "setnewsearchfolder":
case "bm_setnewbookmarkfolder":
case "bm_setpersonaltoolbarfolder":
case "bm_setnewsearchfolder":
BookmarksUtils.doBookmarksCommand(NODE_ID(selectedItem),
NC_NS_CMD + aCommandID, args);
// XXX - The containing node seems to be closed here and the
// focus/selection is destroyed.
this.selectElement(selectedItem);
break;
case "properties":
case "bm_properties":
this.showPropertiesForNode(selectedItem);
break;
case "find":
case "bm_find":
this.findInBookmarks();
break;
case "bm_cut":
@ -356,16 +354,16 @@ BookmarksUIElement.prototype = {
gBookmarksShell.flushDataSource();
}
break;
case "newfolder":
case "bm_newfolder":
var nfseln = this.getBestItem();
this.commands.createBookmarkItem("folder", nfseln);
break;
case "newbookmark":
case "bm_newbookmark":
var folder = this.getSelectedFolder();
openDialog("chrome://communicator/content/bookmarks/addBookmark.xul", "",
"centerscreen,chrome,modal=yes,dialog=yes,resizable=no", null, null, folder, null, "newBookmark");
break;
case "newseparator":
case "bm_newseparator":
nfseln = this.getBestItem();
var parentNode = this.findRDFNode(nfseln, false);
args = [{ property: NC_NS + "parent",
@ -373,9 +371,9 @@ BookmarksUIElement.prototype = {
BookmarksUtils.doBookmarksCommand(NODE_ID(nfseln),
NC_NS_CMD + "newseparator", args);
break;
case "import":
case "export":
const isImport = aCommandID == "import";
case "bm_import":
case "bm_export":
const isImport = aCommandID == "bm_import";
try {
const kFilePickerContractID = "@mozilla.org/filepicker;1";
const kFilePickerIID = Components.interfaces.nsIFilePicker;

Просмотреть файл

@ -43,7 +43,9 @@
function Startup()
{
var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.focus();
bookmarksView.outlinerBoxObject.selection.select(0);
bookmarksView.outliner.focus();
}
function manageBookmarks() {