Merge branch 'master' into social

* master:
  New preference: delay to mark a story as read.
  Closing #52: Adding delicious to sharing services and preferences. Thanks @palewire for the suggestion.

Conflicts:
	media/css/reader.css
	media/js/newsblur/reader/reader.js
	media/js/newsblur/reader/reader_keyboard.js
This commit is contained in:
Samuel Clay 2012-05-07 15:23:56 -07:00
commit c6dda3744d
6 changed files with 176 additions and 51 deletions

View file

@ -4978,6 +4978,9 @@ background: transparent;
.NB-menu-manage .NB-menu-manage-story-thirdparty .NB-menu-manage-thirdparty-tumblr {
background: transparent url('/media/embed/reader/tumblr.png') no-repeat 0 0;
}
.NB-menu-manage .NB-menu-manage-story-thirdparty .NB-menu-manage-thirdparty-delicious {
background: transparent url('/media/embed/reader/delicious.png') no-repeat 0 0;
}
.NB-menu-manage .NB-menu-manage-story-thirdparty .NB-menu-manage-thirdparty-pinboard {
background: transparent url('/media/embed/reader/pinboard.png') no-repeat 0 0;
}
@ -5025,6 +5028,13 @@ background: transparent;
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-tumblr .NB-menu-manage-thirdparty-tumblr {
opacity: 1;
}
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-delicious .NB-menu-manage-image,
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-delicious .NB-menu-manage-thirdparty-icon {
opacity: .2;
}
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-delicious .NB-menu-manage-thirdparty-delicious {
opacity: 1;
}
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-pinboard .NB-menu-manage-image,
.NB-menu-manage .NB-menu-manage-story-thirdparty.NB-menu-manage-highlight-pinboard .NB-menu-manage-thirdparty-icon {
opacity: .2;
@ -6582,7 +6592,7 @@ background: transparent;
margin-right: 0;
}
.NB-modal-keyboard .NB-keyboard-shortcut .NB-keyboard-shortcut-key {
.NB-keyboard-shortcut-key {
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
@ -6599,12 +6609,12 @@ background: transparent;
margin: 0 4px 0 0;
}
.NB-modal-keyboard .NB-keyboard-shortcut .NB-keyboard-shortcut-key span {
.NB-keyboard-shortcut-key span {
color: #A0A0A0;
padding: 0 4px;
}
.NB-modal-keyboard .NB-keyboard-shortcut .NB-keyboard-shortcut-explanation {
.NB-keyboard-shortcut-explanation {
float: right;
font-size: 14px;
font-weight: bold;
@ -6613,11 +6623,11 @@ background: transparent;
color: #404030;
text-shadow: 1px 1px 0 #E0E0E0;
}
.NB-modal-keyboard .NB-keyboard-shortcut .NB-keyboard-shortcut-image {
.NB-keyboard-shortcut-image {
clear: both;
}
.NB-modal-keyboard .NB-keyboard-shortcut .NB-keyboard-shortcut-image img {
.NB-keyboard-shortcut-image img {
margin: 8px 0 0 0;
border: 1px solid #202020;
width: 268px;
@ -6763,6 +6773,12 @@ background: transparent;
-webkit-box-shadow:2px 2px 0 #D0D0D0;
box-shadow:2px 2px 0 #D0D0D0;
}
.NB-modal-preferences .NB-preference-readstorydelay .NB-tangle-readstorydelay {
display: inline-block;
margin: 0 16px 0 8px;
top: 2px;
width: 100px;
}
.NB-modal-preferences .NB-preference.NB-preference-story-share .NB-preference-option {
float: left;
margin: 0 8px 4px 0;
@ -6787,6 +6803,9 @@ background: transparent;
.NB-modal-preferences .NB-preference-story-share label[for=NB-preference-story-share-tumblr] {
background: transparent url('/media/embed/reader/tumblr.png') no-repeat 0 0;
}
.NB-modal-preferences .NB-preference-story-share label[for=NB-preference-story-share-delicious] {
background: transparent url('/media/embed/reader/delicious.png') no-repeat 0 0;
}
.NB-modal-preferences .NB-preference-story-share label[for=NB-preference-story-share-pinboard] {
background: transparent url('/media/embed/reader/pinboard.png') no-repeat 0 0;
}
@ -7095,6 +7114,7 @@ background: transparent;
white-space: nowrap;
/* border-bottom: 1px solid #F6F6f6;*/
}
<<<<<<< HEAD
.NB-static-api table td:last-child {
border-right: none;
}
@ -7345,6 +7365,7 @@ background: transparent;
margin-bottom: 54px;
}
}
<<<<<<< HEAD
/* ================= */
/* = Friends Modal = */

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -1021,15 +1021,14 @@
this.active_story = story;
this.mark_story_title_as_selected($next_story_title);
this.mark_story_as_read(story.id);
this.mark_story_as_read_in_feed_view(story, {'animate': this.story_view == 'feed'});
}
}
},
mark_story_as_read_in_feed_view: function(story, options) {
if (!story) return;
mark_story_as_read_in_feed_view: function(story_id, options) {
if (!story_id) return;
options = options || {};
$story = this.cache.feed_view_stories[story.id] || this.find_story_in_feed_view(story.id);
$story = this.cache.feed_view_stories[story_id] || this.find_story_in_feed_view(story_id);
if ($story) {
$story.addClass('read');
}
@ -1838,6 +1837,7 @@
'feed_title_floater_feed_id': null,
'feed_title_floater_story_id': null,
'last_feed_view_story_feed_id': null,
'last_read_story_id': null,
'$feed_in_feed_list': {},
'$feed_counts_in_feed_list': {},
'$feed_in_social_feed_list': {}
@ -2498,7 +2498,6 @@
if (this.active_story != story || options.story_id) {
this.active_story = story;
this.mark_story_title_as_selected($story_title);
this.mark_story_as_read_in_feed_view(story, {'animate': true});
this.unload_story_iframe();
// Used when auto-tracking the user as they move over the feed/page.
@ -2785,11 +2784,24 @@
// $story_title.parent('.story').next('.story').children('a').addClass('after_selected');
},
mark_story_as_read: function(story_id) {
mark_story_as_read: function(story_id, skip_delay) {
var self = this;
var delay = this.model.preference('read_story_delay');
if (skip_delay) {
delay = 0;
} else if (delay == -1) {
return;
}
this.cache.last_read_story_id = story_id;
clearTimeout(this.cache.read_story_delay);
this.cache.read_story_delay = _.delay(_.bind(function() {
if (skip_delay || this.cache.last_read_story_id == story_id || delay == 0) {
var $story_title = this.find_story_in_story_titles(story_id);
var story = this.model.get_story(story_id);
var feed_id = story.story_feed_id;
var mark_read_fn = this.model.mark_story_as_read;
if (NEWSBLUR.utils.is_feed_social(this.active_feed)) {
mark_read_fn = this.model.mark_social_story_as_read;
@ -2798,6 +2810,9 @@
mark_read_fn.call(this.model, story_id, feed_id, function(read) {
self.update_read_count(story_id, feed_id, false, read);
});
this.mark_story_as_read_in_feed_view(story_id, {'animate': this.story_view == 'feed'});
}
}, this), delay * 1000);
},
mark_story_as_unread: function(story_id, feed_id) {
@ -2928,7 +2943,7 @@
if (_.string.include(this.active_feed, folder_name)) {
$('.story:not(.read)', this.$s.$story_titles).addClass('read');
_.each(this.model.stories, _.bind(function(story) {
this.mark_story_as_read_in_feed_view(story);
this.mark_story_as_read_in_feed_view(story.id);
}, this));
}
},
@ -3289,6 +3304,20 @@
this.mark_story_as_read(story_id);
},
send_story_to_delicious: function(story_id) {
var story = this.model.get_story(story_id);
var url = 'http://www.delicious.com/save';
var delicious_url = [
url,
'?v=6&url=',
encodeURIComponent(story.story_permalink),
'&title=',
encodeURIComponent(story.story_title)
].join('');
window.open(delicious_url, '_blank');
this.mark_story_as_read(story_id);
},
send_story_to_readability: function(story_id) {
var story = this.model.get_story(story_id);
var url = 'http://www.readability.com/save';
@ -5359,6 +5388,11 @@
}, this)).bind('mouseleave', _.bind(function(e) {
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-tumblr');
}, this))),
(NEWSBLUR.Preferences['story_share_delicious'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-delicious'}).bind('mouseenter', _.bind(function(e) {
$(e.target).siblings('.NB-menu-manage-title').text('Delicious').parent().addClass('NB-menu-manage-highlight-delicious');
}, this)).bind('mouseleave', _.bind(function(e) {
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-delicious');
}, this))),
(NEWSBLUR.Preferences['story_share_pinboard'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-pinboard'}).bind('mouseenter', _.bind(function(e) {
$(e.target).siblings('.NB-menu-manage-title').text('Pinboard').parent().addClass('NB-menu-manage-highlight-pinboard');
}, this)).bind('mouseleave', _.bind(function(e) {
@ -5393,6 +5427,8 @@
this.send_story_to_readitlater(story.id);
} else if ($target.hasClass('NB-menu-manage-thirdparty-tumblr')) {
this.send_story_to_tumblr(story.id);
} else if ($target.hasClass('NB-menu-manage-thirdparty-delicious')) {
this.send_story_to_delicious(story.id);
} else if ($target.hasClass('NB-menu-manage-thirdparty-readability')) {
this.send_story_to_readability(story.id);
} else if ($target.hasClass('NB-menu-manage-thirdparty-pinboard')) {
@ -7485,7 +7521,7 @@
$.targetIs(e, { tagSelector: 'a.mark_story_as_read' }, function($t, $p){
e.preventDefault();
var story_id = $t.attr('href').slice(1).split('/');
self.mark_story_as_read(story_id);
self.mark_story_as_read(story_id, true);
});
$.targetIs(e, { tagSelector: '.NB-feed-story-premium-only a' }, function($t, $p){
e.preventDefault();
@ -8439,7 +8475,7 @@
e.preventDefault();
self.page_in_story(0.65, -1);
});
$document.bind('keydown', 'u', function(e) {
$document.bind('keydown', 'shift+u', function(e) {
e.preventDefault();
if (self.flags['sidebar_closed']) {
self.open_sidebar();
@ -8511,11 +8547,11 @@
e.preventDefault();
self.open_river_stories();
});
$document.bind('keydown', 'shift+u', function(e) {
$document.bind('keydown', 'u', function(e) {
e.preventDefault();
var story_id = self.active_story.id;
if (self.active_story && !self.active_story.read_status) {
self.mark_story_as_read(story_id);
self.mark_story_as_read(story_id, true);
} else if (self.active_story && self.active_story.read_status) {
self.mark_story_as_unread(story_id);
}

View file

@ -120,12 +120,14 @@ NEWSBLUR.ReaderKeyboard.prototype = {
'n'
])
]),
$.make('div', { className: 'NB-keyboard-shortcut NB-last' }, [
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Hide Sidebar'),
$.make('div', { className: 'NB-keyboard-group' }, [
$.make('div', { className: 'NB-keyboard-shortcut' }, [
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Toggle read/unread'),
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
'u'
])
])
])
]),
$.make('div', { className: 'NB-keyboard-group' }, [
$.make('div', { className: 'NB-keyboard-shortcut' }, [
@ -224,7 +226,7 @@ NEWSBLUR.ReaderKeyboard.prototype = {
]),
$.make('div', { className: 'NB-keyboard-group' }, [
$.make('div', { className: 'NB-keyboard-shortcut' }, [
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Toggle read/unread'),
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Hide Sidebar'),
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
'shift',
$.make('span', '+'),

View file

@ -313,6 +313,37 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
'When opening a site'
])
]),
$.make('div', { className: 'NB-preference NB-preference-readstorydelay' }, [
$.make('div', { className: 'NB-preference-options' }, [
$.make('div', [
$.make('input', { id: 'NB-preference-readstorydelay-1', type: 'radio', name: 'read_story_delay', value: '0' }),
$.make('label', { 'for': 'NB-preference-readstorydelay-1' }, [
'Immediately'
])
]),
$.make('div', [
$.make('input', { id: 'NB-preference-readstorydelay-2', type: 'radio', name: 'read_story_delay', value: '1' }),
$.make('label', { 'for': 'NB-preference-readstorydelay-2' }, [
'After ',
$.make('span', { className: 'NB-tangle-readstorydelay', 'data-var': 'delay' }),
$.make('span', { className: 'NB-tangle-seconds' }, ' second.')
])
]),
$.make('div', [
$.make('input', { id: 'NB-preference-readstorydelay-0', type: 'radio', name: 'read_story_delay', value: "-1" }),
$.make('label', { 'for': 'NB-preference-readstorydelay-0' }, [
'Manually by hitting ',
$.make('div', { className: 'NB-keyboard-shortcut-key',
style: 'display: inline; float: none' }, [
'u'
])
])
])
]),
$.make('div', { className: 'NB-preference-label'}, [
'Mark a story as read'
])
]),
$.make('div', { className: 'NB-preference NB-preference-hidestorychanges' }, [
$.make('div', { className: 'NB-preference-options' }, [
$.make('div', [
@ -473,6 +504,10 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
$.make('div', { className: 'NB-preference-option', title: 'Tumblr' }, [
$.make('input', { type: 'checkbox', id: 'NB-preference-story-share-tumblr', name: 'story_share_tumblr' }),
$.make('label', { 'for': 'NB-preference-story-share-tumblr' })
]),
$.make('div', { className: 'NB-preference-option', title: 'Delicious' }, [
$.make('input', { type: 'checkbox', id: 'NB-preference-story-share-delicious', name: 'story_share_delicious' }),
$.make('label', { 'for': 'NB-preference-story-share-delicious' })
])
]),
$.make('div', { className: 'NB-preference-label'}, [
@ -515,8 +550,10 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
},
select_preferences: function() {
var $modal = this.$modal;
if (NEWSBLUR.Preferences.timezone) {
$('select[name=timezone] option', this.$modal).each(function() {
$('select[name=timezone] option', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.timezone) {
$(this).attr('selected', true);
return false;
@ -524,85 +561,91 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
});
}
$('input[name=default_view]', this.$modal).each(function() {
$('input[name=default_view]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.default_view) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=story_pane_anchor]', this.$modal).each(function() {
$('input[name=story_pane_anchor]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.story_pane_anchor) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=new_window]', this.$modal).each(function() {
$('input[name=new_window]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.new_window) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=hide_read_feeds]', this.$modal).each(function() {
$('input[name=hide_read_feeds]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.hide_read_feeds) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=feed_order]', this.$modal).each(function() {
$('input[name=feed_order]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.feed_order) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=ssl]', this.$modal).each(function() {
$('input[name=ssl]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.ssl) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=show_unread_counts_in_title]', this.$modal).each(function() {
$('input[name=show_unread_counts_in_title]', $modal).each(function() {
if (NEWSBLUR.Preferences.show_unread_counts_in_title) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=open_feed_action]', this.$modal).each(function() {
$('input[name=open_feed_action]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.open_feed_action) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=hide_story_changes]', this.$modal).each(function() {
$('input[name=read_story_delay]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.read_story_delay) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=hide_story_changes]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.hide_story_changes) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=feed_view_single_story]', this.$modal).each(function() {
$('input[name=feed_view_single_story]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.feed_view_single_story) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=animations]', this.$modal).each(function() {
$('input[name=animations]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.animations) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=folder_counts]', this.$modal).each(function() {
$('input[name=folder_counts]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.folder_counts) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=show_tooltips]', this.$modal).each(function() {
$('input[name=show_tooltips]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.show_tooltips) {
$(this).attr('checked', true);
return false;
}
});
$('input[name=story_styling]', this.$modal).each(function() {
$('input[name=story_styling]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.story_styling) {
$(this).attr('checked', true);
return false;
@ -612,10 +655,32 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
var share_preferences = _.select(_.keys(NEWSBLUR.Preferences), function(p) {
return p.indexOf('story_share') != -1;
});
_.each(share_preferences, _.bind(function(share) {
_.each(share_preferences, function(share) {
var share_name = share.match(/story_share_(.*)/)[1];
$('input#NB-preference-story-share-'+share_name, this.$modal).attr('checked', NEWSBLUR.Preferences[share]);
}, this));
$('input#NB-preference-story-share-'+share_name, $modal).attr('checked', NEWSBLUR.Preferences[share]);
});
$(".NB-tangle-readstorydelay", $modal).slider({
range: 'min',
min: 1,
max: 60,
step: 1,
value: NEWSBLUR.Preferences.read_story_delay > 0 ? NEWSBLUR.Preferences.read_story_delay : 1,
slide: _.bind(this.slide_read_story_delay_slider, this)
});
this.slide_read_story_delay_slider();
},
slide_read_story_delay_slider: function(e, ui) {
var value = (ui && ui.value) ||
(NEWSBLUR.Preferences.read_story_delay > 0 ? NEWSBLUR.Preferences.read_story_delay : 1);
$(".NB-tangle-seconds", this.$modal).text(value == 1 ? value + ' second.' : value + ' seconds.');
if (NEWSBLUR.Preferences.read_story_delay > 0 || ui) {
$("#NB-preference-readstorydelay-2", this.$modal).attr('checked', true).val(value);
if (ui) {
this.enable_save();
}
}
},
serialize_preferences: function() {

View file

@ -44,6 +44,7 @@
'feed_order' : 'ALPHABETICAL',
'ssl' : 0,
'open_feed_action' : 0,
'read_story_delay' : 0,
'hide_story_changes' : 1,
'feed_view_single_story' : 0,
'animations' : true,