mirror of
https://github.com/flarum/framework.git
synced 2025-06-05 07:24:33 +08:00
Move forum ember app into a subdir, preparing for admin app to exist alongside
This commit is contained in:
36
ember/forum/app/components/ui/search-input.js
Normal file
36
ember/forum/app/components/ui/search-input.js
Normal file
@ -0,0 +1,36 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
/**
|
||||
A basic search input. Comes with the ability to be cleared by pressing
|
||||
escape or with a button. Sends an action when enter is pressed.
|
||||
*/
|
||||
export default Ember.Component.extend({
|
||||
layoutName: 'components/ui/search-input',
|
||||
classNames: ['search-input'],
|
||||
classNameBindings: ['active', 'value:clearable'],
|
||||
|
||||
didInsertElement: function() {
|
||||
this.$('input').on('keydown', 'esc', function(e) {
|
||||
self.clear();
|
||||
});
|
||||
|
||||
var self = this;
|
||||
this.$('.clear').on('mousedown click', function(e) {
|
||||
e.preventDefault();
|
||||
}).on('click', function(e) {
|
||||
self.clear();
|
||||
});
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.set('value', '');
|
||||
this.send('search');
|
||||
this.$().find('input').focus();
|
||||
},
|
||||
|
||||
actions: {
|
||||
search: function() {
|
||||
this.get('action')(this.get('value'));
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user