2014-05-28 23:26:05 +04:00
|
|
|
import ModalDialog from 'ghost/components/gh-modal-dialog';
|
2014-06-06 18:44:09 +04:00
|
|
|
import upload from 'ghost/assets/lib/uploader';
|
2014-03-31 08:07:05 +04:00
|
|
|
|
|
|
|
var UploadModal = ModalDialog.extend({
|
2014-05-28 23:26:05 +04:00
|
|
|
layoutName: 'components/gh-modal-dialog',
|
2014-03-31 08:07:05 +04:00
|
|
|
|
|
|
|
didInsertElement: function () {
|
|
|
|
this._super();
|
2014-06-06 18:44:09 +04:00
|
|
|
var filestorage = $('#general').data('filestorage');
|
|
|
|
upload.call(this.$('.js-drop-zone'), {fileStorage: filestorage});
|
|
|
|
},
|
|
|
|
confirm: {
|
|
|
|
reject: {
|
|
|
|
func: function () { // The function called on rejection
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
buttonClass: true,
|
|
|
|
text: 'Cancel' // The reject button text
|
|
|
|
},
|
|
|
|
accept: {
|
|
|
|
buttonClass: 'button-save right',
|
|
|
|
text: 'Save', // The accept button texttext: 'Save'
|
|
|
|
func: function () {
|
|
|
|
var imageType = 'model.' + this.get('imageType');
|
2014-03-31 08:07:05 +04:00
|
|
|
|
2014-06-06 18:44:09 +04:00
|
|
|
if (this.$('.js-upload-url').val()) {
|
|
|
|
this.set(imageType, this.$('.js-upload-url').val());
|
|
|
|
} else {
|
|
|
|
this.set(imageType, this.$('.js-upload-target').attr('src'));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
closeModal: function () {
|
|
|
|
this.sendAction();
|
|
|
|
},
|
|
|
|
confirm: function (type) {
|
|
|
|
var func = this.get('confirm.' + type + '.func');
|
|
|
|
if (typeof func === 'function') {
|
2014-06-06 18:44:09 +04:00
|
|
|
func.apply(this);
|
2014-03-31 08:07:05 +04:00
|
|
|
}
|
|
|
|
this.sendAction();
|
2014-06-20 06:29:49 +04:00
|
|
|
this.sendAction('confirm' + type);
|
2014-03-31 08:07:05 +04:00
|
|
|
}
|
2014-06-06 18:44:09 +04:00
|
|
|
}
|
2014-03-31 08:07:05 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default UploadModal;
|