forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display details about the search context in the placeholder
- Loading branch information
Showing
7 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/templates/search.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/assets/javascripts/discourse/views/search/search_text_field.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
This is a text field that supports a dynamic placeholder based on search context. | ||
@class SearchTextField | ||
@extends Discourse.TextField | ||
@namespace Discourse | ||
@module Discourse | ||
**/ | ||
Discourse.SearchTextField = Discourse.TextField.extend({ | ||
|
||
/** | ||
A dynamic placeholder for the search field based on our context | ||
@property placeholder | ||
**/ | ||
placeholder: function() { | ||
|
||
var ctx = this.get('searchContext'); | ||
if (ctx) { | ||
switch(Em.get(ctx, 'type')) { | ||
case 'user': | ||
return Em.String.i18n('search.prefer.user', {username: Em.get(ctx, 'user.username')}); | ||
case 'category': | ||
return Em.String.i18n('search.prefer.category', {category: Em.get(ctx, 'category.name')}); | ||
} | ||
} | ||
|
||
return Em.String.i18n('search.placeholder'); | ||
}.property('searchContext') | ||
|
||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters