From 6e554272f7afdf86e0cbbeb286083a995a80bdb1 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Fri, 1 Mar 2013 16:16:11 -0600 Subject: [PATCH] Bug 843014 - 'Search for' context menu item should quote selected text. r=fryn --- browser/metro/base/content/ContextCommands.js | 19 ++++++++++++++++--- browser/metro/base/content/browser.xul | 6 ++++-- browser/metro/base/content/helperui/MenuUI.js | 4 ++++ .../locales/en-US/chrome/browser.properties | 4 ++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/browser/metro/base/content/ContextCommands.js b/browser/metro/base/content/ContextCommands.js index a18fcd81c369..e18de84c4c50 100644 --- a/browser/metro/base/content/ContextCommands.js +++ b/browser/metro/base/content/ContextCommands.js @@ -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) { diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul index 593f6f58e645..e8db2dbbd922 100644 --- a/browser/metro/base/content/browser.xul +++ b/browser/metro/base/content/browser.xul @@ -572,6 +572,8 @@ + @@ -585,8 +587,8 @@ - - + + diff --git a/browser/metro/base/content/helperui/MenuUI.js b/browser/metro/base/content/helperui/MenuUI.js index 3e439edfabd6..e6e4de19064e 100644 --- a/browser/metro/base/content/helperui/MenuUI.js +++ b/browser/metro/base/content/helperui/MenuUI.js @@ -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)) { diff --git a/browser/metro/locales/en-US/chrome/browser.properties b/browser/metro/locales/en-US/chrome/browser.properties index e971a0468ca3..e856861de74e 100644 --- a/browser/metro/locales/en-US/chrome/browser.properties +++ b/browser/metro/locales/en-US/chrome/browser.properties @@ -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