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/web/app/pods/components/music-tab/add-soundcloud-sound-modal/component.js
2017-12-09 19:32:12 -08:00

37 lines
831 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(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'));
}
}
});