1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/components/gh-upload-modal.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

import ModalDialog from 'ghost/components/gh-modal-dialog';
2014-06-06 16:44:09 +02:00
import upload from 'ghost/assets/lib/uploader';
2014-03-31 06:07:05 +02:00
var UploadModal = ModalDialog.extend({
layoutName: 'components/gh-modal-dialog',
2014-03-31 06:07:05 +02:00
didInsertElement: function () {
this._super();
upload.call(this.$('.js-drop-zone'), {fileStorage: this.get('config.fileStorage')});
2014-06-06 16:44:09 +02:00
},
confirm: {
reject: {
func: function () { // The function called on rejection
return true;
},
buttonClass: 'btn btn-default',
2014-06-06 16:44:09 +02:00
text: 'Cancel' // The reject button text
},
accept: {
2014-08-06 13:34:08 +02:00
buttonClass: 'btn btn-blue right',
2014-06-06 16:44:09 +02:00
text: 'Save', // The accept button texttext: 'Save'
func: function () {
var imageType = 'model.' + this.get('imageType');
2014-03-31 06:07:05 +02:00
2014-06-06 16:44:09 +02: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 06:07:05 +02:00
},
actions: {
closeModal: function () {
this.sendAction();
},
confirm: function (type) {
var func = this.get('confirm.' + type + '.func');
if (typeof func === 'function') {
2014-06-06 16:44:09 +02:00
func.apply(this);
2014-03-31 06:07:05 +02:00
}
this.sendAction();
this.sendAction('confirm' + type);
2014-03-31 06:07:05 +02:00
}
2014-06-06 16:44:09 +02:00
}
2014-03-31 06:07:05 +02:00
});
export default UploadModal;