Fix for 15805, mis-spellings, duplicate accesskeys and 'save frame as' work.

This commit is contained in:
ben%netscape.com 2006-09-14 05:50:25 +00:00
parent bf3b38091c
commit 9a311c367d
4 changed files with 103 additions and 51 deletions

View File

@ -62,28 +62,76 @@ catch (ex)
var backButton = null;
var forwardButton = null;
function savePage( url ) {
// Default is to save current page.
if ( !url ) {
url = window.content.location.href;
}
// Use stream xfer component to prompt for destination and save.
var xfer = Components
.classes[ "component://netscape/appshell/component/xfer" ]
.getService( Components.interfaces.nsIStreamTransfer );
try {
// When Necko lands, we need to receive the real nsIChannel and
// do SelectFileAndTransferLocation!
///////////////////////////// DOCUMENT SAVE ///////////////////////////////////
// Use this for now...
xfer.SelectFileAndTransferLocationSpec( url, window );
} catch( exception ) {
// Failed (or cancelled), give them another chance.
dump( "SelectFileAndTransferLocationSpec failed, rv=" + exception + "\n" );
}
return;
// focused frame URL
var gFocusedURL = null;
/**
* Save the document at a given location to disk
**/
function savePage( url )
{
// Default is to save current page.
url = url ? url : window.content.location.href;
// Use stream xfer component to prompt for destination and save.
var xfer = getService("component://netscape/appshell/component/xfer", "nsIStreamTransfer");
try {
// When Necko lands, we need to receive the real nsIChannel and
// do SelectFileAndTransferLocation!
// Use this for now...
xfer.SelectFileAndTransferLocationSpec( url, window );
}
catch( exception ) {
// suppress NS_ERROR_ABORT exceptions for cancellation
}
}
/**
* Determine whether or not the content area is displaying a page with frames,
* and if so, toggle the display of the 'save frame as' menu item.
**/
function getContentAreaFrameCount()
{
dump("*** check number of frames in content area \n");
var saveFrameItem = document.getElementById("savepage");
if (!window.content.frames.length ||
!isDocumentFrame(document.commandDispatcher.focusedWindow))
saveFrameItem.setAttribute("hidden", "true");
else
saveFrameItem.removeAttribute("hidden");
}
/**
* When a content area frame is focused, update the focused frame URL
**/
function contentAreaFrameFocus()
{
var saveFrameItem = document.getElementById("savepage");
var focusedWindow = document.commandDispatcher.focusedWindow;
if (isDocumentFrame(focusedWindow)) {
gFocusedURL = focusedWindow.location.href;
saveFrameItem.removeAttribute("hidden");
}
}
/**
* Determine whether or not a given focused DOMWindow is in the content
* area.
**/
function isDocumentFrame(aFocusedWindow)
{
var contentFrames = window.content.frames;
if (contentFrames.length) {
for (var i = 0; i < contentFrames.length; i++ ) {
if (aFocusedWindow == contentFrames[i])
return true;
}
}
return false;
}
//////////////////////////////// BOOKMARKS ////////////////////////////////////
function UpdateBookmarksLastVisitedDate(event)
{
@ -103,8 +151,6 @@ function UpdateBookmarksLastVisitedDate(event)
}
}
function UpdateInternetSearchResults(event)
{
if ((window.content.location.href) && (window.content.location.href != ""))
@ -150,7 +196,7 @@ function UpdateStatusField()
text = jsDefaultStatus;
if(!statusTextFld)
statusTextFld = document.getElementById("statusText");
statusTextFld = document.getElementById("statusbar-display");
statusTextFld.setAttribute("value", text);
}
@ -338,6 +384,8 @@ function Startup()
{
contentArea.addEventListener("load", UpdateBookmarksLastVisitedDate, true);
contentArea.addEventListener("load", UpdateInternetSearchResults, true);
contentArea.addEventListener("load", getContentAreaFrameCount, true);
contentArea.addEventListener("focus", contentAreaFrameFocus, true);
}
dump("*** Pulling out the charset\n");
@ -986,12 +1034,6 @@ function BrowserEditBookmarks()
function BrowserLoadURL()
{
if (appCore == null)
{
dump("BrowserAppCore has not been initialized\n");
return;
}
// rjc: added support for URL shortcuts (3/30/1999)
try
{
@ -1034,7 +1076,8 @@ function BrowserEditBookmarks()
// stifle any exceptions so we're sure to load the URL.
}
appCore.loadUrl(document.getElementById('urlbar').value);
appCore.loadUrl(gURLBar.value);
window.content.focus();
}
function readFromClipboard()
@ -1388,3 +1431,4 @@ function dumpMemoryLeaks() {
if (leakDetector != null)
leakDetector.dumpLeaks();
}

View File

@ -223,7 +223,7 @@ Contributor(s): ______________________________________. -->
<menubar id="main-menubar"/>
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar" persist="collapsed" grippytooltiptext="&navigationBar.tooltip;">
<box id="nav-bar-inner" autostretch="never" flex="1">
<box id="nav-bar-inner" autostretch="never" flex="1" style="min-width: 0px;">
<menubutton class="menubutton-dual toolbar" id="back-button" value="&backButton.label;"
crop="right" observes="canGoBack" oncommand="gotoHistoryIndex(event);"
buttonaction="BrowserBack();" buttontooltiptext="&backButton.tooltip;">
@ -364,15 +364,19 @@ Contributor(s): ______________________________________. -->
ondragdrop="return DropOnContentArea(event);"
ondraggesture="BeginDragContentArea(event);">
<!-- type attribute is used by frame construction to locate iframes
intended to hold (html) content -->
<browser context="context" type="content-primary" id="content"
src="about:blank" flex="100%"/>
<!-- this box is temporary, pending XBLified <browser> -->
<box id="browser" flex="1">
<!-- type attribute is used by frame construction to locate iframes
intended to hold (html) content -->
<browser context="context" type="content-primary" id="content"
src="about:blank" flex="1"/>
</box>
<statusbar id="status-bar" class="chromeclass-status"/>
<box id="status-bar" class="chromeclass-status"/>
</box>
</box>
<toolbox id="taskbar" class="chromeclass-extrachrome toolbox-bottom"/>

View File

@ -31,7 +31,7 @@ Contributor(s): ______________________________________. -->
<overlay id="navigatorOverlay"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- Keysets -->
@ -68,13 +68,15 @@ Contributor(s): ______________________________________. -->
<!-- Search Menu -->
<key id="key_find" xulkey="true" key="&findOnCmd.commandkey;" observes="Browser:Find"/>
<key id="key_findAgain" xulkey="true" key="&findAgainCmd.commandkey;" observes="Browser:FindAgain"/>
<key id="key_savePage" xulkey="true" key="&savePageCmd.commandkey;" observes="Browser:SavePage"/>
<key id="goForwardKb" xulkey="true" key="&goForwardCmd.commandkey;" observes="Browser:GoForward" />
<key id="goBackwardKb" xulkey="true" key="&goBackCmd.commandkey;" observes="Browser:GoBackwards" />
<key id="goHomeKb" xulkey="true" key="&goHomeCmd.commandkey;" observes="Browser:GoHome" />
<key id="goHomeKb" xulkey="true" key="&goHomeCmd.commandkey;" observes="Browser:GoHome" />
<key id="addBookmarkKb" xulkey="true" key="&addCurPageCmd.commandkey;" observes="Browser:AddBookmark" />
<key id="manBookmarkKb" xulkey="true" key="&manBookmarksCmd.commandkey;" observes="Browser:ManageBookmark" />
<key id="addBookmarkKb" xulkey="true" key="&addCurPageCmd.commandkey;" observes="Browser:AddBookmark" />
<key id="manBookmarkKb" xulkey="true" key="&manBookmarksCmd.commandkey;" observes="Browser:ManageBookmark" />
<!-- how to handle return, enter, tab, function keys, arrow keys, others? saari working on solution -->
</keyset>
@ -135,6 +137,8 @@ Contributor(s): ______________________________________. -->
<broadcaster id="Browser:AddBookmark" value="&addCurPageCmd.label;" oncommand="BrowserAddBookmark(window.content.location.href,window.content.document.title);"/>
<broadcaster id="Browser:ManageBookmark" value="&manBookmarksCmd.label;" oncommand="BrowserEditBookmarks();" />
<broadcaster id="Browser:SavePage" value="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;" oncommand="savePage();"/>
</broadcasterset>
@ -157,7 +161,8 @@ Contributor(s): ______________________________________. -->
<menuitem accesskey="&openFileCmd.accesskey;" key="openFileKb" observes="Browser:OpenFile"/>
<menuseparator/>
<menuitem id="menu_close"/>
<menuitem id="context-savepage" value="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;" oncommand="savePage();"/>
<menuitem id="context-savepage" key="savePage" observes="Browser:SavePage"/>
<menuitem id="savepage" value="&saveFrameCmd.label;" accesskey="&saveFrameCmd.accesskey;" oncommand="savePage(gFocusedURL);" hidden="true"/>
<menuseparator/>
<menuitem id="menu_sendPage" observes="cmd_sendPage"/>
<menuitem accesskey="&sendLinkCmd.accesskey;" observes="Browser:SendLink"/>
@ -491,13 +496,11 @@ END of Deprecated -->
<spring flex="100%"/>
</menubar>
<box id="status-bar" class="chromeclass-status">
<statusbar id="status-bar" class="chromeclass-status">
<progressmeter id="statusbar-icon" mode="normal" value="0"/>
<spring style="width: 1em"/>
<image id="status-icon"/>
<text id="statusText" class="status-bar" flex="1" value="&statusText.label;" crop="right"/>
<text class="status-bar" value="&buildId.label;"/>
<button class="plain" id="lock-button" />
</box>
<statusbarpanel id="statusbar-display" value="&statusText.label;" crop="right" flex="1"/>
<statusbarpanel id="statusbar-buildid" value="&buildId.label;"/>
<statusbarpanel id="security-button"/>
</statusbar>
</overlay>

View File

@ -347,10 +347,11 @@
<!ENTITY bookmarkPageCmd.accesskey "b">
<!ENTITY savePageCmd.label "Save Page As...">
<!ENTITY savePageCmd.accesskey "s">
<!ENTITY savePageCmd.commandkey "s">
<!ENTITY saveFrameCmd.label "Save Frame As...">
<!ENTITY saveFrameCmd.accesskey "s">
<!ENTITY saveFrameCmd.accesskey "f">
<!ENTITY saveLinkCmd.label "Save Link As...">
<!ENTITY saveLinkCmd.accesskey "s">
<!ENTITY saveLinkCmd.accesskey "a">
<!ENTITY saveImageCmd.label "Save Image As...">
<!ENTITY saveImageCmd.accesskey "a">
<!ENTITY saveBGImageCmd.label "Save Background Image As...">
@ -360,6 +361,6 @@
<!ENTITY selectAllCmd.label "Select All">
<!ENTITY selectAllCmd.accesskey "l">
<!ENTITY copyLinkCmd.label "Copy Link Location">
<!ENTITY copyLinkCmd.accesskey "l">
<!ENTITY copyLinkCmd.accesskey "n">
<!ENTITY copyImageCmd.label "Copy Image Location">
<!ENTITY copyImageCmd.accesskey "m">