UX: Hide the timeline when the composer is open

This commit is contained in:
Robin Ward 2016-06-01 14:42:00 -04:00
parent 158a0daf32
commit a832d88375
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
10 changed files with 49 additions and 34 deletions

View File

@ -82,7 +82,7 @@ export default Ember.Component.extend({
} }
this._bindUploadTarget(); this._bindUploadTarget();
this.appEvents.trigger('composer:opened'); this.appEvents.trigger('composer:will-open');
}, },
@computed('composer.reply', 'composer.replyLength', 'composer.missingReplyCharacters', 'composer.minimumPostLength', 'lastValidatedAt') @computed('composer.reply', 'composer.replyLength', 'composer.missingReplyCharacters', 'composer.minimumPostLength', 'lastValidatedAt')

View File

@ -1,9 +1,22 @@
export default Ember.Component.extend({ export default Ember.Component.extend({
composerOpen: null,
classNameBindings: ['composerOpen'],
showTimeline: null, showTimeline: null,
info: null,
_checkSize() { _checkSize() {
const width = $(window).width(); const renderTimeline = $(window).width() > 960;
this.set('showTimeline', width > 960); this.set('info', { renderTimeline, showTimeline: renderTimeline && !this.get('composerOpen') });
},
composerOpened() {
this.set('composerOpen', true);
this._checkSize();
},
composerClosed() {
this.set('composerOpen', false);
this._checkSize();
}, },
didInsertElement() { didInsertElement() {
@ -11,9 +24,11 @@ export default Ember.Component.extend({
if (!this.site.mobileView) { if (!this.site.mobileView) {
$(window).on('resize.discourse-topic-navigation', () => this._checkSize()); $(window).on('resize.discourse-topic-navigation', () => this._checkSize());
this.appEvents.on('composer:will-open', this, this.composerOpened);
this.appEvents.on('composer:will-close', this, this.composerClosed);
this._checkSize(); this._checkSize();
} else { } else {
this.set('showTimeline', false); this.set('info', null);
} }
}, },
@ -21,6 +36,8 @@ export default Ember.Component.extend({
this._super(); this._super();
if (!this.site.mobileView) { if (!this.site.mobileView) {
$(window).off('resize.discourse-topic-navigation'); $(window).off('resize.discourse-topic-navigation');
this.appEvents.off('composer:will-open', this, this.composerOpened);
this.appEvents.off('composer:will-close', this, this.composerClosed);
} }
} }
}); });

View File

@ -9,16 +9,15 @@ export default Ember.Component.extend({
progressPosition: null, progressPosition: null,
postStream: Ember.computed.alias('topic.postStream'), postStream: Ember.computed.alias('topic.postStream'),
userWantsToJump: null, userWantsToJump: null,
composerVisible: null,
init() { init() {
this._super(); this._super();
(this.get('delegated') || []).forEach(m => this.set(m, m)); (this.get('delegated') || []).forEach(m => this.set(m, m));
}, },
@computed('userWantsToJump', 'showTimeline', 'composerVisible') @computed('userWantsToJump', 'showTimeline')
hidden(userWantsToJump, showTimeline, composerVisible) { hidden(userWantsToJump, showTimeline) {
return !userWantsToJump && !composerVisible && showTimeline; return !userWantsToJump && showTimeline;
}, },
@observes('hidden') @observes('hidden')
@ -78,22 +77,11 @@ export default Ember.Component.extend({
Ember.run.scheduleOnce('afterRender', this, this._updateProgressBar); Ember.run.scheduleOnce('afterRender', this, this._updateProgressBar);
}, },
_composerOpened() {
this.set('composerVisible', true);
this._dock();
},
_composerWillClose() {
this.set('composerVisible', false);
},
didInsertElement() { didInsertElement() {
this._super(); this._super();
this.appEvents.on('composer:opened', this, this._composerOpened); this.appEvents.on('composer:will-open', this, this._dock)
this.appEvents.on('composer:will-close', this, this._composerWillClose); .on("composer:resized", this, this._dock)
this.appEvents.on("composer:resized", this, this._dock)
.on('composer:closed', this, this._dock) .on('composer:closed', this, this._dock)
.on("topic:scrolled", this, this._dock) .on("topic:scrolled", this, this._dock)
.on('topic:current-post-changed', postNumber => this.set('progressPosition', postNumber)) .on('topic:current-post-changed', postNumber => this.set('progressPosition', postNumber))
@ -104,9 +92,8 @@ export default Ember.Component.extend({
willDestroyElement() { willDestroyElement() {
this._super(); this._super();
this.appEvents.off('composer:opened', this, this._composerOpened); this.appEvents.off('composer:will-open', this, this._dock)
this.appEvents.off('composer:will-close', this, this._composerWillClose); .off("composer:resized", this, this._dock)
this.appEvents.off("composer:resized", this, this._dock)
.off('composer:closed', this, this._dock) .off('composer:closed', this, this._dock)
.off('topic:scrolled', this, this._dock) .off('topic:scrolled', this, this._dock)
.off('topic:current-post-changed') .off('topic:current-post-changed')

View File

@ -29,7 +29,7 @@ export default MountWidget.extend(Docking, {
const topicTop = $('.container.posts').offset().top; const topicTop = $('.container.posts').offset().top;
const topicBottom = $('#topic-bottom').offset().top; const topicBottom = $('#topic-bottom').offset().top;
const $timeline = this.$('.timeline-container'); const $timeline = this.$('.timeline-container');
const timelineHeight = $timeline.height(); const timelineHeight = $timeline.height() || 400;
const footerHeight = $('.timeline-footer-controls').outerHeight(true) || 0; const footerHeight = $('.timeline-footer-controls').outerHeight(true) || 0;
const prev = this.dockAt; const prev = this.dockAt;

View File

@ -344,7 +344,7 @@ export default Ember.Controller.extend({
}).catch(function(error) { }).catch(function(error) {
composer.set('disableDrafts', false); composer.set('disableDrafts', false);
self.appEvents.one('composer:opened', () => bootbox.alert(error)); self.appEvents.one('composer:will-open', () => bootbox.alert(error));
}); });
if (this.get('controllers.application.currentRouteName').split('.')[0] === 'topic' && if (this.get('controllers.application.currentRouteName').split('.')[0] === 'topic' &&

View File

@ -1 +1 @@
{{yield showTimeline}} {{yield info}}

View File

@ -66,8 +66,8 @@
<div class='selected-posts {{unless multiSelect 'hidden'}}'> <div class='selected-posts {{unless multiSelect 'hidden'}}'>
{{partial "selected-posts"}} {{partial "selected-posts"}}
</div> </div>
{{#topic-navigation as |showTimeline|}} {{#topic-navigation as |info|}}
{{#if showTimeline}} {{#if info.renderTimeline}}
{{topic-timeline topic=model {{topic-timeline topic=model
enteredIndex=enteredIndex enteredIndex=enteredIndex
loading=model.postStream.loading loading=model.postStream.loading
@ -76,7 +76,7 @@
{{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}} {{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}}
{{/if}} {{/if}}
{{topic-progress topic=model delegated=topicDelegated showTimeline=showTimeline}} {{topic-progress topic=model delegated=topicDelegated showTimeline=info.showTimeline}}
{{/topic-navigation}} {{/topic-navigation}}
<div class="row"> <div class="row">

View File

@ -92,7 +92,12 @@ const ComposerView = Ember.View.extend({
onDrag: sizePx => this.movePanels(sizePx) onDrag: sizePx => this.movePanels(sizePx)
}); });
afterTransition($replyControl, resize); afterTransition($replyControl, () => {
resize();
if (this.get('composer.composeState') === Composer.OPEN) {
this.appEvents.trigger('composer:opened');
}
});
positioningWorkaround(this.$()); positioningWorkaround(this.$());
}, },

View File

@ -2,6 +2,12 @@
width: 900px; width: 900px;
} }
.composer-open {
.topic-timeline {
opacity: 0;
}
}
.timeline-container { .timeline-container {
box-sizing: border-box; box-sizing: border-box;
z-index: 999; z-index: 999;
@ -11,7 +17,6 @@
&.timeline-docked { &.timeline-docked {
position: absolute; position: absolute;
} }
&.timeline-docked-bottom { &.timeline-docked-bottom {
@ -23,6 +28,7 @@
.topic-timeline { .topic-timeline {
margin-left: 3em; margin-left: 3em;
width: 150px; width: 150px;
transition: opacity 0.2s ease-in;
.timeline-controls { .timeline-controls {
margin-bottom: 1em; margin-bottom: 1em;