This repository has been archived on 2026-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
huegasm/app/pods/components/add-soundcloud-sound-modal/component.js
2015-10-21 01:18:26 -07:00

38 lines
779 B
JavaScript

import Em from 'ember';
export default Em.Component.extend({
actions: {
close () {
this.sendAction();
},
add (){
this.sendAction('action', this.get('url'));
}
},
url: null,
onIsShowingModalChange: function(){
if(this.get('isShowingModal')){
this.set('url', null);
setTimeout(()=>{
Em.$('md-input-container input').focus();
}, 500);
}
}.observes('isShowingModal'),
didInsertElement: function() {
var self = this;
Em.$(document).keypress(function(event) {
if(!self.get('saveDisabled') && event.which === 13) {
self.send('add');
}
});
},
saveDisabled: function(){
return Em.isNone(this.get('url')) || Em.isEmpty(this.get('url').trim());
}.property('url')
});