1) porting back in phoenix a refactoring I made in seamonkey wrt loading bookmarks

2) no context menus on the static menu items. (original patch by Chu Alan)
This commit is contained in:
chanial%noos.fr 2003-04-21 20:11:58 +00:00
parent 618aeeab7d
commit 3d3359f78f
3 changed files with 38 additions and 41 deletions

View File

@ -476,7 +476,7 @@
<!-- bookmarks context menu -->
<popupset>
<menupopup id="bookmarks-context-menu"
onpopupshowing="BookmarksMenu.createContextMenu(event);"
onpopupshowing="return BookmarksMenu.createContextMenu(event);"
onpopuphidden ="BookmarksMenu.destroyContextMenu(event);"/>
</popupset>
@ -779,8 +779,8 @@
template='bookmarks-template'
onpopupshowing="BookmarksMenu.showOpenInTabsMenuItem(event.target)"
onpopuphidden="BookmarksMenu.hideOpenInTabsMenuItem(event.target)"
oncommand="BookmarksUtils.loadBookmarkBrowser(event, event.originalTarget, this.database)"
onclick="BookmarksToolbar.loadBookmarkMiddleClick(event, this.database)"
oncommand="BookmarksMenu.loadBookmark(event, this.database)"
onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)"
ondraggesture="nsDragAndDrop.startDrag(event, BookmarksMenuDNDObserver)"
ondragdrop="nsDragAndDrop.drop(event, BookmarksMenuDNDObserver); event.preventBubble()"
ondragenter="nsDragAndDrop.dragEnter(event, BookmarksMenuDNDObserver); event.preventBubble()"
@ -939,8 +939,8 @@
rdf:type="http://home.netscape.com/NC-rdf#Folder"
onpopupshowing="BookmarksMenu.showOpenInTabsMenuItem(event.target)"
onpopuphidden="BookmarksMenu.hideOpenInTabsMenuItem(event.target)"
oncommand="BookmarksUtils.loadBookmarkBrowser(event, event.target, this.database)"
onclick="BookmarksToolbar.loadBookmarkMiddleClick(event, this.database)"
oncommand="BookmarksMenu.loadBookmark(event, this.database)"
onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)"
ondraggesture="nsDragAndDrop.startDrag(event, BookmarksMenuDNDObserver)"
ondragdrop="nsDragAndDrop.drop(event, BookmarksMenuDNDObserver); event.preventBubble()"
ondragenter="nsDragAndDrop.dragEnter(event, BookmarksMenuDNDObserver); event.preventBubble()"
@ -956,8 +956,8 @@
ref="NC:PersonalToolbarFolder" flags="dont-test-empty"
onpopupshowing="BookmarksMenu.showOpenInTabsMenuItem(event.target)"
onpopuphidden="BookmarksMenu.hideOpenInTabsMenuItem(event.target)"
oncommand="BookmarksUtils.loadBookmarkBrowser(event, event.target, this.database)"
onclick="BookmarksToolbar.loadBookmarkMiddleClick(event, this.database)"
oncommand="BookmarksMenu.loadBookmark(event, this.database)"
onclick="BookmarksMenu.loadBookmarkMiddleClick(event, this.database)"
ondraggesture="nsDragAndDrop.startDrag(event, BookmarksMenuDNDObserver)"
ondragdrop="nsDragAndDrop.drop(event, BookmarksMenuDNDObserver); event.preventBubble()"
ondragenter="nsDragAndDrop.dragEnter(event, BookmarksMenuDNDObserver); event.preventBubble()"

View File

@ -1544,18 +1544,9 @@ var BookmarksUtils = {
return "save"
else
return "current";
},
loadBookmarkBrowser: function (aEvent, aTarget, aDS)
{
var rSource = RDF.GetResource(aTarget.id);
var selection = BookmarksUtils.getSelectionFromResource(rSource);
var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
BookmarksCommand.openBookmark(selection, browserTarget, aDS)
}
}
function BookmarkInsertTransaction (aAction)
{
this.wrappedJSObject = this;

View File

@ -99,13 +99,17 @@ var BookmarksMenu = {
createContextMenu: function (aEvent)
{
var target = document.popupNode;
target.focus() // buttons in the pt have -moz-user-focus: ignore -->
if (!this.isBTBookmark(target.id))
return false;
target.focus(); // buttons in the pt have -moz-user-focus: ignore
this._selection = this.getBTSelection(target);
this._orientation = this.getBTOrientation(aEvent, target);
this._target = this.getBTTarget(target, this._orientation);
BookmarksCommand.createContextMenu(aEvent, this._selection);
this.onCommandUpdate();
aEvent.target.addEventListener("mousemove", BookmarksMenuController.onMouseMove, false)
aEvent.target.addEventListener("mousemove", BookmarksMenuController.onMouseMove, false);
return true;
},
/////////////////////////////////////////////////////////////////////////
@ -132,9 +136,9 @@ var BookmarksMenu = {
break;
default:
item = aNode.id;
if (!this.isBTBookmark(item))
return {length:0};
}
if (!this.isBTBookmark(item))
return {length:0};
var parent = this.getBTContainer(aNode);
var isExpanded = aNode.hasAttribute("open") && aNode.open;
var selection = {};
@ -215,11 +219,12 @@ var BookmarksMenu = {
if (!aURI)
return false;
var type = BookmarksUtils.resolveType(aURI);
return (type == "BookmarkSeparator" ||
type == "Bookmark" ||
type == "Folder" ||
type == "FolderGroup" ||
type == "PersonalToolbarFolder")
return (type == "BookmarkSeparator" ||
type == "Bookmark" ||
type == "Folder" ||
type == "FolderGroup" ||
type == "PersonalToolbarFolder" ||
aURI == "bookmarks-ptf")
},
/////////////////////////////////////////////////////////////////////////
@ -318,14 +323,27 @@ var BookmarksMenu = {
}
},
loadBookmark: function (aTarget, aDS)
loadBookmark: function (aEvent, aDS)
{
// Check for invalid bookmarks (most likely a static menu item like "Manage Bookmarks")
if (!this.isBTBookmark(aTarget.id))
if (!this.isBTBookmark(aEvent.target.id))
return;
var rSource = RDF.GetResource(aTarget.id);
var rSource = RDF.GetResource(aEvent.target.id);
var selection = BookmarksUtils.getSelectionFromResource(rSource);
BookmarksCommand.openBookmark(selection, "current", aDS)
var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
BookmarksCommand.openBookmark(selection, browserTarget, aDS);
},
////////////////////////////////////////////////
// loads a bookmark with the mouse middle button
loadBookmarkMiddleClick: function (aEvent, aDS)
{
if (aEvent.button != 1)
return;
// unlike for command events, we have to close the menus manually
BookmarksMenuDNDObserver.mCurrentDragOverTarget = null;
BookmarksMenuDNDObserver.onDragCloseTarget();
this.loadBookmark(aEvent, aDS);
}
}
@ -738,18 +756,6 @@ var BookmarksMenuDNDObserver = {
var BookmarksToolbar =
{
////////////////////////////////////////////////
// loads a bookmark with the mouse middle button
loadBookmarkMiddleClick: function (aEvent, aDS)
{
if (aEvent.button != 1)
return;
// unlike for command events, we have to close the menus manually
BookmarksMenuDNDObserver.mCurrentDragOverTarget = null;
BookmarksMenuDNDObserver.onDragCloseTarget();
BookmarksUtils.loadBookmarkBrowser(aEvent, aEvent.target, aDS);
},
/////////////////////////////////////////////////////////////////////////////
// returns the node of the last visible bookmark on the toolbar -->
getLastVisibleBookmark: function ()