mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Cleaning up sharing from blurblog. Handling error case gracefully. Also cleaning up when unsharing and no shared comments are left to display.
This commit is contained in:
parent
b2f94dc52c
commit
c817d52193
3 changed files with 51 additions and 47 deletions
|
@ -83,7 +83,9 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Open/resize
|
// Open/resize
|
||||||
this.$('.NB-error').remove();
|
if (!options.resize_open) {
|
||||||
|
this.$('.NB-error').remove();
|
||||||
|
}
|
||||||
$sideoption.addClass('NB-active');
|
$sideoption.addClass('NB-active');
|
||||||
$unshare_button.toggleClass('NB-hidden', !this.model.get("shared"));
|
$unshare_button.toggleClass('NB-hidden', !this.model.get("shared"));
|
||||||
$twitter_button.toggleClass('NB-active', !!NEWSBLUR.assets.preference('post_to_twitter'));
|
$twitter_button.toggleClass('NB-active', !!NEWSBLUR.assets.preference('post_to_twitter'));
|
||||||
|
@ -143,7 +145,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({
|
||||||
mark_story_as_shared: function(options) {
|
mark_story_as_shared: function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var $share_button = this.$('.NB-sideoption-share-save');
|
var $share_button = this.$('.NB-sideoption-share-save');
|
||||||
var $share_button_menu = $('.NB-menu-manage-story-share-save');
|
var $share_button_menu = $('.NB-menu-manage .NB-menu-manage-story-share-save');
|
||||||
var $share_menu = $share_button_menu.closest('.NB-sideoption-share');
|
var $share_menu = $share_button_menu.closest('.NB-sideoption-share');
|
||||||
var $comments_sideoptions = this.$('.NB-sideoption-share-comments');
|
var $comments_sideoptions = this.$('.NB-sideoption-share-comments');
|
||||||
var $comments_menu = $('.NB-sideoption-share-comments', $share_menu);
|
var $comments_menu = $('.NB-sideoption-share-comments', $share_menu);
|
||||||
|
@ -202,7 +204,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({
|
||||||
$share_sideoption.text(shared_text).closest('.NB-sideoption');
|
$share_sideoption.text(shared_text).closest('.NB-sideoption');
|
||||||
|
|
||||||
if (this.options.on_social_page) {
|
if (this.options.on_social_page) {
|
||||||
this.$('.NB-story-comments').replaceWith(data);
|
this.$('.NB-story-comments-container').html(data);
|
||||||
} else {
|
} else {
|
||||||
this.model.story_view.$el.toggleClass('NB-story-shared', this.model.get('shared'));
|
this.model.story_view.$el.toggleClass('NB-story-shared', this.model.get('shared'));
|
||||||
this.model.story_view.render_comments();
|
this.model.story_view.render_comments();
|
||||||
|
@ -237,9 +239,8 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({
|
||||||
post_share_error: function(data, shared) {
|
post_share_error: function(data, shared) {
|
||||||
var $share_button = this.$('.NB-sideoption-share-save');
|
var $share_button = this.$('.NB-sideoption-share-save');
|
||||||
var $unshare_button = this.$('.NB-sideoption-share-unshare');
|
var $unshare_button = this.$('.NB-sideoption-share-unshare');
|
||||||
var $share_button_menu = $('.NB-menu-manage-story-share-save');
|
var $share_button_menu = $('.NB-menu-manage .NB-menu-manage-story-share-save');
|
||||||
var message = data && data.message || ("Sorry, this story could not be " + (shared ? "" : "un") + "shared. Probably a bug.");
|
var message = data && data.message || ("Sorry, this story could not be " + (shared ? "" : "un") + "shared. Probably a bug.");
|
||||||
console.log(["post_share_error", data, shared, message]);
|
|
||||||
|
|
||||||
if (!NEWSBLUR.Globals.is_authenticated) {
|
if (!NEWSBLUR.Globals.is_authenticated) {
|
||||||
message = "You need to be logged in to share a story.";
|
message = "You need to be logged in to share a story.";
|
||||||
|
@ -257,6 +258,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({
|
||||||
$share_button_menu.after($error.clone());
|
$share_button_menu.after($error.clone());
|
||||||
}
|
}
|
||||||
this.toggle_feed_story_share_dialog({'resize_open': true});
|
this.toggle_feed_story_share_dialog({'resize_open': true});
|
||||||
|
console.log(["post_share_error", data, shared, message, $share_button, $unshare_button, $share_button_menu, $error]);
|
||||||
},
|
},
|
||||||
|
|
||||||
update_share_button_label: function() {
|
update_share_button_label: function() {
|
||||||
|
|
|
@ -149,9 +149,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="NB-story-comments-container">
|
||||||
{% if story.share_count %}
|
{% if story.share_count %}
|
||||||
{% render_story_share story %}
|
{% render_story_share story %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
{% load social_tags %}
|
{% load social_tags %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if story.share_count %}
|
||||||
<div class="NB-story-comments">
|
<div class="NB-story-comments">
|
||||||
{% if story.share_count %}
|
<div class="NB-story-comments-shares-teaser-wrapper">
|
||||||
<div class="NB-story-comments-shares-teaser-wrapper">
|
<div class="NB-story-comments-shares-teaser">
|
||||||
<div class="NB-story-comments-shares-teaser">
|
{% if story.share_count %}
|
||||||
{% if story.share_count %}
|
<div class="NB-right">
|
||||||
<div class="NB-right">
|
Shared by
|
||||||
Shared by
|
<b>{{ story.share_count }}</b>
|
||||||
<b>{{ story.share_count }}</b>
|
{{ story.share_count|pluralize:"person, people" }}
|
||||||
{{ story.share_count|pluralize:"person, people" }}
|
</div>
|
||||||
|
{% if story.share_count_public %}
|
||||||
|
<div class="NB-story-share-profiles NB-story-share-profiles-public">
|
||||||
|
{% for share_user in story.shared_by_public %}
|
||||||
|
<a href="{{ share_user.feed_link }}" class="NB-user-avatar" title="{{ share_user.username }}">
|
||||||
|
<img src="{{ share_user.photo_url }}">
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% if story.share_count_public %}
|
|
||||||
<div class="NB-story-share-profiles NB-story-share-profiles-public">
|
|
||||||
{% for share_user in story.shared_by_public %}
|
|
||||||
<a href="{{ share_user.feed_link }}" class="NB-user-avatar" title="{{ share_user.username }}">
|
|
||||||
<img src="{{ share_user.photo_url }}">
|
|
||||||
</a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if story.share_count %}
|
{% endif %}
|
||||||
{% if story.share_count_friends %}
|
{% if story.share_count %}
|
||||||
<div class="NB-story-share-label">Shared by: </div>
|
{% if story.share_count_friends %}
|
||||||
<div class="NB-story-share-profiles NB-story-share-profiles-friends">
|
<div class="NB-story-share-label">Shared by: </div>
|
||||||
{% for share_user in story.shared_by_friends %}
|
<div class="NB-story-share-profiles NB-story-share-profiles-friends">
|
||||||
<a href="{{ share_user.feed_link }}" class="NB-user-avatar" title="{{ share_user.username }}">
|
{% for share_user in story.shared_by_friends %}
|
||||||
<img src="{{ share_user.photo_url }}">
|
<a href="{{ share_user.feed_link }}" class="NB-user-avatar" title="{{ share_user.username }}">
|
||||||
</a>
|
<img src="{{ share_user.photo_url }}">
|
||||||
{% endfor %}
|
</a>
|
||||||
</div>
|
{% endfor %}
|
||||||
{% endif %}
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% render_story_comments story %}
|
|
||||||
|
{% render_story_comments story %}
|
||||||
{% if story.comment_count_public %}
|
|
||||||
<div class="NB-story-comments-public-teaser-wrapper">
|
{% if story.comment_count_public %}
|
||||||
<div class="NB-story-comments-public-teaser">
|
<div class="NB-story-comments-public-teaser-wrapper">
|
||||||
There {{ story.comment_count_public|pluralize:"is,are" }} {{ story.comment_count_public}} public comment{{ story.comment_count_public|pluralize }}
|
<div class="NB-story-comments-public-teaser">
|
||||||
</div>
|
There {{ story.comment_count_public|pluralize:"is,are" }} {{ story.comment_count_public}} public comment{{ story.comment_count_public|pluralize }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue