diff --git a/mozilla/browser/base/content/browser-menubar.inc b/mozilla/browser/base/content/browser-menubar.inc index a95263eef42..378dd70a038 100644 --- a/mozilla/browser/base/content/browser-menubar.inc +++ b/mozilla/browser/base/content/browser-menubar.inc @@ -439,13 +439,18 @@ #else - + - + + - #endif diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index a53408c16e8..e56ae9cf448 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -6974,5 +6974,87 @@ var HistoryMenu = { }, }; +/* + * Functions for the Bookmarks Menu + */ +var BookmarksMenu = { + /* + * Handler for when an item in the bookmarks menu is clicked. + * If the click is a middle-click, opens the item in a new tab + * and closes the menu. (Left-clicks are handled by the command handler) + * @param event DOMEvent for the click + */ + onClick: function BM_onClick(event) { + if (event.button == 1) { + PlacesController.mouseLoadURI(event); + // Menus selected with middle click must be closed manually. + var node = event.target; + while (node && + (node.localName == "menu" || + node.localName == "menupopup")) { + if (node.localName == "menupopup") + node.hidePopup(); + + node = node.parentNode; + } + } + }, + + /* + * Handler for command event for an item in the bookmarks menu. + * Opens the item. + * @param event DOMEvent for the command + */ + onCommand: function BM_onCommand(event) { + PlacesController.mouseLoadURI(event); + } +}; + +/* + * Functions for the Bookmarks Toolbar + */ +var BookmarksToolbar = { + /* + * Handler for click event for an item in the bookmarks toolbar. + * Menus and submenus from the folder buttons bubble up to this handler. + * Only handle middle-click; left-click is handled in the onCommand function. + * When items are middle-clicked, open them in tabs. + * If the click came through a menu, close the menu. + * @param event DOMEvent for the click + */ + onClick: function BT_onClick(event) { + // Only handle middle-clicks. + if (event.button != 1) + return; + + PlacesController.openLinksInTabs(); + + // If this event bubbled up from a menu or menuitem, + // close the menus. + if (event.target.localName == "menu" || + event.target.localName == "menuitem") { + var node = event.target; + while (node && + (node.localName == "menu" || + node.localName == "menupopup")) { + if (node.localName == "menupopup") + node.hidePopup(); + + node = node.parentNode; + } + } + }, + + /* + * Handler for command event for an item in the bookmarks toolbar. + * Menus and submenus from the folder buttons bubble up to this handler. + * Opens the item. + * @param event DOMEvent for the command + */ + onCommand: function BM_onCommand(event) { + PlacesController.mouseLoadURI(event); + } +}; + #endif diff --git a/mozilla/browser/base/content/browser.xul b/mozilla/browser/base/content/browser.xul index 2553583c3c3..e3ef1bdfd10 100644 --- a/mozilla/browser/base/content/browser.xul +++ b/mozilla/browser/base/content/browser.xul @@ -273,7 +273,10 @@ - + @@ -45,8 +45,13 @@ + + diff --git a/mozilla/browser/components/places/content/controller.js b/mozilla/browser/components/places/content/controller.js index 55844ef56cc..8af6c70fb44 100755 --- a/mozilla/browser/components/places/content/controller.js +++ b/mozilla/browser/components/places/content/controller.js @@ -632,6 +632,7 @@ var PlacesController = { this.nodeIsFolder(this._activeView.selectedNode); this._setEnabled("placesCmd_open:tabs", singleFolderSelected || !hasSingleSelection); + this._setEnabled("placesCmd_open:tabsEnabled", true); // Always on // Some views, like menupopups, destroy their result as they hide, but they // are still the "last-active" view. Don't barf. @@ -799,6 +800,8 @@ var PlacesController = { var node = this._activeView.selectedNode; if (this._activeView.hasSingleSelection && this.nodeIsFolder(node)) { asFolder(node); + var wasOpen = node.containerOpen; + node.containerOpen = true; var cc = node.childCount; for (var i = 0; i < cc; ++i) { var childNode = node.getChild(i); @@ -806,6 +809,7 @@ var PlacesController = { this._activeView.browserWindow.openNewTabWith(childNode.uri, null, null); } + node.containerOpen = wasOpen; } else { var nodes = this._activeView.getSelectionNodes(); @@ -1065,8 +1069,11 @@ var PlacesController = { var parent = node.parent; if (!parent || !this.nodeIsContainer(parent)) return -1; - var cc = asContainer(parent).childCount; + var wasOpen = parent.containerOpen; + parent.containerOpen = true; + var cc = parent.childCount; for (var i = 0; i < cc && asContainer(parent).getChild(i) != node; ++i); + parent.containerOpen = wasOpen; return i < cc ? i : -1; }, @@ -1195,6 +1202,8 @@ var PlacesController = { // Get the folder's children var kids = self.getFolderContents(folderId, false, false); + var wasOpen = kids.containerOpen; + kids.containerOpen = true; var cc = kids.childCount; for (var i = 0; i < cc; ++i) { var node = kids.getChild(i); @@ -1206,6 +1215,7 @@ var PlacesController = { index)); } } + kids.containerOpen = wasOpen; } createTransactions(data.folderId, container, index); return new PlacesAggregateTransaction("FolderCopy", transactions); @@ -1800,6 +1810,9 @@ PlacesRemoveFolderTransaction.prototype = { */ _saveFolderContents: function PRFT__saveFolderContents(id, parent) { var contents = PlacesController.getFolderContents(id, false, false); + // Container open status doesn't need to be reset to what it was before + // because it's being deleted. + contents.containerOpen = true; for (var i = contents.childCount - 1; i >= 0; --i) { var child = contents.getChild(i); var obj = null; diff --git a/mozilla/browser/components/places/content/menu.xml b/mozilla/browser/components/places/content/menu.xml index 6f1b227fc05..4c525c84a2a 100755 --- a/mozilla/browser/components/places/content/menu.xml +++ b/mozilla/browser/components/places/content/menu.xml @@ -10,6 +10,9 @@ extends="chrome://global/content/bindings/popup.xml#popup"> 0) + --this._endMarker; + } // If no static items were found at the beginning, remove all items before // the static items at the end. @@ -112,6 +118,8 @@ var end = (this._endMarker == -1) ? this.childNodes.length - 1 : this._endMarker - 1; for (var i = end; i >=0; i--) { this.removeChild(this.childNodes[i]); + if (this._endMarker > 0) + --this._endMarker; } } LOG("KIDS = " + this.childNodes.length); @@ -173,6 +181,8 @@ element.setAttribute("label", child.title); var popup = document.createElementNS(XULNS, "menupopup"); popup.setAttribute("type", "places"); + if (this.hasAttribute("openInTabs")) + popup.setAttribute("openInTabs", "all"); // Include menu option to open in tabs. element.appendChild(popup); #ifndef XP_MACOSX // No context menus on menus on Mac @@ -220,6 +230,18 @@ } } + // If this menu has the attribute set to open children in tabs, + // add the menuitems here to do that. + if ((cc > 0) && this.getAttribute("openInTabs") == "all") { + var separator = document.createElementNS(XULNS, "menuseparator"); + this.appendChild(separator); + var openInTabs = document.createElementNS(XULNS, "menuitem"); + openInTabs.setAttribute("label", this._labelOpenInTabs); + openInTabs.setAttribute("accesskey", this._accesskeyOpenInTabs); + openInTabs.setAttribute("command", "placesCmd_open:tabsEnabled"); + this.appendChild(openInTabs); + } + // Reset the container to the same state it was in before the function was called. this._resultNode.containerOpen = wasOpen; ]]> @@ -474,7 +496,7 @@ // get dropped in/above/below. // Ignore static content at the top and bottom of the menu. var start = (this._self._startMarker != -1) ? (this._self._startMarker + 1) : 0; - var end = (this._self._endMarker != -1) ? this.self._endMarker : this._self.childNodes.length; + var end = (this._self._endMarker != -1) ? this._self._endMarker : this._self.childNodes.length; for (var i = start; i < end; i++) { var xulNode = this._self.childNodes[i]; var nodeY = xulNode.boxObject.y - this._self.boxObject.y; @@ -604,6 +626,40 @@ })]]> + + + + + + + + + + + + @@ -623,54 +679,19 @@ this.removeAttribute("autoopened"); } - - + + - 1) - return; - PlacesController.mouseLoadURI(event); - ]]>