mirror of
https://github.com/flarum/core.git
synced 2025-07-31 13:40:20 +02:00
Hello world!
This commit is contained in:
38
ember/app/components/search-input.js
Normal file
38
ember/app/components/search-input.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ['search-input'],
|
||||
classNameBindings: ['active', 'value:clearable'],
|
||||
|
||||
didInsertElement: function() {
|
||||
var self = this;
|
||||
this.$().find('input').on('keydown', function(e) {
|
||||
if (e.which == 27) {
|
||||
self.clear();
|
||||
}
|
||||
});
|
||||
this.$().find('.clear').on('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
}).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
self.clear();
|
||||
})
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.set('value', '');
|
||||
this.sendAction('action', '');
|
||||
this.$().find('input').focus();
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
this.$().find('input').off('keydown');
|
||||
this.$().find('.clear').off('mousedown click');
|
||||
},
|
||||
|
||||
actions: {
|
||||
search: function() {
|
||||
this.sendAction('action', this.get('value'));
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user