Make "Find" option read "Find x in page".

(imported from commit 5d95b996f4d944c285ca6f5bc0f75ea359cb4df2)
This commit is contained in:
Waseem Daher 2013-01-31 10:54:13 -05:00
parent 98a7d31374
commit 6cefbde820
1 changed files with 13 additions and 9 deletions

View File

@ -15,28 +15,31 @@ function render_object_in_parts(obj) {
// N.B. action is *not* escaped by the caller // N.B. action is *not* escaped by the caller
switch (obj.action) { switch (obj.action) {
case 'search': case 'search':
return {action: 'Find', search: obj.query}; return {prefix: 'Find', query: obj.query, suffix: 'in page'};
case 'stream': case 'stream':
return {action: 'Narrow to stream', search: obj.query}; return {prefix: 'Narrow to stream', query: obj.query, suffix: ''};
case 'private_message': case 'private_message':
return {action: 'Narrow to person', return {prefix: 'Narrow to person',
search: typeahead_helper.render_pm_object(obj.query)}; query: typeahead_helper.render_pm_object(obj.query),
suffix: ''};
case 'operators': case 'operators':
// HACK: This label needs to be distinct from the above, because of the // HACK: This label needs to be distinct from the above, because of the
// way we identify action objects by their labels. Using two spaces // way we identify action objects by their labels. Using two spaces
// after 'Narrow to' ensures this, and is invisible with standard HTML // after 'Narrow to' ensures this, and is invisible with standard HTML
// whitespace handling. // whitespace handling.
return {action: 'Narrow to ', search: narrow.describe(obj.operators)}; return {prefix: 'Narrow to ',
query: narrow.describe(obj.operators),
suffix: ''};
} }
return {action: 'Error', search: 'Error'}; return {prefix: 'Error', query: 'Error', suffix: 'Error'};
} }
function render_object(obj) { function render_object(obj) {
var parts = render_object_in_parts(obj); var parts = render_object_in_parts(obj);
return parts.action + " " + parts.search; return parts.prefix + " " + parts.query + " " + parts.suffix;
} }
exports.update_typeahead = function () { exports.update_typeahead = function () {
@ -194,8 +197,9 @@ exports.initialize = function () {
var parts = render_object_in_parts(mapped[item]); var parts = render_object_in_parts(mapped[item]);
// We provide action, not the user, so this should // We provide action, not the user, so this should
// be fine from a not-needing-escaping perspective. // be fine from a not-needing-escaping perspective.
return parts.action + " " + return parts.prefix + " " +
typeahead_helper.highlight_with_escaping(query, parts.search); typeahead_helper.highlight_with_escaping(query, parts.query)
+ " " + parts.suffix;
}, },
matcher: function (item) { matcher: function (item) {
var obj = mapped[item]; var obj = mapped[item];