diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index af69b6369d20..896507c5126f 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -367,6 +367,10 @@ + diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index a8ad1d8adb63..374b2ceb3ec1 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -147,7 +147,8 @@ - + + diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 5fcf589b246f..ed214b324827 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -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 = { observe: function(subject, topic, data) { @@ -769,6 +800,8 @@ function delayedStartup() initFindBar(); + // add bookmark options to context menu for tabs + addBookmarkMenuitems(); // now load bookmarks BMSVC.readBookmarks(); var bt = document.getElementById("bookmarks-ptf"); @@ -1508,16 +1541,16 @@ function updateGoMenu(goMenu) endSep.hidden = false; } -function addBookmarkAs(aBrowser, aIsWebPanel) +function addBookmarkAs(aBrowser, aBookmarkAllTabs, aIsWebPanel) { const browsers = aBrowser.browsers; if (browsers && browsers.length > 1) - addBookmarkForTabBrowser(aBrowser); + addBookmarkForTabBrowser(aBrowser, aBookmarkAllTabs); else addBookmarkForBrowser(aBrowser.webNavigation, aIsWebPanel); } -function addBookmarkForTabBrowser(aTabBrowser, aSelect) +function addBookmarkForTabBrowser(aTabBrowser, aBookmarkAllTabs, aSelect) { var tabsInfo = []; var currentTabInfo = { name: "", url: "", charset: null }; @@ -1537,11 +1570,16 @@ function addBookmarkForTabBrowser(aTabBrowser, aSelect) } catch (e) { 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) currentTabInfo = tabsInfo[i]; } var dialogArgs = currentTabInfo; + if (aBookmarkAllTabs) { + dialogArgs = { name: gNavigatorBundle.getString("bookmarkAllTabsDefault") }; + dialogArgs.bBookmarkAllTabs = true; + } + dialogArgs.objGroup = tabsInfo; openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "", BROWSER_ADD_BM_FEATURES, dialogArgs); @@ -3427,7 +3465,7 @@ nsBrowserStatusHandler.prototype = } } UpdateBackForwardButtons(); - + UpdateBookmarkAllTabsMenuitem(); if (findField && gFindMode != FIND_NORMAL) { // Close the Find toolbar if we're in old-style TAF mode closeFindBar(); diff --git a/browser/components/bookmarks/content/addBookmark2.js b/browser/components/bookmarks/content/addBookmark2.js index acd1c4cf550c..fc7790eef759 100644 --- a/browser/components/bookmarks/content/addBookmark2.js +++ b/browser/components/bookmarks/content/addBookmark2.js @@ -52,36 +52,36 @@ * Apart from the standard openDialog parameters, this dialog can * be passed additional information, which is contained in the * wArg object: - * - * wArg.name : Bookmark Name. The value to be prefilled - * into the "Name: " field (if visible). - * wArg.description : Bookmark description. The value to be added - * : to the boomarks description field. - * wArg.url : Bookmark URL: The location of the bookmark. - * The value to be filled in the "Location: " - * field (if visible). - * wArg.folderURI : Bookmark Folder. The RDF Resource URI of the - * folder that this bookmark should be created in. - * wArg.charset : Bookmark Charset. The charset that should be - * used when adding a bookmark to the specified - * URL. (Usually the charset of the current - * document when launching this window). - * wArg.bAddGroup : True if adding a group of tabs, false - * otherwise. - * wArg.objGroup[] : If adding a group of tabs, this is an array - * of wArg objects with name, URL and charset - * properties, one for each group member. - * wArg.bWebPanel : If the bookmark should become a web panel. - * wArg.keyword : A suggested keyword for the bookmark. If this - * argument is supplied, the keyword row is made - * visible. - * wArg.bNeedKeyword : Whether or not a keyword is required to add - * the bookmark. - * wArg.postData : PostData to be saved with this bookmark, - * in the format a string of name=value pairs - * separated by CRLFs. - * wArg.feedURL : feed URL for Livemarks (turns bookmark - * into Livemark) + * + * wArg.name : Bookmark Name. The value to be prefilled + * into the "Name: " field (if visible). + * wArg.description : Bookmark description. The value to be added + * : to the boomarks description field. + * wArg.url : Bookmark URL: The location of the bookmark. + * The value to be filled in the "Location: " + * field (if visible). + * wArg.folderURI : Bookmark Folder. The RDF Resource URI of the + * folder that this bookmark should be created in. + * wArg.charset : Bookmark Charset. The charset that should be + * used when adding a bookmark to the specified + * URL. (Usually the charset of the current + * document when launching this window). + * wArg.bBookmarkAllTabs : True if "Bookmark All Tabs" option is chosen, + * false otherwise. + * wArg.objGroup[] : If adding a group of tabs, this is an array + * of wArg objects with name, URL and charset + * properties, one for each group member. + * wArg.bWebPanel : If the bookmark should become a web panel. + * wArg.keyword : A suggested keyword for the bookmark. If this + * argument is supplied, the keyword row is made + * visible. + * wArg.bNeedKeyword : Whether or not a keyword is required to add + * the bookmark. + * wArg.postData : PostData to be saved with this bookmark, + * in the format a string of name=value pairs + * separated by CRLFs. + * wArg.feedURL : feed URL for Livemarks (turns bookmark + * into Livemark) */ var gSelectedFolder; @@ -91,7 +91,6 @@ var gKeywordRow; var gExpander; var gMenulist; var gBookmarksTree; -var gGroup; var gKeywordRequired; var gSuggestedKeyword; var gRequiredFields = []; @@ -110,7 +109,6 @@ function Startup() gRequiredFields.push(gName); gKeywordRow = document.getElementById("keywordRow"); gKeyword = document.getElementById("keyword"); - gGroup = document.getElementById("addgroup"); gExpander = document.getElementById("expander"); gMenulist = document.getElementById("select-menu"); gBookmarksTree = document.getElementById("folder-tree"); @@ -127,10 +125,9 @@ function Startup() if (gKeywordRequired) gRequiredFields.push(gKeyword); } - if (!gArg.bAddGroup) - gGroup.setAttribute("hidden", "true"); sizeToContent(); onFieldInput(); + initTitle(); gSelectedFolder = RDF.GetResource(gMenulist.selectedItem.id); gExpander.setAttribute("tooltiptext", gExpander.getAttribute("tooltiptextdown")); gPostData = gArg.postData; @@ -170,6 +167,14 @@ function Startup() 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() { var ok = document.documentElement.getButton("accept"); @@ -188,7 +193,7 @@ function onOK() var url, rSource; var livemarkFeed = gArg.feedURL; - if (gGroup && gGroup.checked) { + if (gArg.bBookmarkAllTabs) { rSource = BMDS.createFolder(gName.value); const groups = gArg.objGroup; for (var i = 0; i < groups.length; ++i) { diff --git a/browser/components/bookmarks/content/addBookmark2.xul b/browser/components/bookmarks/content/addBookmark2.xul index 00c978c48cea..723475b25b18 100644 --- a/browser/components/bookmarks/content/addBookmark2.xul +++ b/browser/components/bookmarks/content/addBookmark2.xul @@ -62,7 +62,7 @@ #endif buttoniconaccept="add" buttoniconextra2="open" - title="&newBookmark.title;" title-selectFolder="&selectFolder.label;" + title-selectFolder="&selectFolder.label;" onload="Startup();" onunload="setFolderTreeHeight();" persist="screenX screenY width"> @@ -70,7 +70,7 @@