2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2014-09-16 02:46:40 +04:00
|
|
|
import uploader from 'ghost/assets/lib/uploader';
|
|
|
|
|
|
|
|
var PostImageUploader = Ember.Component.extend({
|
|
|
|
classNames: ['image-uploader', 'js-post-image-upload'],
|
|
|
|
|
2015-05-26 05:10:50 +03:00
|
|
|
config: Ember.inject.service(),
|
|
|
|
|
2015-02-09 18:57:50 +03:00
|
|
|
imageSource: Ember.computed('image', function () {
|
|
|
|
return this.get('image') || '';
|
|
|
|
}),
|
|
|
|
|
2014-09-16 02:46:40 +04:00
|
|
|
setup: function () {
|
|
|
|
var $this = this.$(),
|
|
|
|
self = this;
|
|
|
|
|
2014-11-22 04:42:03 +03:00
|
|
|
this.set('uploaderReference', uploader.call($this, {
|
2014-09-16 02:46:40 +04:00
|
|
|
editor: true,
|
|
|
|
fileStorage: this.get('config.fileStorage')
|
2014-11-22 04:42:03 +03:00
|
|
|
}));
|
2014-09-16 02:46:40 +04:00
|
|
|
|
|
|
|
$this.on('uploadsuccess', function (event, result) {
|
|
|
|
if (result && result !== '' && result !== 'http://') {
|
|
|
|
self.sendAction('uploaded', result);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-09 20:27:20 +03:00
|
|
|
$this.on('imagecleared', function () {
|
2014-09-16 02:46:40 +04:00
|
|
|
self.sendAction('canceled');
|
|
|
|
});
|
|
|
|
}.on('didInsertElement'),
|
|
|
|
|
|
|
|
removeListeners: function () {
|
|
|
|
var $this = this.$();
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-09-16 02:46:40 +04:00
|
|
|
$this.off();
|
|
|
|
$this.find('.js-cancel').off();
|
|
|
|
}.on('willDestroyElement')
|
|
|
|
});
|
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
export default PostImageUploader;
|