2014-06-05 20:18:03 -05:00
|
|
|
import uploader from 'ghost/assets/lib/uploader';
|
|
|
|
|
2014-03-03 15:18:10 -05:00
|
|
|
var Markdown = Ember.Component.extend({
|
2014-06-05 20:18:03 -05:00
|
|
|
didInsertElement: function () {
|
|
|
|
this.set('scrollWrapper', this.$().closest('.entry-preview-content'));
|
|
|
|
},
|
|
|
|
|
2014-03-03 15:18:10 -05:00
|
|
|
adjustScrollPosition: function () {
|
2014-06-05 20:18:03 -05:00
|
|
|
var scrollWrapper = this.get('scrollWrapper'),
|
|
|
|
scrollPosition = this.get('scrollPosition');
|
|
|
|
|
|
|
|
scrollWrapper.scrollTop(scrollPosition);
|
|
|
|
}.observes('scrollPosition'),
|
|
|
|
|
|
|
|
// fire off 'enable' API function from uploadManager
|
|
|
|
// might need to make sure markdown has been processed first
|
|
|
|
reInitDropzones: function () {
|
|
|
|
Ember.run.scheduleOnce('afterRender', this, function () {
|
2014-07-31 15:29:35 -05:00
|
|
|
var dropzones = $('.js-drop-zone'),
|
|
|
|
self = this;
|
2014-06-05 20:18:03 -05:00
|
|
|
|
|
|
|
uploader.call(dropzones, {
|
|
|
|
editor: true,
|
2014-06-23 16:12:22 -05:00
|
|
|
fileStorage: this.get('config.fileStorage')
|
2014-06-05 20:18:03 -05:00
|
|
|
});
|
2014-03-03 15:18:10 -05:00
|
|
|
|
2014-07-31 15:29:35 -05:00
|
|
|
function boundSendAction(actionName) {
|
|
|
|
return function() {
|
|
|
|
self.sendAction.call(self, actionName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dropzones.on('uploadstart', boundSendAction('uploadStarted'));
|
|
|
|
dropzones.on('uploadfailure', boundSendAction('uploadFinished'));
|
|
|
|
dropzones.on('uploadsuccess', boundSendAction('uploadFinished'));
|
|
|
|
dropzones.on('uploadsuccess', boundSendAction('uploadSuccess'));
|
2014-06-05 20:18:03 -05:00
|
|
|
});
|
|
|
|
}.observes('markdown')
|
2014-03-03 15:18:10 -05:00
|
|
|
});
|
|
|
|
|
2014-06-05 20:18:03 -05:00
|
|
|
export default Markdown;
|