Merge pull request #494 from ZogStriP/consistent-composer-behavior
consistent behavior of the composer's create button
This commit is contained in:
commit
27b16507ac
|
@ -125,7 +125,6 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
Discourse.Utilities.tinyAvatar(replyUsername) + " " + replyUsername;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch (this.get('action')) {
|
||||
|
@ -155,14 +154,20 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
// Can't submit while loading
|
||||
if (this.get('loading')) return true;
|
||||
|
||||
// Title is required on new posts
|
||||
if (this.get('creatingTopic') && this.get('titleLength') < Discourse.SiteSettings.min_topic_title_length) return true;
|
||||
// Title is required when:
|
||||
// - creating a new topic
|
||||
// - editing the 1st post
|
||||
// - creating a private message
|
||||
if (this.get('editTitle') && this.get('titleLength') < Discourse.SiteSettings.min_topic_title_length) return true;
|
||||
|
||||
// Otherwise just reply is required
|
||||
// Need at least one user when sending a private message
|
||||
if (this.get('creatingPrivateMessage') && (this.get('targetUsernames').trim() + ',').indexOf(',') === 0) return true;
|
||||
|
||||
// reply is always required
|
||||
if (this.get('replyLength') < Discourse.SiteSettings.min_post_length) return true;
|
||||
|
||||
return false;
|
||||
}).property('reply', 'title', 'creatingTopic', 'loading'),
|
||||
}).property('loading', 'editTitle', 'titleLength', 'targetUsernames', 'replyLength'),
|
||||
|
||||
// The text for the save button
|
||||
saveText: (function() {
|
||||
|
@ -179,8 +184,7 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
}).property('action'),
|
||||
|
||||
hasMetaData: (function() {
|
||||
var metaData;
|
||||
metaData = this.get('metaData');
|
||||
var metaData = this.get('metaData');
|
||||
if (!this.get('metaData')) {
|
||||
return false;
|
||||
}
|
||||
|
@ -430,8 +434,6 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
if (this.get('disableDrafts')) return;
|
||||
// Do not save when there is no reply
|
||||
if (!this.get('reply')) return;
|
||||
// Do not save when the title's length is too small (only when creating a new post)
|
||||
if (this.get('creatingTopic') && this.get('titleLength') < Discourse.SiteSettings.min_topic_title_length) return;
|
||||
// Do not save when the reply's length is too small
|
||||
if (this.get('replyLength') < Discourse.SiteSettings.min_post_length) return;
|
||||
|
||||
|
@ -473,7 +475,7 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
// hide the counters if the currently focused text field is OK
|
||||
this.set('draftStatus', null);
|
||||
|
||||
}).observes('reply', 'title'),
|
||||
}).observes('replyLength', 'titleLength'),
|
||||
|
||||
/**
|
||||
Computes the length of the title minus non-significant whitespaces
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
{{#if content.editTitle}}
|
||||
<div class='form-element clearfix'>
|
||||
{{#if content.creatingPrivateMessage}}
|
||||
{{view Discourse.TextField id="private-message-users" class="span8" placeholderKey="composer.users_placeholder"}}
|
||||
{{view Discourse.TextField id="private-message-users" class="span8" placeholderKey="composer.users_placeholder" tabindex="1"}}
|
||||
{{/if}}
|
||||
{{view Discourse.TextField valueBinding="content.title" tabindex="1" id="reply-title" maxlength="255" class="span8" placeholderKey="composer.title_placeholder"}}
|
||||
{{view Discourse.TextField valueBinding="content.title" tabindex="2" id="reply-title" maxlength="255" class="span8" placeholderKey="composer.title_placeholder"}}
|
||||
{{#unless content.creatingPrivateMessage}}
|
||||
{{view Discourse.ComboboxViewCategory valueAttribute="name" contentBinding="Discourse.site.categories" valueBinding="content.categoryName"}}
|
||||
{{#if content.archetype.hasOptions}}
|
||||
|
@ -43,7 +43,7 @@
|
|||
<div class='wmd-controls'>
|
||||
<div class='textarea-wrapper'>
|
||||
<div class='wmd-button-bar' id='wmd-button-bar'></div>
|
||||
{{view Discourse.NotifyingTextArea parentBinding="view" tabindex="2" valueBinding="content.reply" id="wmd-input" placeholderKey="composer.reply_placeholder"}}
|
||||
{{view Discourse.NotifyingTextArea parentBinding="view" tabindex="3" valueBinding="content.reply" id="wmd-input" placeholderKey="composer.reply_placeholder"}}
|
||||
</div>
|
||||
<div class='preview-wrapper'>
|
||||
<div id='wmd-preview' {{bindAttr class="controller.hidePreview:hidden"}}></div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
|
||||
{{#if Discourse.currentUser}}
|
||||
<div class='submit-panel'>
|
||||
<button {{action save target="controller"}} tabindex="3" {{bindAttr disabled="content.cantSubmitPost"}} class='btn btn-primary create'>{{view.content.saveText}}</button>
|
||||
<button {{action save target="controller"}} tabindex="4" {{bindAttr disabled="content.cantSubmitPost"}} class='btn btn-primary create'>{{view.content.saveText}}</button>
|
||||
<a href='#' {{action cancel target="controller"}} class='cancel' tabindex="4">{{i18n cancel}}</a>
|
||||
{{#if view.loadingImage}}
|
||||
<div id="image-uploading">
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar target="controller"}} href='#' title="{{i18n favorite.help}}"></a>
|
||||
{{/if}}
|
||||
{{#if view.editingTopic}}
|
||||
<input id='edit-title' type='text' {{bindAttr value="view.topic.title"}}>
|
||||
<input id='edit-title' type='text' {{bindAttr value="view.topic.title"}} autofocus>
|
||||
{{view Discourse.ComboboxViewCategory valueAttribute="name" contentBinding="Discourse.site.categories" sourceBinding="view.topic.categoryName"}}
|
||||
<button class='btn btn-primary btn-small' {{action finishedEdit target="view"}}><i class='icon-ok'></i></button>
|
||||
<button class='btn btn-small' {{action cancelEdit target="view"}}><i class='icon-remove'></i></button>
|
||||
|
|
Loading…
Reference in New Issue