Merge pull request #4962 from nbianca/add_composer_events

Added events to show and hide the preview pane.
This commit is contained in:
Sam 2017-07-11 08:26:25 -04:00 committed by GitHub
commit 9840e4285d
1 changed files with 15 additions and 1 deletions

View File

@ -30,6 +30,14 @@ export default Ember.Component.extend({
_setupPreview() {
const val = (this.site.mobileView ? false : (this.keyValueStore.get('composer.showPreview') || 'true'));
this.set('showPreview', val === 'true');
this.appEvents.on('composer:show-preview', () => {
this.set('showPreview', true);
});
this.appEvents.on('composer:hide-preview', () => {
this.set('showPreview', false);
});
},
@computed('site.mobileView', 'showPreview')
@ -42,6 +50,11 @@ export default Ember.Component.extend({
return showPreview ? I18n.t('composer.hide_preview') : I18n.t('composer.show_preview');
},
@observes('showPreview')
showPreviewChanged() {
this.keyValueStore.set({ key: 'composer.showPreview', value: this.get('showPreview') });
},
@computed
markdownOptions() {
return {
@ -445,6 +458,8 @@ export default Ember.Component.extend({
@on('willDestroyElement')
_composerClosed() {
this.appEvents.trigger('composer:will-close');
this.appEvents.off('composer:show-preview');
this.appEvents.off('composer:hide-preview');
Ember.run.next(() => {
$('#main-outlet').css('padding-bottom', 0);
// need to wait a bit for the "slide down" transition of the composer
@ -486,7 +501,6 @@ export default Ember.Component.extend({
togglePreview() {
this.toggleProperty('showPreview');
this.keyValueStore.set({ key: 'composer.showPreview', value: this.get('showPreview') });
},
extraButtons(toolbar) {