0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/components/gh-markdown.js
Hannah Wolfe 962accfec7 Functional tests for Ember
issue #2989

- Adds lodash for bind and isNumber - looking for a better solution for this
- Still needs the editor and flow tests porting
- Some of the tests are commented out awaiting further implementations
2014-06-20 15:20:59 +01:00

36 lines
1.3 KiB
JavaScript

import uploader from 'ghost/assets/lib/uploader';
var Markdown = Ember.Component.extend({
classNames: ['rendered-markdown'],
didInsertElement: function () {
this.set('scrollWrapper', this.$().closest('.entry-preview-content'));
},
adjustScrollPosition: function () {
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 () {
var dropzones = $('.js-drop-zone');
uploader.call(dropzones, {
editor: true,
filestorage: false
});
dropzones.on('uploadstart', _.bind(this.sendAction, this, 'uploadStarted'));
dropzones.on('uploadfailure', _.bind(this.sendAction, this, 'uploadFinished'));
dropzones.on('uploadsuccess', _.bind(this.sendAction, this, 'uploadFinished'));
dropzones.on('uploadsuccess', _.bind(this.sendAction, this, 'uploadSuccess'));
});
}.observes('markdown')
});
export default Markdown;