flash draft status when requirements are not met for new users

This commit is contained in:
Régis Hanol 2013-04-28 02:37:53 +02:00
parent b30445c3ef
commit 0b222550f7
5 changed files with 20 additions and 7 deletions

View file

@ -459,6 +459,14 @@ Discourse.Composer = Discourse.Model.extend({
}); });
}, },
flashDraftStatusForNewUser: function() {
var $draftStatus = $('#draft-status');
if (Discourse.get('currentUser.trust_level') === 0) {
$draftStatus.toggleClass('flash', true);
setTimeout(function() { $draftStatus.removeClass('flash'); }, 250);
}
},
updateDraftStatus: function() { updateDraftStatus: function() {
var $title = $('#reply-title'), var $title = $('#reply-title'),
$reply = $('#wmd-input'); $reply = $('#wmd-input');
@ -467,6 +475,7 @@ Discourse.Composer = Discourse.Model.extend({
if ($title.is(':focus')) { if ($title.is(':focus')) {
var titleDiff = this.get('missingTitleCharacters'); var titleDiff = this.get('missingTitleCharacters');
if (titleDiff > 0) { if (titleDiff > 0) {
this.flashDraftStatusForNewUser();
return this.set('draftStatus', Em.String.i18n('composer.min_length.need_more_for_title', { n: titleDiff })); return this.set('draftStatus', Em.String.i18n('composer.min_length.need_more_for_title', { n: titleDiff }));
} }
// 'reply' is focused // 'reply' is focused

View file

@ -50,7 +50,7 @@
</div> </div>
{{#if Discourse.currentUser}} {{#if Discourse.currentUser}}
<a href="#" {{action togglePreview target="controller"}} class='toggle-preview'>{{{content.toggleText}}}</a> <a href="#" {{action togglePreview target="controller"}} class='toggle-preview'>{{{content.toggleText}}}</a>
<div class='draft-status'></div> <div id='draft-status'></div>
{{#if view.loadingImage}} {{#if view.loadingImage}}
<div id="image-uploading"> <div id="image-uploading">
{{i18n image_selector.uploading_image}} {{view.uploadProgress}}% <a id="cancel-image-upload">{{i18n cancel}}</a> {{i18n image_selector.uploading_image}} {{view.uploadProgress}}% <a id="cancel-image-upload">{{i18n cancel}}</a>

View file

@ -27,7 +27,7 @@ Discourse.ComposerView = Discourse.View.extend({
}.property('content.composeState'), }.property('content.composeState'),
draftStatus: function() { draftStatus: function() {
this.$('.draft-status').text(this.get('content.draftStatus') || ""); $('#draft-status').text(this.get('content.draftStatus') || "");
}.observes('content.draftStatus'), }.observes('content.draftStatus'),
// Disable fields when we're loading // Disable fields when we're loading

View file

@ -96,7 +96,7 @@
.requirements-not-met { .requirements-not-met {
background-color: rgba(255, 0, 0, 0.12); background-color: rgba(255, 0, 0, 0.12);
} }
.toggle-preview, .draft-status, #image-uploading { .toggle-preview, #draft-status, #image-uploading {
position: absolute; position: absolute;
bottom: -31px; bottom: -31px;
margin-top: 0px; margin-top: 0px;
@ -110,9 +110,12 @@
font-size: 12px; font-size: 12px;
color: darken($gray, 40); color: darken($gray, 40);
} }
.draft-status { #draft-status {
right: 51%; right: 51%;
color: lighten($black, 60); color: lighten($black, 60);
&.flash {
color: lighten($red, 20);
}
} }
@include transition(height 0.4s ease); @include transition(height 0.4s ease);
width: 100%; width: 100%;

View file

@ -10,7 +10,8 @@ class CurrentUserSerializer < BasicUserSerializer
:reply_count, :reply_count,
:topic_count, :topic_count,
:enable_quoting, :enable_quoting,
:external_links_in_new_tab :external_links_in_new_tab,
:trust_level
# we probably want to move this into site, but that json is cached so hanging it off current user seems okish # we probably want to move this into site, but that json is cached so hanging it off current user seems okish