From 0b222550f7a490177102f371c98603f286f7d757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 28 Apr 2013 02:37:53 +0200 Subject: [PATCH] flash draft status when requirements are not met for new users --- app/assets/javascripts/discourse/models/composer.js | 9 +++++++++ .../discourse/templates/composer.js.handlebars | 2 +- app/assets/javascripts/discourse/views/composer_view.js | 2 +- app/assets/stylesheets/application/compose.css.scss | 9 ++++++--- app/serializers/current_user_serializer.rb | 5 +++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js index 197ab4376d9..50eb2cbc62a 100644 --- a/app/assets/javascripts/discourse/models/composer.js +++ b/app/assets/javascripts/discourse/models/composer.js @@ -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() { var $title = $('#reply-title'), $reply = $('#wmd-input'); @@ -467,6 +475,7 @@ Discourse.Composer = Discourse.Model.extend({ if ($title.is(':focus')) { var titleDiff = this.get('missingTitleCharacters'); if (titleDiff > 0) { + this.flashDraftStatusForNewUser(); return this.set('draftStatus', Em.String.i18n('composer.min_length.need_more_for_title', { n: titleDiff })); } // 'reply' is focused diff --git a/app/assets/javascripts/discourse/templates/composer.js.handlebars b/app/assets/javascripts/discourse/templates/composer.js.handlebars index 0b0e3c204e3..2e77f1a6e99 100644 --- a/app/assets/javascripts/discourse/templates/composer.js.handlebars +++ b/app/assets/javascripts/discourse/templates/composer.js.handlebars @@ -50,7 +50,7 @@ {{#if Discourse.currentUser}} {{{content.toggleText}}} -
+
{{#if view.loadingImage}}
{{i18n image_selector.uploading_image}} {{view.uploadProgress}}% {{i18n cancel}} diff --git a/app/assets/javascripts/discourse/views/composer_view.js b/app/assets/javascripts/discourse/views/composer_view.js index e0f56f32902..d4201e5104e 100644 --- a/app/assets/javascripts/discourse/views/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer_view.js @@ -27,7 +27,7 @@ Discourse.ComposerView = Discourse.View.extend({ }.property('content.composeState'), draftStatus: function() { - this.$('.draft-status').text(this.get('content.draftStatus') || ""); + $('#draft-status').text(this.get('content.draftStatus') || ""); }.observes('content.draftStatus'), // Disable fields when we're loading diff --git a/app/assets/stylesheets/application/compose.css.scss b/app/assets/stylesheets/application/compose.css.scss index 72215d1dba6..5d816216ef6 100755 --- a/app/assets/stylesheets/application/compose.css.scss +++ b/app/assets/stylesheets/application/compose.css.scss @@ -96,7 +96,7 @@ .requirements-not-met { background-color: rgba(255, 0, 0, 0.12); } - .toggle-preview, .draft-status, #image-uploading { + .toggle-preview, #draft-status, #image-uploading { position: absolute; bottom: -31px; margin-top: 0px; @@ -110,9 +110,12 @@ font-size: 12px; color: darken($gray, 40); } - .draft-status { + #draft-status { right: 51%; color: lighten($black, 60); + &.flash { + color: lighten($red, 20); + } } @include transition(height 0.4s ease); width: 100%; @@ -219,7 +222,7 @@ margin-right: auto; float: none; } - + // When the post is new (new topic) the sizings are different &.edit-title { &.open { diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index 42f32dc32b4..988525510b1 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -9,8 +9,9 @@ class CurrentUserSerializer < BasicUserSerializer :moderator?, :reply_count, :topic_count, - :enable_quoting, - :external_links_in_new_tab + :enable_quoting, + :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