зеркало из https://github.com/mozilla/gecko-dev.git
bug 121054 - adding history to go menu.
r=jag, sr=hewitt
This commit is contained in:
Родитель
10aefd0792
Коммит
1be72aadcb
|
@ -83,6 +83,7 @@
|
|||
<key id="key_findAgain" key="&findAgainCmd.commandkey;" command="Browser:FindAgain" modifiers="accel"/>
|
||||
|
||||
<!-- Go Menu -->
|
||||
<key id="key_gotoHistory" key="&history.commandKey;" oncommand="openHistory();" modifiers="accel"/>
|
||||
|
||||
<!-- Bookmarks Menu -->
|
||||
<key id="addBookmarkKb" key="&addCurPageCmd.commandkey;" command="Browser:AddBookmark" modifiers="accel"/>
|
||||
|
@ -288,12 +289,61 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu accesskey="&goMenu.accesskey;" label="&goMenu.label;" oncommand="gotoHistoryIndex(event);">
|
||||
<menu accesskey="&goMenu.accesskey;" label="&goMenu.label;"
|
||||
oncommand="loadHistoryItem(event);"
|
||||
datasources="rdf:history rdf:bookmarks" ref="NC:HistoryByDate"
|
||||
template="historyMenuTemplate">
|
||||
<menupopup onpopupshowing="updateGoMenu(event);">
|
||||
<menuitem label="&goBackCmd.label;" accesskey="&goBackCmd.accesskey;" key="goBackKb" command="Browser:Back"/>
|
||||
<menuitem label="&goForwardCmd.label;" accesskey="&goForwardCmd.accesskey;" key="goForwardKb" command="Browser:Forward"/>
|
||||
<menuitem label="&goHomeCmd.label;" accesskey="&goHomeCmd.accesskey;" command="Browser:Home" key="goHome"/>
|
||||
<menuseparator hidden="true"/>
|
||||
<menuseparator/>
|
||||
<menuseparator id="after-session-history-separator" hidden="true"/>
|
||||
<menuitem label="&historyCmd.label;" accesskey="&historyCmd.accesskey;"
|
||||
oncommand="openHistory()" key="key_gotoHistory"/>
|
||||
<menuseparator />
|
||||
<template id="historyMenuTemplate">
|
||||
<rule rdf:type="rdf:http://home.netscape.com/NC-rdf#Folder">
|
||||
<menupopup>
|
||||
<menu class="menu-iconic bookmark-item" uri="rdf:*"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never"
|
||||
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name">
|
||||
<menupopup>
|
||||
<menuitem label="&emptyItem.label;" disabled="true"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule rdf:type="http://home.netscape.com/NC-rdf#Separator">
|
||||
<menupopup>
|
||||
<menuseparator uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule iscontainer="true">
|
||||
<menupopup>
|
||||
<menu class="menu-iconic bookmark-item" uri="rdf:*"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never" container="true"
|
||||
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name">
|
||||
<menupopup />
|
||||
</menu>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem class="menuitem-iconic bookmark-item" uri="rdf:*"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
url="rdf:http://home.netscape.com/NC-rdf#URL"
|
||||
validate="never"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
status="rdf:http://home.netscape.com/WEB-rdf#status"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
|
||||
</template>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ var gRDF = null;
|
|||
var gRDFC = null;
|
||||
var gLocalStore = null;
|
||||
|
||||
function FillHistoryMenu(aParent, aMenu)
|
||||
function FillHistoryMenu(aParent, aMenu, aAdjacentElement)
|
||||
{
|
||||
// Remove old entries if any
|
||||
deleteHistoryItems(aParent);
|
||||
|
@ -79,13 +79,16 @@ function FillHistoryMenu(aParent, aMenu)
|
|||
}
|
||||
break;
|
||||
case "go":
|
||||
if (count > 0) aParent.lastChild.removeAttribute( "hidden" );
|
||||
if (count > 0) {
|
||||
if (aAdjacentElement)
|
||||
aAdjacentElement.removeAttribute( "hidden" );
|
||||
}
|
||||
end = count > MAX_HISTORY_MENU_ITEMS ? count - MAX_HISTORY_MENU_ITEMS : 0;
|
||||
for (j = count - 1; j >= end; j--)
|
||||
{
|
||||
entry = sessionHistory.getEntryAtIndex(j, false);
|
||||
if (entry)
|
||||
createCheckboxMenuItem(aParent, j, entry.title, j==index);
|
||||
createCheckboxMenuItem(aParent, j, entry.title, j == index, aAdjacentElement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -258,23 +261,29 @@ function addToUrlbarHistory()
|
|||
} // localstore
|
||||
}
|
||||
|
||||
function createMenuItem( aParent, aIndex, aLabel)
|
||||
function createMenuItem( aParent, aIndex, aLabel, aAdjacentElement)
|
||||
{
|
||||
var menuitem = document.createElement( "menuitem" );
|
||||
menuitem.setAttribute( "label", aLabel );
|
||||
menuitem.setAttribute( "index", aIndex );
|
||||
aParent.appendChild( menuitem );
|
||||
if ( !aAdjacentElement )
|
||||
aParent.appendChild( menuitem );
|
||||
else
|
||||
aParent.insertBefore( menuitem, aAdjacentElement );
|
||||
}
|
||||
|
||||
function createCheckboxMenuItem( aParent, aIndex, aLabel, aChecked)
|
||||
function createCheckboxMenuItem( aParent, aIndex, aLabel, aChecked, aAdjacentElement)
|
||||
{
|
||||
var menuitem = document.createElement( "menuitem" );
|
||||
menuitem.setAttribute( "type", "checkbox" );
|
||||
menuitem.setAttribute( "label", aLabel );
|
||||
menuitem.setAttribute( "index", aIndex );
|
||||
if (aChecked==true)
|
||||
if (aChecked)
|
||||
menuitem.setAttribute( "checked", "true" );
|
||||
aParent.appendChild( menuitem );
|
||||
if ( !aAdjacentElement )
|
||||
aParent.appendChild( menuitem );
|
||||
else
|
||||
aParent.insertBefore( menuitem, aAdjacentElement );
|
||||
}
|
||||
|
||||
function deleteHistoryItems(aParent)
|
||||
|
@ -290,6 +299,50 @@ function deleteHistoryItems(aParent)
|
|||
|
||||
function updateGoMenu(event)
|
||||
{
|
||||
FillHistoryMenu(event.target, "go");
|
||||
var adjacentElement = document.getElementById("after-session-history-separator");
|
||||
FillHistoryMenu(event.target, "go", adjacentElement);
|
||||
}
|
||||
|
||||
function openHistory()
|
||||
{
|
||||
// Use a single history dialog
|
||||
|
||||
var cwindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
var iwindowManager = Components.interfaces.nsIWindowMediator;
|
||||
var windowManager = cwindowManager.QueryInterface(iwindowManager);
|
||||
|
||||
var historyWindow = windowManager.getMostRecentWindow('history:manager');
|
||||
|
||||
if (historyWindow)
|
||||
historyWindow.focus();
|
||||
else {
|
||||
if (gDisableHistory)
|
||||
return;
|
||||
gDisableHistory = true;
|
||||
|
||||
window.open( "chrome://communicator/content/history/history.xul", "_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar" );
|
||||
setTimeout(enableHistory, 2000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loadHistoryItem(aEvent)
|
||||
{
|
||||
var element = aEvent.target;
|
||||
|
||||
var index = element.getAttribute("index");
|
||||
if (index) {
|
||||
try {
|
||||
getWebNavigation().gotoIndex(index);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
var url = element.getAttribute("url");
|
||||
var isContainer = element.getAttribute("container") == "true";
|
||||
if (url && !isContainer)
|
||||
loadURI(url);
|
||||
}
|
||||
|
|
|
@ -144,6 +144,9 @@
|
|||
<!ENTITY goHomeCmd.label "Home">
|
||||
<!ENTITY goHomeCmd.accesskey "h">
|
||||
|
||||
<!ENTITY historyCmd.label "Complete History...">
|
||||
<!ENTITY historyCmd.accesskey "c">
|
||||
<!ENTITY history.commandKey "h">
|
||||
|
||||
<!ENTITY bookmarksMenu.label "Bookmarks">
|
||||
<!ENTITY bookmarksMenu.accesskey "b">
|
||||
|
|
|
@ -48,35 +48,6 @@ function enableHistory() {
|
|||
gDisableHistory = false;
|
||||
}
|
||||
|
||||
function toHistory()
|
||||
{
|
||||
// Use a single sidebar history dialog
|
||||
|
||||
var cwindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
var iwindowManager = Components.interfaces.nsIWindowMediator;
|
||||
var windowManager = cwindowManager.QueryInterface(iwindowManager);
|
||||
|
||||
var historyWindow = windowManager.getMostRecentWindow('history:manager');
|
||||
|
||||
if (historyWindow) {
|
||||
//debug("Reuse existing history window");
|
||||
historyWindow.focus();
|
||||
} else {
|
||||
//debug("Open a new history dialog");
|
||||
|
||||
if (true == gDisableHistory) {
|
||||
//debug("Recently opened one. Wait a little bit.");
|
||||
return;
|
||||
}
|
||||
gDisableHistory = true;
|
||||
|
||||
window.open( "chrome://communicator/content/history/history.xul", "_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar" );
|
||||
setTimeout(enableHistory, 2000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function toJavaScriptConsole()
|
||||
{
|
||||
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
<key id="key_navigator" key="&navigatorCmd.commandkey;" command="Tasks:Navigator" modifiers="accel"/>
|
||||
<key id="key_editor" key="&editorCmd.commandkey;" command="Tasks:Editor" modifiers="accel"/>
|
||||
|
||||
<!-- Tools Menu -->
|
||||
<key id="key_gotoHistory" key="&history.commandKey;" oncommand="toHistory();" modifiers="accel"/>
|
||||
</keyset>
|
||||
<commandset id="tasksCommands">
|
||||
<command id="Tasks:Navigator" oncommand="toNavigator();"/>
|
||||
|
@ -56,7 +54,6 @@
|
|||
|
||||
<menu label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
|
||||
<menupopup id="toolsPopup" onpopupshowing="javaItemEnabling();">
|
||||
<menuitem label="&historyCmd.label;" accesskey="&historyCmd.accesskey;" oncommand="toHistory()" key="key_gotoHistory"/>
|
||||
<menuitem label="&importUtilCmd.label;" accesskey="&importUtilCmd.accesskey;" oncommand="toImport()"/>
|
||||
<menuitem id="java" label="&javaConsoleCmd.label;" accesskey="&javaConsoleCmd.accesskey;" oncommand="toJavaConsole()"/>
|
||||
<menuitem label="&javaScriptConsoleCmd.label;" accesskey="&javaScriptConsoleCmd.accesskey;" oncommand="toJavaScriptConsole();"/>
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
|
||||
<!ENTITY toolsMenu.label "Tools">
|
||||
<!ENTITY toolsMenu.accesskey "t">
|
||||
<!ENTITY historyCmd.label "History">
|
||||
<!ENTITY historyCmd.accesskey "h">
|
||||
<!ENTITY history.commandKey "h">
|
||||
<!ENTITY securityInfoCmd.label ".Security Info">
|
||||
<!ENTITY securityInfoCmd.accesskey "s">
|
||||
<!ENTITY importUtilCmd.label "Import Utility">
|
||||
|
|
Загрузка…
Ссылка в новой задаче