Bug 530629 - For composition, implement find bar (Ctrl+F) with "Replace..." button. r=Neil, r=mkmelin, ui-r=Paenglab, ui-r=JosiahOne

This commit is contained in:
Suyash Agarwal 2014-04-18 09:25:28 -04:00
Родитель 94fa4393ce
Коммит 78ecf83b3d
19 изменённых файлов: 156 добавлений и 45 удалений

Просмотреть файл

@ -85,6 +85,7 @@ function SetupTextEditorCommands()
//dump("Registering plain text editor commands\n");
commandTable.registerCommand("cmd_findReplace",nsFindReplaceCommand);
commandTable.registerCommand("cmd_find", nsFindCommand);
commandTable.registerCommand("cmd_findNext", nsFindAgainCommand);
commandTable.registerCommand("cmd_findPrev", nsFindAgainCommand);
@ -2242,6 +2243,24 @@ var nsPrintSetupCommand =
}
};
//-----------------------------------------------------------------------------------
var nsFindReplaceCommand =
{
isCommandEnabled: function(aCommand, editorElement)
{
return editorElement.getEditor(editorElement.contentWindow) != null;
},
getCommandStateParams: function(aCommand, aParams, editorElement) {},
doCommandParams: function(aCommand, aParams, editorElement) {},
doCommand: function(aCommand, editorElement)
{
window.openDialog("chrome://editor/content/EdReplace.xul", "_blank",
"chrome,modal,titlebar", editorElement);
}
};
//-----------------------------------------------------------------------------------
var nsFindCommand =
{
@ -2255,13 +2274,7 @@ var nsFindCommand =
doCommand: function(aCommand, editorElement)
{
try {
window.openDialog("chrome://editor/content/EdReplace.xul", "_blank",
"chrome,modal,titlebar", editorElement);
}
catch(ex) {
dump("*** Exception: couldn't open Replace Dialog\n");
}
document.getElementById("FindToolbar").onFindCommand();
}
};
@ -2280,17 +2293,8 @@ var nsFindAgainCommand =
doCommand: function(aCommand, editorElement)
{
try {
var findPrev = aCommand == "cmd_findPrev";
var findInst = editorElement.webBrowserFind;
var findService = Components.classes["@mozilla.org/find/find_service;1"]
.getService(Components.interfaces.nsIFindService);
findInst.findBackwards = findService.findBackwards ^ findPrev;
findInst.findNext();
// reset to what it was in dialog, otherwise dialog setting can get reversed
findInst.findBackwards = findService.findBackwards;
}
catch (ex) {}
let findPrev = (aCommand == "cmd_findPrev");
document.getElementById("FindToolbar").onFindAgainCommand(findPrev);
}
};

Просмотреть файл

@ -76,6 +76,7 @@ function EditorOnLoad()
gSourceContentWindow.contentWindow.controllers.insertControllerAt(0, controller);
var commandTable = controller.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIControllerCommandTable);
commandTable.registerCommand("cmd_findReplace", nsFindReplaceCommand);
commandTable.registerCommand("cmd_find", nsFindCommand);
commandTable.registerCommand("cmd_findNext", nsFindAgainCommand);
commandTable.registerCommand("cmd_findPrev", nsFindAgainCommand);

Просмотреть файл

@ -315,11 +315,8 @@
<vbox id="appcontent" flex="1">
<deck id="ContentWindowDeck" selectedIndex="0" flex="1">
<!-- KLUDGE: Temporary fix for bug 34414:
The current editor tag doesn't have a view,
which breaks deck frame-hiding mechanism
-->
<stack>
<vbox>
<findbar id="FindToolbar" browserid="content-frame"/>
<editor editortype="html"
type="content-primary"
id="content-frame"
@ -328,7 +325,7 @@
context="contentAreaContextMenu"
flex="1"
tooltip="aHTMLTooltip"/>
</stack>
</vbox>
<vbox>
<label id="doctype-text" crop="right"/>
<editor type="content"

Просмотреть файл

@ -174,6 +174,7 @@
<command id="cmd_delete"/>
<command id="cmd_selectAll"/>
<command id="cmd_preferences" oncommand="goDoCommand('cmd_preferences')"/>
<command id="cmd_findReplace" oncommand="goDoCommand('cmd_findReplace')"/>
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
<command id="cmd_findNext" oncommand="goDoCommand('cmd_findNext');"/>
<command id="cmd_findPrev" oncommand="goDoCommand('cmd_findPrev');"/>
@ -308,7 +309,10 @@
<menuseparator id="sep_selectAll"/>
<menuitem id="menu_selectAll"/>
<menuseparator id="sep_find"/>
<menuitem id="menu_find" label="&findCmd.label;"/>
<menuitem id="menu_find"
label="&findBarCmd.label;"/>
<menuitem id="menu_findReplace"
label="&findReplaceCmd.label;"/>
<menuitem id="menu_findNext"/>
<menuitem id="menu_findPrev"/>
<menuseparator id="sep_checkspelling"/>

Просмотреть файл

@ -16,7 +16,8 @@
<!ENTITY pasteAsQuotationCmd.label "Paste As Quotation">
<!ENTITY pasteAsQuotationCmd.accesskey "Q">
<!ENTITY pasteAsQuotationCmd.key "o">
<!ENTITY findCmd.label "Find and Replace…">
<!ENTITY findBarCmd.label "Find…">
<!ENTITY findReplaceCmd.label "Find and Replace…">
<!ENTITY enableInlineSpellChecker.label "Spellcheck As You Type">
<!ENTITY enableInlineSpellChecker.accesskey "S">
<!ENTITY checkSpellingCmd2.label "Check Spelling…">

Просмотреть файл

@ -940,6 +940,15 @@ function CommandUpdate_MsgCompose()
updateComposeItems();
}
function findbarFindReplace()
{
SetMsgBodyFrameFocus();
let findbar = document.getElementById("FindToolbar");
findbar.close();
goDoCommand("cmd_findReplace");
findbar.open();
}
function updateComposeItems()
{
try {
@ -1076,6 +1085,7 @@ function updateEditItems()
goUpdateCommand("cmd_renameAttachment");
goUpdateCommand("cmd_selectAll");
goUpdateCommand("cmd_openAttachment");
goUpdateCommand("cmd_findReplace");
goUpdateCommand("cmd_find");
goUpdateCommand("cmd_findNext");
goUpdateCommand("cmd_findPrev");
@ -1777,10 +1787,20 @@ function handleMailtoArgs(mailtoUrl)
*/
function handleEsc()
{
let activeElement = document.activeElement;
// If findbar is visible and the focus is in the message body,
// hide it. (Focus on the findbar is handled by findbar itself).
let findbar = document.getElementById('FindToolbar');
if (!findbar.hidden && activeElement.id == "content-frame") {
findbar.close();
return;
}
// If there is a notification in the attachmentNotificationBox
// AND focus is in message body or on the notification, hide it.
let activeElement = document.activeElement;
let notification = document.getElementById("attachmentNotificationBox").currentNotification;
let notification = document.getElementById("attachmentNotificationBox")
.currentNotification;
if (notification && (activeElement.id == "content-frame" ||
notification.contains(activeElement) ||
activeElement.classList.contains("messageCloseButton"))) {
@ -1994,6 +2014,24 @@ CheckForAttachmentNotification.shouldFire = true;
function ComposeStartup(recycled, aParams)
{
// Findbar overlay
if (!document.getElementById("findbar-replaceButton")) {
let replaceButton = document.createElement("toolbarbutton");
replaceButton.setAttribute("id", "findbar-replaceButton");
replaceButton.setAttribute("class", "tabbable");
replaceButton.setAttribute("label", getComposeBundle().getString("replaceButton.label"));
replaceButton.setAttribute("accesskey", getComposeBundle().getString("replaceButton.accesskey"));
replaceButton.setAttribute("tooltiptext", getComposeBundle().getString("replaceButton.tooltip"));
replaceButton.setAttribute("oncommand", "findbarFindReplace();");
let findbar = document.getElementById("FindToolbar");
let lastButton = findbar.getElement("find-case-sensitive");
let tSeparator = document.createElement("toolbarseparator");
tSeparator.setAttribute("id", "findbar-beforeReplaceSeparator");
lastButton.parentNode.insertBefore(replaceButton, lastButton.nextSibling);
lastButton.parentNode.insertBefore(tSeparator, lastButton.nextSibling);
}
var params = null; // New way to pass parameters to the compose window as a nsIMsgComposeParameters object
var args = null; // old way, parameters are passed as a string

Просмотреть файл

@ -98,6 +98,7 @@
<command id="cmd_pasteNoFormatting" oncommand="goDoCommand('cmd_pasteNoFormatting')"
label="&pasteNoFormatting.label;" accesskey="&pasteNoFormatting.accesskey;"/>
<command id="cmd_preferences" oncommand="goDoCommand('cmd_preferences')"/>
<command id="cmd_findReplace" oncommand="goDoCommand('cmd_findReplace')"/>
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
<command id="cmd_findNext" oncommand="goDoCommand('cmd_findNext');"/>
<command id="cmd_findPrev" oncommand="goDoCommand('cmd_findPrev');"/>

Просмотреть файл

@ -221,9 +221,9 @@
<key id="key_renameAttachment" keycode="VK_F2" oncommand="goDoCommand('cmd_renameAttachment');"/>
#endif
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
<key id="key_find" key="&findCmd.key;" command="cmd_find" modifiers="accel"/>
<key id="key_find" key="&findBarCmd.key;" command="cmd_find" modifiers="accel"/>
#ifndef XP_MACOSX
<key id="key_findReplace" key="&findReplaceCmd.key;" command="cmd_find" modifiers="accel"/>
<key id="key_findReplace" key="&findReplaceCmd.key;" command="cmd_findReplace" modifiers="accel"/>
#endif
<key id="key_findNext" key="&findAgainCmd.key;" command="cmd_findNext" modifiers="accel"/>
<key id="key_findPrev" key="&findPrevCmd.key;" command="cmd_findPrev" modifiers="accel, shift"/>
@ -518,9 +518,33 @@
<menuseparator/>
<menuitem id="menu_selectAll" label="&selectAllCmd.label;" key="key_selectAll" accesskey="&selectAllCmd.accesskey;" command="cmd_selectAll"/>
<menuseparator/>
<menuitem label="&findCmd.label;" key="key_find" accesskey="&findCmd.accesskey;" command="cmd_find"/>
<menuitem label="&findAgainCmd.label;" key="key_findNext" accesskey="&findAgainCmd.accesskey;" command="cmd_findNext"/>
<menuitem label="&findPrevCmd.label;" key="key_findPrev" accesskey="&findPrevCmd.accesskey;" command="cmd_findPrev"/>
<menuitem id="menu_findBar"
label="&findBarCmd.label;"
accesskey="&findBarCmd.accesskey;"
key="key_find"
command="cmd_find"/>
#ifndef XP_MACOSX
<menuitem id="menu_findReplace"
label="&findReplaceCmd.label;"
accesskey="&findReplaceCmd.accesskey;"
key="key_findReplace"
command="cmd_findReplace"/>
#else
<menuitem id="menu_findReplace"
label="&findReplaceCmd.label;"
accesskey="&findReplaceCmd.accesskey;"
command="cmd_findReplace"/>
#endif
<menuitem id="menu_findNext"
label="&findAgainCmd.label;"
accesskey="&findAgainCmd.accesskey;"
key="key_findNext"
command="cmd_findNext"/>
<menuitem id="menu_findPrev"
label="&findPrevCmd.label;"
accesskey="&findPrevCmd.accesskey;"
key="key_findPrev"
command="cmd_findPrev"/>
#ifdef XP_UNIX
#ifndef XP_MACOSX
<menuseparator id="prefSep"/>
@ -1026,6 +1050,7 @@
<editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
ondblclick="EditorDblClick(event);"
context="msgComposeContext"/>
<findbar id="FindToolbar" browserid="content-frame"/>
</vbox>
</vbox>

Просмотреть файл

@ -411,3 +411,7 @@ cloudAttachmentListItem=* %1$S (%2$S) hosted on %3$S: %4$S
## upload notification bar to allow the user to dismiss the notification permanently.
stopShowingUploadingNotification.accesskey=N
stopShowingUploadingNotification.label=Never show this again
replaceButton.label=Replace…
replaceButton.accesskey=l
replaceButton.tooltip=Show the Find and Replace dialog

Просмотреть файл

@ -88,18 +88,20 @@
<!ENTITY selectAllCmd.label "Select All">
<!ENTITY selectAllCmd.key "A">
<!ENTITY selectAllCmd.accesskey "a">
<!ENTITY findCmd.label "Find and Replace…">
<!ENTITY findCmd.key "F">
<!ENTITY findCmd.accesskey "F">
<!ENTITY findBarCmd.label "Find…">
<!ENTITY findBarCmd.accesskey "F">
<!ENTITY findBarCmd.key "F">
<!ENTITY findReplaceCmd.label "Find and Replace…">
<!ENTITY findReplaceCmd.accesskey "l">
<!ENTITY findReplaceCmd.key "H">
<!ENTITY findAgainCmd.label "Find Again">
<!ENTITY findAgainCmd.key "G">
<!ENTITY findAgainCmd.accesskey "g">
<!ENTITY findAgainCmd.key "G">
<!ENTITY findAgainCmd.key2 "VK_F3">
<!ENTITY findPrevCmd.label "Find Previous">
<!ENTITY findPrevCmd.accesskey "v">
<!ENTITY findPrevCmd.key "G">
<!ENTITY findPrevCmd.key2 "VK_F3">
<!ENTITY findPrevCmd.accesskey "v">
<!-- View Menu -->
<!ENTITY viewMenu.label "View">

Просмотреть файл

@ -89,3 +89,6 @@ notification[value="addon-install-failed"] .messageCloseButton {
to { background-color: transparent; }
}
#findbar-beforeReplaceSeparator {
height: 16px;
}

Просмотреть файл

@ -1035,3 +1035,7 @@ toolbarbutton.formatting-button {
background-color: hsl(210, 75%, 92%);
}
}
#findbar-replaceButton > .toolbarbutton-icon {
display: none;
}

Просмотреть файл

@ -1009,3 +1009,7 @@ toolbarbutton.formatting-button {
#sidebar-splitter {
background-color: ThreeDFace;
}
#findbar-replaceButton > .toolbarbutton-icon {
display: none;
}

Просмотреть файл

@ -32,6 +32,7 @@
<!-- Edit Menu -->
<key id="key_redo" key="&redoCmd.key;" command="cmd_redo" modifiers="accel"/>
<menuitem id="menu_findReplace" key="key_findReplace"/>
<!-- Select All Key -->
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="alt"/>
@ -42,6 +43,10 @@
<keyset id="findKeys">
<key keycode="&findCmd.key2;"
command="cmd_find"/>
<key id="key_findReplace"
key="&findReplaceCmd.key;"
modifiers="accel"
command="cmd_findReplace"/>
</keyset>
<!-- Find As You Type Keys -->
<key id="key_findTypeText"

Просмотреть файл

@ -228,7 +228,7 @@
<keyset id="findKeys">
<key id="key_find"
key="&findCmd.key;"
key="&findBarCmd.key;"
command="cmd_find"
modifiers="accel"/>
<key id="key_findNext"
@ -280,9 +280,12 @@
accesskey="&selectAllCmd.accesskey;"
command="cmd_selectAll"/>
<menuitem id="menu_find"
accesskey="&findCmd.accesskey;"
accesskey="&findBarCmd.accesskey;"
key="key_find"
command="cmd_find"/>
<menuitem id="menu_findReplace"
accesskey="&findReplaceCmd.accesskey;"
command="cmd_findReplace"/>
<menuitem id="menu_findNext"
label="&findAgainCmd.label;"
accesskey="&findAgainCmd.accesskey;"

Просмотреть файл

@ -32,12 +32,22 @@
<!-- Edit Menu -->
<key id="key_redo" key="&redoCmd.key;" command="cmd_redo" modifiers="accel"/>
<menuitem id="menu_findReplace" key="key_findReplace"/>
<!-- Select All Key -->
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
<!-- Delete Key -->
<key id="key_delete" keycode="VK_DELETE" command="cmd_delete"/>
<!-- Keyset for find keys -->
<keyset id="findKeys">
<key id="key_findReplace"
key="&findReplaceCmd.key;"
modifiers="accel"
command="cmd_findReplace"/>
</keyset>
<!-- Find As You Type Keys -->
<key id="key_findTypeText"
key="&findTypeTextCmd.key;"/>

Просмотреть файл

@ -69,11 +69,13 @@
<!ENTITY preferencesCmd.label "Preferences…">
<!ENTITY preferencesCmd.key "E">
<!ENTITY preferencesCmd.accesskey "e">
<!ENTITY findCmd.key "F">
<!-- LOCALIZATION NOTE (findCmd.accesskey): This accesskey should be within
findCmd.label found in messengercompose.dtd, messenger.dtd and
editorOverlay.dtd and findOnCmd.label found in navigatorOverlay.dtd -->
<!ENTITY findCmd.accesskey "F">
<!ENTITY findBarCmd.key "F">
<!-- LOCALIZATION NOTE (findBarCmd.accesskey): This accesskey should be within
findBarCmd.label found in editorOverlay.dtd, findCmd.label in messenger.dtd
and messengercompose.dtd and findOnCmd.label found in navigatorOverlay.dtd -->
<!ENTITY findBarCmd.accesskey "F">
<!ENTITY findReplaceCmd.key "H">
<!ENTITY findReplaceCmd.accesskey "l">
<!ENTITY findAgainCmd.label "Find Again">
<!ENTITY findAgainCmd.key "G">
<!ENTITY findAgainCmd.accesskey "g">

Просмотреть файл

@ -634,6 +634,7 @@ function updateEditItems()
goUpdateCommand("cmd_renameAttachment");
goUpdateCommand("cmd_selectAll");
goUpdateCommand("cmd_openAttachment");
goUpdateCommand("cmd_findReplace");
goUpdateCommand("cmd_find");
goUpdateCommand("cmd_findNext");
goUpdateCommand("cmd_findPrev");

Просмотреть файл

@ -102,6 +102,7 @@
<!--command id="cmd_pasteQuote"/ DO NOT INCLUDE THOSE COMMANDS ELSE THE EDIT MENU WILL BE BROKEN! -->
<!--command id="cmd_find"/-->
<!--command id="cmd_findNext"/-->
<!--command id="cmd_findReplace"/-->
<command id="cmd_rewrap"
label="&editRewrapCmd.label;"
accesskey="&editRewrapCmd.accesskey;"
@ -630,6 +631,7 @@
<!-- The mail message body frame -->
<vbox id="appcontent" flex="1">
<findbar id="FindToolbar" browserid="content-frame"/>
<editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
ondblclick="EditorDblClick(event);"
context="contentAreaContextMenu"/>