Bug 422181 - Add Create Bookmark in history item context menu, r=mak77

This commit is contained in:
Michael Kohler 2009-05-11 11:06:06 +02:00
Родитель a2ec3984cf
Коммит 4b73eab455
6 изменённых файлов: 20 добавлений и 29 удалений

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

@ -192,6 +192,9 @@ PlacesController.prototype = {
!PlacesUtils.nodeIsReadOnly(selectedNode) && !PlacesUtils.nodeIsReadOnly(selectedNode) &&
this._view.getResult().sortingMode == this._view.getResult().sortingMode ==
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE; Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
case "placesCmd_createBookmark":
var node = this._view.selectedNode;
return node && PlacesUtils.nodeIsURI(node) && node.itemId == -1;
default: default:
return false; return false;
} }
@ -280,6 +283,10 @@ PlacesController.prototype = {
case "placesCmd_sortBy:name": case "placesCmd_sortBy:name":
this.sortFolderByName(); this.sortFolderByName();
break; break;
case "placesCmd_createBookmark":
var node = this._view.selectedNode;
PlacesUIUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
break;
} }
}, },

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

@ -61,35 +61,16 @@ function HistorySidebarInit()
document.getElementById("bydayandsite").setAttribute("checked", "true"); document.getElementById("bydayandsite").setAttribute("checked", "true");
else else
document.getElementById("byday").setAttribute("checked", "true"); document.getElementById("byday").setAttribute("checked", "true");
initContextMenu();
searchHistory(""); searchHistory("");
} }
function initContextMenu() {
// Insert "Bookmark This Link" right before the copy item
document.getElementById("placesContext")
.insertBefore(document.getElementById("addBookmarkContextItem"),
document.getElementById("placesContext_copy"));
}
function GroupBy(groupingType) function GroupBy(groupingType)
{ {
gHistoryGrouping = groupingType; gHistoryGrouping = groupingType;
searchHistory(gSearchBox.value); searchHistory(gSearchBox.value);
} }
function historyAddBookmarks()
{
// no need to check gHistoryTree.view.selection.count
// node will be null if there is a multiple selection
// or if the selected item is not a URI node
var node = gHistoryTree.selectedNode;
if (node && PlacesUtils.nodeIsURI(node))
PlacesUIUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
}
function searchHistory(aInput) function searchHistory(aInput)
{ {
var query = PlacesUtils.history.getNewQuery(); var query = PlacesUtils.history.getNewQuery();

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

@ -74,14 +74,8 @@
#endif #endif
</keyset> </keyset>
<popup id="placesContext"> <!-- required to overlay the context menu -->
<menuitem id="addBookmarkContextItem" <popup id="placesContext" />
label="&bookmarkLink.label;"
accesskey="&bookmarkLink.accesskey;"
selection="link"
selectiontype="single"
oncommand="historyAddBookmarks();"/>
</popup>
<hbox align="center"> <hbox align="center">
<label value="&find.label;" accesskey="&find.accesskey;" <label value="&find.label;" accesskey="&find.accesskey;"

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

@ -20,6 +20,7 @@
# Contributor(s): # Contributor(s):
# Ben Goodger <beng@google.com> # Ben Goodger <beng@google.com>
# Asaf Romano <mano@mozilla.com> # Asaf Romano <mano@mozilla.com>
# Michael Kohler <michaelkohler@live.com>
# #
# Alternatively, the contents of this file may be used under the terms of # Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -93,6 +94,8 @@
oncommand="goDoCommand('placesCmd_moveBookmarks');"/> oncommand="goDoCommand('placesCmd_moveBookmarks');"/>
<command id="placesCmd_deleteDataHost" <command id="placesCmd_deleteDataHost"
oncommand="goDoCommand('placesCmd_deleteDataHost');"/> oncommand="goDoCommand('placesCmd_deleteDataHost');"/>
<command id="placesCmd_createBookmark"
oncommand="goDoCommand('placesCmd_createBookmark');"/>
</commandset> </commandset>
<popup id="placesContext" <popup id="placesContext"
@ -155,6 +158,12 @@
selection="any" selection="any"
hideifnoinsertionpoint="true"/> hideifnoinsertionpoint="true"/>
<menuseparator id="placesContext_newSeparator"/> <menuseparator id="placesContext_newSeparator"/>
<menuitem id="placesContext_createBookmark"
command="placesCmd_createBookmark"
label="&cmd.bookmarkLink.label;"
accesskey="&cmd.bookmarkLink.accesskey;"
selection="link"
forcehideselection="bookmark|tagChild"/>
<menuitem id="placesContext_cut" <menuitem id="placesContext_cut"
command="cmd_cut" command="cmd_cut"
label="&cutCmd.label;" label="&cutCmd.label;"

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

@ -22,7 +22,5 @@
<!ENTITY openInNewTab.accesskey "T"> <!ENTITY openInNewTab.accesskey "T">
<!ENTITY openInNewWindow.label "Open in New Window"> <!ENTITY openInNewWindow.label "Open in New Window">
<!ENTITY openInNewWindow.accesskey "W"> <!ENTITY openInNewWindow.accesskey "W">
<!ENTITY bookmarkLink.label "Bookmark This Link…">
<!ENTITY bookmarkLink.accesskey "B">
<!ENTITY copyLink.label "Copy Link Location"> <!ENTITY copyLink.label "Copy Link Location">
<!ENTITY copyLink.accesskey "C"> <!ENTITY copyLink.accesskey "C">

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

@ -71,6 +71,8 @@
<!ENTITY cmd.edit_redo.accesskey "R"> <!ENTITY cmd.edit_redo.accesskey "R">
<!ENTITY cmd.edit_redo.key "y"> <!ENTITY cmd.edit_redo.key "y">
<!ENTITY cmd.bookmarkLink.label "Bookmark This Page…">
<!ENTITY cmd.bookmarkLink.accesskey "B">
<!ENTITY cmd.delete.label "Delete This Page"> <!ENTITY cmd.delete.label "Delete This Page">
<!ENTITY cmd.delete.accesskey "D"> <!ENTITY cmd.delete.accesskey "D">
<!ENTITY cmd.deleteDomainData.label "Forget About This Site"> <!ENTITY cmd.deleteDomainData.label "Forget About This Site">