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/mobile/app/pods/components/music-tab/add-soundcloud-sound-modal/component.js

46 lines
848 B
JavaScript

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