diff --git a/app/assets/javascripts/app/views/bookmarklet_view.js b/app/assets/javascripts/app/views/bookmarklet_view.js index 29e63daca..28bce5f47 100644 --- a/app/assets/javascripts/app/views/bookmarklet_view.js +++ b/app/assets/javascripts/app/views/bookmarklet_view.js @@ -35,10 +35,11 @@ app.views.Bookmarklet = Backbone.View.extend({ _postSuccess: function(evt) { this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_success')); app.publisher.close(); + this.$("#publisher").addClass("hidden"); _.delay(window.close, 2000); }, _postError: function(evt) { - this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_error')); + this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_something')); } }); diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 901a8c11b..6c8497a61 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -69,6 +69,18 @@ app.views.Publisher = Backbone.View.extend({ _this.tryClose() } }); + + // close publisher on post + this.on('publisher:add', function() { + this.close(); + this.showSpinner(true); + }); + + // open publisher on post error + this.on('publisher:error', function() { + this.open(); + this.showSpinner(false); + }); this.initSubviews(); return this; @@ -134,6 +146,7 @@ app.views.Publisher = Backbone.View.extend({ }, createStatusMessage : function(evt) { + this.setButtonsEnabled(false); var self = this; if(evt){ evt.preventDefault(); } @@ -179,6 +192,9 @@ app.views.Publisher = Backbone.View.extend({ error: function() { if( app.publisher ) app.publisher.trigger('publisher:error'); self.setInputEnabled(true); + Diaspora.page.flashMessages.render({ 'success':false, 'notice':Diaspora.I18n.t('failed_to_post_message') }); + self.setButtonsEnabled(true); + self.setInputEnabled(true); } }); }, @@ -344,8 +360,14 @@ app.views.Publisher = Backbone.View.extend({ // disable submitting this.checkSubmitAvailability(); + // hide spinner + this.showSpinner(false); + // enable input this.setInputEnabled(true); + + // enable buttons + this.setButtonsEnabled(true); // clear location this.destroyLocation(); @@ -386,7 +408,14 @@ app.views.Publisher = Backbone.View.extend({ this.view_poll_creator.$el.removeClass('active'); return this; }, - + + showSpinner: function(bool) { + if (bool) + this.$('#publisher_spinner').removeClass('hidden'); + else + this.$('#publisher_spinner').addClass('hidden'); + }, + checkSubmitAvailability: function() { if( this._submittable() ) { this.setButtonsEnabled(true); diff --git a/app/assets/stylesheets/publisher.css.scss b/app/assets/stylesheets/publisher.css.scss index 550221777..696f573d6 100644 --- a/app/assets/stylesheets/publisher.css.scss +++ b/app/assets/stylesheets/publisher.css.scss @@ -23,6 +23,10 @@ margin-top: 10px; } + #publisher_spinner { + text-align: center; + } + .options_and_submit { #publisher_service_icons { .btn-link { text-decoration: none; } diff --git a/app/assets/stylesheets/publisher_blueprint.css.scss b/app/assets/stylesheets/publisher_blueprint.css.scss index 3cbb468a2..9c81db04c 100644 --- a/app/assets/stylesheets/publisher_blueprint.css.scss +++ b/app/assets/stylesheets/publisher_blueprint.css.scss @@ -42,6 +42,15 @@ width: 483px; } + #publisher_spinner { + clear: both; + margin-bottom: -2px; + min-height: 21px; + padding-top: 6px; + position: relative; + text-align: center; + } + .options_and_submit { min-height: 21px; clear: both; diff --git a/app/views/publisher/_publisher_blueprint.html.haml b/app/views/publisher/_publisher_blueprint.html.haml index 68ea93d6f..a97beb2e7 100644 --- a/app/views/publisher/_publisher_blueprint.html.haml +++ b/app/views/publisher/_publisher_blueprint.html.haml @@ -47,6 +47,8 @@ - for aspect_id in aspect_ids = hidden_field_tag 'aspect_ids[]', aspect_id.to_s + #publisher_spinner{:class => 'hidden'} + = image_tag 'ajax-loader.gif' .options_and_submit .public_toggle %span#publisher_service_icons diff --git a/app/views/publisher/_publisher_bootstrap.html.haml b/app/views/publisher/_publisher_bootstrap.html.haml index a35f22d36..3c2478cb9 100644 --- a/app/views/publisher/_publisher_bootstrap.html.haml +++ b/app/views/publisher/_publisher_bootstrap.html.haml @@ -53,6 +53,8 @@ - for aspect_id in aspect_ids = hidden_field_tag 'aspect_ids[]', aspect_id.to_s + .row-fluid#publisher_spinner{:class => 'hidden'} + = image_tag 'ajax-loader.gif' .row-fluid.options_and_submit .public_toggle %button.btn.btn-default.pull-left#hide_publisher{:title => t('shared.publisher.discard_post')} diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index a9647a999..a8e9ea909 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -50,10 +50,13 @@ en: limited: "Limited - your post will only be seen by people you are sharing with" public: "Public - your post will be visible to everyone and found by search engines" near_from: "Posted from: <%= location %>" + option: "Option <%= nr %>" + add_option: "Add option" + question: "Question" bookmarklet: + post_something: "Post to diaspora*" post_submit: "Submitting post..." post_success: "Posted! Closing popup window..." - post_error: "An error occurred, try again later." infinite_scroll: no_more: "No more posts." no_more_contacts: "No more contacts." @@ -110,11 +113,6 @@ en: mark_read: "Mark read" mark_unread: "Mark unread" - publisher: - option: "Option <%= nr %>" - add_option: "Add option" - question: "Question" - stream: hide: "Hide" public: "Public"