Switching between shared and unshared states.

This commit is contained in:
Samuel Clay 2011-12-14 09:51:47 -08:00
parent 76feb2ff13
commit e6a20e41fc
3 changed files with 45 additions and 6 deletions

View file

@ -1989,7 +1989,9 @@ background: transparent;
#story_pane .NB-sideoption:hover .NB-sideoption-icon,
#story_pane .NB-sideoption:hover .NB-sideoption-title,
#story_pane .NB-sideoption.NB-active .NB-sideoption-icon,
#story_pane .NB-sideoption.NB-active .NB-sideoption-title {
#story_pane .NB-sideoption.NB-active .NB-sideoption-title,
#story_pane .NB-sideoption.NB-shared .NB-sideoption-icon,
#story_pane .NB-sideoption.NB-shared .NB-sideoption-title {
background-color: #2B478C;
color: #D7DDF7;
opacity: 1;
@ -2034,6 +2036,9 @@ background: transparent;
box-shadow:2px 2px 0 #95AB76;
text-shadow: 0 1px 0 #101010;
}
#story_pane .NB-sideoption-share .NB-sideoption-share-save.NB-saving {
background-color: #b5b4bB;
}
#story_pane .NB-feed-story-endbar {
height: 8px;

View file

@ -193,6 +193,14 @@ NEWSBLUR.AssetModel.Reader.prototype = {
}, callback);
},
save_shared_story: function(story_id, feed_id, comments, callback, error_callback) {
this.make_request('/social/save_shared_story', {
story_id: story_id,
feed_id: feed_id,
comments: comments
}, callback, error_callback);
},
load_feeds: function(callback, error_callback) {
var self = this;

View file

@ -2752,6 +2752,21 @@
});
},
save_shared_story: function($story) {
var story_id = $story.data('story_id');
var feed_id = $story.data('feed_id');
var comments = $('.NB-sideoption-share-comments', $story).val();
var $share_button = $('.NB-sideoption-share-save', $story);
var $share_sideoption = $('.NB-feed-story-share .NB-sideoption-title', $story);
$share_button.addClass('NB-saving').text('Sharing...');
this.model.save_shared_story(story_id, feed_id, comments, _.bind(function() {
this.open_feed_story_share(story_id, feed_id);
$share_button.removeClass('NB-saving').text('Share');
$share_sideoption.text('Shared').closest('.NB-sideoption').addClass('NB-shared');
}, this));
},
send_story_to_instapaper: function(story_id) {
var story = this.model.get_story(story_id);
var url = 'http://www.instapaper.com/edit';
@ -3605,10 +3620,16 @@
$.make('div', { className: 'NB-sideoption-icon'}, ' '),
$.make('div', { className: 'NB-sideoption-title'}, 'Train this story')
]),
$.make('div', { className: 'NB-sideoption NB-feed-story-save' }, [
$.make('div', { className: 'NB-sideoption-icon'}, ' '),
$.make('div', { className: 'NB-sideoption-title'}, 'Save this story')
]),
(story.starred_date &&
$.make('div', { className: 'NB-sideoption NB-feed-story-save NB-active' }, [
$.make('div', { className: 'NB-sideoption-icon'}, ' '),
$.make('div', { className: 'NB-sideoption-title'}, 'Saved')
])),
(!story.starred_date &&
$.make('div', { className: 'NB-sideoption NB-feed-story-save' }, [
$.make('div', { className: 'NB-sideoption-icon'}, ' '),
$.make('div', { className: 'NB-sideoption-title'}, 'Save this story')
])),
$.make('div', { className: 'NB-sideoption NB-feed-story-share' }, [
$.make('div', { className: 'NB-sideoption-icon'}, ' '),
$.make('div', { className: 'NB-sideoption-title'}, 'Share this story')
@ -3618,7 +3639,7 @@
$.make('div', { className: 'NB-sideoption-share-optional' }, 'Optional'),
$.make('div', { className: 'NB-sideoption-share-title' }, 'Comments:'),
$.make('textarea', { className: 'NB-sideoption-share-comments' }),
$.make('div', { className: 'NB-sideoption-share-save NB-modal-submit-green NB-modal-submit-button' }, 'Share')
$.make('div', { className: 'NB-sideoption-share-save NB-modal-submit-button' }, 'Share')
])
])
])
@ -6026,6 +6047,11 @@
}
story_prevent_bubbling = true;
});
$.targetIs(e, { tagSelector: '.NB-sideoption-share-save' }, function($t, $p){
e.preventDefault();
var $story = $t.closest('.NB-feed-story');
self.save_shared_story($story);
});
$.targetIs(e, { tagSelector: '.NB-feed-story-hide-changes' }, function($t, $p){
e.preventDefault();
var $story = $t.closest('.NB-feed-story');