diff --git a/app/assets/javascripts/discourse/components/composer-toggles.js.es6 b/app/assets/javascripts/discourse/components/composer-toggles.js.es6 new file mode 100644 index 00000000000..cd5369638c7 --- /dev/null +++ b/app/assets/javascripts/discourse/components/composer-toggles.js.es6 @@ -0,0 +1,14 @@ +import computed from 'ember-addons/ember-computed-decorators'; + +export default Ember.Component.extend({ + tagName: '', + + @computed('composeState') + toggleIcon(composeState) { + if (composeState === "draft" || composeState === "saving") { + return "times"; + } + return "chevron-down"; + } +}); + diff --git a/app/assets/javascripts/discourse/components/flat-button.js.es6 b/app/assets/javascripts/discourse/components/flat-button.js.es6 new file mode 100644 index 00000000000..792db361387 --- /dev/null +++ b/app/assets/javascripts/discourse/components/flat-button.js.es6 @@ -0,0 +1,16 @@ +import { default as computed } from 'ember-addons/ember-computed-decorators'; + +export default Ember.Component.extend({ + tagName: 'button', + classNames: ['btn-flat'], + attributeBindings: ['disabled', 'translatedTitle:title'], + + @computed("title") + translatedTitle(title) { + if (title) return I18n.t(title); + }, + + click() { + return this.attrs.action(); + } +}); diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 88e3dba6c2f..af23cb7d436 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -277,7 +277,17 @@ export default Ember.Controller.extend({ // Toggle the reply view toggle() { - this.toggle(); + this.closeAutocomplete(); + if (this.get('model.composeState') === Composer.OPEN) { + if (Ember.isEmpty(this.get('model.reply')) && Ember.isEmpty(this.get('model.title'))) { + this.close(); + } else { + this.shrink(); + } + } else { + this.close(); + } + return false; }, togglePreview() { @@ -390,20 +400,6 @@ export default Ember.Controller.extend({ return Discourse.Category.list(); }.property(), - toggle() { - this.closeAutocomplete(); - if (this.get('model.composeState') === Composer.OPEN) { - if (Ember.isEmpty(this.get('model.reply')) && Ember.isEmpty(this.get('model.title'))) { - this.close(); - } else { - this.shrink(); - } - } else { - this.close(); - } - return false; - }, - disableSubmit: Ember.computed.or("model.loading", "isUploading"), save(force) { diff --git a/app/assets/javascripts/discourse/templates/components/composer-toggles.hbs b/app/assets/javascripts/discourse/templates/components/composer-toggles.hbs new file mode 100644 index 00000000000..09e841bd85b --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/composer-toggles.hbs @@ -0,0 +1,12 @@ +{{#if site.mobileView}} + {{flat-button + class="toggle-toolbar" + icon="bars" + action=toggleToolbar}} +{{/if}} + +{{flat-button + class="toggler" + icon=toggleIcon + action=toggleComposer + title='composer.toggler'}} diff --git a/app/assets/javascripts/discourse/templates/components/flat-button.hbs b/app/assets/javascripts/discourse/templates/components/flat-button.hbs new file mode 100644 index 00000000000..41ee1dc6407 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/flat-button.hbs @@ -0,0 +1 @@ +{{fa-icon icon}} diff --git a/app/assets/javascripts/discourse/templates/composer.hbs b/app/assets/javascripts/discourse/templates/composer.hbs index 9e20fd73309..24912fed6be 100644 --- a/app/assets/javascripts/discourse/templates/composer.hbs +++ b/app/assets/javascripts/discourse/templates/composer.hbs @@ -22,10 +22,10 @@ {{composer-messages composer=model messageCount=messageCount addLinkLookup="addLinkLookup"}}