diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 1c4b93510ddd..d388e5364379 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -190,7 +190,8 @@ var PlacesCommandHook = { } catch (e) { } - var parent = aParent != undefined ? aParent : PlacesUtils.unfiledRootId; + var parent = aParent != undefined ? + aParent : PlacesUtils.unfiledBookmarksFolderId; var descAnno = { name: DESCRIPTION_ANNO, value: description }; var txn = PlacesUtils.ptm.createItem(uri, parent, -1, title, null, [descAnno]); diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index 9066f494aae1..adaa7bac3871 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -89,7 +89,7 @@ observes="isImage"/> + oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksMenuFolderId);"/> GetBookmarksRoot(&root); + rv = bms->GetBookmarksMenuFolder(&root); NS_ENSURE_SUCCESS(rv, rv); PRInt64 folder; diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp index 2eea04bc8d47..1779020a60df 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -1174,7 +1174,7 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) { nsCOMPtr bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); PRInt64 root; - rv = bms->GetBookmarksRoot(&root); + rv = bms->GetBookmarksMenuFolder(&root); NS_ENSURE_SUCCESS(rv, rv); nsAutoString personalToolbarFolderName; diff --git a/browser/components/migration/src/nsOperaProfileMigrator.cpp b/browser/components/migration/src/nsOperaProfileMigrator.cpp index 5dd5ea5ea2fb..ad57d08b3546 100644 --- a/browser/components/migration/src/nsOperaProfileMigrator.cpp +++ b/browser/components/migration/src/nsOperaProfileMigrator.cpp @@ -1050,7 +1050,7 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace) nsCOMPtr bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); PRInt64 root; - rv = bms->GetBookmarksRoot(&root); + rv = bms->GetBookmarksMenuFolder(&root); NS_ENSURE_SUCCESS(rv, rv); PRInt64 parentFolder = root; diff --git a/browser/components/migration/src/nsSafariProfileMigrator.cpp b/browser/components/migration/src/nsSafariProfileMigrator.cpp index 909bb817edd8..09be79ce3967 100644 --- a/browser/components/migration/src/nsSafariProfileMigrator.cpp +++ b/browser/components/migration/src/nsSafariProfileMigrator.cpp @@ -905,7 +905,7 @@ nsSafariProfileMigrator::CopyBookmarks(PRBool aReplace) nsCOMPtr bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); PRInt64 root; - rv = bms->GetBookmarksRoot(&root); + rv = bms->GetBookmarksMenuFolder(&root); NS_ENSURE_SUCCESS(rv, rv); PRInt64 folder; diff --git a/browser/components/places/content/bookmarkProperties.js b/browser/components/places/content/bookmarkProperties.js index 3e2ddb3b3023..70d0b82fe489 100755 --- a/browser/components/places/content/bookmarkProperties.js +++ b/browser/components/places/content/bookmarkProperties.js @@ -201,7 +201,7 @@ var BookmarkPropertiesPanel = { else { // default to the bookmarks root this._defaultInsertionPoint = - new InsertionPoint(PlacesUtils.bookmarks.bookmarksRoot, -1); + new InsertionPoint(PlacesUtils.bookmarksMenuFolderId, -1); } switch(dialogInfo.type) { @@ -1041,12 +1041,19 @@ var BookmarkPropertiesPanel = { expander.getAttribute("tooltiptextup")); document.documentElement.buttons = "accept,cancel,extra2"; - if (!this._folderTree.treeBoxObject.view.isContainerOpen(0)) - this._folderTree.treeBoxObject.view.toggleOpenState(0); - this._folderTree.selectFolders([this._getFolderIdFromMenuList()]); + this._folderTree.collapsed = false; + + if (!this._folderTree.place) { + const FOLDER_TREE_PLACE_URI = + "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" + + PlacesUtils.allBookmarksFolderId; + this._folderTree.place = FOLDER_TREE_PLACE_URI; + } + + var currentFolder = this._getFolderIdFromMenuList(); + this._folderTree.selectItems([currentFolder]); this._folderTree.focus(); - this._folderTree.collapsed = false; resizeTo(window.outerWidth, window.outerHeight + this._folderTreeHeight); } }, @@ -1056,7 +1063,7 @@ var BookmarkPropertiesPanel = { var selectedItem = this._folderMenuList.selectedItem switch (selectedItem.id) { case "bookmarksRootItem": - return PlacesUtils.bookmarksRootId; + return PlacesUtils.bookmarksMenuFolderId; case "toolbarFolderItem": return PlacesUtils.toolbarFolderId; } @@ -1089,7 +1096,7 @@ var BookmarkPropertiesPanel = { } if (aCheckStaticFolderItems) { - if (aFolderId == PlacesUtils.bookmarksRootId) + if (aFolderId == PlacesUtils.bookmarksMenuFolderId) return this._element("bookmarksRootItem") if (aFolderId == PlacesUtils.toolbarFolderId) return this._element("toolbarFolderItem") @@ -1106,7 +1113,7 @@ var BookmarkPropertiesPanel = { if (this._folderTree.hidden) return; - this._folderTree.selectFolders([this._getFolderIdFromMenuList()]); + this._folderTree.selectItems([this._getFolderIdFromMenuList()]); }, onFolderTreeSelect: function BPP_onFolderTreeSelect() { @@ -1119,9 +1126,9 @@ var BookmarkPropertiesPanel = { // already selected var oldSelectedItem = this._folderMenuList.selectedItem; if ((oldSelectedItem.id == "toolbarFolderItem" && - folderId == PlacesUtils.bookmarks.toolbarFolder) || + folderId == PlacesUtils.toolbarFolderId) || (oldSelectedItem.id == "bookmarksRootItem" && - folderId == PlacesUtils.bookmarks.bookmarksRoot)) + folderId == PlacesUtils.bookmarksMenuFolderId)) return; var folderItem = this._getFolderMenuItem(folderId, false); diff --git a/browser/components/places/content/bookmarkProperties.xul b/browser/components/places/content/bookmarkProperties.xul index e660c2ff691a..1f1b47d6741f 100755 --- a/browser/components/places/content/bookmarkProperties.xul +++ b/browser/components/places/content/bookmarkProperties.xul @@ -163,8 +163,6 @@ height="150" persist="height" onselect="BookmarkPropertiesPanel.onFolderTreeSelect();" - showRoot="true" - place="place:folder=2&excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1" hidecolumnpicker="true"> diff --git a/browser/components/places/content/bookmarksPanel.js b/browser/components/places/content/bookmarksPanel.js index 2d12a2b7f51b..11e0c026d98e 100644 --- a/browser/components/places/content/bookmarksPanel.js +++ b/browser/components/places/content/bookmarksPanel.js @@ -36,7 +36,9 @@ # ***** END LICENSE BLOCK ***** function init() { - document.getElementById('search-box').focus(); + document.getElementById("bookmarks-view").place = + "place:queryType=1&folder=" + window.top.PlacesUtils.allBookmarksFolderId; + document.getElementById("search-box").focus(); } function searchBookmarks(aSearchString) { @@ -45,5 +47,7 @@ function searchBookmarks(aSearchString) { tree.place = tree.place; else tree.applyFilter(aSearchString, true, - [PlacesUtils.bookmarksRootId, PlacesUtils.unfiledRootId]); + [PlacesUtils.bookmarksMenuFolderId, + PlacesUtils.unfiledBookmarksFolderId, + PlacesUtils.toolbarFolderId]); } diff --git a/browser/components/places/content/bookmarksPanel.xul b/browser/components/places/content/bookmarksPanel.xul index 8de3bf4235ed..f1e01324aa8f 100644 --- a/browser/components/places/content/bookmarksPanel.xul +++ b/browser/components/places/content/bookmarksPanel.xul @@ -70,7 +70,6 @@ diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 5a9028a02dd1..3e234c179ec3 100755 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -160,18 +160,6 @@ PlacesController.prototype = { // Livemark containers if (PlacesUtils.nodeIsLivemarkContainer(selectedNode)) return true; - -#ifdef EXTENDED_LIVEBOOKMARKS_UI - // Subscriptions View - not yet exposed anywhere - if (selectedNode.uri.indexOf("livemark%2F") != -1) - return true; - - // children of a live bookmark (legacy bookmarks UI doesn't support - // this) - if (PlacesUtils.nodeIsURI() && - PlacesUtils.nodeIsLivemarkItem(selectedNode)) - return true; -#endif } return false; case "placesCmd_sortBy:name": @@ -181,15 +169,6 @@ PlacesController.prototype = { !PlacesUtils.nodeIsReadOnly(selectedNode) && this._view.getResult().sortingMode == Ci.nsINavHistoryQueryOptions.SORT_BY_NONE; - case "placesCmd_setAsBookmarksToolbarFolder": - if (this._view.hasSingleSelection) { - var selectedNode = this._view.selectedNode; - if (PlacesUtils.nodeIsFolder(selectedNode) && - selectedNode.itemId != PlacesUtils.toolbarFolderId) { - return true; - } - } - return false; default: return false; } @@ -266,7 +245,7 @@ PlacesController.prototype = { this.moveSelectedBookmarks(); break; case "placesCmd_reload": - this.reloadSelectedLivemarks(); + this.reloadSelectedLivemark(); break; case "placesCmd_reloadMicrosummary": this.reloadSelectedMicrosummary(); @@ -274,9 +253,6 @@ PlacesController.prototype = { case "placesCmd_sortBy:name": this.sortFolderByName(); break; - case "placesCmd_setAsBookmarksToolbarFolder": - this.setBookmarksToolbarFolder(); - break; } }, @@ -411,7 +387,6 @@ PlacesController.prototype = { * "separator" node is a separator line * "host" node is a host * "mutable" node can have items inserted or reordered - * "allLivemarks" node is a query containing every livemark * * @returns an array of objects corresponding the selected nodes. Each * object has each of the properties above set if its corresponding @@ -448,7 +423,6 @@ PlacesController.prototype = { break; case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER: nodeData["folder"] = true; - uri = PlacesUtils.bookmarks.getFolderURI(node.itemId); break; case Ci.nsINavHistoryResultNode.RESULT_TYPE_HOST: nodeData["host"] = true; @@ -489,29 +463,15 @@ PlacesController.prototype = { var names = PlacesUtils.annotations.getPageAnnotationNames(uri, {}); for (var j = 0; j < names.length; ++j) nodeData[names[j]] = true; + } - // For items also include the item-specific annotations - if ("bookmark" in nodeData || "folder" in nodeData) { - names = PlacesUtils.annotations - .getItemAnnotationNames(node.itemId, {}); - for (j = 0; j < names.length; ++j) - nodeData[names[j]] = true; - } + // For items also include the item-specific annotations + if (node.itemId != -1) { + names = PlacesUtils.annotations + .getItemAnnotationNames(node.itemId, {}); + for (j = 0; j < names.length; ++j) + nodeData[names[j]] = true; } -#ifdef EXTENDED_LIVEBOOKMARKS_UI - else if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) { - // Various queries might live in the left-hand side of the organizer - // window. If this one happens to have collected all the livemark feeds, - // allow its context menu to contain "Reload All Livemarks". That will - // usually only mean the Subscriptions folder, but if some other folder - // happens to use the same query, it's fine too. Queries have very - // limited data (no annotations), so we're left checking the query URI - // directly. - uri = PlacesUtils._uri(nodes[i].uri); - if (uri.spec == ORGANIZER_SUBSCRIPTIONS_QUERY) - nodeData["allLivemarks"] = true; - } -#endif metadata.push(nodeData); } @@ -716,32 +676,13 @@ PlacesController.prototype = { }, /** - * Reloads the livemarks associated with the selection. For the - * "Subscriptions" folder, reloads all livemarks; for a livemark folder, - * reloads its children; for a single livemark, reloads its siblings (the - * children of its parent). + * Reloads the selected livemark if any. */ - reloadSelectedLivemarks: function PC_reloadSelectedLivemarks() { - var selectedNode = this._view.selectedNode; + reloadSelectedLivemark: function PC_reloadSelectedLivemark() { if (this._view.hasSingleSelection) { -#ifdef EXTENDED_LIVEBOOKMARKS_UI - if (selectedNode.uri.indexOf("livemark%2F") != -1) { - PlacesUtils.livemarks.reloadAllLivemarks(); - return; - } -#endif - var folder = null; - if (PlacesUtils.nodeIsLivemarkContainer(selectedNode)) { - folder = selectedNode; - } -#ifdef EXTENDED_LIVEBOOKMARKS_UI - else if (PlacesUtils.nodeIsURI()) { - if (PlacesUtils.nodeIsLivemarkItem(selectedNode)) - folder = selectedNode.parent; - } -#endif - if (folder) - PlacesUtils.livemarks.reloadLivemarkFolder(folder.itemId); + var selectedNode = this._view.selectedNode; + if (PlacesUtils.nodeIsLivemarkContainer(selectedNode)) + PlacesUtils.livemarks.reloadLivemarkFolder(selectedNode.itemId); } }, @@ -883,19 +824,6 @@ PlacesController.prototype = { PlacesUtils.ptm.commitTransaction(txn); }, - /** - * Makes the selected node the bookmarks toolbar folder. - */ - setBookmarksToolbarFolder: function PC_setBookmarksToolbarFolder() { - if (!this._view.hasSingleSelection) - return; - - var selectedNode = this._view.selectedNode; - var txn = PlacesUtils.ptm.setBookmarksToolbar(selectedNode.itemId); - PlacesUtils.ptm.commitTransaction(txn); - }, - - /** * Walk the list of folders we're removing in this delete operation, and * see if the selected node specified is already implicitly being removed @@ -1687,7 +1615,6 @@ function goUpdatePlacesCommands() { updatePlacesCommand("placesCmd_new:separator"); updatePlacesCommand("placesCmd_show:info"); updatePlacesCommand("placesCmd_moveBookmarks"); - updatePlacesCommand("placesCmd_setAsBookmarksToolbarFolder"); updatePlacesCommand("placesCmd_reload"); updatePlacesCommand("placesCmd_reloadMicrosummary"); updatePlacesCommand("placesCmd_sortBy:name"); diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index 1efc47915a79..342a99459eb8 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -205,12 +205,21 @@ var gEditItemOverlay = { while (menupopup.childNodes.length > 4) menupopup.removeChild(menupopup.lastChild); - // only show "All Bookmarks" if the url isn't bookmarked somewhere else - this._element("unfiledRootItem").hidden = - aSelectedFolder != PlacesUtils.unfiledRootId; + const bms = PlacesUtils.bookmarks; + const annos = PlacesUtils.annotations; + + // Build the static list + var unfiledItem = this._element("unfiledRootItem"); + unfiledItem.label = bms.getItemTitle(PlacesUtils.unfiledBookmarksFolderId); + // only show "Unfiled Bookmarks" if the url isn't bookmarked somewhere else + unfiledItem.hidden = aSelectedFolder != PlacesUtils.unfiledBookmarksFolderId; + + this._element("bmRootItem").label = + bms.getItemTitle(PlacesUtils.bookmarksMenuFolderId); + this._element("toolbarFolderItem").label = + bms.getItemTitle(PlacesUtils.toolbarFolderId); // List of recently used folders: - var annos = PlacesUtils.annotations; var folderIds = annos.getItemsWithAnnotation(LAST_USED_ANNO, { }); /** @@ -571,25 +580,14 @@ var gEditItemOverlay = { this._folderTree.collapsed = false; if (!this._folderTree.place) { const FOLDER_TREE_PLACE_URI = - "place:folder=2&excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1"; + "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" + + window.top.PlacesUtils.allBookmarksFolderId; this._folderTree.place = FOLDER_TREE_PLACE_URI; } var currentFolder = this._getFolderIdFromMenuList(); - // Don't select anything in the tree if the item is "unfiled" - if (currentFolder == PlacesUtils.unfiledRootId) - this._folderTree.selectFolders([]); - else { - this._folderTree.selectFolders([currentFolder]); - this._folderTree.focus(); - } - - if ((currentFolder == PlacesUtils.bookmarksRootId || - currentFolder == PlacesUtils.unfiledRootId) && - !this._folderTree.treeBoxObject.view.isContainerOpen(0)) { - // Expand the root node if selectFolder didn't - this._folderTree.treeBoxObject.view.toggleOpenState(0); - } + this._folderTree.selectItems([currentFolder]); + this._folderTree.focus(); } }, @@ -598,9 +596,9 @@ var gEditItemOverlay = { var selectedItem = this._folderMenuList.selectedItem switch (selectedItem.id) { case "editBMPanel_unfiledRootItem": - return PlacesUtils.unfiledRootId; + return PlacesUtils.unfiledBookmarksFolderId; case "editBMPanel_bmRootItem": - return PlacesUtils.bookmarksRootId; + return PlacesUtils.bookmarksMenuFolderId; case "editBMPanel_toolbarFolderItem": return PlacesUtils.toolbarFolderId; } @@ -633,9 +631,9 @@ var gEditItemOverlay = { } if (aCheckStaticFolderItems) { - if (aFolderId == PlacesUtils.unfiledRootId) + if (aFolderId == PlacesUtils.unfiledBookmarksFolderId) return this._element("unfiledRootItem"); - if (aFolderId == PlacesUtils.bookmarksRootId) + if (aFolderId == PlacesUtils.bookmarksMenuFolderId) return this._element("bmRootItem"); if (aFolderId == PlacesUtils.toolbarFolderId) return this._element("toolbarFolderItem"); @@ -658,7 +656,7 @@ var gEditItemOverlay = { // Mark the containing folder as recently-used if it isn't the // "All Bookmarks" root - if (container != PlacesUtils.unfiledRootId) + if (container != PlacesUtils.unfiledBookmarksFolderId) this._markFolderAsRecentlyUsed(container); } @@ -666,7 +664,7 @@ var gEditItemOverlay = { if (!this._folderTree.collapsed) { var selectedNode = this._folderTree.selectedNode; if (!selectedNode || selectedNode.itemId != container) - this._folderTree.selectFolders([container]); + this._folderTree.selectItems([container]); } }, diff --git a/browser/components/places/content/editBookmarkOverlay.xul b/browser/components/places/content/editBookmarkOverlay.xul index 658e7bc01942..2120b7252343 100644 --- a/browser/components/places/content/editBookmarkOverlay.xul +++ b/browser/components/places/content/editBookmarkOverlay.xul @@ -41,6 +41,7 @@ ]> + @@ -117,13 +118,10 @@ @@ -143,7 +141,6 @@ height="150" collapsed="true" onselect="gEditItemOverlay.onFolderTreeSelect();" - showRoot="true" hidecolumnpicker="true" observes="paneElementsBroadcaster"> diff --git a/browser/components/places/content/menu.xml b/browser/components/places/content/menu.xml index 0e4536a2e581..4f6b4100f88a 100755 --- a/browser/components/places/content/menu.xml +++ b/browser/components/places/content/menu.xml @@ -324,6 +324,10 @@ var title = aNode.title; if (menuitem.getAttribute("label") != title) menuitem.setAttribute("label", title); + + if (!menuitem.hasAttribute("livemark") && + PlacesUtils.nodeIsLivemarkContainer(aNode)) + menuItem.setAttribute("livemark", "true"); }, itemReplaced: diff --git a/browser/components/places/content/moveBookmarks.js b/browser/components/places/content/moveBookmarks.js index 1d7d2bea3dc1..d23e65399717 100644 --- a/browser/components/places/content/moveBookmarks.js +++ b/browser/components/places/content/moveBookmarks.js @@ -52,9 +52,9 @@ var gMoveBookmarksDialog = { this._nodes = window.arguments[0]; this._tm = window.arguments[1]; - // select and expand the root node - this.foldersTree.selectFolders([PlacesUtils.bookmarksRootId]); - this.foldersTree.selectedNode.containerOpen = true; + this.foldersTree.place = + "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" + + PlacesUtils.allBookmarksFolderId; }, onOK: function MBD_onOK(aEvent) { diff --git a/browser/components/places/content/moveBookmarks.xul b/browser/components/places/content/moveBookmarks.xul index 81d4ecb341d8..0b450af8e862 100644 --- a/browser/components/places/content/moveBookmarks.xul +++ b/browser/components/places/content/moveBookmarks.xul @@ -67,9 +67,7 @@ class="placesTree" flex="1" type="places" - showRoot="true" seltype="single" - place="place:folder=2&excludeItems=1&excludeReadOnlyFolders=1" hidecolumnpicker="true"> diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index fef15dc7a6ad..f034f0b84594 100755 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -37,35 +37,22 @@ * * ***** END LICENSE BLOCK ***** */ -const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - -/** - * Selects a place URI in the places list. - * This function is global so it can be easily accessed by openers. - * @param placeURI - * A place: URI string to select - */ -function selectPlaceURI(placeURI) { - PlacesOrganizer._places.selectPlaceURI(placeURI); -} - var PlacesOrganizer = { _places: null, _content: null, + _initFolderTree: function() { + var leftPaneRoot = PlacesUtils.leftPaneFolderId; + var allBookmarksId = PlacesUtils.allBookmarksFolderId; + this._places.place = "place:excludeItems=1&expandQueries=0&folder=" + leftPaneRoot; + this._places.selectItems([allBookmarksId]); + asContainer(this._places.selectedNode).containerOpen = true; + }, + init: function PO_init() { this._places = document.getElementById("placesList"); this._content = document.getElementById("placeContent"); - - OptionsFilter.init(Groupers); - Groupers.init(); - - // Select the specified place in the places list. - var placeURI = "place:"; - if ("arguments" in window) - placeURI = window.arguments[0]; - - selectPlaceURI(placeURI); + this._initFolderTree(); var view = this._content.treeBoxObject.view; if (view.rowCount > 0) @@ -140,99 +127,6 @@ var PlacesOrganizer = { this.location = historyEntry; }, - HEADER_TYPE_SHOWING: 1, - HEADER_TYPE_SEARCH: 2, - HEADER_TYPE_ADVANCED_SEARCH: 3, - - /** - * Updates the text shown in the heading banner above the content view. - * @param type - * The type of information being shown - normal (built-in history or - * other query, bookmark folder), search results from the toolbar - * search box, or advanced search. - * @param text - * The text (if any) to display - */ - setHeaderText: function PO_setHeaderText(type, text) { - NS_ASSERT(type == 1 || type == 2 || type == 3, "Invalid Header Type"); - - var prefix = document.getElementById("showingPrefix"); - prefix.setAttribute("value", - PlacesUtils.getString("headerTextPrefix" + type)); - - var contentTitle = document.getElementById("contentTitle"); - contentTitle.setAttribute("value", text); - }, - - onPlaceURIKeypress: function PO_onPlaceURIKeypress(aEvent) { - var keyCode = aEvent.keyCode; - if (keyCode == KeyEvent.DOM_VK_RETURN) - this.loadPlaceURI(); - else if (keyCode == KeyEvent.DOM_VK_ESCAPE) { - event.target.value = ""; - this.onPlaceSelected(true); - } - }, - - /** - * Shows or hides the debug panel. - */ - toggleDebugPanel: function PO_toggleDebugPanel() { - var dp = document.getElementById("debugPanel"); - dp.hidden = !dp.hidden; - if (!dp.hidden) - document.getElementById("placeURI").focus(); - }, - - /** - * Loads the place URI entered in the debug - */ - loadPlaceURI: function PO_loadPlaceURI() { - // clear forward history - this._forwardHistory.splice(0); - - var placeURI = document.getElementById("placeURI"); - - var queriesRef = { }, optionsRef = { }; - PlacesUtils.history.queryStringToQueries(placeURI.value, - queriesRef, { }, optionsRef); - - // for debug panel - var autoFilterResults = document.getElementById("autoFilterResults"); - if (autoFilterResults.checked) { - var options = - OptionsFilter.filter(queriesRef.value, optionsRef.value, null); - } - else - options = optionsRef.value; - - this.location = - PlacesUtils.history.queriesToQueryString(queriesRef.value, - queriesRef.value.length, - options); - - placeURI.value = this.location; - - this.setHeaderText(this.HEADER_TYPE_SHOWING, "Debug results for: " + placeURI.value); - - this.updateLoadedURI(); - - placeURI.focus(); - }, - - /** - * Updates the URI displayed in the debug panel. - */ - updateLoadedURI: function PO_updateLoadedURI() { - var queryNode = asQuery(this._content.getResult().root); - var queries = queryNode.getQueries({}); - var options = queryNode.queryOptions; - var loadedURI = document.getElementById("loadedURI"); - loadedURI.value = - PlacesUtils.history.queriesToQueryString(queries, queries.length, - options); - }, - /** * Called when a place folder is selected in the left pane. * @param resetSearchBox @@ -264,10 +158,6 @@ var PlacesOrganizer = { searchFilter.reset(); } - this.setHeaderText(this.HEADER_TYPE_SHOWING, node.title); - - this.updateLoadedURI(); - // Update the "Find in " command and the gray text in // the search box in the toolbar if the active collection is the current // collection. @@ -308,7 +198,22 @@ var PlacesOrganizer = { } }, - onTreeDblClick: function PO_onTreeDblClick(aEvent) { + _openSelectedRow: function PO__openSelectedRow(aEvent) { + var node = this._content.selectedNode; + if (!node) + return; + + if (PlacesUtils.nodeIsContainer(node)) { + if (node.itemId != -1) + this._places.selectItems([node.itemId]); + else if (PlacesUtils.nodeIsQuery(node)) + this._places.selectPlaceURI(node.uri); + } + else if (PlacesUtils.nodeIsURI(this._content.selectedNode)) + this._content.controller.openSelectedNodeWithEvent(aEvent); + }, + + onContentTreeDblClick: function PO_onContentTreeDblClick(aEvent) { if (aEvent.button != 0 || !this._content.hasSingleSelection || aEvent.originalTarget.localName != "treechildren") return; @@ -316,10 +221,15 @@ var PlacesOrganizer = { var row = { }, col = { }, obj = { }; this._content.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj); - if (row.value == -1 || obj.value == "twisty") + if (row.value == -1) return; - this._content.controller.openSelectedNodeWithEvent(aEvent); + this._openSelectedRow(aEvent); + }, + + onContentTreeKeypress: function PO_onContentTreeKeypress(aEvent) { + if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) + this._openSelectedRow(aEvent); }, /** @@ -555,6 +465,7 @@ var PlacesOrganizer = { } }, + // NOT YET USED updateThumbnailProportions: function PO_updateThumbnailProportions() { var previewBox = document.getElementById("previewBox"); var canvas = document.getElementById("itemThumbnail"); @@ -592,8 +503,6 @@ var PlacesOrganizer = { { hiddenRows: ["folderPicker"] }); this._detectAndSetDetailsPaneMinimalState(selectedNode); - this.updateThumbnailProportions(); - this._updateThumbnail(); return; } } @@ -617,9 +526,6 @@ var PlacesOrganizer = { [rowCount]); } } - - this.updateThumbnailProportions(); - this._updateThumbnail(); } // Nothing to do if the pane was already disabled @@ -630,6 +536,7 @@ var PlacesOrganizer = { } }, + // NOT YET USED _updateThumbnail: function PO__updateThumbnail() { var bo = document.getElementById("previewBox").boxObject; var width = bo.width; @@ -711,7 +618,7 @@ var PlacesOrganizer = { // Add the place: uri as a bookmark under the bookmarks root. var txn = PlacesUtils.ptm.createItem(placeURI, - PlacesUtils.bookmarksRootId, + PlacesUtils.bookmarksMenuFolderId, PlacesUtils.bookmarks.DEFAULT_INDEX, input.value); PlacesUtils.ptm.commitTransaction(txn); @@ -736,7 +643,9 @@ var PlacesSearchBox = { _folders: [], get folders() { if (this._folders.length == 0) - this._folders.push(PlacesUtils.bookmarksRootId, PlacesUtils.unfiledRootId); + this._folders.push(PlacesUtils.bookmarksMenuFolderId, + PlacesUtils.unfiledBookmarksFolderId, + PlacesUtils.toolbarFolderId); return this._folders; }, set folders(aFolders) { @@ -774,8 +683,9 @@ var PlacesSearchBox = { break; case "bookmarks": content.applyFilter(filterString, true, - [PlacesUtils.bookmarksRootId, - PlacesUtils.unfiledRootId]); + [PlacesUtils.bookmarksMenuFolderId, + PlacesUtils.toolbarFolderId, + PlacesUtils.unfiledBookmarksFolderId]); break; case "history": if (currentOptions.queryType != Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) { @@ -794,7 +704,6 @@ var PlacesSearchBox = { break; } - PO.setHeaderText(PO.HEADER_TYPE_SEARCH, filterString); PlacesSearchBox.showSearchUI(); this.searchFilter.setAttribute("filtered", "true"); }, @@ -1029,9 +938,6 @@ var PlacesQueryBuilder = { var titleDeck = document.getElementById("titleDeck"); titleDeck.setAttribute("selectedIndex", (this.numRows <= 1) ? 0 : 1); - const asType = PlacesOrganizer.HEADER_TYPE_ADVANCED_SEARCH; - PlacesOrganizer.setHeaderText(asType, ""); - // Update the "can add more criteria" command to make sure various + // buttons are disabled. var command = document.getElementById("OrganizerCommand_search:moreCriteria"); @@ -1374,7 +1280,6 @@ var PlacesQueryBuilder = { // XXXben - find some public way of doing this! PlacesOrganizer._content.load(this.queries, OptionsFilter.filter(this.queries, this.options, null)); - PlacesOrganizer.updateLoadedURI(); }, onScopeSelected: function PQB_onScopeSelected(aButton) { @@ -1403,7 +1308,7 @@ var PlacesQueryBuilder = { break; case "scopeBarMenu": PlacesSearchBox.filterCollection = "collection"; - folders.push(PlacesUtils.bookmarksRootId); + folders.push(PlacesUtils.bookmarksMenuFolderId); break; case "scopeBarHistory": PlacesSearchBox.filterCollection = "history"; @@ -1411,8 +1316,9 @@ var PlacesQueryBuilder = { break; default: // all bookmarks PlacesSearchBox.filterCollection = "bookmarks"; - folders.push(PlacesUtils.bookmarksRootId, - PlacesUtils.unfiledRootId); + folders.push(PlacesUtils.bookmarksMenuFolderId, + PlacesUtils.toolbarFolderId, + PlacesUtils.unfiledBookmarksFolderId); } // set scope, and re-search @@ -1505,7 +1411,7 @@ var ViewMenu = { var columns = content.columns; for (var i = 0; i < columns.count; ++i) { var column = columns.getColumnAt(i).element; - var menuitem = document.createElementNS(XUL_NS, "menuitem"); + var menuitem = document.createElement("menuitem"); menuitem.id = "menucol_" + column.id; menuitem.setAttribute("column", column.id); var label = column.getAttribute("label"); @@ -1690,225 +1596,3 @@ var ViewMenu = { OptionsFilter.update(result); } }; - -/** - * A "Configuration" set for a class of history query results. Some results - * will require that the grouping UI be labeled differently from the standard - * so this object is provided to allow those results to configure the UI when - * they are displayed. - * @param substr - * A prefix substring of an annotation that the result's query - * matches. - * @param onLabel - * The label for the "Grouping On" command - * @param onAccesskey - * The accesskey for the "Grouping On" command - * @param offLabel - * The label for the "Grouping Off" command - * @param offAccesskey - * The accesskey for the "Grouping Off" command - * @param onOncommand - * The "oncommand" attribute of the "Grouping On" command - * @param offOncommand - * The "oncommand" attribute of the "Grouping Off" command - * @param disabled - * Whether or not grouping is disabled for results that match this - * config. - */ -function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey, - onOncommand, offOncommand, disabled) { - this.substr = substr; - this.onLabel = onLabel; - this.onAccesskey = onAccesskey; - this.offLabel = offLabel; - this.offAccesskey = offAccesskey; - this.onOncommand = onOncommand; - this.offOncommand = offOncommand; - this.disabled = disabled; -} - -/** - * Handles Grouping within the Content View, and the commands that support it. - */ -var Groupers = { - defaultGrouper: null, - annotationGroupers: [], - - /** - * Initializes groupings for various view types. - */ - init: function G_init() { - this.defaultGrouper = - new GroupingConfig(null, PlacesUtils.getString("defaultGroupOnLabel"), - PlacesUtils.getString("defaultGroupOnAccesskey"), - PlacesUtils.getString("defaultGroupOffLabel"), - PlacesUtils.getString("defaultGroupOffAccesskey"), - "Groupers.groupBySite()", - "Groupers.groupByPage()", false); - var subscriptionConfig = - new GroupingConfig("livemark/", PlacesUtils.getString("livemarkGroupOnLabel"), - PlacesUtils.getString("livemarkGroupOnAccesskey"), - PlacesUtils.getString("livemarkGroupOffLabel"), - PlacesUtils.getString("livemarkGroupOffAccesskey"), - "Groupers.groupByFeed()", - "Groupers.groupByPost()", false); - this.annotationGroupers.push(subscriptionConfig); - }, - - /** - * Get the most appropriate GroupingConfig for the set of queries that are - * about to be executed. - * @param queries - * An array of queries that are about to be executed. - * @param handler - * Optionally specify which handler to use to filter the options. - * If null, the default handler for the queries will be used. - */ - _getConfig: function G__getConfig(queries, handler) { - if (!handler) - handler = OptionsFilter.getHandler(queries); - - // If the queries will generate a bookmarks folder, there is no "grouper - // config" since all of the grouping UI should be hidden (there is only one - // grouping mode - group by folder). - if (handler == OptionsFilter.bookmarksHandler) - return null; - - var query = queries[0]; - for (var i = 0; i < this.annotationGroupers.length; ++i) { - var config = this.annotationGroupers[i]; - if (query.annotation.substr(0, config.substr.length) == config.substr && - !config.disabled) - return config; - } - - return this.defaultGrouper; - }, - - /** - * Updates the grouping broadcasters for the given result. - * @param queries - * An array of queries that are going to be executed. - * @param options - * The options that are being used to generate the forthcoming - * result. - * @param handler - * Optionally specify which handler to use to filter the options. - * If null, the default handler for the queries will be used. - * @param - */ - updateGroupingUI: function G_updateGroupingUI(queries, options, handler) { - var separator = document.getElementById("placesBC_grouping:separator"); - var groupOff = document.getElementById("placesBC_grouping:off"); - var groupOn = document.getElementById("placesBC_grouping:on"); - separator.removeAttribute("hidden"); - groupOff.removeAttribute("hidden"); - groupOn.removeAttribute("hidden"); - - // Walk the list of registered annotationGroupers, determining what are - // available and notifying the broadcaster - var config = this._getConfig(queries, handler); - if (!config) { - // Generic Bookmarks Folder or custom container that disables grouping. - separator.setAttribute("hidden", "true"); - groupOff.setAttribute("hidden", "true"); - groupOn.setAttribute("hidden", "true"); - } - else { - groupOn.setAttribute("label", config.onLabel); - groupOn.setAttribute("accesskey", config.onAccesskey); - groupOn.setAttribute("oncommand", config.onOncommand); - groupOff.setAttribute("label", config.offLabel); - groupOff.setAttribute("accesskey", config.offAccesskey); - groupOff.setAttribute("oncommand", config.offOncommand); - // Update the checked state of the UI: - // Grouping UI is "enabled" if there is at least one set of grouping - // options. - var groupingsCountRef = { }; - options.getGroupingMode(groupingsCountRef); - this._updateBroadcasters(groupingsCountRef.value > 0); - } - }, - - /** - * Update the visual state of UI that controls grouping. - */ - _updateBroadcasters: function G__updateGroupingBroadcasters(on) { - var groupingOn = document.getElementById("placesBC_grouping:on"); - var groupingOff = document.getElementById("placesBC_grouping:off"); - if (on) { - groupingOn.setAttribute("checked", "true"); - groupingOff.removeAttribute("checked"); - } - else { - groupingOff.setAttribute("checked", "true"); - groupingOn.removeAttribute("checked"); - } - }, - - /** - * Shows visited pages grouped by site. - */ - groupBySite: function G_groupBySite() { - var query = asQuery(PlacesOrganizer._content.getResult().root); - var queries = query.getQueries({ }); - var options = query.queryOptions; - var newOptions = options.clone(); - const NHQO = Ci.nsINavHistoryQueryOptions; - newOptions.setGroupingMode([NHQO.GROUP_BY_DOMAIN], 1); - var content = PlacesOrganizer._content; - content.load(queries, newOptions); - PlacesOrganizer.updateLoadedURI(); - this._updateBroadcasters(true); - OptionsFilter.update(content.getResult()); - }, - - /** - * Shows visited pages without grouping. - */ - groupByPage: function G_groupByPage() { - var query = asQuery(PlacesOrganizer._content.getResult().root); - var queries = query.getQueries({ }); - var options = query.queryOptions; - var newOptions = options.clone(); - newOptions.setGroupingMode([], 0); - var content = PlacesOrganizer._content; - content.load(queries, newOptions); - PlacesOrganizer.updateLoadedURI(); - this._updateBroadcasters(false); - OptionsFilter.update(content.getResult()); - }, - - /** - * Shows all subscribed feeds (Live Bookmarks) grouped under their parent - * feed. - */ - groupByFeed: function G_groupByFeed() { - var content = PlacesOrganizer._content; - var query = asQuery(content.getResult().root); - var queries = query.getQueries({ }); - var newOptions = query.queryOptions.clone(); - var newQuery = queries[0].clone(); - newQuery.annotation = "livemark/feedURI"; - content.load([newQuery], newOptions); - PlacesOrganizer.updateLoadedURI(); - this._updateBroadcasters(false); - OptionsFilter.update(content.getResult()); - }, - - /** - * Shows all subscribed feed (Live Bookmarks) content in a flat list - */ - groupByPost: function G_groupByPost() { - var content = PlacesOrganizer._content; - var query = asQuery(content.getResult().root); - var queries = query.getQueries({ }); - var newOptions = query.queryOptions.clone(); - var newQuery = queries[0].clone(); - newQuery.annotation = "livemark/bookmarkFeedURI"; - content.load([newQuery], newOptions); - PlacesOrganizer.updateLoadedURI(); - this._updateBroadcasters(false); - OptionsFilter.update(content.getResult()); - } -}; diff --git a/browser/components/places/content/places.xul b/browser/components/places/content/places.xul index 3a63fcf6c038..65fef2104d0d 100755 --- a/browser/components/places/content/places.xul +++ b/browser/components/places/content/places.xul @@ -112,20 +112,11 @@ oncommand="PlacesOrganizer.forward();"/> - - - - - - - - - - - - @@ -195,6 +168,7 @@ label="&cmd.new_separator.label;" accesskey="&cmd.new_separator.accesskey;"/> +#ifndef XP_MACOSX +#endif - + - +#ifndef XP_MACOSX +#endif @@ -351,18 +330,16 @@ + width="200"> - + - + @@ -370,12 +347,6 @@ - - + flex="1" type="places" + flatList="true" + ondblclick="PlacesOrganizer.onContentTreeDblClick(event);" + onkeypress="PlacesOrganizer.onContentTreeKeypress(event);" + onselect="PlacesOrganizer.onContentTreeSelect();" + onclick="PlacesOrganizer.onTreeClick(event);"> - - - - - + - - - @@ -484,39 +454,6 @@ -