зеркало из https://github.com/mozilla/gecko-dev.git
Bug 843014 - 'Search for' context menu item should quote selected text. r=fryn
This commit is contained in:
Родитель
ab07a99d5f
Коммит
6e554272f7
|
@ -10,6 +10,15 @@
|
|||
var ContextCommands = {
|
||||
_picker: null,
|
||||
|
||||
get _ellipsis() {
|
||||
delete this._ellipsis;
|
||||
this._ellipsis = "\u2026";
|
||||
try {
|
||||
this._ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
|
||||
} catch (ex) { }
|
||||
return this._ellipsis;
|
||||
},
|
||||
|
||||
get clipboard() {
|
||||
return Cc["@mozilla.org/widget/clipboardhelper;1"]
|
||||
.getService(Ci.nsIClipboardHelper);
|
||||
|
@ -98,6 +107,7 @@ var ContextCommands = {
|
|||
searchTextSetup: function cc_searchTextSetup(aRichListItem, aSearchString) {
|
||||
let defaultURI;
|
||||
let defaultName;
|
||||
aSearchString = aSearchString.trim();
|
||||
try {
|
||||
let defaultPB = Services.prefs.getDefaultBranch(null);
|
||||
const nsIPLS = Ci.nsIPrefLocalizedString;
|
||||
|
@ -108,11 +118,15 @@ var ContextCommands = {
|
|||
Cu.reportError(ex);
|
||||
return false;
|
||||
}
|
||||
let displayString = aSearchString;
|
||||
if (displayString.length > 15) {
|
||||
displayString = displayString.substring(0, 15) + this._ellipsis;
|
||||
}
|
||||
// label child node
|
||||
let label = Services.strings
|
||||
.createBundle("chrome://browser/locale/browser.properties")
|
||||
.formatStringFromName("browser.search.contextTextSearchLabel",
|
||||
[defaultName], 1);
|
||||
.formatStringFromName("browser.search.contextTextSearchLabel2",
|
||||
[defaultName, displayString], 2);
|
||||
aRichListItem.childNodes[0].setAttribute("value", label);
|
||||
aRichListItem.setAttribute("searchString", defaultURI);
|
||||
return true;
|
||||
|
@ -355,7 +369,6 @@ var ContextCommands = {
|
|||
var newDir = file.parent.QueryInterface(Ci.nsILocalFile);
|
||||
Services.prefs.setComplexValue("browser.download.lastDir", Ci.nsILocalFile, newDir);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
function AutoChosen(aFileAutoChosen, aUriAutoChosen) {
|
||||
|
|
|
@ -572,6 +572,8 @@
|
|||
<richlistbox id="context-commands" bindingType="contextmenu" flex="1">
|
||||
<!-- priority="low" items are hidden by default when a context is being displayed
|
||||
for two or more media types. (e.g. a linked image) -->
|
||||
<!-- content types preceeded by '!' act as exclusion rules, the menu item will not
|
||||
be displayed if the content type is present. -->
|
||||
<!-- Note the order of richlistitem here is important as it is reflected in the
|
||||
menu itself. -->
|
||||
<!-- ux spec: https://bug782810.bugzilla.mozilla.org/attachment.cgi?id=714804 -->
|
||||
|
@ -585,8 +587,8 @@
|
|||
<richlistitem id="context-paste" type="paste" onclick="ContextCommands.paste();">
|
||||
<label value="&contextTextPaste.label;"/>
|
||||
</richlistitem>
|
||||
<!-- Search Bing for "..." -->
|
||||
<richlistitem id="context-search" type="copy,selected-text" onclick="ContextCommands.searchText(this);">
|
||||
<!-- Search Bing for "(text..)", displayed on selected content text only -->
|
||||
<richlistitem id="context-search" type="selected-text,!input-text" onclick="ContextCommands.searchText(this);">
|
||||
<label id="context-search-label" value=""/>
|
||||
</richlistitem>
|
||||
<!-- only display if there is text on the clipboard and the target is the urlbar -->
|
||||
|
|
|
@ -161,6 +161,10 @@ var ContextMenuUI = {
|
|||
continue;
|
||||
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
// If one of the item's types has '!' before it, treat it as an exclusion rule.
|
||||
if (types[i].charAt(0) == '!' && contentTypes.indexOf(types[i].substring(1)) != -1) {
|
||||
break;
|
||||
}
|
||||
if (contentTypes.indexOf(types[i]) != -1) {
|
||||
// If this is the special search text item, we need to set its label dynamically.
|
||||
if (searchTextItem && !ContextCommands.searchTextSetup(command, this._popupState.string)) {
|
||||
|
|
|
@ -10,8 +10,8 @@ browser.search.order.1=Bing
|
|||
browser.search.order.2=Google
|
||||
browser.search.order.3=Yahoo
|
||||
|
||||
# l10n: search context menu item text will be: |Search (browser.search.defaultenginename) for ".."
|
||||
browser.search.contextTextSearchLabel=Search %S for ".."
|
||||
# l10n: search context menu item text will be: |Search (browser.search.defaultenginename) for "(string).."
|
||||
browser.search.contextTextSearchLabel2=Search %S for "%S"
|
||||
|
||||
# Settings Charms
|
||||
aboutCharm1=About
|
||||
|
|
Загрузка…
Ссылка в новой задаче