зеркало из https://github.com/mozilla/pjs.git
Bug 254542 Support middle-clicks in history p=trev@gtchat.de r=me sr=dmose a=asa
This commit is contained in:
Родитель
644c8fab5e
Коммит
96b20d8fc5
|
@ -61,7 +61,7 @@
|
||||||
</keyset>
|
</keyset>
|
||||||
<popupset id="historyContextMenu"/>
|
<popupset id="historyContextMenu"/>
|
||||||
<!-- use deep merging to hide certain columns by default -->
|
<!-- use deep merging to hide certain columns by default -->
|
||||||
<tree id="historyTree" onfocus="goUpdateSelectEditMenuItems();">
|
<tree id="historyTree" onfocus="goUpdateSelectEditMenuItems();" seltype="single">
|
||||||
<treecols id="historyTreeCols">
|
<treecols id="historyTreeCols">
|
||||||
<treecol id="Name"/>
|
<treecol id="Name"/>
|
||||||
<splitter id="pre-URL-splitter"/>
|
<splitter id="pre-URL-splitter"/>
|
||||||
|
|
|
@ -61,6 +61,10 @@ function HistoryCommonInit()
|
||||||
var historyController = new nsHistoryController;
|
var historyController = new nsHistoryController;
|
||||||
gHistoryTree.controllers.appendController(historyController);
|
gHistoryTree.controllers.appendController(historyController);
|
||||||
|
|
||||||
|
gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
|
PREF = gPrefService; // need this for bookmarks.js
|
||||||
|
|
||||||
if ("arguments" in window && window.arguments[0] && window.arguments.length >= 1) {
|
if ("arguments" in window && window.arguments[0] && window.arguments.length >= 1) {
|
||||||
// We have been supplied a resource URI to root the tree on
|
// We have been supplied a resource URI to root the tree on
|
||||||
var uri = window.arguments[0];
|
var uri = window.arguments[0];
|
||||||
|
@ -77,8 +81,6 @@ function HistoryCommonInit()
|
||||||
document.getElementById("groupingMenu").setAttribute("hidden", "true");
|
document.getElementById("groupingMenu").setAttribute("hidden", "true");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
|
||||||
try {
|
try {
|
||||||
gHistoryGrouping = gPrefService.getCharPref("browser.history.grouping");
|
gHistoryGrouping = gPrefService.getCharPref("browser.history.grouping");
|
||||||
}
|
}
|
||||||
|
@ -135,17 +137,22 @@ function historyOnClick(aEvent)
|
||||||
// This is kind of a hack but matches the currently implemented behaviour.
|
// This is kind of a hack but matches the currently implemented behaviour.
|
||||||
// If a status bar is not present, assume we're in sidebar mode, and thus single clicks on containers
|
// If a status bar is not present, assume we're in sidebar mode, and thus single clicks on containers
|
||||||
// will open the container. Single clicks on non-containers are handled below in historyOnSelect.
|
// will open the container. Single clicks on non-containers are handled below in historyOnSelect.
|
||||||
if (!gHistoryStatus && aEvent.button == 0) {
|
if (gHistoryStatus && aEvent.button == 0)
|
||||||
var row = { };
|
return;
|
||||||
var col = { };
|
|
||||||
var elt = { };
|
var target = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
|
||||||
gHistoryTree.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, elt);
|
if (!target)
|
||||||
if (row.value >= 0 && col.value) {
|
return;
|
||||||
if (!isContainer(gHistoryTree, row.value))
|
|
||||||
OpenURL("current");
|
var row = { };
|
||||||
else if (elt.value != "twisty")
|
var col = { };
|
||||||
gHistoryTree.treeBoxObject.view.toggleOpenState(row.value);
|
var elt = { };
|
||||||
}
|
gHistoryTree.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, elt);
|
||||||
|
if (row.value >= 0 && col.value) {
|
||||||
|
if (!isContainer(gHistoryTree, row.value))
|
||||||
|
OpenURL(target);
|
||||||
|
else if (aEvent.button == 0 && elt.value != "twisty")
|
||||||
|
gHistoryTree.treeBoxObject.view.toggleOpenState(row.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,9 +338,9 @@ function OpenURL(aTarget)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (URLArray.length > 0)
|
if (URLArray.length > 0)
|
||||||
OpenURLArrayInTabs(URLArray);
|
OpenURLArrayInTabs(URLArray, aTarget == "tab_background");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!isContainer(gHistoryTree, currentIndex))
|
else if (!isContainer(gHistoryTree, currentIndex))
|
||||||
openTopWin(url);
|
openTopWin(url);
|
||||||
return true;
|
return true;
|
||||||
|
@ -341,14 +348,16 @@ function OpenURL(aTarget)
|
||||||
|
|
||||||
// This opens the URLs contained in the given array in new tabs
|
// This opens the URLs contained in the given array in new tabs
|
||||||
// of the most recent window, creates a new window if necessary.
|
// of the most recent window, creates a new window if necessary.
|
||||||
function OpenURLArrayInTabs(aURLArray)
|
function OpenURLArrayInTabs(aURLArray, aBackground)
|
||||||
{
|
{
|
||||||
var browserWin = getTopWin();
|
var browserWin = getTopWin();
|
||||||
if (browserWin) {
|
if (browserWin) {
|
||||||
var browser = browserWin.getBrowser();
|
var browser = browserWin.getBrowser();
|
||||||
browser.selectedTab = browser.addTab(aURLArray[0]);
|
var tab = browser.addTab(aURLArray[0]);
|
||||||
|
if (!aBackground)
|
||||||
|
browser.selectedTab = tab;
|
||||||
for (var i = 1; i < aURLArray.length; ++i)
|
for (var i = 1; i < aURLArray.length; ++i)
|
||||||
tab = browser.addTab(aURLArray[i]);
|
browser.addTab(aURLArray[i]);
|
||||||
} else {
|
} else {
|
||||||
openTopWin(aURLArray.join("\n")); // Pretend that we're a home page group
|
openTopWin(aURLArray.join("\n")); // Pretend that we're a home page group
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<menuitem id="miOpenInNewWindow" label="&openLinkCmd.label;" accesskey="&openLinkCmd.accesskey;"
|
<menuitem id="miOpenInNewWindow" label="&openLinkCmd.label;" accesskey="&openLinkCmd.accesskey;"
|
||||||
oncommand="OpenURL('window');"/>
|
oncommand="OpenURL('window');"/>
|
||||||
<menuitem id="miOpenInNewTab" label="&openLinkCmdInTab.label;" accesskey="&openLinkCmdInTab.accesskey;"
|
<menuitem id="miOpenInNewTab" label="&openLinkCmdInTab.label;" accesskey="&openLinkCmdInTab.accesskey;"
|
||||||
oncommand="OpenURL('tab');"/>
|
oncommand="OpenURL(BookmarksUtils.shouldLoadTabInBackground(event) ? 'tab_background' : 'tab');"/>
|
||||||
<menuseparator id="pre-bookmarks-separator"/>
|
<menuseparator id="pre-bookmarks-separator"/>
|
||||||
<menuitem id="miAddBookmark" label="&bookmarkLinkCmd.label;" accesskey="&bookmarkLinkCmd.accesskey;" oncommand="historyAddBookmarks();"/>
|
<menuitem id="miAddBookmark" label="&bookmarkLinkCmd.label;" accesskey="&bookmarkLinkCmd.accesskey;" oncommand="historyAddBookmarks();"/>
|
||||||
<menuitem id="miCopyLinkLocation" label="©LinkCmd.label;" accesskey="©LinkCmd.accesskey;"
|
<menuitem id="miCopyLinkLocation" label="©LinkCmd.label;" accesskey="©LinkCmd.accesskey;"
|
||||||
|
@ -93,12 +93,12 @@
|
||||||
<tree id="historyTree" flex="1" enableColumnDrag="true" class="plain"
|
<tree id="historyTree" flex="1" enableColumnDrag="true" class="plain"
|
||||||
context="historyMenu"
|
context="historyMenu"
|
||||||
datasources="rdf:history" ref="NC:HistoryByDate" flags="dont-build-content"
|
datasources="rdf:history" ref="NC:HistoryByDate" flags="dont-build-content"
|
||||||
onkeypress="if (event.keyCode == 13) OpenURL(event.ctrlKey || event.metaKey ? 'window' : 'current');"
|
onkeypress="if (event.keyCode == 13) OpenURL(BookmarksUtils.getBrowserTargetFromEvent(event));"
|
||||||
onselect="this.view.selectionChanged();
|
onselect="this.view.selectionChanged();
|
||||||
historyOnSelect();"
|
historyOnSelect();"
|
||||||
onclick="historyOnClick(event);"
|
onclick="historyOnClick(event);"
|
||||||
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, historyDNDObserver);"
|
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, historyDNDObserver);"
|
||||||
ondblclick="if (validClickConditions(event)) OpenURL(event.ctrlKey || event.metaKey ? 'window' : 'current');">
|
ondblclick="if (validClickConditions(event)) OpenURL(BookmarksUtils.getBrowserTargetFromEvent(event));">
|
||||||
<template>
|
<template>
|
||||||
<rule>
|
<rule>
|
||||||
<treechildren>
|
<treechildren>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче