bug 300412 - add "Bookmark all Tabs" menu option to bookmarks menu, improves discoverability of bookmark tab groups per usability testing. patch by Grace Shih <gsshih@gmail.com> r=ben@mozilla.org

This commit is contained in:
ben@bengoodger.com
2005-08-12 00:42:16 +00:00
parent 567a55d381
commit b51c5f12f6
12 changed files with 108 additions and 51 deletions

View File

@@ -367,6 +367,10 @@
<menuitem key="addBookmarkAsKb" <menuitem key="addBookmarkAsKb"
label="&addCurPageAsCmd.label;" label="&addCurPageAsCmd.label;"
command="Browser:AddBookmarkAs"/> command="Browser:AddBookmarkAs"/>
<menuitem id="bookmarkAllCmd"
key="addBookmarkGroupKb"
label="&bookmarkAllCmd.label;"
command="Browser:BookmarkAllTabs"/>
<menuitem key="manBookmarkKb" <menuitem key="manBookmarkKb"
label="&manBookmarksCmd.label;" label="&manBookmarksCmd.label;"
oncommand="toOpenWindowByType('bookmarks:manager', 'chrome://browser/content/bookmarks/bookmarksManager.xul');"/> oncommand="toOpenWindowByType('bookmarks:manager', 'chrome://browser/content/bookmarks/bookmarksManager.xul');"/>

View File

@@ -147,7 +147,8 @@
<command id="cmd_find" oncommand="onFindCmd();"/> <command id="cmd_find" oncommand="onFindCmd();"/>
<command id="cmd_findAgain" oncommand="onFindAgainCmd();"/> <command id="cmd_findAgain" oncommand="onFindAgainCmd();"/>
<command id="cmd_findPrevious" oncommand="onFindPreviousCmd();"/> <command id="cmd_findPrevious" oncommand="onFindPreviousCmd();"/>
<command id="Browser:AddBookmarkAs" oncommand="addBookmarkAs(document.getElementById('content'));"/> <command id="Browser:AddBookmarkAs" oncommand="addBookmarkAs(document.getElementById('content'), false);"/>
<command id="Browser:BookmarkAllTabs" oncommand="addBookmarkAs(document.getElementById('content'), true);"/>
<command id="Browser:Home" oncommand="BrowserHome();"/> <command id="Browser:Home" oncommand="BrowserHome();"/>
<command id="Browser:Back" oncommand="BrowserBack();" disabled="true"/> <command id="Browser:Back" oncommand="BrowserBack();" disabled="true"/>
<command id="Browser:Forward" oncommand="BrowserForward();" disabled="true"/> <command id="Browser:Forward" oncommand="BrowserForward();" disabled="true"/>

View File

@@ -185,6 +185,37 @@ function UpdateBackForwardButtons()
} }
} }
function UpdateBookmarkAllTabsMenuitem()
{
var tabbrowser = getBrowser();
var numTabs = tabbrowser.tabContainer.childNodes.length;
var bookmarkAllCommand = document.getElementById("Browser:BookmarkAllTabs");
if (numTabs > 1)
bookmarkAllCommand.removeAttribute("disabled");
else
bookmarkAllCommand.setAttribute("disabled", "true");
}
function addBookmarkMenuitems()
{
var tabbrowser = getBrowser();
var tabMenu = document.getAnonymousElementByAttribute(tabbrowser,"anonid","tabContextMenu");
var bookmarkAllTabsItem = document.createElement("menuitem");
bookmarkAllTabsItem.setAttribute("label", gNavigatorBundle.getString("bookmarkAllTabs_label"));
bookmarkAllTabsItem.setAttribute("accesskey", gNavigatorBundle.getString("bookmarkAllTabs_accesskey"));
bookmarkAllTabsItem.setAttribute("command", "Browser:BookmarkAllTabs");
var bookmarkCurTabItem = document.createElement("menuitem");
bookmarkCurTabItem.setAttribute("label", gNavigatorBundle.getString("bookmarkCurTab_label"));
bookmarkCurTabItem.setAttribute("accesskey", gNavigatorBundle.getString("bookmarkCurTab_accesskey"));
bookmarkCurTabItem.setAttribute("oncommand", "addBookmarkAs((getBrowser().mContextTab).linkedBrowser, false);");
var menuseparator = document.createElement("menuseparator");
var insertPos = tabMenu.lastChild.previousSibling;
tabMenu.insertBefore(bookmarkAllTabsItem, insertPos);
tabMenu.insertBefore(bookmarkCurTabItem, bookmarkAllTabsItem);
tabMenu.insertBefore(menuseparator, bookmarkCurTabItem);
}
const gSessionHistoryObserver = { const gSessionHistoryObserver = {
observe: function(subject, topic, data) observe: function(subject, topic, data)
{ {
@@ -769,6 +800,8 @@ function delayedStartup()
initFindBar(); initFindBar();
// add bookmark options to context menu for tabs
addBookmarkMenuitems();
// now load bookmarks // now load bookmarks
BMSVC.readBookmarks(); BMSVC.readBookmarks();
var bt = document.getElementById("bookmarks-ptf"); var bt = document.getElementById("bookmarks-ptf");
@@ -1508,16 +1541,16 @@ function updateGoMenu(goMenu)
endSep.hidden = false; endSep.hidden = false;
} }
function addBookmarkAs(aBrowser, aIsWebPanel) function addBookmarkAs(aBrowser, aBookmarkAllTabs, aIsWebPanel)
{ {
const browsers = aBrowser.browsers; const browsers = aBrowser.browsers;
if (browsers && browsers.length > 1) if (browsers && browsers.length > 1)
addBookmarkForTabBrowser(aBrowser); addBookmarkForTabBrowser(aBrowser, aBookmarkAllTabs);
else else
addBookmarkForBrowser(aBrowser.webNavigation, aIsWebPanel); addBookmarkForBrowser(aBrowser.webNavigation, aIsWebPanel);
} }
function addBookmarkForTabBrowser(aTabBrowser, aSelect) function addBookmarkForTabBrowser(aTabBrowser, aBookmarkAllTabs, aSelect)
{ {
var tabsInfo = []; var tabsInfo = [];
var currentTabInfo = { name: "", url: "", charset: null }; var currentTabInfo = { name: "", url: "", charset: null };
@@ -1537,11 +1570,16 @@ function addBookmarkForTabBrowser(aTabBrowser, aSelect)
} catch (e) { } catch (e) {
name = url; name = url;
} }
tabsInfo[i] = { name: name, url: url, charset: charSet, description: description, bAddGroup: true }; tabsInfo[i] = { name: name, url: url, charset: charSet, description: description };
if (browsers[i] == activeBrowser) if (browsers[i] == activeBrowser)
currentTabInfo = tabsInfo[i]; currentTabInfo = tabsInfo[i];
} }
var dialogArgs = currentTabInfo; var dialogArgs = currentTabInfo;
if (aBookmarkAllTabs) {
dialogArgs = { name: gNavigatorBundle.getString("bookmarkAllTabsDefault") };
dialogArgs.bBookmarkAllTabs = true;
}
dialogArgs.objGroup = tabsInfo; dialogArgs.objGroup = tabsInfo;
openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "", openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
BROWSER_ADD_BM_FEATURES, dialogArgs); BROWSER_ADD_BM_FEATURES, dialogArgs);
@@ -3427,7 +3465,7 @@ nsBrowserStatusHandler.prototype =
} }
} }
UpdateBackForwardButtons(); UpdateBackForwardButtons();
UpdateBookmarkAllTabsMenuitem();
if (findField && gFindMode != FIND_NORMAL) { if (findField && gFindMode != FIND_NORMAL) {
// Close the Find toolbar if we're in old-style TAF mode // Close the Find toolbar if we're in old-style TAF mode
closeFindBar(); closeFindBar();

View File

@@ -52,36 +52,36 @@
* Apart from the standard openDialog parameters, this dialog can * Apart from the standard openDialog parameters, this dialog can
* be passed additional information, which is contained in the * be passed additional information, which is contained in the
* wArg object: * wArg object:
* *
* wArg.name : Bookmark Name. The value to be prefilled * wArg.name : Bookmark Name. The value to be prefilled
* into the "Name: " field (if visible). * into the "Name: " field (if visible).
* wArg.description : Bookmark description. The value to be added * wArg.description : Bookmark description. The value to be added
* : to the boomarks description field. * : to the boomarks description field.
* wArg.url : Bookmark URL: The location of the bookmark. * wArg.url : Bookmark URL: The location of the bookmark.
* The value to be filled in the "Location: " * The value to be filled in the "Location: "
* field (if visible). * field (if visible).
* wArg.folderURI : Bookmark Folder. The RDF Resource URI of the * wArg.folderURI : Bookmark Folder. The RDF Resource URI of the
* folder that this bookmark should be created in. * folder that this bookmark should be created in.
* wArg.charset : Bookmark Charset. The charset that should be * wArg.charset : Bookmark Charset. The charset that should be
* used when adding a bookmark to the specified * used when adding a bookmark to the specified
* URL. (Usually the charset of the current * URL. (Usually the charset of the current
* document when launching this window). * document when launching this window).
* wArg.bAddGroup : True if adding a group of tabs, false * wArg.bBookmarkAllTabs : True if "Bookmark All Tabs" option is chosen,
* otherwise. * false otherwise.
* wArg.objGroup[] : If adding a group of tabs, this is an array * wArg.objGroup[] : If adding a group of tabs, this is an array
* of wArg objects with name, URL and charset * of wArg objects with name, URL and charset
* properties, one for each group member. * properties, one for each group member.
* wArg.bWebPanel : If the bookmark should become a web panel. * wArg.bWebPanel : If the bookmark should become a web panel.
* wArg.keyword : A suggested keyword for the bookmark. If this * wArg.keyword : A suggested keyword for the bookmark. If this
* argument is supplied, the keyword row is made * argument is supplied, the keyword row is made
* visible. * visible.
* wArg.bNeedKeyword : Whether or not a keyword is required to add * wArg.bNeedKeyword : Whether or not a keyword is required to add
* the bookmark. * the bookmark.
* wArg.postData : PostData to be saved with this bookmark, * wArg.postData : PostData to be saved with this bookmark,
* in the format a string of name=value pairs * in the format a string of name=value pairs
* separated by CRLFs. * separated by CRLFs.
* wArg.feedURL : feed URL for Livemarks (turns bookmark * wArg.feedURL : feed URL for Livemarks (turns bookmark
* into Livemark) * into Livemark)
*/ */
var gSelectedFolder; var gSelectedFolder;
@@ -91,7 +91,6 @@ var gKeywordRow;
var gExpander; var gExpander;
var gMenulist; var gMenulist;
var gBookmarksTree; var gBookmarksTree;
var gGroup;
var gKeywordRequired; var gKeywordRequired;
var gSuggestedKeyword; var gSuggestedKeyword;
var gRequiredFields = []; var gRequiredFields = [];
@@ -110,7 +109,6 @@ function Startup()
gRequiredFields.push(gName); gRequiredFields.push(gName);
gKeywordRow = document.getElementById("keywordRow"); gKeywordRow = document.getElementById("keywordRow");
gKeyword = document.getElementById("keyword"); gKeyword = document.getElementById("keyword");
gGroup = document.getElementById("addgroup");
gExpander = document.getElementById("expander"); gExpander = document.getElementById("expander");
gMenulist = document.getElementById("select-menu"); gMenulist = document.getElementById("select-menu");
gBookmarksTree = document.getElementById("folder-tree"); gBookmarksTree = document.getElementById("folder-tree");
@@ -127,10 +125,9 @@ function Startup()
if (gKeywordRequired) if (gKeywordRequired)
gRequiredFields.push(gKeyword); gRequiredFields.push(gKeyword);
} }
if (!gArg.bAddGroup)
gGroup.setAttribute("hidden", "true");
sizeToContent(); sizeToContent();
onFieldInput(); onFieldInput();
initTitle();
gSelectedFolder = RDF.GetResource(gMenulist.selectedItem.id); gSelectedFolder = RDF.GetResource(gMenulist.selectedItem.id);
gExpander.setAttribute("tooltiptext", gExpander.getAttribute("tooltiptextdown")); gExpander.setAttribute("tooltiptext", gExpander.getAttribute("tooltiptextdown"));
gPostData = gArg.postData; gPostData = gArg.postData;
@@ -170,6 +167,14 @@ function Startup()
setTimeout(initMenulist, 0); setTimeout(initMenulist, 0);
} }
function initTitle()
{
if(gArg.bBookmarkAllTabs)
document.title = document.getElementById("bookmarksBundle").getString("bookmarkAllTabsTitle");
else
document.title = document.getElementById("bookmarksBundle").getString("bookmarkCurTabTitle");
}
function onFieldInput() function onFieldInput()
{ {
var ok = document.documentElement.getButton("accept"); var ok = document.documentElement.getButton("accept");
@@ -188,7 +193,7 @@ function onOK()
var url, rSource; var url, rSource;
var livemarkFeed = gArg.feedURL; var livemarkFeed = gArg.feedURL;
if (gGroup && gGroup.checked) { if (gArg.bBookmarkAllTabs) {
rSource = BMDS.createFolder(gName.value); rSource = BMDS.createFolder(gName.value);
const groups = gArg.objGroup; const groups = gArg.objGroup;
for (var i = 0; i < groups.length; ++i) { for (var i = 0; i < groups.length; ++i) {

View File

@@ -62,7 +62,7 @@
#endif #endif
buttoniconaccept="add" buttoniconaccept="add"
buttoniconextra2="open" buttoniconextra2="open"
title="&newBookmark.title;" title-selectFolder="&selectFolder.label;" title-selectFolder="&selectFolder.label;"
onload="Startup();" onload="Startup();"
onunload="setFolderTreeHeight();" onunload="setFolderTreeHeight();"
persist="screenX screenY width"> persist="screenX screenY width">
@@ -70,7 +70,7 @@
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarks.js"/> <script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/addBookmark2.js"/> <script type="application/x-javascript" src="chrome://browser/content/bookmarks/addBookmark2.js"/>
<stringbundle id="bookmarksBundle" <stringbundle id="bookmarksBundle"
src="chrome://browser/locale/bookmarks/bookmarks.properties"/> src="chrome://browser/locale/bookmarks/bookmarks.properties"/>
@@ -116,11 +116,6 @@
tooltiptextdown="&expanderDown.tooltip;" tooltiptextdown="&expanderDown.tooltip;"
tooltiptextup="&expanderUp.tooltip;"/> tooltiptextup="&expanderUp.tooltip;"/>
</row> </row>
<row>
<spacer/>
<checkbox id="addgroup" label="&addGroup.label;"
accesskey="&addGroup.accesskey;"/>
</row>
</rows> </rows>
</grid> </grid>

View File

@@ -300,6 +300,7 @@ var MigrationWizard = {
items.removeChild(items.firstChild); items.removeChild(items.firstChild);
var bundle = document.getElementById("bundle"); var bundle = document.getElementById("bundle");
var brandBundle = document.getElementById("brandBundle");
var itemID; var itemID;
for (var i = 0; i < 16; ++i) { for (var i = 0; i < 16; ++i) {
var itemID = (this._itemsFlags >> i) & 0x1 ? Math.pow(2, i) : 0; var itemID = (this._itemsFlags >> i) & 0x1 ? Math.pow(2, i) : 0;

View File

@@ -52,6 +52,7 @@
<script type="application/x-javascript" src="chrome://browser/content/migration/migration.js"/> <script type="application/x-javascript" src="chrome://browser/content/migration/migration.js"/>
<stringbundle id="bundle" src="chrome://browser/locale/migration/migration.properties"/> <stringbundle id="bundle" src="chrome://browser/locale/migration/migration.properties"/>
<stringbundle id="brandBundle" src="chrome://branding/locale/brand.properties"/>
<wizardpage id="importSource" pageid="importSource" next="selectProfile" <wizardpage id="importSource" pageid="importSource" next="selectProfile"
label="&importSource.title;" label="&importSource.title;"

View File

@@ -22,7 +22,5 @@
<!ENTITY expanderDown.tooltip "Show all the bookmarks folders"> <!ENTITY expanderDown.tooltip "Show all the bookmarks folders">
<!ENTITY expanderUp.tooltip "Hide"> <!ENTITY expanderUp.tooltip "Hide">
<!ENTITY addGroup.label "Bookmark all tabs in a folder">
<!ENTITY addGroup.accesskey "B">
<!ENTITY acceptButton.label "Add"> <!ENTITY acceptButton.label "Add">
<!ENTITY bookmarksToolbar.label "Bookmarks Toolbar"> <!ENTITY bookmarksToolbar.label "Bookmarks Toolbar">

View File

@@ -176,3 +176,6 @@ addLiveBookmarkTitle=Add Live Bookmark
BookmarksLivemarkLoading=Live Bookmark loading... BookmarksLivemarkLoading=Live Bookmark loading...
BookmarksLivemarkFailed=Live Bookmark feed failed to load. BookmarksLivemarkFailed=Live Bookmark feed failed to load.
bookmarkCurTabTitle=Add Bookmark
bookmarkAllTabsTitle=Bookmark All Tabs

View File

@@ -61,6 +61,8 @@
<!ENTITY addCurPageAsCmd.label "Bookmark This Page..."> <!ENTITY addCurPageAsCmd.label "Bookmark This Page...">
<!ENTITY addCurPageAsCmd.commandkey "d"> <!ENTITY addCurPageAsCmd.commandkey "d">
<!ENTITY manBookmarksCmd.label "Manage Bookmarks..."> <!ENTITY manBookmarksCmd.label "Manage Bookmarks...">
<!ENTITY manBookmarksCmd.accesskey "M">
<!ENTITY bookmarkAllCmd.label "Bookmark All Tabs...">
<!ENTITY backCmd.label "Back"> <!ENTITY backCmd.label "Back">
<!ENTITY backCmd.accesskey "B"> <!ENTITY backCmd.accesskey "B">

View File

@@ -40,6 +40,15 @@ DefaultSaveFileName=index
WebPageCompleteFilter=Web Page, complete WebPageCompleteFilter=Web Page, complete
WebPageHTMLOnlyFilter=Web Page, HTML only WebPageHTMLOnlyFilter=Web Page, HTML only
bookmarkAllTabs_label=Bookmark All Tabs...
bookmarkAllTabs_accesskey=T
bookmarkCurTab_label=Bookmark This Tab...
bookmarkCurTab_accesskey=B
# bookmark dialog strings
bookmarkAllTabsDefault=[Folder Name]
# LOCALIZATION NOTE (filesFolder): # LOCALIZATION NOTE (filesFolder):
# This is the name of the folder that is created parallel to a HTML file # This is the name of the folder that is created parallel to a HTML file
# when it is saved "With Images". The %S section is replaced with the # when it is saved "With Images". The %S section is replaced with the

View File

@@ -68,7 +68,7 @@
ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode); event.stopPropagation();" ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode); event.stopPropagation();"
ondragexit="nsDragAndDrop.dragExit(event, this.parentNode.parentNode); event.stopPropagation();"> ondragexit="nsDragAndDrop.dragExit(event, this.parentNode.parentNode); event.stopPropagation();">
<xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.hasAttribute('label')) { this.setAttribute('label', document.tooltipNode.getAttribute('label')); return true; } return false;"/> <xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.hasAttribute('label')) { this.setAttribute('label', document.tooltipNode.getAttribute('label')); return true; } return false;"/>
<xul:menupopup onpopupshowing="this.parentNode.parentNode.parentNode.updatePopupMenu(this);"> <xul:menupopup anonid="tabContextMenu" onpopupshowing="this.parentNode.parentNode.parentNode.updatePopupMenu(this);">
<xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;" <xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;"
xbl:inherits="oncommand=onnewtab"/> xbl:inherits="oncommand=onnewtab"/>
<xul:menuseparator/> <xul:menuseparator/>