2024-04-30 18:18:14 -04:00
( function ( $ ) {
2012-02-14 10:34:10 -08:00
2012-05-17 18:40:46 -07:00
NEWSBLUR . Reader = Backbone . Router . extend ( {
2024-04-30 18:18:14 -04:00
init : function ( options ) {
2012-09-12 12:12:58 -07:00
var defaults = { } ;
2021-01-12 20:15:42 -05:00
// if (console && console.clear && _.isFunction(console.clear)) console.clear();
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
// ===========
// = Globals =
// ===========
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
NEWSBLUR . assets = new NEWSBLUR . AssetModel ( ) ;
this . model = NEWSBLUR . assets ;
this . story _view = 'page' ;
2015-02-06 13:28:55 -08:00
this . story _layout = 'split' ;
2012-09-12 12:12:58 -07:00
this . options = _ . extend ( { } , defaults , options ) ;
2012-05-17 18:40:46 -07:00
this . $s = {
2012-09-17 12:29:46 -07:00
$body : $ ( 'body' ) ,
2012-09-17 11:52:11 -07:00
$layout : $ ( '.NB-layout' ) ,
2012-10-01 13:07:45 -07:00
$sidebar : $ ( '.NB-sidebar' ) ,
2012-05-17 18:40:46 -07:00
$feed _lists : $ ( '.NB-feedlists' ) ,
$feed _list : $ ( '#feed_list' ) ,
2012-10-03 16:20:56 -07:00
$social _feeds : $ ( '.NB-socialfeeds-folder' ) ,
2013-08-16 16:02:45 -07:00
$starred _feeds : $ ( '.NB-starred-folder' ) ,
2016-02-27 15:51:42 -08:00
$searches _feeds : $ ( '.NB-searches-folder' ) ,
2012-05-17 18:40:46 -07:00
$story _titles : $ ( '#story_titles' ) ,
2013-09-12 21:26:09 -07:00
$story _titles _header : $ ( '.NB-story-titles-header' ) ,
2012-05-17 18:40:46 -07:00
$content _pane : $ ( '.content-pane' ) ,
$story _taskbar : $ ( '#story_taskbar' ) ,
$story _pane : $ ( '#story_pane .NB-story-pane-container' ) ,
$feed _view : $ ( '.NB-feed-story-view' ) ,
2013-07-08 17:06:01 -07:00
$feed _scroll : $ ( '.NB-feed-stories-container' ) ,
2012-05-17 18:40:46 -07:00
$feed _stories : $ ( '.NB-feed-stories' ) ,
$feed _iframe : $ ( '.NB-feed-iframe' ) ,
2013-07-04 01:10:38 -07:00
$story _view : $ ( '.NB-story-view' ) ,
2012-05-17 18:40:46 -07:00
$story _iframe : $ ( '.NB-story-iframe' ) ,
2013-01-08 18:33:30 -08:00
$text _view : $ ( '.NB-text-view' ) ,
2012-05-17 18:40:46 -07:00
$intelligence _slider : $ ( '.NB-intelligence-slider' ) ,
$mouse _indicator : $ ( '#mouse-indicator' ) ,
2021-02-03 18:52:39 -05:00
$feed _link _loader : $ ( '.NB-feeds-list-loader' ) ,
$feed _link _error : $ ( '.NB-feeds-list-error' ) ,
2012-05-17 18:40:46 -07:00
$feeds _progress : $ ( '#NB-progress' ) ,
$dashboard : $ ( '.NB-feeds-header-dashboard' ) ,
2022-05-04 11:27:32 -04:00
$header _dashboard : $ ( '.NB-feeds-header-river-dashboard' ) ,
2012-08-07 14:37:07 -07:00
$river _sites _header : $ ( '.NB-feeds-header-river-sites' ) ,
2017-10-16 14:22:37 -07:00
$river _infrequent _header : $ ( '.NB-feeds-header-river-infrequent' ) ,
2012-08-07 14:37:07 -07:00
$river _blurblogs _header : $ ( '.NB-feeds-header-river-blurblogs' ) ,
2012-11-30 14:28:55 -08:00
$river _global _header : $ ( '.NB-feeds-header-river-global' ) ,
2012-05-17 18:40:46 -07:00
$starred _header : $ ( '.NB-feeds-header-starred' ) ,
2016-02-27 15:51:42 -08:00
$searches _header : $ ( '.NB-feeds-header-searches' ) ,
2013-12-05 16:08:45 -08:00
$read _header : $ ( '.NB-feeds-header-read' ) ,
2012-05-17 18:40:46 -07:00
$tryfeed _header : $ ( '.NB-feeds-header-tryfeed' ) ,
2013-01-31 18:24:53 -08:00
$taskbar : $ ( '.NB-taskbar-view' ) ,
2013-01-24 18:23:10 -08:00
$feedbar : $ ( '.NB-feedbar' ) ,
2014-04-07 19:52:26 -07:00
$add _button : $ ( '.NB-task-add' ) ,
2017-03-03 15:43:41 -05:00
$taskbar _options : $ ( '.NB-taskbar-options' ) ,
$search _header : $ ( '.NB-search-header' )
2012-05-17 18:40:46 -07:00
} ;
this . flags = {
'bouncing_callout' : false ,
'has_unfetched_feeds' : false ,
'count_unreads_after_import_working' : false ,
2020-06-10 15:48:40 -04:00
'sidebar_closed' : this . options . hide _sidebar ,
2020-06-10 16:47:46 -04:00
'splash_page_frontmost' : true
2012-05-17 18:40:46 -07:00
} ;
this . locks = { } ;
this . counts = {
'page' : 1 ,
'feature_page' : 0 ,
'unfetched_feeds' : 0 ,
'fetched_feeds' : 0 ,
'recommended_feed_page' : 0 ,
'interactions_page' : 1 ,
2013-03-15 17:05:44 -07:00
'activities_page' : 1 ,
'socket_reconnects' : 0
2012-05-17 18:40:46 -07:00
} ;
this . cache = {
'iframe_story_positions' : { } ,
'feed_view_story_positions' : { } ,
'iframe_story_positions_keys' : [ ] ,
'feed_view_story_positions_keys' : [ ] ,
'river_feeds_with_unreads' : [ ] ,
'$feed_in_social_feed_list' : { }
} ;
2012-05-23 14:11:42 -07:00
this . views = { } ;
2012-05-17 18:40:46 -07:00
this . layout = { } ;
this . constants = {
2024-04-30 18:18:14 -04:00
FEED _REFRESH _INTERVAL : ( 1000 * 60 ) * 1 , // 1 minute
FILL _OUT _PAGES : 100 ,
FIND _NEXT _UNREAD _STORY _TRIES : 100 ,
RIVER _STORIES _FOR _STANDARD _ACCOUNT : 3 ,
MIN _FEED _LIST _SIZE : 225 ,
MIN _STORY _LIST _SIZE : 68
2012-05-17 18:40:46 -07:00
} ;
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
// ==================
// = Event Handlers =
// ==================
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
$ ( window ) . bind ( 'resize.reader' , _ . throttle ( $ . rescope ( this . resize _window , this ) , 1000 ) ) ;
this . $s . $body . bind ( 'click.reader' , $ . rescope ( this . handle _clicks , this ) ) ;
this . $s . $body . bind ( 'keyup.reader' , $ . rescope ( this . handle _keyup , this ) ) ;
this . handle _keystrokes ( ) ;
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
// ==================
// = Initialization =
// ==================
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
var refresh _page = this . check _and _load _ssl ( ) ;
if ( refresh _page ) return ;
this . load _javascript _elements _on _page ( ) ;
this . apply _resizable _layout ( ) ;
this . add _body _classes ( ) ;
2013-04-22 11:45:06 -07:00
NEWSBLUR . app . sidebar _header = new NEWSBLUR . Views . SidebarHeader ( {
feed _collection : NEWSBLUR . assets . feeds ,
socialfeed _collection : NEWSBLUR . assets . social _feeds
} ) ;
2012-10-01 13:07:45 -07:00
NEWSBLUR . app . sidebar = new NEWSBLUR . Views . Sidebar ( ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . feed _list = new NEWSBLUR . Views . FeedList ( { el : this . $s . $feed _list [ 0 ] } ) ;
2016-11-30 18:53:32 -08:00
NEWSBLUR . app . story _titles = new NEWSBLUR . Views . StoryTitlesView ( {
2016-11-30 20:06:24 -08:00
el : this . $s . $story _titles . find ( '.NB-story-titles' ) ,
2016-11-30 18:53:32 -08:00
collection : NEWSBLUR . assets . stories
} ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . story _list = new NEWSBLUR . Views . StoryListView ( { collection : NEWSBLUR . assets . stories } ) ;
NEWSBLUR . app . original _tab _view = new NEWSBLUR . Views . OriginalTabView ( { collection : NEWSBLUR . assets . stories } ) ;
NEWSBLUR . app . story _tab _view = new NEWSBLUR . Views . StoryTabView ( { collection : NEWSBLUR . assets . stories } ) ;
2013-02-12 13:15:14 -08:00
NEWSBLUR . app . text _tab _view = new NEWSBLUR . Views . TextTabView ( {
el : this . $s . $text _view ,
collection : NEWSBLUR . assets . stories
} ) ;
2012-09-26 13:49:17 -07:00
NEWSBLUR . app . feed _selector = new NEWSBLUR . Views . FeedSelector ( ) ;
2012-10-24 18:52:24 -07:00
NEWSBLUR . app . follow _requests _module = new NEWSBLUR . Views . FollowRequestsModule ( ) ;
2013-02-22 16:02:45 -08:00
NEWSBLUR . app . dashboard _search = new NEWSBLUR . Views . DashboardSearch ( ) ;
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info = new NEWSBLUR . Views . ReaderTaskbarInfo ( ) . render ( ) ;
2013-09-17 12:18:34 -07:00
NEWSBLUR . app . story _titles _header = new NEWSBLUR . Views . StoryTitlesHeader ( ) ;
2017-03-03 15:43:41 -05:00
NEWSBLUR . app . search _header = new NEWSBLUR . Views . FeedSearchHeader ( ) ;
2024-04-30 18:18:14 -04:00
2020-12-10 18:33:43 -05:00
NEWSBLUR . assets . feeds . bind ( 'reset' , _ . bind ( function ( ) {
this . load _dashboard _rivers ( ) ;
2021-02-03 18:52:39 -05:00
this . load _intelligence _slider ( ) ;
2020-12-10 18:33:43 -05:00
} , this ) ) ;
2012-05-17 18:40:46 -07:00
this . handle _mouse _indicator _hover ( ) ;
this . handle _login _and _signup _forms ( ) ;
2020-07-27 09:41:28 -04:00
this . handle _wakeup ( ) ;
2012-05-17 18:40:46 -07:00
this . apply _story _styling ( ) ;
2022-05-20 10:51:17 -04:00
// this.load_recommended_feeds();
2012-05-17 18:40:46 -07:00
this . setup _dashboard _graphs ( ) ;
this . setup _feedback _table ( ) ;
this . setup _howitworks _hovers ( ) ;
2012-06-19 13:01:30 -07:00
this . setup _unfetched _feed _check ( ) ;
2013-02-11 12:35:42 -08:00
this . switch _story _layout ( ) ;
2014-04-10 11:07:02 -07:00
this . load _delayed _stylesheets ( ) ;
2020-06-11 19:25:03 -04:00
this . load _theme ( ) ;
2012-05-17 18:40:46 -07:00
} ,
2010-06-08 11:19:41 -04:00
// ========
// = Page =
// ========
2024-04-30 18:18:14 -04:00
logout : function ( ) {
2016-02-27 16:02:58 -08:00
console . log ( [ 'Logout' ] ) ;
2013-02-01 12:05:45 -08:00
window . location . href = "/reader/logout" ;
} ,
2024-04-30 18:18:14 -04:00
check _and _load _ssl : function ( ) {
2012-02-29 17:18:55 -08:00
if ( window . location . protocol == 'http:' && this . model . preference ( 'ssl' ) ) {
window . location . href = window . location . href . replace ( 'http:' , 'https:' ) ;
return true ;
}
} ,
2024-04-30 18:18:14 -04:00
load _javascript _elements _on _page : function ( ) {
$ ( '.NB-javascript' ) . removeClass ( 'NB-javascript' ) ;
2011-03-04 12:27:31 -05:00
} ,
2024-04-30 18:18:14 -04:00
resize _window : function ( ) {
2011-02-22 19:11:29 -05:00
var flag ;
var view = this . story _view ;
2024-04-30 18:18:14 -04:00
2011-02-22 19:11:29 -05:00
if ( this . flags [ 'page_view_showing_feed_view' ] ) {
view = 'feed' ;
flag = 'page' ;
} else if ( this . flags [ 'feed_view_showing_story_view' ] ) {
view = 'story' ;
flag = 'story' ;
2013-01-09 11:57:47 -08:00
} else if ( this . flags [ 'temporary_story_view' ] ) {
view = 'text' ;
flag = 'text' ;
2011-02-22 19:11:29 -05:00
}
2024-04-30 18:18:14 -04:00
2011-09-29 22:12:46 -07:00
this . flags . scrolling _by _selecting _story _title = true ;
clearTimeout ( this . locks . scrolling ) ;
2024-04-30 18:18:14 -04:00
this . locks . scrolling = _ . delay ( _ . bind ( function ( ) {
2011-09-29 22:12:46 -07:00
this . flags . scrolling _by _selecting _story _title = false ;
} , this ) , 1000 ) ;
2012-07-02 16:24:41 -07:00
this . position _mouse _indicator ( ) ;
2024-04-30 18:18:14 -04:00
2012-07-23 16:51:27 -07:00
this . switch _taskbar _view ( view , {
skip _save _type : flag ,
resize : true
} ) ;
2013-07-11 15:09:00 -07:00
2022-02-18 17:52:24 -05:00
if ( _ . contains ( [ 'split' , 'list' , 'grid' , 'magazine' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-07-11 15:09:00 -07:00
NEWSBLUR . app . story _titles . fill _out ( ) ;
} else {
NEWSBLUR . app . story _list . fill _out ( ) ;
}
2012-06-18 23:51:03 -07:00
this . flags . fetch _story _locations _in _feed _view = this . flags . fetch _story _locations _in _feed _view ||
2024-04-30 18:18:14 -04:00
_ . throttle ( function ( ) {
NEWSBLUR . app . story _list . reset _story _positions ( ) ;
} , 2000 ) ;
2012-06-18 23:51:03 -07:00
this . flags . fetch _story _locations _in _feed _view ( ) ;
2013-02-11 12:35:42 -08:00
this . adjust _for _narrow _window ( ) ;
} ,
2024-04-30 18:18:14 -04:00
adjust _for _narrow _window : function ( ) {
2020-06-10 17:54:24 -04:00
// Check if layout is ready or still being assembled
if ( ! NEWSBLUR . reader . layout . contentLayout ) return ;
2024-04-30 18:18:14 -04:00
2013-07-30 16:12:53 -07:00
var north , center , west ;
2015-02-06 13:28:55 -08:00
var story _layout = NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ;
2013-07-30 17:20:13 -07:00
var content _width ;
2013-07-30 16:33:57 -07:00
var $windows = this . $s . $body . add ( this . $s . $feed _view )
2024-04-30 18:18:14 -04:00
. add ( this . $s . $story _titles )
. add ( this . $s . $text _view ) ;
2013-02-11 13:17:49 -08:00
if ( story _layout == 'split' ) {
2013-02-08 11:26:29 -08:00
north = NEWSBLUR . reader . layout . contentLayout . panes . north ;
center = NEWSBLUR . reader . layout . contentLayout . panes . center ;
2013-07-30 16:12:53 -07:00
west = NEWSBLUR . reader . layout . contentLayout . panes . west ;
2013-07-08 17:06:01 -07:00
} else {
2013-02-08 11:26:29 -08:00
center = NEWSBLUR . reader . layout . rightLayout . panes . center ;
}
2020-06-10 19:24:02 -04:00
2013-07-30 17:20:13 -07:00
if ( center ) {
2015-02-02 18:22:14 -08:00
var center _width = center . width ( ) ;
2021-04-06 19:24:54 -04:00
var narrow = center _width < 980 ;
2014-04-17 10:25:30 -07:00
if ( NEWSBLUR . assets . preference ( 'story_button_placement' ) == "bottom" ) {
narrow = true ;
}
2014-04-01 15:20:21 -07:00
$windows . toggleClass ( 'NB-narrow-content' , narrow ) ;
2016-12-13 12:23:56 -08:00
var extranarrow = center _width < 666 ;
2014-07-31 10:53:17 -07:00
$windows . toggleClass ( 'NB-extra-narrow-content' , extranarrow ) ;
2015-02-02 18:22:14 -08:00
var wide = center _width > 860 ;
$windows . toggleClass ( 'NB-wide-content' , wide ) ;
var extrawide = center _width > 1180 ;
$windows . toggleClass ( 'NB-extra-wide-content' , extrawide ) ;
2014-04-01 15:20:21 -07:00
this . flags . narrow _content = ! ! narrow ;
2015-02-02 18:22:14 -08:00
content _width = center _width + ( west ? west . width ( ) : 0 ) ;
2013-07-30 17:20:13 -07:00
}
2024-04-30 18:18:14 -04:00
2013-07-08 17:06:01 -07:00
if ( ( north && north . width ( ) < 640 ) ||
2013-07-30 17:20:13 -07:00
( content _width && content _width < 780 ) ) {
2013-07-30 16:33:57 -07:00
$windows . addClass ( 'NB-narrow' ) ;
2012-08-14 14:39:28 -07:00
} else {
2013-07-30 16:33:57 -07:00
$windows . removeClass ( 'NB-narrow' ) ;
2012-08-14 14:39:28 -07:00
}
2024-04-30 18:18:14 -04:00
2014-05-28 21:01:37 -07:00
var pane = this . layout . outerLayout . panes . west ;
2014-05-28 21:09:19 -07:00
var width = this . layout . outerLayout . state . west . size ;
2021-04-15 20:00:19 -04:00
pane . toggleClass ( "NB-narrow-pane-blue" , width < 306 ) ;
pane . toggleClass ( "NB-narrow-pane-green" , width < 278 ) ;
pane . toggleClass ( "NB-narrow-pane-yellow" , width < 258 ) ;
2024-04-30 18:18:14 -04:00
2013-03-27 11:53:39 -07:00
this . apply _tipsy _titles ( ) ;
2011-02-22 19:11:29 -05:00
} ,
2024-04-30 18:18:14 -04:00
apply _resizable _layout : function ( options ) {
2015-02-09 17:47:05 -08:00
options = options || { } ;
2011-09-26 10:27:21 -07:00
var story _anchor = this . model . preference ( 'story_pane_anchor' ) ;
2024-04-30 18:18:14 -04:00
2015-02-09 17:47:05 -08:00
if ( options . right _side ) {
2011-09-29 09:53:55 -07:00
this . layout . contentLayout && this . layout . contentLayout . destroy ( ) ;
this . layout . rightLayout && this . layout . rightLayout . destroy ( ) ;
2015-02-09 17:47:05 -08:00
// this.layout.leftCenterLayout && this.layout.leftCenterLayout.destroy();
// this.layout.leftLayout && this.layout.leftLayout.destroy();
// this.layout.outerLayout && this.layout.outerLayout.destroy();
2011-09-29 22:12:46 -07:00
2011-09-29 09:53:55 -07:00
var feed _stories _bin = $ . make ( 'div' ) . append ( this . $s . $feed _stories . children ( ) ) ;
var story _titles _bin = $ . make ( 'div' ) . append ( this . $s . $story _titles . children ( ) ) ;
}
2024-04-30 18:18:14 -04:00
2011-09-29 09:53:55 -07:00
$ ( '.right-pane' ) . removeClass ( 'NB-story-pane-west' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-story-pane-north' )
. removeClass ( 'NB-story-pane-south' )
. removeClass ( 'NB-story-pane-hidden' )
. toggleClass ( 'NB-story-pane-' + story _anchor ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'split' ) ;
2015-02-09 17:47:05 -08:00
if ( ! options . right _side ) {
2024-04-30 18:18:14 -04:00
this . layout . outerLayout = this . $s . $layout . layout ( {
zIndex : 2 ,
fxName : "slideOffscreen" ,
fxSettings : { duration : 560 , easing : "easeInOutQuint" } ,
center _ _paneSelector : ".right-pane" ,
west _ _paneSelector : ".left-pane" ,
west _ _size : this . model . preference ( 'feed_pane_size' ) ,
west _ _minSize : this . constants . MIN _FEED _LIST _SIZE ,
west _ _onresize _end : _ . bind ( this . save _feed _pane _size , this ) ,
west _ _onopen : _ . bind ( this . resize _window , this ) ,
2015-02-09 17:47:05 -08:00
// west__initHidden: this.options.hide_sidebar,
2024-04-30 18:18:14 -04:00
west _ _spacing _open : this . options . hide _sidebar ? 1 : 1 ,
resizerDragOpacity : 0.6 ,
resizeWhileDragging : true ,
enableCursorHotkey : false ,
togglerLength _open : 0
} ) ;
2015-02-09 17:47:05 -08:00
this . layout . leftLayout = $ ( '.left-pane' ) . layout ( {
2024-04-30 18:18:14 -04:00
closable : false ,
resizeWhileDragging : true ,
fxName : "slideOffscreen" ,
fxSettings : { duration : 560 , easing : "easeInOutQuint" } ,
animatePaneSizing : true ,
north _ _paneSelector : ".left-north" ,
north _ _size : 37 ,
north _ _resizeable : false ,
north _ _spacing _open : 0 ,
center _ _paneSelector : ".left-center" ,
center _ _resizable : false ,
south _ _paneSelector : ".left-south" ,
south _ _size : 37 ,
south _ _resizable : false ,
enableCursorHotkey : false ,
togglerLength _open : 0 ,
south _ _spacing _open : 0
2015-02-09 17:47:05 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
2015-02-09 17:47:05 -08:00
this . layout . leftCenterLayout = $ ( '.left-center' ) . layout ( {
2024-04-30 18:18:14 -04:00
closable : false ,
slidable : false ,
resizeWhileDragging : true ,
center _ _paneSelector : ".left-center-content" ,
center _ _resizable : false ,
south _ _paneSelector : ".left-center-footer" ,
south _ _size : 'auto' ,
south _ _resizable : false ,
south _ _slidable : true ,
south _ _spacing _open : 0 ,
south _ _spacing _closed : 0 ,
south _ _closable : true ,
south _ _initClosed : true ,
fxName : "slideOffscreen" ,
fxSettings _close : { duration : 560 , easing : "easeInOutQuint" } ,
fxSettings _open : { duration : 0 } ,
enableCursorHotkey : false ,
togglerLength _open : 0
2015-02-09 17:47:05 -08:00
} ) ;
}
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'split' , 'full' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2024-04-30 18:18:14 -04:00
var rightLayoutOptions = {
resizeWhileDragging : true ,
center _ _paneSelector : ".content-pane" ,
spacing _open : 0 ,
resizerDragOpacity : 0.6 ,
enableCursorHotkey : false ,
togglerLength _open : 0 ,
fxName : "slideOffscreen" ,
fxSettings _close : { duration : 560 , easing : "easeInOutQuint" } ,
fxSettings _open : { duration : 0 , easing : "easeInOutQuint" } ,
north _ _paneSelector : ".content-north" ,
north _ _size : 37 ,
south _ _paneSelector : ".content-south" ,
south _ _size : 37
2013-02-08 11:26:29 -08:00
} ;
2010-06-08 11:19:41 -04:00
2024-04-30 18:18:14 -04:00
this . layout . rightLayout = $ ( '.right-pane' ) . layout ( rightLayoutOptions ) ;
var contentLayoutOptions = {
fxName : "slideOffscreen" ,
fxSettings _close : { duration : 560 , easing : "easeInOutQuint" } ,
fxSettings _open : { duration : 0 , easing : "easeInOutQuint" } ,
resizeWhileDragging : true ,
center _ _paneSelector : ".content-center" ,
spacing _open : story _anchor == 'west' ? 1 : 1 ,
resizerDragOpacity : 0.6 ,
enableCursorHotkey : false ,
togglerLength _open : 0
2013-02-08 11:26:29 -08:00
} ;
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2024-04-30 18:18:14 -04:00
contentLayoutOptions [ story _anchor + '__initHidden' ] = true ;
this . flags [ 'story_titles_closed' ] = true ;
2013-07-08 17:06:01 -07:00
} else {
this . flags [ 'story_titles_closed' ] = false ;
2013-06-17 17:37:38 -07:00
}
2024-04-30 18:18:14 -04:00
contentLayoutOptions [ story _anchor + '__paneSelector' ] = '.right-north' ;
contentLayoutOptions [ story _anchor + '__minSize' ] = this . constants . MIN _STORY _LIST _SIZE ;
contentLayoutOptions [ story _anchor + '__size' ] = this . model . preference ( 'story_titles_pane_size' ) ;
contentLayoutOptions [ story _anchor + '__onresize_end' ] = $ . rescope ( this . save _story _titles _pane _size , this ) ;
contentLayoutOptions [ story _anchor + '__onclose_start' ] = $ . rescope ( this . toggle _story _titles _pane , this ) ;
contentLayoutOptions [ story _anchor + '__onopen_start' ] = $ . rescope ( this . toggle _story _titles _pane , this ) ;
this . layout . contentLayout = this . $s . $content _pane . layout ( contentLayoutOptions ) ;
2022-02-18 17:52:24 -05:00
} else if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
var rightLayoutOptions = {
resizeWhileDragging : true ,
center _ _paneSelector : ".content-pane" ,
spacing _open : 0 ,
resizerDragOpacity : 0.6 ,
enableCursorHotkey : false ,
togglerLength _open : 0 ,
fxName : "slideOffscreen" ,
fxSettings : { duration : 560 , easing : "easeInOutQuint" } ,
north _ _paneSelector : ".content-north" ,
north _ _size : 37 ,
south _ _paneSelector : ".content-south" ,
south _ _size : 37
2013-02-08 11:26:29 -08:00
} ;
2024-04-30 18:18:14 -04:00
this . layout . rightLayout = $ ( '.right-pane' ) . layout ( rightLayoutOptions ) ;
var contentLayoutOptions = {
resizeWhileDragging : true ,
center _ _paneSelector : ".right-north" ,
spacing _open : 0 ,
resizerDragOpacity : 0.6 ,
enableCursorHotkey : false ,
togglerLength _open : 0
2013-02-08 11:26:29 -08:00
} ;
2024-04-30 18:18:14 -04:00
this . layout . contentLayout = this . $s . $content _pane . layout ( contentLayoutOptions ) ;
2013-07-08 17:06:01 -07:00
this . flags [ 'story_titles_closed' ] = false ;
2013-02-08 11:26:29 -08:00
}
2011-09-29 22:12:46 -07:00
2015-02-09 17:47:05 -08:00
if ( options . right _side ) {
2011-09-29 09:53:55 -07:00
this . $s . $feed _stories . append ( feed _stories _bin . children ( ) ) ;
this . $s . $story _titles . append ( story _titles _bin . children ( ) ) ;
this . resize _window ( ) ;
}
2024-04-30 18:18:14 -04:00
2014-05-28 21:01:37 -07:00
this . adjust _for _narrow _window ( ) ;
2021-04-15 19:12:51 -04:00
this . add _drag _handles ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
apply _tipsy _titles : function ( ) {
2013-03-27 11:53:39 -07:00
$ ( '.NB-task-add' ) . tipsy ( 'disable' ) ;
$ ( '.NB-task-manage' ) . tipsy ( 'disable' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-taskbar-button.NB-tipsy' ) . each ( function ( ) {
2013-03-27 11:53:39 -07:00
$ ( this ) . tipsy ( 'disable' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
2011-05-01 20:22:54 -04:00
if ( this . model . preference ( 'show_tooltips' ) ) {
$ ( '.NB-task-add' ) . tipsy ( {
gravity : 'sw' ,
delayIn : 375
2013-04-18 16:32:42 -07:00
} ) . tipsy ( 'enable' ) ;
2011-05-01 20:22:54 -04:00
$ ( '.NB-task-manage' ) . tipsy ( {
gravity : 's' ,
delayIn : 375
2013-04-18 16:32:42 -07:00
} ) . tipsy ( 'enable' ) ;
2016-02-19 07:50:20 -08:00
$ ( '.NB-narrow .NB-taskbar-button.NB-tipsy' ) . tipsy ( {
2013-09-13 23:44:00 -07:00
gravity : 's' ,
delayIn : 175 ,
2013-03-27 11:53:39 -07:00
title : 'tipsy-title'
2024-04-30 18:18:14 -04:00
} ) . each ( function ( ) {
2013-03-27 11:53:39 -07:00
$ ( this ) . tipsy ( 'enable' ) ;
} ) ;
2011-05-01 20:22:54 -04:00
}
2024-04-30 18:18:14 -04:00
2013-04-18 16:32:42 -07:00
$ ( '.NB-module-content-account-realtime' ) . tipsy ( 'disable' ) . tipsy ( {
2012-07-28 16:41:17 -07:00
gravity : 'se' ,
2013-07-02 18:26:57 -07:00
delayIn : 0
2013-04-18 16:32:42 -07:00
} ) . tipsy ( 'enable' ) ;
2011-02-22 19:11:29 -05:00
} ,
2024-04-30 18:18:14 -04:00
save _feed _pane _size : function ( pane , $pane , state , options , name ) {
2021-04-15 19:12:51 -04:00
if ( ! this . layout . outerLayout ) return ;
var feed _pane _size = this . layout . outerLayout . state . west . size ;
2024-04-30 18:18:14 -04:00
2011-05-09 18:30:11 -04:00
$ ( '#NB-splash' ) . css ( 'left' , feed _pane _size ) ;
2014-05-28 21:01:37 -07:00
this . adjust _for _narrow _window ( ) ;
2024-04-30 18:18:14 -04:00
this . flags . set _feed _pane _size = this . flags . set _feed _pane _size || _ . debounce ( _ . bind ( function ( ) {
2011-09-27 22:16:09 -07:00
var feed _pane _size = this . layout . outerLayout . state . west . size ;
2021-04-15 19:12:51 -04:00
// console.log('debounced save_feed_pane_size', this, feed_pane_size);
2011-09-26 10:27:21 -07:00
this . model . preference ( 'feed_pane_size' , feed _pane _size ) ;
this . flags . set _feed _pane _size = null ;
} , this ) , 1000 ) ;
this . flags . set _feed _pane _size ( ) ;
2010-08-13 19:50:56 -04:00
} ,
2024-04-30 18:18:14 -04:00
save _story _titles _pane _size : function ( pane , $pane , state , options , name ) {
2021-04-15 19:12:51 -04:00
if ( ! this . layout . contentLayout ) return ;
2011-09-29 22:12:46 -07:00
this . flags . scrolling _by _selecting _story _title = true ;
clearTimeout ( this . locks . scrolling ) ;
2024-04-30 18:18:14 -04:00
2011-09-27 22:16:09 -07:00
var offset = 0 ;
if ( this . story _view == 'feed' ) {
offset = this . $s . $feed _iframe . width ( ) ;
} else if ( this . story _view == 'story' ) {
offset = 2 * this . $s . $feed _iframe . width ( ) ;
}
this . $s . $story _pane . css ( 'left' , - 1 * offset ) ;
2024-04-30 18:18:14 -04:00
this . flags . set _story _titles _size = this . flags . set _story _titles _size || _ . debounce ( _ . bind ( function ( ) {
2013-03-26 12:18:39 -07:00
var story _titles _size = this . layout . contentLayout . state [ this . model . preference ( 'story_pane_anchor' ) ] . size ;
2011-09-27 22:16:09 -07:00
this . model . preference ( 'story_titles_pane_size' , story _titles _size ) ;
this . flags . set _story _titles _size = null ;
2024-04-30 18:18:14 -04:00
this . locks . scrolling = _ . delay ( _ . bind ( function ( ) {
2011-09-29 22:12:46 -07:00
this . flags . scrolling _by _selecting _story _title = false ;
} , this ) , 100 ) ;
2011-09-27 22:16:09 -07:00
} , this ) , 1000 ) ;
this . flags . set _story _titles _size ( ) ;
2024-04-30 18:18:14 -04:00
this . flags . resize _window = this . flags . resize _window || _ . debounce ( _ . bind ( function ( ) {
2011-09-29 22:12:46 -07:00
this . resize _window ( ) ;
this . flags . resize _window = null ;
} , this ) , 10 ) ;
this . flags . resize _window ( ) ;
2024-04-30 18:18:14 -04:00
2010-08-13 19:50:56 -04:00
} ,
2024-04-30 18:18:14 -04:00
2021-04-15 19:12:51 -04:00
add _drag _handles : function ( ) {
var $resizer = NEWSBLUR . reader . layout . outerLayout . resizers . west ;
2021-04-16 17:37:27 -04:00
if ( $resizer . find ( ".NB-task-drag" ) . length ) return ;
2024-04-30 18:18:14 -04:00
2021-04-15 19:12:51 -04:00
$resizer . append ( $ . make ( 'div' , { className : "NB-task-drag" } , [
$ . make ( 'div' , { className : "NB-task-image" } )
] ) ) . css ( 'overflow' , 'visible' ) ;
} ,
2024-04-30 18:18:14 -04:00
add _body _classes : function ( ) {
this . $s . $body . toggleClass ( 'NB-is-premium' , NEWSBLUR . Globals . is _premium ) ;
this . $s . $body . toggleClass ( 'NB-is-anonymous' , NEWSBLUR . Globals . is _anonymous ) ;
2022-02-17 17:19:26 -05:00
this . $s . $body . toggleClass ( 'NB-is-authenticated' , NEWSBLUR . Globals . is _authenticated ) ;
if ( ! ! this . model . preference ( 'full_width_story' ) ) {
this . model . preference ( 'story_position' , 'stretch' ) ;
this . model . preference ( 'full_width_story' , false ) ; // Turn off to ignore and deprecate
}
2022-05-12 10:04:59 -04:00
var columns ;
switch ( this . model . preference ( 'dashboard_columns' ) ) {
case 1 :
columns = "single" ;
break ;
case 2 :
columns = "double" ;
break ;
case 3 :
columns = "triple" ;
break ;
}
2022-02-17 17:19:26 -05:00
this . $s . $body . removeClass ( 'NB-pref-story-position-stretch' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-pref-story-position-left' )
. removeClass ( 'NB-pref-story-position-center' )
. removeClass ( 'NB-pref-story-position-right' )
. toggleClass ( 'NB-pref-story-position-' + this . model . preference ( 'story_position' ) ) ;
2022-05-12 10:04:59 -04:00
this . $s . $body . removeClass ( 'NB-dashboard-columns-single' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-dashboard-columns-double' )
. removeClass ( 'NB-dashboard-columns-triple' )
. toggleClass ( 'NB-dashboard-columns-' + columns ) ;
2011-01-25 09:17:15 -05:00
} ,
2024-04-30 18:18:14 -04:00
load _delayed _stylesheets : function ( ) {
_ . delay ( function ( ) {
2014-04-10 11:07:02 -07:00
var $stylesheets = $ ( "head link" ) ;
2024-04-30 18:18:14 -04:00
$stylesheets . each ( function ( ) {
2014-04-10 11:07:02 -07:00
var $ss = $ ( this ) ;
if ( ! $ss . attr ( 'delay' ) ) return ;
$ ( "head" ) . append ( $ . make ( 'link' , {
rel : $ss . attr ( 'rel' ) ,
type : $ss . attr ( 'type' ) ,
href : $ss . attr ( 'delay' )
} ) ) ;
} ) ;
} , 500 ) ;
2011-01-25 09:17:15 -05:00
} ,
2024-04-30 18:18:14 -04:00
hide _splash _page : function ( ) {
2010-08-13 19:21:29 -04:00
var self = this ;
2012-03-14 17:48:28 -07:00
var resize = false ;
if ( ! $ ( '.right-pane' ) . is ( ':visible' ) ) {
resize = true ;
}
2013-01-25 10:57:09 -08:00
this . $s . $body . addClass ( 'NB-show-reader' ) ;
2020-06-10 15:48:40 -04:00
this . flags [ 'splash_page_frontmost' ] = false ;
2022-05-04 11:27:32 -04:00
this . $s . $header _dashboard . removeClass ( 'NB-selected' ) ;
2012-03-14 17:48:28 -07:00
if ( resize ) {
2012-09-17 11:52:11 -07:00
this . $s . $layout . layout ( ) . resizeAll ( ) ;
2013-02-11 12:35:42 -08:00
this . adjust _for _narrow _window ( ) ;
2012-03-14 17:48:28 -07:00
}
2024-04-30 18:18:14 -04:00
2013-03-27 11:53:39 -07:00
this . apply _tipsy _titles ( ) ;
2010-06-08 11:19:41 -04:00
if ( NEWSBLUR . Globals . is _anonymous ) {
this . setup _ftux _signup _callout ( ) ;
}
} ,
2024-04-30 18:18:14 -04:00
show _splash _page : function ( skip _router ) {
2010-11-22 10:44:52 -05:00
this . reset _feed ( ) ;
2020-06-10 15:48:40 -04:00
this . open _sidebar ( ) ;
2013-01-25 10:57:09 -08:00
this . $s . $body . removeClass ( 'NB-show-reader' ) ;
2022-05-04 11:27:32 -04:00
this . $s . $header _dashboard . addClass ( 'NB-selected' ) ;
2020-06-10 15:48:40 -04:00
this . flags [ 'splash_page_frontmost' ] = true ;
2024-04-30 18:18:14 -04:00
2012-01-18 17:39:00 -08:00
if ( ! skip _router ) {
2016-11-21 13:02:13 -08:00
NEWSBLUR . log ( [ "Navigating to splash" ] ) ;
2012-01-18 17:39:00 -08:00
NEWSBLUR . router . navigate ( '' ) ;
}
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
animate _progress _bar : function ( $bar , seconds , percentage ) {
2011-01-31 19:51:39 -05:00
var self = this ;
percentage = percentage || 0 ;
2011-01-31 20:50:33 -05:00
seconds = parseFloat ( Math . max ( 1 , parseInt ( seconds , 10 ) ) , 10 ) ;
2022-02-28 11:53:05 -05:00
var time ;
2011-01-31 19:51:39 -05:00
if ( percentage > 90 ) {
2012-08-09 10:34:41 -07:00
time = seconds ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 80 ) {
2012-08-09 10:34:41 -07:00
time = seconds / 8 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 70 ) {
2012-08-09 10:34:41 -07:00
time = seconds / 16 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 60 ) {
2012-08-09 10:34:41 -07:00
time = seconds / 40 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 50 ) {
2012-08-09 10:34:41 -07:00
time = seconds / 80 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 40 ) {
2011-02-01 00:23:44 -05:00
time = seconds / 160 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 30 ) {
2011-02-01 00:23:44 -05:00
time = seconds / 200 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 20 ) {
2011-02-01 00:23:44 -05:00
time = seconds / 300 ;
2011-01-31 19:51:39 -05:00
} else if ( percentage > 10 ) {
2011-02-01 00:23:44 -05:00
time = seconds / 400 ;
2011-01-31 19:51:39 -05:00
} else {
2011-02-01 00:23:44 -05:00
time = seconds / 500 ;
2011-01-31 19:51:39 -05:00
}
2024-04-30 18:18:14 -04:00
2011-01-31 19:51:39 -05:00
if ( percentage <= 100 ) {
2024-04-30 18:18:14 -04:00
this . locks [ 'animate_progress_bar' ] = setTimeout ( function ( ) {
2011-02-01 00:23:44 -05:00
percentage += 1 ;
2024-04-30 18:18:14 -04:00
$bar . progressbar ( { value : percentage } ) ;
2011-02-01 00:23:44 -05:00
self . animate _progress _bar ( $bar , seconds , percentage ) ;
2011-01-31 19:51:39 -05:00
} , time * 1000 ) ;
}
} ,
2024-04-30 18:18:14 -04:00
blur _to _page : function ( options ) {
2012-06-27 11:08:11 -07:00
options = options || { } ;
2024-04-30 18:18:14 -04:00
2012-06-27 11:08:11 -07:00
if ( options . manage _menu ) {
2016-02-03 13:31:55 -08:00
$ ( '.NB-menu-manage-container .NB-menu-manage :focus' ) . blur ( ) ;
2012-06-27 11:08:11 -07:00
} else {
$ ( ':focus' ) . blur ( ) ;
}
2012-04-27 17:44:00 -07:00
} ,
2024-04-30 18:18:14 -04:00
2010-06-08 11:19:41 -04:00
// ==============
// = Navigation =
// ==============
2024-04-30 18:18:14 -04:00
active _story _view : function ( feed _id ) {
2016-12-08 16:32:59 -08:00
feed _id = feed _id || this . active _feed ;
2024-04-30 18:18:14 -04:00
2016-12-08 16:32:59 -08:00
if ( _ . string . startsWith ( feed _id , 'river:' ) ) {
if ( this . active _story && this . active _story . get ( 'story_feed_id' ) ) {
feed _id = this . active _story . get ( 'story_feed_id' ) ;
2024-04-30 18:18:14 -04:00
console . log ( [ 'Hijacking view setting' , feed _id , ' --> ' ,
this . active _story && this . active _story . get ( 'story_feed_id' ) , NEWSBLUR . assets . view _setting ( feed _id , 'view' ) ] ) ;
2016-12-08 16:32:59 -08:00
}
}
2024-04-30 18:18:14 -04:00
2016-12-08 16:32:59 -08:00
return feed _id ;
} ,
2024-04-30 18:18:14 -04:00
show _next _story : function ( direction ) {
2012-06-13 13:47:50 -07:00
var story = NEWSBLUR . assets . stories . get _next _story ( direction , {
score : this . get _unread _view _score ( )
} ) ;
2016-12-01 19:23:38 -08:00
console . log ( [ 'story show_next_story' , story , direction ] ) ;
2012-05-25 20:52:30 -07:00
if ( story ) {
story . set ( 'selected' , true ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' &&
2021-04-29 11:44:12 -04:00
! NEWSBLUR . assets . stories . no _more _stories ) {
2014-04-08 11:54:21 -07:00
var visible = NEWSBLUR . assets . stories . visible ( ) ;
var visible _count = visible . length ;
var visible _index = visible . indexOf ( this . active _story ) ;
2024-04-30 18:18:14 -04:00
2014-04-08 11:54:21 -07:00
if ( visible _index >= visible _count - 3 ) {
this . load _page _of _feed _stories ( ) ;
}
}
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
show _next _unread _story : function ( ) {
2013-07-11 15:09:00 -07:00
var unread _count = this . get _total _unread _count ( ) ;
2014-05-28 19:17:44 -07:00
if ( this . flags [ 'feed_list_showing_starred' ] ) {
this . slide _intelligence _slider ( 0 ) ;
this . flags [ 'feed_list_showing_starred' ] = false ;
this . open _next _unread _story _across _feeds ( ) ;
} else if ( unread _count ) {
2012-06-13 15:54:18 -07:00
var next _story = NEWSBLUR . assets . stories . get _next _unread _story ( ) ;
if ( next _story ) {
2011-04-12 11:02:02 -04:00
this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] = 0 ;
2012-06-13 15:54:18 -07:00
next _story . set ( 'selected' , true ) ;
} else if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] <
2024-04-30 18:18:14 -04:00
this . constants . FIND _NEXT _UNREAD _STORY _TRIES &&
! NEWSBLUR . assets . stories . no _more _stories ) {
2010-06-08 11:19:41 -04:00
// Nothing up, nothing down, but still unread. Load 1 page then find it.
2011-04-12 11:02:02 -04:00
this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] += 1 ;
2010-06-08 11:19:41 -04:00
this . load _page _of _feed _stories ( ) ;
2012-07-31 15:53:16 -07:00
} else if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] >=
2024-04-30 18:18:14 -04:00
this . constants . FIND _NEXT _UNREAD _STORY _TRIES ) {
2012-07-31 15:53:16 -07:00
this . open _next _unread _story _across _feeds ( true ) ;
2010-06-08 11:19:41 -04:00
}
}
} ,
2024-04-30 18:18:14 -04:00
open _next _unread _story _across _feeds : function ( force _next _feed ) {
2013-07-11 15:09:00 -07:00
var unread _count = ! force _next _feed && this . active _feed && this . get _total _unread _count ( ) ;
2014-05-28 19:17:44 -07:00
if ( ! unread _count && ! this . flags [ 'feed_list_showing_starred' ] ) {
2012-08-29 23:16:23 -07:00
if ( this . flags . river _view && ! this . flags . social _view ) {
2012-08-27 18:48:19 -07:00
var $next _folder = this . get _next _unread _folder ( 1 ) ;
var folder = NEWSBLUR . assets . folders . get _view ( $next _folder ) ;
2012-10-25 14:18:25 -07:00
if ( folder != this . active _folder ) {
this . open _river _stories ( $next _folder , folder && folder . model ) ;
}
2011-11-02 08:49:58 -07:00
} else {
// Find next feed with unreads
var $next _feed = this . get _next _unread _feed ( 1 ) ;
2012-07-31 15:53:16 -07:00
if ( ! $next _feed || ! $next _feed . length ) return ;
2012-05-09 16:56:32 -07:00
var next _feed _id = $next _feed . data ( 'id' ) ;
2012-10-25 14:18:25 -07:00
if ( next _feed _id == this . active _feed ) return ;
2024-04-30 18:18:14 -04:00
2012-05-09 16:56:32 -07:00
if ( NEWSBLUR . utils . is _feed _social ( next _feed _id ) ) {
2024-04-30 18:18:14 -04:00
this . open _social _stories ( next _feed _id , { force : true , $feed : $next _feed } ) ;
2012-05-09 16:56:32 -07:00
} else {
next _feed _id = parseInt ( next _feed _id , 10 ) ;
2024-04-30 18:18:14 -04:00
this . open _feed ( next _feed _id , { force : true , $feed : $next _feed } ) ;
2012-05-09 16:56:32 -07:00
}
2011-11-02 08:49:58 -07:00
}
}
2012-03-01 17:08:41 -08:00
2011-04-12 11:02:02 -04:00
this . show _next _unread _story ( ) ;
} ,
2024-04-30 18:18:14 -04:00
show _last _unread _story : function ( ) {
2013-07-11 15:09:00 -07:00
var unread _count = this . get _total _unread _count ( ) ;
2024-04-30 18:18:14 -04:00
2011-11-02 09:43:06 -07:00
if ( unread _count ) {
2012-06-13 17:34:26 -07:00
var last _story = NEWSBLUR . assets . stories . get _last _unread _story ( unread _count ) ;
2024-04-30 18:18:14 -04:00
2012-06-13 17:34:26 -07:00
if ( last _story ) {
2011-11-02 09:43:06 -07:00
this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] = 0 ;
2012-06-13 17:34:26 -07:00
last _story . set ( 'selected' , true ) ;
2024-04-30 18:18:14 -04:00
} else if ( this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] < this . constants . FILL _OUT _PAGES &&
! NEWSBLUR . assets . stories . no _more _stories ) {
2011-11-02 09:43:06 -07:00
// Nothing up, nothing down, but still unread. Load 1 page then find it.
this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] += 1 ;
this . load _page _of _feed _stories ( ) ;
}
}
2011-04-12 11:02:02 -04:00
} ,
2024-04-30 18:18:14 -04:00
select _story _in _feed : function ( options ) {
2016-11-18 17:20:39 -08:00
options = _ . extend ( { } , options ) ;
2012-06-13 15:09:19 -07:00
var story _id = this . flags [ 'select_story_in_feed' ] ;
var story = NEWSBLUR . assets . stories . get ( story _id ) ;
2016-11-16 11:35:02 -08:00
if ( ! story ) story = NEWSBLUR . assets . stories . get _by _story _hash ( story _id ) ;
2012-06-13 15:09:19 -07:00
// NEWSBLUR.log(['select_story_in_feed', story_id, story, this.story_view, this.counts['select_story_in_feed'], this.flags['no_more_stories']]);
2024-04-30 18:18:14 -04:00
2012-06-13 15:09:19 -07:00
if ( story ) {
this . counts [ 'select_story_in_feed' ] = 0 ;
this . flags [ 'select_story_in_feed' ] = null ;
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
story . set ( 'selected' , true , { scroll _to _comments : options . scroll _to _comments } ) ;
2012-06-13 18:06:35 -07:00
} , this ) , 100 ) ;
2024-04-30 18:18:14 -04:00
} else if ( this . counts [ 'select_story_in_feed' ] < this . constants . FILL _OUT _PAGES &&
! NEWSBLUR . assets . stories . no _more _stories ) {
2012-04-11 15:20:57 -07:00
// Nothing up, nothing down, but still not found. Load 1 page then find it.
2012-06-13 15:09:19 -07:00
this . counts [ 'select_story_in_feed' ] += 1 ;
2012-04-11 15:20:57 -07:00
this . load _page _of _feed _stories ( ) ;
} else {
2012-06-13 15:09:19 -07:00
this . counts [ 'select_story_in_feed' ] = 0 ;
this . flags [ 'select_story_in_feed' ] = null ;
2012-04-11 15:20:57 -07:00
}
} ,
2024-04-30 18:18:14 -04:00
show _previous _story : function ( ) {
2012-06-14 15:30:34 -07:00
NEWSBLUR . assets . stories . select _previous _story ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
show _next _feed : function ( direction , $current _feed ) {
2012-05-09 16:56:32 -07:00
var $feed _list = this . $s . $feed _list . add ( this . $s . $social _feeds ) ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
if ( this . flags . river _view && ! this . flags . social _view ) {
return this . show _next _folder ( direction , $current _feed ) ;
}
2024-04-30 18:18:14 -04:00
2014-01-24 15:59:49 -08:00
var $next _feed = this . get _next _feed ( direction , $current _feed , {
include _selected : true ,
feed _id : this . active _feed
} ) ;
2024-04-30 18:18:14 -04:00
2014-09-15 11:16:20 -07:00
if ( ! $next _feed || $current _feed == $next _feed ) return ;
if ( $current _feed && $current _feed . data ( 'id' ) == $next _feed . data ( 'id' ) ) return ;
2024-04-30 18:18:14 -04:00
2012-05-09 16:56:32 -07:00
var next _feed _id = $next _feed . data ( 'id' ) ;
if ( next _feed _id && next _feed _id == this . active _feed ) {
2011-04-12 11:02:02 -04:00
this . show _next _feed ( direction , $next _feed ) ;
2012-05-09 16:56:32 -07:00
} else if ( NEWSBLUR . utils . is _feed _social ( next _feed _id ) ) {
2024-04-30 18:18:14 -04:00
this . open _social _stories ( next _feed _id , { force : true , $feed : $next _feed } ) ;
2012-05-09 16:56:32 -07:00
} else {
next _feed _id = parseInt ( next _feed _id , 10 ) ;
2024-04-30 18:18:14 -04:00
this . open _feed ( next _feed _id , { force : true , $feed : $next _feed } ) ;
2011-04-12 11:02:02 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
show _next _folder : function ( direction , $current _folder ) {
2012-08-27 18:48:19 -07:00
var $next _folder = this . get _next _folder ( direction , $current _folder ) ;
2024-04-30 18:18:14 -04:00
2014-09-15 11:16:20 -07:00
if ( ! $next _folder ) return ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
var folder = NEWSBLUR . assets . folders . get _view ( $next _folder ) ;
this . open _river _stories ( $next _folder , folder && folder . model ) ;
} ,
2024-04-30 18:18:14 -04:00
get _next _feed : function ( direction , $current _feed , options ) {
2012-09-26 17:32:00 -07:00
options = options || { } ;
2010-11-24 13:16:10 -05:00
var self = this ;
2012-05-09 16:56:32 -07:00
var $feed _list = this . $s . $feed _list . add ( this . $s . $social _feeds ) ;
2014-01-24 15:59:49 -08:00
if ( ! $current _feed ) {
$current _feed = $ ( '.selected' , $feed _list ) ;
}
if ( options . feed _id && $current _feed && $current _feed . length ) {
var current _feed = NEWSBLUR . assets . get _feed ( options . feed _id ) ;
if ( current _feed ) {
var selected _title _view = current _feed . get ( "selected_title_view" ) ;
if ( selected _title _view ) {
$current _feed = selected _title _view . $el ;
}
}
}
2010-06-08 11:19:41 -04:00
var $next _feed ,
scroll ;
2012-09-26 13:49:17 -07:00
var $feeds = $ ( '.feed:visible:not(.NB-empty)' , $feed _list ) ;
2010-06-08 11:19:41 -04:00
if ( ! $current _feed . length ) {
2012-09-26 17:32:00 -07:00
if ( options . include _selected ) {
$feeds = $feeds . add ( '.NB-feedlists .feed.NB-selected' ) ;
}
2024-04-30 18:18:14 -04:00
$current _feed = $ ( '.feed:visible:not(.NB-empty)' , $feed _list ) [ direction == - 1 ? 'last' : 'first' ] ( ) ;
2010-06-08 11:19:41 -04:00
$next _feed = $current _feed ;
2010-10-21 18:52:25 -04:00
} else {
2012-08-27 18:48:19 -07:00
var current _feed = 0 ;
2024-04-30 18:18:14 -04:00
$feeds . each ( function ( i ) {
2010-10-21 18:52:25 -04:00
if ( this == $current _feed [ 0 ] ) {
current _feed = i ;
return false ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$next _feed = $feeds . eq ( ( current _feed + direction ) % ( $feeds . length ) ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2011-04-12 11:02:02 -04:00
return $next _feed ;
} ,
2024-04-30 18:18:14 -04:00
get _next _folder : function ( direction , $current _folder ) {
2012-08-27 18:48:19 -07:00
var self = this ;
var $feed _list = this . $s . $feed _list . add ( this . $s . $social _feeds ) ;
var $current _folder = $ ( '.folder.NB-selected' , $feed _list ) ;
var $folders = $ ( 'li.folder:visible:not(.NB-empty)' , $feed _list ) ;
var current _folder = 0 ;
2024-04-30 18:18:14 -04:00
$folders . each ( function ( i ) {
2012-08-27 18:48:19 -07:00
if ( this == $current _folder [ 0 ] ) {
current _folder = i ;
return false ;
}
} ) ;
2024-04-30 18:18:14 -04:00
var next _folder _index = ( current _folder + direction ) % ( $folders . length ) ;
2012-08-27 18:48:19 -07:00
var $next _folder = $folders . eq ( next _folder _index ) ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
return $next _folder ;
} ,
2024-04-30 18:18:14 -04:00
get _next _unread _feed : function ( direction , $current _feed ) {
2011-04-12 11:02:02 -04:00
var self = this ;
2012-05-09 16:56:32 -07:00
var $feed _list = this . $s . $feed _list . add ( this . $s . $social _feeds ) ;
2011-04-12 11:02:02 -04:00
$current _feed = $current _feed || $ ( '.selected' , $feed _list ) ;
var unread _view = this . get _unread _view _name ( ) ;
var $next _feed ;
2012-07-31 15:53:16 -07:00
var current _feed ;
2024-04-30 18:18:14 -04:00
var $feeds = $ ( '.feed:visible:not(.NB-empty)' , $feed _list ) . filter ( function ( ) {
var $this = $ ( this ) ;
if ( $this . hasClass ( 'selected' ) ) {
return true ;
} else if ( unread _view == 'positive' ) {
return $this . is ( '.unread_positive' ) ;
} else if ( unread _view == 'neutral' ) {
return $this . is ( '.unread_positive,.unread_neutral' ) ;
} else if ( unread _view == 'negative' ) {
return $this . is ( '.unread_positive,.unread_neutral,.unread_negative' ) ;
}
2012-07-31 15:53:16 -07:00
} ) . add ( '.NB-feedlists .feed.NB-selected' ) ;
2011-04-12 11:02:02 -04:00
if ( ! $current _feed . length ) {
2024-04-30 18:18:14 -04:00
$next _feed = $feeds . first ( ) ;
2011-04-12 11:02:02 -04:00
} else {
2024-04-30 18:18:14 -04:00
$feeds . each ( function ( i ) {
if ( this == $current _feed . get ( 0 ) ) {
current _feed = i ;
return false ;
}
} ) ;
$next _feed = $feeds . eq ( ( current _feed + direction ) % ( $feeds . length ) ) ;
}
2011-04-12 11:02:02 -04:00
return $next _feed ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
get _next _unread _folder : function ( direction ) {
2012-08-27 18:48:19 -07:00
var self = this ;
var $feed _list = this . $s . $feed _list . add ( this . $s . $social _feeds ) ;
var $current _folder = $ ( '.folder.NB-selected' , $feed _list ) ;
var unread _view = this . get _unread _view _name ( ) ;
var $next _folder ;
var current _folder = 0 ;
var $folders = $ ( 'li.folder:visible:not(.NB-empty)' , $feed _list ) ;
2024-04-30 18:18:14 -04:00
$folders = $folders . filter ( function ( ) {
2012-08-27 18:48:19 -07:00
var $this = $ ( this ) ;
var folder _view = NEWSBLUR . assets . folders . get _view ( $current _folder ) ;
var folder _model = folder _view && folder _view . model ;
if ( ! folder _model ) return false ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
var counts = folder _model . collection . unread _counts ( ) ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
if ( this == $current _folder [ 0 ] ) return true ;
2024-04-30 18:18:14 -04:00
2012-08-27 18:48:19 -07:00
if ( unread _view == 'positive' ) {
return counts . ps ;
} else if ( unread _view == 'neutral' ) {
return counts . ps + counts . nt ;
} else if ( unread _view == 'negative' ) {
return counts . ps + counts . nt + counts . ng ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$folders . each ( function ( i ) {
2012-08-27 18:48:19 -07:00
if ( this == $current _folder [ 0 ] ) {
current _folder = i ;
return false ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$next _folder = $folders . eq ( ( current _folder + direction ) % ( $folders . length ) ) ;
2012-08-27 18:48:19 -07:00
return $next _folder ;
} ,
2024-04-30 18:18:14 -04:00
page _in _story : function ( amount , direction ) {
2013-05-22 16:40:56 -07:00
amount = parseInt ( amount , 10 ) / 100.0 ;
2010-06-14 13:17:38 -04:00
var page _height = this . $s . $story _pane . height ( ) ;
2022-02-18 17:52:24 -05:00
if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-05-22 16:40:56 -07:00
page _height = this . $s . $story _titles . height ( ) ;
}
2010-06-08 11:19:41 -04:00
var scroll _height = parseInt ( page _height * amount , 10 ) ;
2024-04-30 18:18:14 -04:00
var feed _view = NEWSBLUR . assets . preference ( 'feed_view_single_story' ) &&
( ( this . story _view == 'feed' && ! this . flags [ 'temporary_story_view' ] ) ||
this . flags [ 'page_view_showing_feed_view' ] ) ;
2015-03-11 13:13:11 -07:00
var text _view = this . story _view == 'text' || this . flags [ 'temporary_story_view' ] ;
2024-04-30 18:18:14 -04:00
2013-05-22 16:40:56 -07:00
this . scroll _in _story ( scroll _height , direction ) ;
2024-04-30 18:18:14 -04:00
2015-04-01 17:07:46 -07:00
if ( NEWSBLUR . assets . preference ( 'space_bar_action' ) == 'scroll_only' ) return ;
if ( NEWSBLUR . assets . preference ( 'space_bar_action' ) == 'next_unread_50' ) {
page _height = page _height / 2 + 36 ;
}
2024-04-30 18:18:14 -04:00
2015-03-11 17:41:52 -07:00
if ( ! this . active _story || ! this . active _story . get ( 'selected' ) ) {
2024-04-30 18:18:14 -04:00
this . open _next _unread _story _across _feeds ( ) ;
2015-03-18 11:54:13 -07:00
} else if ( _ . contains ( [ 'split' , 'full' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2015-03-11 16:45:41 -07:00
if ( direction > 0 ) {
if ( feed _view ) {
var scroll _top = this . $s . $feed _scroll . scrollTop ( ) ;
2024-04-30 18:18:14 -04:00
var story _height = this . $s . $feed _scroll . find ( '.NB-feed-story.NB-selected' ) . height ( ) - 12 ;
2015-03-11 16:45:41 -07:00
if ( page _height + scroll _top >= story _height ) {
this . open _next _unread _story _across _feeds ( ) ;
}
} else if ( text _view ) {
var scroll _top = this . $s . $text _view . scrollTop ( ) ;
2024-04-30 18:18:14 -04:00
var story _height = this . $s . $text _view . find ( '.NB-feed-story' ) . height ( ) - 24 ;
2015-03-11 16:45:41 -07:00
if ( page _height + scroll _top >= story _height ) {
this . open _next _unread _story _across _feeds ( ) ;
}
2015-03-11 13:06:10 -07:00
}
2015-03-11 16:45:41 -07:00
} else if ( split _layout && direction < 0 ) {
if ( feed _view || text _view ) {
var scroll _top = this . $s . $feed _scroll . scrollTop ( ) ;
if ( scroll _top == 0 ) {
this . show _previous _story ( ) ;
}
2015-03-11 13:13:11 -07:00
}
}
2022-02-18 17:52:24 -05:00
} else if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2015-03-11 16:45:41 -07:00
var scroll _top = this . $s . $story _titles . scrollTop ( ) ;
2015-03-11 17:41:52 -07:00
var $story = this . active _story . story _title _view . $el ;
2015-03-11 16:45:41 -07:00
var story _height = $story . height ( ) ;
var story _offset = $story . position ( ) . top ;
2024-04-30 18:18:14 -04:00
console . log ( [ 'space list' , $story [ 0 ] , scroll _top , story _height , story _offset , story _height + story _offset - scroll _height , page _height ] ) ;
if ( direction > 0 &&
( story _height + story _offset - scroll _height + 52 < 0 ||
story _height + story _offset + 52 < page _height ) ) {
this . open _next _unread _story _across _feeds ( ) ;
} else if ( direction < 0 && story _offset >= 0 ) {
this . show _previous _story ( ) ;
}
}
} ,
scroll _in _story : function ( amount , direction ) {
2010-06-08 11:19:41 -04:00
var dir = '+' ;
if ( direction == - 1 ) {
dir = '-' ;
}
2013-05-22 16:40:56 -07:00
// NEWSBLUR.log(['scroll_in_story', this.$s.$story_pane, direction, amount]);
2022-02-18 17:52:24 -05:00
if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-07-18 12:46:47 -07:00
this . $s . $story _titles . stop ( ) . scrollTo ( {
2024-04-30 18:18:14 -04:00
top : dir + '=' + amount ,
left : '+=0'
} , 130 , { queue : false } ) ;
} else if ( this . story _view == 'page' &&
2013-01-09 15:49:33 -08:00
! this . flags [ 'page_view_showing_feed_view' ] &&
! this . flags [ 'temporary_story_view' ] ) {
2013-07-18 12:46:47 -07:00
this . $s . $feed _iframe . stop ( ) . scrollTo ( {
2024-04-30 18:18:14 -04:00
top : dir + '=' + amount ,
left : '+=0'
} , 130 , { queue : false } ) ;
2013-01-09 15:59:12 -08:00
} else if ( ( this . story _view == 'feed' &&
2024-04-30 18:18:14 -04:00
! this . flags [ 'temporary_story_view' ] ) ||
this . flags [ 'page_view_showing_feed_view' ] ) {
2013-07-18 12:46:47 -07:00
this . $s . $feed _scroll . stop ( ) . scrollTo ( {
2024-04-30 18:18:14 -04:00
top : dir + '=' + amount ,
left : '+=0'
} , 130 , { queue : false } ) ;
2013-01-09 15:49:33 -08:00
} else if ( this . story _view == 'text' ||
2024-04-30 18:18:14 -04:00
this . flags [ 'temporary_story_view' ] ) {
2013-07-18 12:46:47 -07:00
this . $s . $text _view . stop ( ) . scrollTo ( {
2024-04-30 18:18:14 -04:00
top : dir + '=' + amount ,
left : '+=0'
} , 130 , { queue : false } ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2012-07-12 13:43:39 -07:00
this . show _mouse _indicator ( ) ;
// _.delay(_.bind(this.hide_mouse_indicator, this), 350);
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
find _story _with _action _preference _on _open _feed : function ( ) {
2012-02-17 18:36:33 -08:00
var open _feed _action = this . model . preference ( 'open_feed_action' ) ;
2012-02-24 12:47:39 -08:00
2014-06-20 12:13:28 -07:00
if ( ! this . active _story && open _feed _action == 'newest' &&
! this . flags [ 'feed_list_showing_starred' ] ) {
2012-02-17 18:36:33 -08:00
this . show _next _unread _story ( ) ;
2024-04-30 18:18:14 -04:00
} else if ( ! this . active _story &&
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' &&
NEWSBLUR . assets . preference ( 'feed_view_single_story' ) ) {
this . show _next _unread _story ( ) ;
2012-02-17 18:36:33 -08:00
}
} ,
2024-04-30 18:18:14 -04:00
2010-06-08 11:19:41 -04:00
// =============
// = Feed Pane =
// =============
2024-04-30 18:18:14 -04:00
sort _feeds : function ( $feeds ) {
$ ( '.feed' , $feeds ) . tsort ( '' , { sortFunction : NEWSBLUR . Collections . Folders . comparator } ) ;
2011-03-30 09:30:45 -04:00
$ ( '.folder' , $feeds ) . tsort ( '.folder_title_text' ) ;
} ,
2024-04-30 18:18:14 -04:00
load _sortable _feeds : function ( ) {
2010-07-10 17:59:17 -04:00
var self = this ;
2024-04-30 18:18:14 -04:00
2010-11-03 21:27:52 -04:00
this . $s . $feed _list . sortable ( {
2011-02-08 09:44:24 -05:00
items : '.feed,li.folder' ,
connectWith : 'ul.folder,.feed.NB-empty' ,
2010-07-10 17:59:17 -04:00
placeholder : 'NB-feeds-list-highlight' ,
axis : 'y' ,
2010-12-10 09:32:06 -05:00
distance : 4 ,
2010-07-11 11:10:45 -04:00
cursor : 'move' ,
2012-05-09 16:56:32 -07:00
containment : '#feed_list' ,
2010-12-10 09:32:06 -05:00
tolerance : 'pointer' ,
2010-12-25 23:04:43 -05:00
scrollSensitivity : 35 ,
2024-04-30 18:18:14 -04:00
start : function ( e , ui ) {
2010-07-10 17:59:17 -04:00
self . flags [ 'sorting_feed' ] = true ;
ui . placeholder . attr ( 'class' , ui . item . attr ( 'class' ) + ' NB-feeds-list-highlight' ) ;
2012-05-18 18:13:45 -07:00
NEWSBLUR . app . feed _list . start _sorting ( ) ;
2010-07-10 17:59:17 -04:00
ui . item . addClass ( 'NB-feed-sorting' ) ;
2012-01-14 18:54:59 -08:00
ui . placeholder . data ( 'id' , ui . item . data ( 'id' ) ) ;
2010-12-16 23:57:05 -05:00
if ( ui . item . is ( '.folder' ) ) {
ui . placeholder . html ( ui . item . children ( ) . clone ( ) ) ;
ui . item . data ( 'previously_collapsed' , ui . item . data ( 'collapsed' ) ) ;
self . collapse _folder ( ui . item . children ( '.folder_title' ) , true ) ;
self . collapse _folder ( ui . placeholder . children ( '.folder_title' ) , true ) ;
ui . item . css ( 'height' , ui . item . children ( '.folder_title' ) . outerHeight ( true ) + 'px' ) ;
2010-12-25 23:04:43 -05:00
ui . helper . css ( 'height' , ui . helper . children ( '.folder_title' ) . outerHeight ( true ) + 'px' ) ;
2010-11-03 21:27:52 -04:00
} else {
ui . placeholder . html ( ui . item . children ( ) . clone ( ) ) ;
2010-09-05 18:08:08 -07:00
}
2010-07-10 17:59:17 -04:00
} ,
2024-04-30 18:18:14 -04:00
change : function ( e , ui ) {
2011-04-25 20:53:29 -04:00
var $feeds = ui . placeholder . closest ( 'ul.folder' ) ;
self . sort _feeds ( $feeds ) ;
2010-07-10 17:59:17 -04:00
} ,
2024-04-30 18:18:14 -04:00
stop : function ( e , ui ) {
setTimeout ( function ( ) {
2010-07-10 17:59:17 -04:00
self . flags [ 'sorting_feed' ] = false ;
} , 100 ) ;
ui . item . removeClass ( 'NB-feed-sorting' ) ;
2012-05-18 18:13:45 -07:00
NEWSBLUR . app . feed _list . end _sorting ( ) ;
2011-04-25 20:53:29 -04:00
self . sort _feeds ( e . target ) ;
2010-07-10 17:59:17 -04:00
self . save _feed _order ( ) ;
2024-04-30 18:18:14 -04:00
ui . item . css ( { 'backgroundColor' : '#D7DDE6' } )
. animate ( { 'backgroundColor' : '#F0F076' } , { 'duration' : 800 } )
. animate ( { 'backgroundColor' : '#D7DDE6' } , { 'duration' : 1000 } ) ;
2010-12-16 23:57:05 -05:00
if ( ui . item . is ( '.folder' ) && ! ui . item . data ( 'previously_collapsed' ) ) {
self . collapse _folder ( ui . item . children ( '.folder_title' ) ) ;
self . collapse _folder ( ui . placeholder . children ( '.folder_title' ) ) ;
2010-09-05 18:08:08 -07:00
}
2010-07-10 17:59:17 -04:00
}
} ) ;
} ,
2024-04-30 18:18:14 -04:00
save _feed _order : function ( ) {
var combine _folders = function ( $folder ) {
2010-07-11 11:10:45 -04:00
var folders = [ ] ;
var $items = $folder . children ( 'li.folder, .feed' ) ;
2024-04-30 18:18:14 -04:00
for ( var i = 0 , i _count = $items . length ; i < i _count ; i ++ ) {
2010-07-11 11:10:45 -04:00
var $item = $items . eq ( i ) ;
if ( $item . hasClass ( 'feed' ) ) {
2012-02-10 19:33:31 -08:00
var feed _id = parseInt ( $item . data ( 'id' ) , 10 ) ;
2010-12-10 09:32:06 -05:00
if ( feed _id ) {
folders . push ( feed _id ) ;
}
2010-07-11 11:10:45 -04:00
} else if ( $item . hasClass ( 'folder' ) ) {
2010-09-05 18:08:08 -07:00
var folder _title = $item . find ( '.folder_title_text' ) . eq ( 0 ) . text ( ) ;
2010-07-11 11:10:45 -04:00
var child _folders = { } ;
child _folders [ folder _title ] = combine _folders ( $item . children ( 'ul.folder' ) . eq ( 0 ) ) ;
folders . push ( child _folders ) ;
}
}
2024-04-30 18:18:14 -04:00
2010-07-11 11:10:45 -04:00
return folders ;
} ;
2024-04-30 18:18:14 -04:00
2010-07-11 11:10:45 -04:00
var combined _folders = combine _folders ( this . $s . $feed _list ) ;
2010-10-30 00:27:52 -04:00
// NEWSBLUR.log(['Save new folder/feed order', {'combined': combined_folders}]);
2010-07-11 11:10:45 -04:00
this . model . save _feed _order ( combined _folders ) ;
2010-07-10 17:59:17 -04:00
} ,
2024-04-30 18:18:14 -04:00
show _feed _chooser _button : function ( ) {
2010-09-28 18:53:57 -04:00
var self = this ;
var $progress = this . $s . $feeds _progress ;
var $bar = $ ( '.NB-progress-bar' , $progress ) ;
var percentage = 0 ;
2024-04-30 18:18:14 -04:00
2010-09-28 18:53:57 -04:00
$ ( '.NB-progress-title' , $progress ) . text ( 'Get Started' ) ;
$ ( '.NB-progress-counts' , $progress ) . hide ( ) ;
$ ( '.NB-progress-percentage' , $progress ) . hide ( ) ;
2010-10-02 17:05:55 -04:00
$progress . addClass ( 'NB-progress-error' ) . addClass ( 'NB-progress-big' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-progress-link' , $progress ) . html ( $ . make ( 'div' , {
2012-03-12 12:33:54 -07:00
className : 'NB-modal-submit-button NB-modal-submit-green NB-menu-manage-feedchooser'
2013-03-17 10:28:26 -07:00
} , [ 'Choose your 64 sites' ] ) ) ;
2024-04-30 18:18:14 -04:00
2010-09-28 18:53:57 -04:00
this . show _progress _bar ( ) ;
} ,
2024-04-30 18:18:14 -04:00
hide _feed _chooser _button : function ( ) {
2010-10-02 17:05:55 -04:00
var $progress = this . $s . $feeds _progress ;
var $bar = $ ( '.NB-progress-bar' , $progress ) ;
$progress . removeClass ( 'NB-progress-error' ) . removeClass ( 'NB-progress-big' ) ;
2024-04-30 18:18:14 -04:00
2010-10-02 17:05:55 -04:00
this . hide _progress _bar ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _dialog _after _feeds _loaded : function ( options ) {
2012-07-20 19:43:28 -07:00
options = options || { } ;
2012-03-12 12:33:54 -07:00
if ( ! NEWSBLUR . Globals . is _authenticated ) return ;
2024-04-30 18:18:14 -04:00
2012-12-10 16:25:21 -08:00
if ( ! NEWSBLUR . assets . folders . length ||
! NEWSBLUR . assets . preference ( 'has_setup_feeds' ) ) {
2012-07-20 19:43:28 -07:00
if ( options . delayed _import || this . flags . delayed _import ) {
this . setup _ftux _add _feed _callout ( "Check your email..." ) ;
2013-02-26 10:00:35 -08:00
} else if ( options . finished _intro || NEWSBLUR . assets . preference ( 'has_setup_feeds' ) ) {
2012-03-19 14:15:38 -07:00
this . setup _ftux _add _feed _callout ( ) ;
2012-03-19 16:35:56 -07:00
} else if ( ! NEWSBLUR . intro || ! NEWSBLUR . intro . flags . open ) {
_ . defer ( _ . bind ( this . open _intro _modal , this ) , 100 ) ;
2012-03-19 14:15:38 -07:00
}
2012-12-10 16:25:21 -08:00
} else if ( ! NEWSBLUR . assets . flags [ 'has_chosen_feeds' ] &&
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . folders . length ) {
2013-03-25 13:01:04 -07:00
if ( NEWSBLUR . Globals . is _premium ) {
2024-04-30 18:18:14 -04:00
this . model . save _feed _chooser ( null , function ( ) {
2013-03-25 13:01:04 -07:00
NEWSBLUR . reader . hide _feed _chooser _button ( ) ;
NEWSBLUR . assets . load _feeds ( ) ;
} ) ;
} else {
_ . defer ( _ . bind ( this . open _feedchooser _modal , this ) , 100 ) ;
}
2012-12-10 16:25:21 -08:00
} else if ( ! NEWSBLUR . Globals . is _premium &&
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . feeds . active ( ) . length > 64 ) {
2012-03-12 12:33:54 -07:00
_ . defer ( _ . bind ( this . open _feedchooser _modal , this ) , 100 ) ;
}
} ,
2024-04-30 18:18:14 -04:00
2010-11-22 10:44:52 -05:00
// ================
// = Progress Bar =
// ================
2024-04-30 18:18:14 -04:00
check _feed _fetch _progress : function ( ) {
2010-11-22 10:44:52 -05:00
$ . extend ( this . counts , {
'unfetched_feeds' : 0 ,
'fetched_feeds' : 0
} ) ;
2024-04-30 18:18:14 -04:00
2012-07-29 00:49:34 -07:00
var counts = this . model . count _unfetched _feeds ( ) ;
this . counts [ 'unfetched_feeds' ] = counts [ 'unfetched_feeds' ] ;
this . counts [ 'fetched_feeds' ] = counts [ 'fetched_feeds' ] ;
2010-11-22 10:44:52 -05:00
2012-07-29 00:49:34 -07:00
if ( this . counts [ 'unfetched_feeds' ] == 0 ) {
this . flags [ 'has_unfetched_feeds' ] = false ;
this . hide _unfetched _feed _progress ( ) ;
} else {
this . flags [ 'has_unfetched_feeds' ] = true ;
this . show _unfetched _feed _progress ( ) ;
2010-11-22 10:44:52 -05:00
}
} ,
2024-04-30 18:18:14 -04:00
show _progress _bar : function ( ) {
2010-11-24 15:01:35 -05:00
var $layout = this . $s . $feeds _progress . parents ( '.left-center' ) . layout ( ) ;
2010-11-22 10:44:52 -05:00
if ( ! this . flags [ 'showing_progress_bar' ] ) {
this . flags [ 'showing_progress_bar' ] = true ;
2010-11-24 13:16:10 -05:00
$layout . open ( 'south' ) ;
2010-11-22 10:44:52 -05:00
}
2010-11-24 15:01:35 -05:00
$layout . sizePane ( 'south' ) ;
2010-11-22 10:44:52 -05:00
} ,
2024-04-30 18:18:14 -04:00
hide _progress _bar : function ( permanent ) {
2010-11-22 10:44:52 -05:00
var self = this ;
2024-04-30 18:18:14 -04:00
2010-11-22 10:44:52 -05:00
if ( permanent ) {
this . model . preference ( 'hide_fetch_progress' , true ) ;
}
2024-04-30 18:18:14 -04:00
2010-11-22 10:44:52 -05:00
this . flags [ 'showing_progress_bar' ] = false ;
this . $s . $feeds _progress . parents ( '.left-center' ) . layout ( ) . close ( 'south' ) ;
} ,
2024-04-30 18:18:14 -04:00
show _unfetched _feed _progress : function ( ) {
2010-11-22 10:44:52 -05:00
var self = this ;
var $progress = this . $s . $feeds _progress ;
var percentage = parseInt ( this . counts [ 'fetched_feeds' ] / ( this . counts [ 'unfetched_feeds' ] + this . counts [ 'fetched_feeds' ] ) * 100 , 10 ) ;
$ ( '.NB-progress-title' , $progress ) . text ( 'Fetching your feeds' ) ;
$ ( '.NB-progress-counts' , $progress ) . show ( ) ;
$ ( '.NB-progress-counts-fetched' , $progress ) . text ( this . counts [ 'fetched_feeds' ] ) ;
$ ( '.NB-progress-counts-total' , $progress ) . text ( this . counts [ 'unfetched_feeds' ] + this . counts [ 'fetched_feeds' ] ) ;
$ ( '.NB-progress-percentage' , $progress ) . show ( ) . text ( percentage + '%' ) ;
$ ( '.NB-progress-bar' , $progress ) . progressbar ( {
value : percentage
} ) ;
2024-04-30 18:18:14 -04:00
2011-03-19 11:22:10 -04:00
if ( ! $progress . is ( ':visible' ) && ! this . model . preference ( 'hide_fetch_progress' ) ) {
2024-04-30 18:18:14 -04:00
setTimeout ( function ( ) {
2010-11-22 10:44:52 -05:00
self . show _progress _bar ( ) ;
} , 1000 ) ;
}
2024-04-30 18:18:14 -04:00
2011-02-05 15:34:43 -05:00
this . setup _feed _refresh ( true ) ;
2010-11-22 10:44:52 -05:00
} ,
2024-04-30 18:18:14 -04:00
hide _unfetched _feed _progress : function ( permanent ) {
2010-11-22 10:44:52 -05:00
if ( permanent ) {
this . model . preference ( 'hide_fetch_progress' , true ) ;
}
2024-04-30 18:18:14 -04:00
2011-01-30 21:48:17 -05:00
this . setup _feed _refresh ( ) ;
2010-11-22 10:44:52 -05:00
this . hide _progress _bar ( ) ;
} ,
2024-04-30 18:18:14 -04:00
2010-09-05 18:08:08 -07:00
// ===============================
// = Feed bar - Individual Feeds =
// ===============================
2024-04-30 18:18:14 -04:00
reset _feed : function ( options ) {
2012-09-17 13:24:00 -07:00
options = options || { } ;
2024-04-30 18:18:14 -04:00
2010-07-02 12:02:10 -04:00
$ . extend ( this . flags , {
'scrolling_by_selecting_story_title' : false ,
'page_view_showing_feed_view' : false ,
2010-12-07 09:52:14 -05:00
'feed_view_showing_story_view' : false ,
2013-01-09 11:57:47 -08:00
'temporary_story_view' : false ,
2010-07-06 18:30:16 -04:00
'story_titles_loaded' : false ,
2010-08-30 22:42:44 -04:00
'iframe_prevented_from_loading' : false ,
2010-09-12 13:50:27 -04:00
'pause_feed_refreshing' : false ,
2011-01-04 19:27:00 -05:00
'feed_list_showing_manage_menu' : false ,
2011-01-19 08:54:59 -05:00
'unread_threshold_temporarily' : null ,
2011-02-13 14:49:13 -05:00
'river_view' : false ,
2012-01-31 10:15:11 -08:00
'social_view' : false ,
2013-08-23 18:07:13 -07:00
'starred_view' : false ,
2012-11-30 14:28:55 -08:00
'select_story_in_feed' : null ,
2013-09-13 15:54:52 -07:00
'global_blurblogs' : false ,
2013-09-13 16:35:48 -07:00
'reloading_feeds' : false
2010-07-02 12:02:10 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
2010-07-02 12:02:10 -04:00
$ . extend ( this . cache , {
2010-11-06 12:53:42 -04:00
'iframe' : { } ,
2010-06-08 11:19:41 -04:00
'iframe_stories' : { } ,
'iframe_story_positions' : { } ,
'feed_view_story_positions' : { } ,
'iframe_story_positions_keys' : [ ] ,
'feed_view_story_positions_keys' : [ ] ,
2010-12-12 22:52:15 -05:00
'river_feeds_with_unreads' : [ ] ,
2010-11-06 12:53:42 -04:00
'prefetch_last_story' : 0 ,
2011-01-25 22:59:38 -05:00
'prefetch_iteration' : 0 ,
'feed_title_floater_story_id' : null ,
2012-01-25 09:52:34 -08:00
'$feed_in_social_feed_list' : { }
2010-07-02 12:02:10 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
2011-03-09 09:48:24 -05:00
$ . extend ( this . counts , {
2012-02-17 18:36:33 -08:00
'page' : 1 ,
2011-11-02 09:43:06 -07:00
'find_next_unread_on_page_of_feed_stories_load' : 0 ,
2012-04-11 15:20:57 -07:00
'find_last_unread_on_page_of_feed_stories_load' : 0 ,
2012-06-13 15:09:19 -07:00
'select_story_in_feed' : 0
2010-07-02 12:02:10 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
2017-03-06 19:55:18 -08:00
// console.log(['reset feed', options, options.search]);
2024-04-30 18:18:14 -04:00
2012-12-19 14:21:46 -08:00
if ( _ . isUndefined ( options . search ) ) {
2013-09-09 18:29:07 -07:00
this . flags . search = "" ;
2013-07-25 17:05:32 -07:00
this . flags . searching = false ;
2012-12-19 14:21:46 -08:00
}
2013-07-10 14:27:52 -07:00
this . $s . $feed _scroll . scrollTop ( 0 ) ;
2010-12-02 11:09:09 -05:00
this . $s . $starred _header . removeClass ( 'NB-selected' ) ;
2013-12-05 16:08:45 -08:00
this . $s . $read _header . removeClass ( 'NB-selected' ) ;
2012-08-07 14:37:07 -07:00
this . $s . $river _sites _header . removeClass ( 'NB-selected' ) ;
2017-10-16 14:22:37 -07:00
this . $s . $river _infrequent _header . removeClass ( 'NB-selected' ) ;
2012-08-07 14:37:07 -07:00
this . $s . $river _blurblogs _header . removeClass ( 'NB-selected' ) ;
2012-11-30 14:28:55 -08:00
this . $s . $river _global _header . removeClass ( 'NB-selected' ) ;
2011-03-15 23:42:27 -04:00
this . $s . $tryfeed _header . removeClass ( 'NB-selected' ) ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . removeClass ( 'NB-view-river' ) ;
2011-02-27 21:44:47 -05:00
$ ( '.task_view_page' , this . $s . $taskbar ) . removeClass ( 'NB-disabled' ) ;
2012-05-07 16:26:31 -07:00
$ ( '.task_view_story' , this . $s . $taskbar ) . removeClass ( 'NB-disabled' ) ;
2011-02-02 14:10:24 -05:00
$ ( '.task_view_page' , this . $s . $taskbar ) . removeClass ( 'NB-task-return' ) ;
2012-02-17 17:41:20 -08:00
clearTimeout ( this . flags [ 'next_fetch' ] ) ;
2024-04-30 18:18:14 -04:00
2013-01-31 18:24:53 -08:00
if ( this . flags [ 'showing_feed_in_tryfeed_view' ] ||
this . flags [ 'showing_social_feed_in_tryfeed_view' ] ) {
2011-03-15 23:42:27 -04:00
this . hide _tryfeed _view ( ) ;
}
2012-09-17 12:29:46 -07:00
if ( NEWSBLUR . Globals . is _anonymous ) {
2012-09-17 13:24:00 -07:00
if ( options . router ) {
this . $s . $layout . layout ( ) . show ( 'west' , true ) ;
this . $s . $layout . show ( ) ;
}
2012-09-17 12:29:46 -07:00
this . hide _tryout _signup _button ( ) ;
}
2024-04-30 18:18:14 -04:00
2016-12-07 19:07:00 -08:00
this . model . feeds . deselect ( ) ;
2016-12-08 16:32:59 -08:00
this . model . stories . deselect ( ) ;
2016-12-07 19:07:00 -08:00
this . model . starred _feeds . deselect ( ) ;
2017-03-06 16:23:03 -08:00
this . model . searches _feeds . deselect ( ) ;
2016-12-07 19:07:00 -08:00
if ( _ . string . contains ( this . active _feed , 'social:' ) ) {
this . model . social _feeds . deselect ( ) ;
}
if ( _ . string . contains ( this . active _feed , 'river:' ) ) {
this . model . folders . deselect ( ) ;
}
2016-12-08 16:32:59 -08:00
2012-06-11 22:25:20 -07:00
this . active _folder = null ;
2012-05-24 11:54:10 -07:00
this . active _feed = null ;
this . active _story = null ;
2024-04-30 18:18:14 -04:00
2012-05-25 22:13:50 -07:00
NEWSBLUR . assets . stories . reset ( ) ;
2012-09-26 13:49:17 -07:00
NEWSBLUR . app . feed _selector . hide _feed _selector ( ) ;
2012-10-01 17:24:08 -07:00
NEWSBLUR . app . original _tab _view . unload _feed _iframe ( ) ;
NEWSBLUR . app . story _tab _view . unload _story _iframe ( ) ;
2013-01-08 19:29:02 -08:00
NEWSBLUR . app . text _tab _view . unload ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
reload _feed : function ( options ) {
2012-12-19 14:21:46 -08:00
options = options || { } ;
2024-04-30 18:18:14 -04:00
2013-09-09 15:43:42 -07:00
if ( this . flags [ 'starred_view' ] && this . flags [ 'starred_tag' ] ) {
options [ 'tag' ] = this . flags [ 'starred_tag' ] ;
this . open _starred _stories ( options ) ;
} else if ( this . flags [ 'starred_view' ] ) {
2012-12-19 14:21:46 -08:00
this . open _starred _stories ( options ) ;
2013-12-05 16:08:45 -08:00
} else if ( this . active _feed == 'read' ) {
this . open _read _stories ( options ) ;
2024-04-30 18:18:14 -04:00
} else if ( this . flags [ 'social_view' ] &&
this . active _feed == 'river:blurblogs' ) {
2012-12-19 14:21:46 -08:00
this . open _river _blurblogs _stories ( ) ;
2024-04-30 18:18:14 -04:00
} else if ( this . flags [ 'social_view' ] &&
this . active _feed == 'river:global' ) {
this . open _river _blurblogs _stories ( { 'global' : true } ) ;
2012-12-19 14:21:46 -08:00
} else if ( this . flags [ 'social_view' ] ) {
2013-07-25 11:10:56 -07:00
this . open _social _stories ( this . active _feed , options ) ;
2012-12-19 14:21:46 -08:00
} else if ( this . flags [ 'river_view' ] ) {
2017-10-18 16:15:51 -07:00
if ( this . active _feed == 'river:infrequent' ) {
2017-11-05 14:01:25 -08:00
options . infrequent = NEWSBLUR . assets . preference ( 'infrequent_stories_per_month' ) ;
2017-10-18 16:15:51 -07:00
}
2024-04-30 18:18:14 -04:00
this . open _river _stories ( this . active _folder &&
this . active _folder . folder _view &&
this . active _folder . folder _view . $el ,
this . active _folder ,
options ) ;
2014-05-28 18:06:52 -07:00
} else if ( this . active _feed ) {
2012-12-19 14:21:46 -08:00
this . open _feed ( this . active _feed , options ) ;
}
2024-04-30 18:18:14 -04:00
2013-07-25 15:39:12 -07:00
if ( options . search && ! _ . contains ( [ 'feed' , 'text' , 'story' ] , this . story _view ) ) {
this . switch _taskbar _view ( 'feed' , {
skip _save _type : true
} ) ;
}
2012-12-19 14:21:46 -08:00
} ,
2024-04-30 18:18:14 -04:00
open _feed : function ( feed _id , options ) {
2012-01-16 17:55:13 -08:00
options = options || { } ;
2010-06-08 11:19:41 -04:00
var self = this ;
2010-06-14 13:17:38 -04:00
var $story _titles = this . $s . $story _titles ;
2012-05-21 14:36:54 -07:00
var feed = this . model . get _feed ( feed _id ) || options . feed ;
2014-01-17 13:58:52 -08:00
var temp = feed && feed . get ( 'temp' ) && ! feed . get ( 'subscribed' ) ;
2024-04-30 18:18:14 -04:00
2012-05-04 15:49:39 -07:00
if ( ! feed || ( temp && ! options . try _feed ) ) {
2012-06-13 13:47:50 -07:00
// Setup tryfeed views first, then come back here.
2014-01-28 17:39:58 -08:00
console . log ( [ "Temp open feed" , feed _id , feed , options , temp ] ) ;
2012-06-14 17:21:51 -07:00
options . feed = options . feed && options . feed . attributes ;
2012-05-04 15:27:53 -07:00
return this . load _feed _in _tryfeed _view ( feed _id , options ) ;
}
2010-06-08 11:19:41 -04:00
this . flags [ 'opening_feed' ] = true ;
2024-04-30 18:18:14 -04:00
2012-05-19 10:29:27 -07:00
if ( options . try _feed || feed ) {
2012-09-17 13:24:00 -07:00
this . reset _feed ( options ) ;
2010-06-08 11:19:41 -04:00
this . hide _splash _page ( ) ;
2012-04-16 11:21:52 -07:00
if ( options . story _id ) {
2012-06-13 15:09:19 -07:00
this . flags [ 'select_story_in_feed' ] = options . story _id ;
2012-04-16 11:21:52 -07:00
}
2024-04-30 18:18:14 -04:00
2012-05-19 10:29:27 -07:00
this . active _feed = feed . id ;
this . next _feed = feed . id ;
2024-04-30 18:18:14 -04:00
2014-01-24 15:59:49 -08:00
if ( options . $feed ) {
2024-04-30 18:18:14 -04:00
var selected _title _view = _ . detect ( feed . views , function ( view ) {
2014-01-24 15:59:49 -08:00
return view . el == options . $feed . get ( 0 ) ;
} ) ;
if ( selected _title _view ) {
2024-04-30 18:18:14 -04:00
feed . set ( "selected_title_view" , selected _title _view , { silent : true } ) ;
2014-01-24 15:59:49 -08:00
}
}
2017-03-24 16:17:23 -07:00
if ( options . feed && options . feed . set ) {
2017-03-06 19:55:18 -08:00
options . feed . set ( 'selected' , true , options ) ;
} else {
feed . set ( 'selected' , true , options ) ;
}
2024-04-30 18:18:14 -04:00
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
2010-06-08 11:19:41 -04:00
this . iframe _scroll = null ;
2012-05-19 10:29:27 -07:00
this . set _correct _story _view _for _feed ( feed . id ) ;
2012-09-07 17:36:12 -07:00
this . make _feed _title _in _stories ( ) ;
2010-06-08 11:19:41 -04:00
this . switch _taskbar _view ( this . story _view ) ;
2015-02-06 13:28:55 -08:00
this . switch _story _layout ( ) ;
2024-04-30 18:18:14 -04:00
2015-07-22 12:43:55 -07:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2012-05-19 10:29:27 -07:00
if ( ! options . delay || feed . id == self . next _feed ) {
2024-04-30 18:18:14 -04:00
this . model . load _feed ( feed . id , 1 , true , $ . rescope ( this . post _open _feed , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error ) ;
2010-11-24 13:16:10 -05:00
}
2012-01-16 17:55:13 -08:00
} , this ) , options . delay || 0 ) ;
2011-02-27 21:44:47 -05:00
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'split' , 'full' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
2013-02-12 13:15:14 -08:00
( ! this . story _view || this . story _view == 'page' ) ) {
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2012-05-19 10:29:27 -07:00
if ( ! options . delay || feed . id == this . next _feed ) {
2012-06-11 18:56:19 -07:00
NEWSBLUR . app . original _tab _view . load _feed _iframe ( feed . id ) ;
2010-11-24 13:16:10 -05:00
}
2012-01-16 17:55:13 -08:00
} , this ) , options . delay || 0 ) ;
2010-07-06 18:30:16 -04:00
} else {
2012-06-11 18:56:19 -07:00
NEWSBLUR . app . original _tab _view . unload _feed _iframe ( ) ;
2012-10-01 17:24:08 -07:00
NEWSBLUR . app . story _tab _view . unload _story _iframe ( ) ;
2013-01-08 19:29:02 -08:00
NEWSBLUR . app . text _tab _view . unload ( ) ;
2010-07-06 18:30:16 -04:00
this . flags [ 'iframe_prevented_from_loading' ] = true ;
}
2010-12-02 11:09:09 -05:00
this . setup _mousemove _on _views ( ) ;
2024-04-30 18:18:14 -04:00
2012-02-10 19:33:31 -08:00
if ( ! options . silent ) {
2012-06-14 17:21:51 -07:00
var feed _title = feed . get ( 'feed_title' ) || '' ;
var slug = _ . string . words ( _ . string . clean ( feed _title . replace ( /[^a-z0-9\. ]/ig , '' ) ) ) . join ( '-' ) . toLowerCase ( ) ;
2012-05-19 10:29:27 -07:00
var url = "site/" + feed . id + "/" + slug ;
2017-06-07 18:49:11 -07:00
if ( window . location . search . length ) {
url = url + window . location . search ;
}
2012-02-10 19:33:31 -08:00
if ( ! _ . string . include ( window . location . pathname , url ) ) {
2012-10-26 18:10:23 -07:00
NEWSBLUR . log ( [ "Navigating to url" , url ] ) ;
2012-02-10 19:33:31 -08:00
NEWSBLUR . router . navigate ( url ) ;
}
}
2010-06-08 11:19:41 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
post _open _feed : function ( e , data , first _load ) {
2010-10-06 20:26:42 -04:00
if ( ! data ) {
2012-07-10 15:26:34 -07:00
NEWSBLUR . log ( [ "No data from feed, trying again..." ] ) ;
2024-04-30 18:18:14 -04:00
return this . open _feed ( this . active _feed , { force : true } ) ;
2010-10-06 20:26:42 -04:00
}
2010-06-08 11:19:41 -04:00
var stories = data . stories ;
var tags = data . tags ;
2010-10-25 20:44:52 -04:00
var feed _id = data . feed _id ;
2024-04-30 18:18:14 -04:00
2011-01-14 00:59:51 -05:00
if ( data . dupe _feed _id && this . active _feed == data . dupe _feed _id ) {
this . active _feed = data . feed _id ;
}
2024-04-30 18:18:14 -04:00
2011-06-07 12:57:14 -04:00
this . flags [ 'opening_feed' ] = false ;
2016-11-16 21:07:19 -08:00
this . load _next _after _load ( ) ;
2013-02-11 12:48:20 -08:00
NEWSBLUR . app . story _titles _header . show _feed _hidden _story _title _indicator ( first _load ) ;
2013-04-25 13:01:36 -07:00
// this.show_story_titles_above_intelligence_level({'animate': false});
2011-06-07 12:57:14 -04:00
if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
this . show _next _unread _story ( true ) ;
2011-11-02 09:43:06 -07:00
} else if ( this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] ) {
this . show _last _unread _story ( true ) ;
2012-06-13 15:09:19 -07:00
} else if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
2011-06-07 12:57:14 -04:00
}
this . flags [ 'story_titles_loaded' ] = true ;
2012-06-19 11:20:42 -07:00
if ( first _load ) {
2012-09-21 11:36:27 -07:00
this . find _story _with _action _preference _on _open _feed ( ) ;
2013-07-08 20:41:45 -07:00
this . position _mouse _indicator ( ) ;
2024-04-30 18:18:14 -04:00
2013-01-08 18:33:30 -08:00
if ( _ . contains ( [ 'story' , 'text' ] , this . story _view ) &&
2012-09-21 11:36:27 -07:00
! this . active _story &&
2015-02-06 13:28:55 -08:00
_ . contains ( [ 'split' , 'full' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
2012-06-19 11:20:42 -07:00
! this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
2013-07-04 01:10:38 -07:00
if ( this . story _view == 'text' ) {
NEWSBLUR . app . text _tab _view . show _explainer _single _story _mode ( ) ;
} else if ( this . story _view == 'story' ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . story _tab _view . show _explainer _single _story _mode ( ) ;
2013-07-04 01:10:38 -07:00
}
2011-03-15 23:42:27 -04:00
}
2010-06-08 11:19:41 -04:00
}
2012-09-21 11:36:27 -07:00
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _progress _bar ( ) ;
2012-09-17 12:29:46 -07:00
if ( NEWSBLUR . Globals . is _anonymous ) {
this . show _tryout _signup _button ( ) ;
} else if ( this . flags [ 'showing_feed_in_tryfeed_view' ] ) {
2011-06-07 12:57:14 -04:00
this . show _tryfeed _add _button ( ) ;
2012-04-19 22:38:00 -07:00
this . correct _tryfeed _title ( ) ;
2011-06-07 12:57:14 -04:00
}
2011-12-24 14:45:19 -08:00
} ,
2024-04-30 18:18:14 -04:00
load _next _after _load : function ( ) {
2016-11-16 21:07:19 -08:00
if ( this . flags [ 'loaded_next_after_load' ] ) return ;
this . flags [ 'loaded_next_after_load' ] = true ;
2024-04-30 18:18:14 -04:00
2016-11-16 21:07:19 -08:00
var next = $ . getQueryString ( 'next' ) || $ . getQueryString ( 'test' ) ;
2020-06-08 20:40:45 -04:00
var add _url = $ . getQueryString ( 'add' ) || $ . getQueryString ( 'url' ) ;
2016-11-16 21:07:19 -08:00
var story = $ . getQueryString ( 'story' ) ;
if ( next == 'notifications' ) {
2024-04-30 18:18:14 -04:00
_ . defer ( function ( ) {
2016-11-16 21:07:19 -08:00
NEWSBLUR . reader . open _notifications _modal ( NEWSBLUR . assets . active _feed && NEWSBLUR . assets . active _feed . id ) ;
} ) ;
}
2020-06-08 20:40:45 -04:00
if ( add _url ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . reader . open _add _feed _modal ( { url : url } ) ;
2020-06-08 20:40:45 -04:00
}
2016-11-16 21:07:19 -08:00
if ( story ) {
this . flags [ 'select_story_in_feed' ] = story ;
}
2016-11-21 13:02:13 -08:00
// if (window.history.replaceState && !$.getQueryString('test')) {
// // In case this needs to be found again: window.location.href = BACKBONE
// window.history.replaceState({}, null, '/');
// }
2016-11-16 21:07:19 -08:00
} ,
2024-04-30 18:18:14 -04:00
set _correct _story _view _for _feed : function ( feed _id , view ) {
2015-02-10 17:25:45 -08:00
feed _id = feed _id || this . active _feed ;
2016-12-08 16:32:59 -08:00
feed _id = this . active _story _view ( feed _id ) ;
2015-02-10 17:25:45 -08:00
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
2012-05-14 15:26:56 -07:00
var $original _tabs = $ ( '.task_view_page, .task_view_story' ) ;
2012-06-25 17:15:57 -07:00
var $page _tab = $ ( '.task_view_page' ) ;
2012-07-23 18:13:52 -07:00
view = view || NEWSBLUR . assets . view _setting ( feed _id ) ;
2016-12-13 16:29:42 -08:00
// console.log(['set_correct_story_view_for_feed', feed_id, view]);
2024-04-30 18:18:14 -04:00
2013-02-01 16:01:54 -08:00
$original _tabs . removeClass ( 'NB-disabled-page' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-disabled' )
. removeClass ( 'NB-hidden' )
. removeClass ( 'NB-exception-page' ) ;
$original _tabs . each ( function ( ) {
2013-02-01 16:01:54 -08:00
$ ( this ) . tipsy ( 'disable' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
if ( feed && view == 'original' &&
2013-03-04 12:16:22 -08:00
( feed . get ( 'disabled_page' ) ||
2024-04-30 18:18:14 -04:00
NEWSBLUR . utils . is _url _iframe _buster ( feed . get ( 'feed_link' ) ) ) ) {
2012-05-09 12:09:23 -07:00
view = 'feed' ;
2012-05-14 15:26:56 -07:00
$original _tabs . addClass ( 'NB-disabled-page' )
2024-04-30 18:18:14 -04:00
. addClass ( 'NB-disabled' )
. attr ( 'title' , 'The original page has been disabled by the publisher.' )
. tipsy ( {
gravity : 'n' ,
fade : true ,
delayIn : 200
} ) ;
$original _tabs . each ( function ( ) {
2012-05-14 15:26:56 -07:00
$ ( this ) . tipsy ( 'enable' ) ;
} ) ;
2013-02-01 16:01:54 -08:00
} else if ( this . flags . river _view ) {
$page _tab . addClass ( 'NB-disabled' ) ;
2013-04-03 12:37:20 -07:00
$ ( '.NB-taskbar-button.task_view_page' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_feed' ) . addClass ( 'NB-first' ) ;
2012-05-21 14:36:54 -07:00
} else if ( feed && feed . get ( 'has_exception' ) && feed . get ( 'exception_type' ) == 'page' ) {
2012-05-09 12:09:23 -07:00
if ( view == 'page' ) {
view = 'feed' ;
}
$ ( '.task_view_page' ) . addClass ( 'NB-exception-page' ) ;
2010-10-28 18:17:14 -04:00
}
2024-04-30 18:18:14 -04:00
2013-02-08 11:26:29 -08:00
var $split = $ ( ".NB-task-layout-split" ) ;
var $list = $ ( ".NB-task-layout-list" ) ;
2014-12-18 21:17:32 -08:00
var $grid = $ ( ".NB-task-layout-grid" ) ;
2022-02-18 17:52:24 -05:00
var $magazine = $ ( ".NB-task-layout-magazine" ) ;
2013-07-08 17:06:01 -07:00
var $full = $ ( ".NB-task-layout-full" ) ;
2015-02-06 13:28:55 -08:00
var story _layout = NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ;
2014-12-18 21:17:32 -08:00
this . $s . $story _titles [ 0 ] . className = this . $s . $story _titles [ 0 ] . className . replace ( / ?NB-layout-\w+/gi , '' ) ;
this . $s . $story _titles . addClass ( 'NB-layout-' + story _layout ) ;
2024-04-30 18:18:14 -04:00
2013-02-11 13:17:49 -08:00
if ( story _layout == 'list' ) {
2013-02-12 12:07:16 -08:00
$ ( '.NB-taskbar-button.task_view_page' ) . addClass ( 'NB-hidden' ) ;
2013-04-03 12:37:20 -07:00
$ ( '.NB-taskbar-button.task_view_feed' ) . addClass ( 'NB-first' ) ;
2013-02-12 12:07:16 -08:00
$ ( '.NB-taskbar-button.task_view_story' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_text' ) . addClass ( 'NB-last' ) ;
2013-07-08 17:06:01 -07:00
$full . removeClass ( 'NB-active' ) ;
2013-02-08 11:26:29 -08:00
$split . removeClass ( 'NB-active' ) ;
$list . addClass ( 'NB-active' ) ;
2014-12-18 21:17:32 -08:00
$grid . removeClass ( 'NB-active' ) ;
2022-02-18 17:52:24 -05:00
$magazine . removeClass ( 'NB-active' ) ;
2014-12-18 21:17:32 -08:00
} else if ( story _layout == 'grid' ) {
$ ( '.NB-taskbar-button.task_view_page' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_feed' ) . addClass ( 'NB-first' ) ;
$ ( '.NB-taskbar-button.task_view_story' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_text' ) . addClass ( 'NB-last' ) ;
$full . removeClass ( 'NB-active' ) ;
$split . removeClass ( 'NB-active' ) ;
$list . removeClass ( 'NB-active' ) ;
$grid . addClass ( 'NB-active' ) ;
2022-02-18 17:52:24 -05:00
$magazine . removeClass ( 'NB-active' ) ;
} else if ( story _layout == 'magazine' ) {
$ ( '.NB-taskbar-button.task_view_page' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_feed' ) . addClass ( 'NB-first' ) ;
$ ( '.NB-taskbar-button.task_view_story' ) . addClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_text' ) . addClass ( 'NB-last' ) ;
$full . removeClass ( 'NB-active' ) ;
$split . removeClass ( 'NB-active' ) ;
$list . removeClass ( 'NB-active' ) ;
$grid . removeClass ( 'NB-active' ) ;
$magazine . addClass ( 'NB-active' ) ;
2013-02-11 13:17:49 -08:00
} else if ( story _layout == 'split' ) {
2024-04-30 18:18:14 -04:00
if ( ! this . flags . river _view ) {
2013-04-03 12:37:20 -07:00
$ ( '.NB-taskbar-button.task_view_page' ) . removeClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_feed' ) . removeClass ( 'NB-first' ) ;
}
2013-02-12 12:07:16 -08:00
$ ( '.NB-taskbar-button.task_view_story' ) . removeClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_text' ) . removeClass ( 'NB-last' ) ;
2013-07-08 17:06:01 -07:00
$full . removeClass ( 'NB-active' ) ;
2013-02-08 11:26:29 -08:00
$split . addClass ( 'NB-active' ) ;
$list . removeClass ( 'NB-active' ) ;
2014-12-18 21:17:32 -08:00
$grid . removeClass ( 'NB-active' ) ;
2022-02-18 17:52:24 -05:00
$magazine . removeClass ( 'NB-active' ) ;
2013-07-08 17:06:01 -07:00
} else if ( story _layout == 'full' ) {
2024-04-30 18:18:14 -04:00
if ( ! this . flags . river _view ) {
2013-07-08 17:06:01 -07:00
$ ( '.NB-taskbar-button.task_view_page' ) . removeClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_feed' ) . removeClass ( 'NB-first' ) ;
}
$ ( '.NB-taskbar-button.task_view_story' ) . removeClass ( 'NB-hidden' ) ;
$ ( '.NB-taskbar-button.task_view_text' ) . removeClass ( 'NB-last' ) ;
$full . addClass ( 'NB-active' ) ;
$split . removeClass ( 'NB-active' ) ;
$list . removeClass ( 'NB-active' ) ;
2014-12-18 21:17:32 -08:00
$grid . removeClass ( 'NB-active' ) ;
2022-02-18 17:52:24 -05:00
$magazine . removeClass ( 'NB-active' ) ;
2013-02-08 11:26:29 -08:00
}
2013-04-03 12:37:20 -07:00
2013-12-05 16:08:45 -08:00
if ( _ . contains ( [ 'starred' , 'read' ] , feed _id ) ) {
2013-04-03 12:37:20 -07:00
$page _tab . addClass ( 'NB-disabled' ) ;
}
2024-04-30 18:18:14 -04:00
2016-12-13 16:29:42 -08:00
// console.log(['setting reader.story_view', view, " was:", this.story_view]);
2013-04-03 12:37:20 -07:00
this . story _view = view ;
} ,
2024-04-30 18:18:14 -04:00
2013-04-03 12:37:20 -07:00
// ================
// = Story Layout =
// ================
2024-04-30 18:18:14 -04:00
switch _story _layout : function ( story _layout , force ) {
2015-02-06 13:28:55 -08:00
var feed _layout = NEWSBLUR . assets . view _setting ( this . active _feed , 'layout' ) ;
var active _layout = this . story _layout ;
var original _layout = this . story _layout ;
story _layout = story _layout || feed _layout || active _layout ;
2024-04-30 18:18:14 -04:00
2015-02-10 17:04:32 -08:00
// console.log(['switch_story_layout', active_layout, feed_layout, story_layout, this.active_feed, story_layout == active_layout]);
2022-05-02 11:36:58 -04:00
if ( story _layout == active _layout && ! force ) return ;
2024-04-30 18:18:14 -04:00
2015-02-06 13:28:55 -08:00
this . story _layout = story _layout ;
2024-04-30 18:18:14 -04:00
2015-02-06 13:28:55 -08:00
if ( ! this . active _feed ) return ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , { 'layout' : story _layout } ) ;
2015-02-06 13:28:55 -08:00
2013-04-03 12:37:20 -07:00
this . set _correct _story _view _for _feed ( ) ;
2024-04-30 18:18:14 -04:00
this . apply _resizable _layout ( { right _side : true } ) ;
NEWSBLUR . app . story _titles . render ( { immediate : ! ! force } ) ;
2022-04-20 16:52:42 -04:00
2013-02-13 11:40:12 -08:00
if ( story _layout == 'list' ) {
if ( this . active _story ) {
2015-02-10 17:04:32 -08:00
this . active _story . story _title _view . toggle _selected ( ) ;
2013-02-13 11:40:12 -08:00
}
2013-02-11 17:09:38 -08:00
NEWSBLUR . app . story _list . clear ( ) ;
2014-12-18 21:17:32 -08:00
} else if ( story _layout == 'grid' ) {
if ( this . active _story ) {
2015-02-10 17:04:32 -08:00
this . active _story . story _title _view . toggle _selected ( ) ;
2014-12-18 21:17:32 -08:00
}
NEWSBLUR . app . story _list . clear ( ) ;
2022-02-18 17:52:24 -05:00
} else if ( story _layout == 'magazine' ) {
if ( this . active _story ) {
this . active _story . story _title _view . toggle _selected ( ) ;
}
NEWSBLUR . app . story _list . clear ( ) ;
2013-02-13 11:40:12 -08:00
} else if ( story _layout == 'split' ) {
2013-02-11 17:09:38 -08:00
NEWSBLUR . app . story _list . render ( ) ;
2013-02-13 11:40:12 -08:00
if ( this . active _story ) {
2015-05-15 13:37:10 -07:00
NEWSBLUR . app . story _list . show _only _selected _story ( ) ;
2015-02-10 17:04:32 -08:00
this . active _story . story _title _view . toggle _selected ( ) ;
2015-05-15 13:37:10 -07:00
this . active _story . story _view . toggle _selected ( ) ;
2013-02-13 11:40:12 -08:00
}
2013-07-08 17:06:01 -07:00
} else if ( story _layout == 'full' ) {
NEWSBLUR . app . story _list . render ( ) ;
if ( this . active _story ) {
2015-05-15 13:37:10 -07:00
NEWSBLUR . app . story _list . show _only _selected _story ( ) ;
2015-02-10 17:04:32 -08:00
this . active _story . story _title _view . toggle _selected ( ) ;
2015-05-15 13:37:10 -07:00
this . active _story . story _view . toggle _selected ( ) ;
2016-11-17 11:47:39 -08:00
} else {
this . find _story _with _action _preference _on _open _feed ( ) ;
2013-07-08 17:06:01 -07:00
}
2013-02-11 13:42:32 -08:00
}
2024-04-30 18:18:14 -04:00
2013-02-11 17:09:38 -08:00
this . switch _to _correct _view ( ) ;
2013-07-08 18:38:09 -07:00
this . make _feed _title _in _stories ( ) ;
2014-04-07 16:55:08 -07:00
this . add _body _classes ( ) ;
2024-04-30 18:18:14 -04:00
_ . defer ( function ( ) {
2013-02-11 17:09:38 -08:00
NEWSBLUR . app . story _titles . scroll _to _selected _story ( ) ;
NEWSBLUR . app . story _list . scroll _to _selected _story ( ) ;
2013-09-13 17:01:10 -07:00
NEWSBLUR . app . feed _list . scroll _to _selected ( ) ;
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'split' , 'list' , 'grid' , 'magazine' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-07-11 15:09:00 -07:00
NEWSBLUR . app . story _titles . fill _out ( ) ;
} else {
NEWSBLUR . app . story _list . fill _out ( ) ;
}
2013-02-11 17:09:38 -08:00
} ) ;
2013-02-08 11:26:29 -08:00
} ,
2024-04-30 18:18:14 -04:00
2017-03-06 19:55:18 -08:00
// ==================
// = Saved Searches =
// ==================
2024-04-30 18:18:14 -04:00
open _saved _search : function ( options ) {
2017-03-06 19:55:18 -08:00
var search _model = options . search _model ;
var feed _id = search _model . get ( 'feed_id' ) ;
var query = search _model . get ( 'query' ) ;
var feed _model = NEWSBLUR . assets . get _feed ( feed _id ) ;
NEWSBLUR . reader . flags . searching = true ;
NEWSBLUR . reader . flags . search = query ;
options [ 'search' ] = query ;
options [ 'router' ] = true ;
search _model . set ( 'selected' , true ) ;
2017-03-06 20:34:20 -08:00
options . feed = options . search _model ;
2024-04-30 18:18:14 -04:00
2017-03-06 19:55:18 -08:00
if ( feed _id == 'river:' ) {
2017-03-06 20:34:20 -08:00
this . open _river _stories ( options . $feed , feed _model , options ) ;
2017-11-05 14:32:16 -08:00
} else if ( feed _id == 'river:infrequent' ) {
options . infrequent = NEWSBLUR . assets . preference ( 'infrequent_stories_per_month' ) ;
this . open _river _stories ( options . $feed , feed _model , options ) ;
2017-03-06 19:55:18 -08:00
} else if ( _ . string . startsWith ( feed _id , 'river:' ) ) {
2017-03-06 20:34:20 -08:00
this . open _river _stories ( options . $feed , feed _model , options ) ;
2017-03-06 19:55:18 -08:00
} else if ( feed _id == "read" ) {
this . open _read _stories ( options ) ;
2017-03-06 21:01:10 -08:00
} else if ( feed _id == 'starred' ) {
this . open _starred _stories ( options ) ;
2017-03-06 19:55:18 -08:00
} else if ( _ . string . startsWith ( feed _id , 'starred:' ) ) {
2017-03-06 20:34:20 -08:00
options . tag = feed _model . tag _slug ( ) ;
2017-03-06 19:55:18 -08:00
this . open _starred _stories ( options ) ;
} else if ( _ . string . startsWith ( feed _id , 'feed:' ) ) {
this . open _feed ( parseInt ( feed _id . replace ( 'feed:' , '' ) , 10 ) , options ) ;
} else if ( _ . string . startsWith ( feed _id , 'social:' ) ) {
2017-03-06 20:34:20 -08:00
this . open _social _stories ( feed _id , options ) ;
2017-03-06 19:55:18 -08:00
}
2024-04-30 18:18:14 -04:00
2017-03-06 19:55:18 -08:00
window . history . replaceState ( { } , "" , $ . updateQueryString ( 'search' , query , window . location . pathname ) ) ;
2024-04-30 18:18:14 -04:00
2017-03-06 19:55:18 -08:00
NEWSBLUR . reader . reload _feed ( options ) ;
NEWSBLUR . app . story _titles _header . show _hidden _story _titles ( ) ;
} ,
2024-04-30 18:18:14 -04:00
2013-12-05 16:08:45 -08:00
// ===================
// = Starred Stories =
// ===================
2024-04-30 18:18:14 -04:00
update _starred _counts : function ( ) {
NEWSBLUR . assets . update _starred _counts ( _ . bind ( function ( data ) {
2016-12-08 16:05:13 -08:00
this . update _starred _count ( ) ;
} , this ) ) ;
} ,
2024-04-30 18:18:14 -04:00
update _starred _count : function ( ) {
2010-12-02 11:09:09 -05:00
var starred _count = this . model . starred _count ;
2011-03-14 21:44:04 -04:00
var $starred _count = $ ( '.NB-feeds-header-count' , this . $s . $starred _header ) ;
var $starred _container = this . $s . $starred _header . closest ( '.NB-feeds-header-container' ) ;
2010-12-02 11:09:09 -05:00
if ( starred _count <= 0 ) {
this . $s . $starred _header . addClass ( 'NB-empty' ) ;
$starred _count . text ( '' ) ;
$starred _container . slideUp ( 350 ) ;
} else if ( starred _count > 0 ) {
$starred _count . text ( starred _count ) ;
this . $s . $starred _header . removeClass ( 'NB-empty' ) ;
$starred _container . slideDown ( 350 ) ;
2010-09-05 18:08:08 -07:00
}
} ,
2024-04-30 18:18:14 -04:00
open _starred _stories : function ( options ) {
2012-04-11 15:53:53 -07:00
options = options || { } ;
2010-12-02 11:09:09 -05:00
var $story _titles = this . $s . $story _titles ;
2024-04-30 18:18:14 -04:00
2012-12-19 14:21:46 -08:00
this . reset _feed ( options ) ;
2010-12-02 11:09:09 -05:00
this . hide _splash _page ( ) ;
2012-04-11 15:53:53 -07:00
if ( options . story _id ) {
2012-06-13 15:09:19 -07:00
this . flags [ 'select_story_in_feed' ] = options . story _id ;
2012-04-11 15:53:53 -07:00
}
2011-03-14 21:44:04 -04:00
2010-12-02 11:09:09 -05:00
this . iframe _scroll = null ;
2013-09-09 15:01:47 -07:00
if ( options . tag && ! options . model ) {
2020-07-10 17:59:11 -04:00
if ( options . tag == 'highlights' ) {
2024-04-30 18:18:14 -04:00
var model = NEWSBLUR . assets . starred _feeds . detect ( function ( feed ) {
2020-07-13 13:05:13 -04:00
return feed . get ( 'is_highlights' ) ;
2020-07-10 17:59:11 -04:00
} ) ;
} else {
2024-04-30 18:18:14 -04:00
var model = NEWSBLUR . assets . starred _feeds . detect ( function ( feed ) {
2020-07-10 17:59:11 -04:00
return feed . tag _slug ( ) == options . tag || feed . get ( 'tag' ) == options . tag ;
} ) ;
}
2013-09-09 15:01:47 -07:00
if ( model ) {
options . model = model ;
options . tag = model . get ( 'tag' ) ;
2020-07-13 13:05:13 -04:00
options . highlights = model . get ( 'is_highlights' ) ;
2020-07-10 17:59:11 -04:00
if ( options . highlights ) options . tag = "highlights" ;
2013-09-09 15:01:47 -07:00
}
}
2020-07-10 17:59:11 -04:00
if ( options . tag == "highlights" ) {
this . active _feed = options . model . id ;
this . flags [ 'starred_tag' ] = "highlights" ;
options . model . set ( 'selected' , true ) ;
} else if ( options . tag ) {
2013-09-09 15:03:46 -07:00
this . active _feed = options . model . id ;
2013-09-09 15:01:47 -07:00
this . flags [ 'starred_tag' ] = options . model . get ( 'tag' ) ;
2017-03-06 20:34:20 -08:00
if ( options . feed ) {
options . feed . set ( 'selected' , true ) ;
} else {
options . model . set ( 'selected' , true ) ;
}
2013-08-23 18:07:13 -07:00
} else {
this . active _feed = 'starred' ;
2017-03-06 21:01:10 -08:00
if ( options . feed ) {
options . feed . set ( 'selected' , true ) ;
} else {
this . $s . $starred _header . addClass ( 'NB-selected' ) ;
}
2013-09-09 15:43:42 -07:00
this . flags [ 'starred_tag' ] = null ;
2013-08-23 18:07:13 -07:00
}
2013-09-09 15:01:47 -07:00
this . flags [ 'starred_view' ] = true ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . addClass ( 'NB-view-river' ) ;
2011-01-19 08:54:59 -05:00
this . flags . river _view = true ;
2024-04-30 18:18:14 -04:00
2010-12-04 21:53:39 -05:00
$ ( '.task_view_page' , this . $s . $taskbar ) . addClass ( 'NB-disabled' ) ;
2012-07-18 20:19:54 -07:00
var explicit _view _setting = this . model . view _setting ( this . active _feed , 'view' ) ;
2012-06-25 17:15:57 -07:00
if ( ! explicit _view _setting || explicit _view _setting == 'page' ) {
2024-04-30 18:18:14 -04:00
explicit _view _setting = 'feed' ;
2010-12-04 13:32:13 -05:00
}
this . set _correct _story _view _for _feed ( this . active _feed , explicit _view _setting ) ;
2010-12-02 11:09:09 -05:00
this . switch _taskbar _view ( this . story _view ) ;
2024-04-30 18:18:14 -04:00
this . switch _story _layout ( ) ;
2010-12-02 11:09:09 -05:00
this . setup _mousemove _on _views ( ) ;
2024-04-30 18:18:14 -04:00
this . make _feed _title _in _stories ( ) ;
2016-01-05 12:40:34 -08:00
NEWSBLUR . app . feed _list . scroll _to _show _selected _folder ( ) ;
2013-08-16 16:02:45 -07:00
if ( ! options . silent ) {
2013-09-09 15:01:47 -07:00
var url = "/saved" ;
if ( options . model ) {
url += "/" + options . model . tag _slug ( ) ;
}
2013-08-16 18:26:56 -07:00
if ( window . location . pathname != url ) {
2013-08-16 16:02:45 -07:00
NEWSBLUR . log ( [ "Navigating to url" , url ] ) ;
NEWSBLUR . router . navigate ( url ) ;
}
}
2016-01-05 12:40:34 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
2024-04-30 18:18:14 -04:00
this . model . fetch _starred _stories ( 1 , this . flags [ 'starred_tag' ] , this . flags [ 'starred_tag' ] == 'highlights' , _ . bind ( this . post _open _starred _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , true ) ;
2016-01-05 12:40:34 -08:00
2010-12-02 11:09:09 -05:00
} ,
2024-04-30 18:18:14 -04:00
post _open _starred _stories : function ( data , first _load ) {
2014-05-28 19:17:44 -07:00
if ( ! this . flags [ 'starred_view' ] ) return ;
// NEWSBLUR.log(['post_open_starred_stories', data.stories.length, first_load]);
this . flags [ 'opening_feed' ] = false ;
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
2010-09-14 20:49:28 -04:00
}
2014-05-28 19:17:44 -07:00
if ( first _load ) {
this . find _story _with _action _preference _on _open _feed ( ) ;
}
// this.show_story_titles_above_intelligence_level({'animate': false});
this . flags [ 'story_titles_loaded' ] = true ;
2010-12-02 11:09:09 -05:00
} ,
2024-04-30 18:18:14 -04:00
2013-12-05 16:08:45 -08:00
// =====================
// = Read Stories Feed =
// =====================
2024-04-30 18:18:14 -04:00
open _read _stories : function ( options ) {
2013-12-05 16:08:45 -08:00
options = options || { } ;
var $story _titles = this . $s . $story _titles ;
2024-04-30 18:18:14 -04:00
2013-12-05 16:08:45 -08:00
this . reset _feed ( options ) ;
this . hide _splash _page ( ) ;
this . active _feed = 'read' ;
if ( options . story _id ) {
this . flags [ 'select_story_in_feed' ] = options . story _id ;
}
this . iframe _scroll = null ;
this . $s . $read _header . addClass ( 'NB-selected' ) ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . addClass ( 'NB-view-river' ) ;
2013-12-05 16:08:45 -08:00
this . flags . river _view = true ;
2016-01-05 13:23:48 -08:00
2013-12-05 16:08:45 -08:00
$ ( '.task_view_page' , this . $s . $taskbar ) . addClass ( 'NB-disabled' ) ;
var explicit _view _setting = this . model . view _setting ( this . active _feed , 'view' ) ;
if ( ! explicit _view _setting || explicit _view _setting == 'page' ) {
2016-01-05 13:23:48 -08:00
explicit _view _setting = 'feed' ;
2013-12-05 16:08:45 -08:00
}
this . set _correct _story _view _for _feed ( this . active _feed , explicit _view _setting ) ;
this . switch _taskbar _view ( this . story _view ) ;
2016-01-05 13:23:48 -08:00
this . switch _story _layout ( ) ;
2013-12-05 16:08:45 -08:00
this . setup _mousemove _on _views ( ) ;
2024-04-30 18:18:14 -04:00
this . make _feed _title _in _stories ( ) ;
2016-01-05 13:23:48 -08:00
if ( ! options . silent ) {
var url = "/read" ;
if ( window . location . pathname != url ) {
2016-11-21 13:02:13 -08:00
NEWSBLUR . log ( [ "Navigating to url" , url ] ) ;
2016-01-05 13:23:48 -08:00
NEWSBLUR . router . navigate ( url ) ;
}
}
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2013-12-05 16:08:45 -08:00
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
2024-04-30 18:18:14 -04:00
this . model . fetch _read _stories ( 1 , _ . bind ( this . post _open _read _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , true ) ;
2013-12-05 16:08:45 -08:00
} ,
2024-04-30 18:18:14 -04:00
post _open _read _stories : function ( data , first _load ) {
2013-12-05 16:08:45 -08:00
if ( this . active _feed == 'read' ) {
// NEWSBLUR.log(['post_open_read_stories', data.stories.length, first_load]);
this . flags [ 'opening_feed' ] = false ;
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
}
if ( first _load ) {
this . find _story _with _action _preference _on _open _feed ( ) ;
}
// this.show_story_titles_above_intelligence_level({'animate': false});
this . flags [ 'story_titles_loaded' ] = true ;
}
} ,
2024-04-30 18:18:14 -04:00
2010-12-10 15:26:50 -05:00
// =================
// = River of News =
// =================
2024-04-30 18:18:14 -04:00
open _river _stories : function ( $folder , folder , options ) {
2012-08-02 12:27:15 -07:00
options = options || { } ;
2010-12-10 15:26:50 -05:00
var $story _titles = this . $s . $story _titles ;
2010-12-12 22:52:15 -05:00
$folder = $folder || this . $s . $feed _list ;
2012-08-02 12:27:15 -07:00
var folder _title = folder && folder . get ( 'folder_title' ) || "Everything" ;
2024-04-30 18:18:14 -04:00
2012-09-17 13:24:00 -07:00
this . reset _feed ( options ) ;
2016-11-30 19:27:11 -08:00
if ( options . story _id ) {
this . flags [ 'select_story_in_feed' ] = options . story _id ;
}
2010-12-10 15:26:50 -05:00
this . hide _splash _page ( ) ;
2017-10-16 14:22:37 -07:00
if ( options . infrequent ) {
2017-10-16 14:32:24 -07:00
folder _title = "Infrequent" ;
2017-10-16 14:22:37 -07:00
this . active _feed = 'river:infrequent' ;
2017-11-05 14:32:16 -08:00
if ( options . feed ) {
options . feed . set ( 'selected' , true ) ;
} else {
this . $s . $river _infrequent _header . addClass ( 'NB-selected' ) ;
}
2017-10-16 14:22:37 -07:00
} else if ( ! folder || folder . get ( 'fake' ) || ! folder . get ( 'folder_title' ) ) {
2010-12-12 22:52:15 -05:00
this . active _feed = 'river:' ;
2017-03-06 20:34:20 -08:00
if ( options . feed ) {
options . feed . set ( 'selected' , true ) ;
} else {
this . $s . $river _sites _header . addClass ( 'NB-selected' ) ;
}
2010-12-12 20:06:32 -05:00
} else {
this . active _feed = 'river:' + folder _title ;
2017-03-06 20:34:20 -08:00
if ( options . feed ) {
options . feed . set ( 'selected' , true ) ;
} else {
var folder _view = NEWSBLUR . assets . folders . get _view ( $folder ) ||
2024-04-30 18:18:14 -04:00
this . active _folder && this . active _folder . folder _view ;
2017-03-06 20:34:20 -08:00
folder _view . model . set ( 'selected' , true ) ;
}
2010-12-12 20:06:32 -05:00
}
2013-02-05 16:03:55 -08:00
this . active _folder = folder || NEWSBLUR . assets . folders ;
2024-04-30 18:18:14 -04:00
2010-12-10 15:26:50 -05:00
this . iframe _scroll = null ;
2011-02-01 00:23:44 -05:00
this . flags [ 'opening_feed' ] = true ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . addClass ( 'NB-view-river' ) ;
2011-01-19 08:54:59 -05:00
this . flags . river _view = true ;
2024-04-30 18:18:14 -04:00
2010-12-10 15:26:50 -05:00
$ ( '.task_view_page' , this . $s . $taskbar ) . addClass ( 'NB-disabled' ) ;
2012-07-18 20:19:54 -07:00
var explicit _view _setting = this . model . view _setting ( this . active _feed , 'view' ) ;
2012-01-23 09:42:05 -08:00
if ( ! explicit _view _setting || explicit _view _setting == 'page' ) {
2013-02-05 16:03:55 -08:00
explicit _view _setting = 'feed' ;
2010-12-10 15:26:50 -05:00
}
this . set _correct _story _view _for _feed ( this . active _feed , explicit _view _setting ) ;
this . switch _taskbar _view ( this . story _view ) ;
2015-02-06 13:28:55 -08:00
this . switch _story _layout ( ) ;
2010-12-10 15:26:50 -05:00
this . setup _mousemove _on _views ( ) ;
2012-06-11 21:25:17 -07:00
this . make _feed _title _in _stories ( ) ;
2012-08-02 12:27:15 -07:00
NEWSBLUR . app . feed _list . scroll _to _show _selected _folder ( ) ;
if ( ! options . silent ) {
var slug = folder _title . replace ( / /g , '-' ) . toLowerCase ( ) ;
var url = "folder/" + slug ;
if ( ! _ . string . include ( window . location . pathname , url ) ) {
NEWSBLUR . log ( [ "Navigating to url" , url ] ) ;
NEWSBLUR . router . navigate ( url ) ;
}
}
2024-04-30 18:18:14 -04:00
2013-01-10 12:23:04 -08:00
var visible _only = this . model . view _setting ( this . active _feed , 'read_filter' ) == 'unread' ;
2014-04-15 15:50:29 -07:00
if ( NEWSBLUR . reader . flags . search ) visible _only = false ;
2014-05-28 18:06:52 -07:00
if ( NEWSBLUR . reader . flags . feed _list _showing _starred ) visible _only = false ;
2013-01-10 12:23:04 -08:00
var feeds ;
if ( visible _only ) {
2013-02-05 16:03:55 -08:00
feeds = _ . pluck ( this . active _folder . feeds _with _unreads ( ) , 'id' ) ;
2013-02-14 17:16:47 -08:00
if ( ! feeds . length ) {
feeds = this . active _folder . feed _ids _in _folder ( ) ;
}
2013-01-10 12:23:04 -08:00
} else {
feeds = this . active _folder . feed _ids _in _folder ( ) ;
}
2011-02-04 09:56:15 -05:00
this . cache [ 'river_feeds_with_unreads' ] = feeds ;
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2013-07-08 17:06:01 -07:00
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
2013-07-08 18:59:31 -07:00
// NEWSBLUR.app.taskbar_info.show_stories_progress_bar(feeds.length);
2016-12-01 18:05:41 -08:00
if ( options . dashboard _transfer ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . reset ( options . dashboard _transfer . map ( function ( story ) {
2016-12-02 19:04:48 -08:00
return story . toJSON ( ) ;
} ) ) ;
2016-12-14 14:51:49 -08:00
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
}
2024-04-30 18:18:14 -04:00
this . model . fetch _river _stories ( this . active _feed , feeds , 1 , { 'infrequent' : options . infrequent } ,
2016-12-13 16:29:42 -08:00
_ . bind ( this . post _open _river _stories , this ) , NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
} else {
2024-04-30 18:18:14 -04:00
this . model . fetch _river _stories ( this . active _feed , feeds , 1 , { 'infrequent' : options . infrequent } ,
2016-12-13 16:29:42 -08:00
_ . bind ( this . post _open _river _stories , this ) , NEWSBLUR . app . taskbar _info . show _stories _error , true ) ;
2016-12-01 16:22:51 -08:00
}
2010-12-10 15:26:50 -05:00
} ,
2024-04-30 18:18:14 -04:00
post _open _river _stories : function ( data , first _load ) {
2011-11-15 18:19:09 -08:00
if ( ! data ) {
2024-04-30 18:18:14 -04:00
return NEWSBLUR . app . taskbar _info . show _stories _error ( data ) ;
2011-11-15 18:19:09 -08:00
}
2024-04-30 18:18:14 -04:00
2014-04-24 10:02:29 -07:00
if ( this . active _feed && _ . isString ( this . active _feed ) &&
this . active _feed . indexOf ( 'river:' ) != - 1 ) {
2011-02-01 00:23:44 -05:00
this . flags [ 'opening_feed' ] = false ;
2013-02-11 12:48:20 -08:00
NEWSBLUR . app . story _titles _header . show _feed _hidden _story _title _indicator ( first _load ) ;
2013-04-25 13:01:36 -07:00
// this.show_story_titles_above_intelligence_level({'animate': false});
2010-12-10 15:26:50 -05:00
this . flags [ 'story_titles_loaded' ] = true ;
2011-04-12 11:02:02 -04:00
if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
2011-01-11 19:33:55 -05:00
this . show _next _unread _story ( true ) ;
2011-11-02 09:43:06 -07:00
} else if ( this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] ) {
this . show _last _unread _story ( true ) ;
2012-06-13 15:09:19 -07:00
} else if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
2011-01-11 19:33:55 -05:00
}
2013-07-08 18:59:31 -07:00
// NEWSBLUR.app.taskbar_info.hide_stories_progress_bar(_.bind(function() {
2024-04-30 18:18:14 -04:00
if ( first _load ) {
this . position _mouse _indicator ( ) ;
}
2013-07-08 18:59:31 -07:00
// }, this));
2012-09-17 12:29:46 -07:00
if ( NEWSBLUR . Globals . is _anonymous ) {
this . show _tryout _signup _button ( ) ;
} else if ( first _load ) {
2013-01-09 10:58:43 -08:00
this . find _story _with _action _preference _on _open _feed ( ) ;
2016-12-19 13:14:35 -08:00
if ( NEWSBLUR . assets . preference ( 'feed_view_single_story' ) &&
2013-01-09 10:58:43 -08:00
! this . active _story &&
2016-12-19 13:14:35 -08:00
_ . contains ( [ 'full' ] , NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
2013-01-09 10:58:43 -08:00
! this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
this . show _next _story ( 1 ) ;
}
2012-09-07 15:35:00 -07:00
}
2010-12-10 15:26:50 -05:00
}
} ,
2024-04-30 18:18:14 -04:00
2012-08-07 14:37:07 -07:00
// ===================
// = River Blurblogs =
// ===================
2024-04-30 18:18:14 -04:00
open _river _blurblogs _stories : function ( options ) {
2012-08-07 14:37:07 -07:00
options = options || { } ;
var $story _titles = this . $s . $story _titles ;
2012-11-30 14:28:55 -08:00
var folder _title = options . global ? "Global Blurblogs" : "Blurblogs" ;
2024-04-30 18:18:14 -04:00
2012-09-17 13:24:00 -07:00
this . reset _feed ( options ) ;
2012-08-07 14:37:07 -07:00
this . hide _splash _page ( ) ;
2024-04-30 18:18:14 -04:00
2013-02-05 16:03:55 -08:00
this . active _feed = options . global ? 'river:global' : 'river:blurblogs' ;
2012-09-07 17:52:08 -07:00
this . active _folder = new Backbone . Model ( {
2013-02-05 16:03:55 -08:00
id : this . active _feed ,
2012-11-30 14:28:55 -08:00
folder _title : options . global ? "Global Shared Stories" : "All Shared Stories" ,
2013-10-07 15:00:12 -07:00
fake : true ,
show _options : true
2012-09-07 17:52:08 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
2012-11-30 14:28:55 -08:00
if ( options . global ) {
this . $s . $river _global _header . addClass ( 'NB-selected' ) ;
} else {
this . $s . $river _blurblogs _header . addClass ( 'NB-selected' ) ;
}
2024-04-30 18:18:14 -04:00
2012-08-07 14:37:07 -07:00
this . iframe _scroll = null ;
this . flags [ 'opening_feed' ] = true ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . addClass ( 'NB-view-river' ) ;
2012-08-07 14:37:07 -07:00
this . flags . river _view = true ;
this . flags . social _view = true ;
2012-11-30 14:28:55 -08:00
this . flags . global _blurblogs = options . global ;
2020-12-16 13:09:51 -05:00
if ( options . story _id ) {
this . flags [ 'select_story_in_feed' ] = options . story _id ;
}
2024-04-30 18:18:14 -04:00
2012-08-07 14:37:07 -07:00
$ ( '.task_view_page' , this . $s . $taskbar ) . addClass ( 'NB-disabled' ) ;
var explicit _view _setting = this . model . view _setting ( this . active _feed , 'view' ) ;
if ( ! explicit _view _setting || explicit _view _setting == 'page' ) {
2016-12-08 16:32:59 -08:00
explicit _view _setting = 'feed' ;
2012-08-07 14:37:07 -07:00
}
this . set _correct _story _view _for _feed ( this . active _feed , explicit _view _setting ) ;
this . switch _taskbar _view ( this . story _view ) ;
2015-02-06 13:28:55 -08:00
this . switch _story _layout ( ) ;
2012-08-07 14:37:07 -07:00
this . setup _mousemove _on _views ( ) ;
this . make _feed _title _in _stories ( ) ;
NEWSBLUR . app . feed _list . scroll _to _show _selected _folder ( ) ;
if ( ! options . silent ) {
var slug = folder _title . replace ( / /g , '-' ) . toLowerCase ( ) ;
var url = "folder/" + slug ;
if ( ! _ . string . include ( window . location . pathname , url ) ) {
NEWSBLUR . log ( [ "Navigating to url" , url ] ) ;
NEWSBLUR . router . navigate ( url ) ;
}
}
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2013-07-08 17:06:01 -07:00
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
NEWSBLUR . app . taskbar _info . show _stories _progress _bar ( 100 ) ; // Assume 100 followees for popular
2020-07-15 11:51:03 -04:00
if ( options . dashboard _transfer ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . reset ( options . dashboard _transfer . map ( function ( story ) {
2020-07-15 11:51:03 -04:00
return story . toJSON ( ) ;
} ) ) ;
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
}
2024-04-30 18:18:14 -04:00
this . model . fetch _river _blurblogs _stories ( this . active _feed , 1 ,
{ 'global' : this . flags . global _blurblogs } ,
_ . bind ( this . post _open _river _blurblogs _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2020-07-15 11:51:03 -04:00
} else {
2024-04-30 18:18:14 -04:00
this . model . fetch _river _blurblogs _stories ( this . active _feed , 1 ,
{ 'global' : this . flags . global _blurblogs } ,
_ . bind ( this . post _open _river _blurblogs _stories , this ) ,
2020-07-15 11:51:03 -04:00
NEWSBLUR . app . taskbar _info . show _stories _error , true ) ;
}
2012-08-07 14:37:07 -07:00
} ,
2024-04-30 18:18:14 -04:00
post _open _river _blurblogs _stories : function ( data , first _load ) {
2012-08-07 14:37:07 -07:00
// NEWSBLUR.log(['post_open_river_stories', data, this.active_feed]);
if ( ! data ) {
2024-04-30 18:18:14 -04:00
return NEWSBLUR . app . taskbar _info . show _stories _error ( data ) ;
2012-08-07 14:37:07 -07:00
}
2024-04-30 18:18:14 -04:00
2014-04-24 10:02:29 -07:00
if ( this . active _feed && _ . isString ( this . active _feed ) &&
this . active _feed . indexOf ( 'river:' ) != - 1 ) {
2012-08-07 14:37:07 -07:00
this . flags [ 'opening_feed' ] = false ;
2013-02-11 12:48:20 -08:00
NEWSBLUR . app . story _titles _header . show _feed _hidden _story _title _indicator ( first _load ) ;
2013-04-25 13:01:36 -07:00
// this.show_story_titles_above_intelligence_level({'animate': false});
2012-08-07 14:37:07 -07:00
this . flags [ 'story_titles_loaded' ] = true ;
if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
this . show _next _unread _story ( true ) ;
} else if ( this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] ) {
this . show _last _unread _story ( true ) ;
2012-11-30 15:42:15 -08:00
} else if ( this . counts [ 'select_story_in_feed' ] ||
2024-04-30 18:18:14 -04:00
this . flags [ 'select_story_in_feed' ] ) {
2012-08-07 14:37:07 -07:00
this . select _story _in _feed ( ) ;
}
2012-09-21 11:36:27 -07:00
if ( first _load ) {
this . find _story _with _action _preference _on _open _feed ( ) ;
2013-07-08 20:41:45 -07:00
this . position _mouse _indicator ( ) ;
2012-09-21 11:36:27 -07:00
}
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _progress _bar ( ) ;
2012-09-17 12:29:46 -07:00
if ( NEWSBLUR . Globals . is _anonymous ) {
this . show _tryout _signup _button ( ) ;
}
2012-08-07 14:37:07 -07:00
}
} ,
2024-04-30 18:18:14 -04:00
2012-01-25 09:52:34 -08:00
// ==================
// = Social Stories =
// ==================
2024-04-30 18:18:14 -04:00
open _social _stories : function ( feed _id , options ) {
2012-07-10 15:26:34 -07:00
// NEWSBLUR.log(["open_social_stories", feed_id, options]);
2012-01-31 10:15:11 -08:00
options = options || { } ;
2012-04-11 15:20:57 -07:00
if ( _ . isNumber ( feed _id ) ) feed _id = "social:" + feed _id ;
2024-04-30 18:18:14 -04:00
2012-01-26 08:43:46 -08:00
var feed = this . model . get _feed ( feed _id ) ;
2012-01-25 09:52:34 -08:00
var $story _titles = this . $s . $story _titles ;
2012-01-26 08:43:46 -08:00
var $social _feed = this . find _social _feed _with _feed _id ( feed _id ) ;
2012-06-29 21:06:33 -07:00
if ( ! feed && ! options . try _feed ) {
// Setup tryfeed views first, then come back here.
var socialsub = this . model . add _social _feed ( {
id : feed _id ,
user _id : parseInt ( feed _id . replace ( 'social:' , '' ) , 10 )
} ) ;
return this . load _social _feed _in _tryfeed _view ( socialsub , options ) ;
}
2024-04-30 18:18:14 -04:00
2012-09-18 13:05:48 -07:00
this . reset _feed ( options ) ;
2012-01-25 09:52:34 -08:00
this . hide _splash _page ( ) ;
2024-04-30 18:18:14 -04:00
2012-01-26 08:43:46 -08:00
this . active _feed = feed . id ;
2012-03-14 12:38:59 -07:00
this . next _feed = feed . id ;
2013-02-05 17:46:53 -08:00
this . flags . river _view = false ;
this . flags . social _view = true ;
2012-04-11 15:20:57 -07:00
if ( options . story _id ) {
2012-06-13 15:09:19 -07:00
this . flags [ 'select_story_in_feed' ] = options . story _id ;
2012-04-11 15:20:57 -07:00
}
2024-04-30 18:18:14 -04:00
2012-01-25 09:52:34 -08:00
this . iframe _scroll = null ;
this . flags [ 'opening_feed' ] = true ;
2017-03-06 20:34:20 -08:00
if ( options . feed ) {
2024-04-30 18:18:14 -04:00
options . feed . set ( 'selected' , true , options ) ;
2017-03-06 20:34:20 -08:00
} else {
2024-04-30 18:18:14 -04:00
feed . set ( 'selected' , true , options ) ;
2017-03-06 20:34:20 -08:00
}
2013-07-25 11:10:56 -07:00
this . set _correct _story _view _for _feed ( this . active _feed ) ;
2012-09-07 17:36:12 -07:00
this . make _feed _title _in _stories ( ) ;
2021-04-06 15:04:44 -04:00
this . $s . $layout . addClass ( 'NB-view-river' ) ;
2024-04-30 18:18:14 -04:00
2012-06-25 17:59:01 -07:00
// TODO: Only make feed the default for blurblogs, not overriding an explicit pref.
2013-02-12 13:15:14 -08:00
this . switch _taskbar _view ( this . story _view ) ;
2015-02-06 13:28:55 -08:00
this . switch _story _layout ( ) ;
2012-01-25 09:52:34 -08:00
this . setup _mousemove _on _views ( ) ;
2024-04-30 18:18:14 -04:00
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2013-07-08 17:06:01 -07:00
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
NEWSBLUR . app . taskbar _info . show _stories _progress _bar ( ) ;
2021-01-14 14:16:51 -05:00
if ( options . dashboard _transfer ) {
NEWSBLUR . assets . stories . reset ( options . dashboard _transfer . map ( function ( story ) {
return story . toJSON ( ) ;
} ) ) ;
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
}
this . model . fetch _social _stories ( this . active _feed , 1 ,
_ . bind ( this . post _open _social _stories , this ) , NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
} else {
this . model . fetch _social _stories ( this . active _feed , 1 ,
_ . bind ( this . post _open _social _stories , this ) , NEWSBLUR . app . taskbar _info . show _stories _error , true ) ;
}
2012-05-29 11:48:40 -07:00
if ( this . story _view == 'page' ) {
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2012-06-25 17:15:57 -07:00
if ( ! options . delay || feed . id == this . next _feed ) {
2012-06-11 18:56:19 -07:00
NEWSBLUR . app . original _tab _view . load _feed _iframe ( ) ;
2012-05-29 11:48:40 -07:00
}
} , this ) , options . delay || 0 ) ;
2012-06-25 17:15:57 -07:00
} else {
this . flags [ 'iframe_prevented_from_loading' ] = true ;
2012-05-29 11:48:40 -07:00
}
2012-03-14 12:38:59 -07:00
2012-05-21 14:36:54 -07:00
if ( ! options . silent && feed . get ( 'feed_title' ) ) {
var slug = _ . string . words ( _ . string . clean ( feed . get ( 'feed_title' ) . replace ( /[^a-z0-9\. ]/ig , '' ) ) ) . join ( '-' ) . toLowerCase ( ) ;
var url = "social/" + feed . get ( 'user_id' ) + "/" + slug ;
2012-02-10 19:33:31 -08:00
if ( ! _ . string . include ( window . location . pathname , url ) ) {
2012-06-28 11:00:50 -07:00
var params = { } ;
if ( _ . string . include ( window . location . pathname , "social/" + feed . get ( 'user_id' ) ) ) {
params [ 'replace' ] = true ;
}
2012-10-26 18:10:23 -07:00
NEWSBLUR . log ( [ "Navigating to social" , url , window . location . pathname ] ) ;
2012-06-28 11:00:50 -07:00
NEWSBLUR . router . navigate ( url , params ) ;
2012-02-10 19:33:31 -08:00
}
2012-05-21 14:36:54 -07:00
} else if ( ! feed . get ( 'feed_title' ) ) {
2012-07-10 15:26:34 -07:00
NEWSBLUR . log ( [ "No feed title on social" , feed ] ) ;
2012-03-14 12:38:59 -07:00
NEWSBLUR . router . navigate ( '' ) ;
2012-02-10 19:33:31 -08:00
}
2012-01-25 09:52:34 -08:00
} ,
2024-04-30 18:18:14 -04:00
post _open _social _stories : function ( data , first _load ) {
2012-06-13 15:09:19 -07:00
// NEWSBLUR.log(['post_open_river_stories', data, this.active_feed, this.flags['select_story_in_feed']]);
2012-01-25 09:52:34 -08:00
if ( ! data ) {
2024-04-30 18:18:14 -04:00
return NEWSBLUR . app . taskbar _info . show _stories _error ( data ) ;
2012-01-25 09:52:34 -08:00
}
2024-04-30 18:18:14 -04:00
2012-02-22 09:11:35 -08:00
if ( this . active _feed && NEWSBLUR . utils . is _feed _social ( this . active _feed ) ) {
2012-01-25 09:52:34 -08:00
this . flags [ 'opening_feed' ] = false ;
2013-04-25 13:01:36 -07:00
// this.show_story_titles_above_intelligence_level({'animate': false});
2013-02-11 12:48:20 -08:00
NEWSBLUR . app . story _titles _header . show _feed _hidden _story _title _indicator ( first _load ) ;
2012-01-25 09:52:34 -08:00
this . flags [ 'story_titles_loaded' ] = true ;
2012-06-13 15:09:19 -07:00
if ( this . counts [ 'select_story_in_feed' ] || this . flags [ 'select_story_in_feed' ] ) {
this . select _story _in _feed ( ) ;
2012-04-11 15:20:57 -07:00
} else if ( this . counts [ 'find_next_unread_on_page_of_feed_stories_load' ] ) {
2012-01-25 09:52:34 -08:00
this . show _next _unread _story ( true ) ;
} else if ( this . counts [ 'find_last_unread_on_page_of_feed_stories_load' ] ) {
this . show _last _unread _story ( true ) ;
}
2012-09-21 11:36:27 -07:00
if ( first _load ) {
2022-05-26 12:06:30 -04:00
NEWSBLUR . app . taskbar _info . hide _stories _progress _bar ( ) ;
2012-09-21 11:36:27 -07:00
this . find _story _with _action _preference _on _open _feed ( ) ;
2013-07-08 20:41:45 -07:00
this . position _mouse _indicator ( ) ;
2012-09-21 11:36:27 -07:00
}
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _progress _bar ( ) ;
2012-09-17 12:29:46 -07:00
if ( NEWSBLUR . Globals . is _anonymous ) {
this . show _tryout _signup _button ( ) ;
} else if ( this . flags [ 'showing_social_feed_in_tryfeed_view' ] ) {
2012-03-15 11:33:00 -07:00
this . show _tryfeed _follow _button ( ) ;
2012-05-10 09:45:07 -07:00
this . correct _tryfeed _title ( ) ;
2012-03-15 11:33:00 -07:00
}
2012-01-25 09:52:34 -08:00
}
} ,
2024-04-30 18:18:14 -04:00
find _social _feed _with _feed _id : function ( feed _id ) {
2012-01-26 08:43:46 -08:00
if ( _ . contains ( this . cache . $feed _in _social _feed _list , feed _id ) ) {
return this . cache . $feed _in _social _feed _list [ feed _id ] ;
2012-01-25 09:52:34 -08:00
}
2024-04-30 18:18:14 -04:00
2012-01-25 09:52:34 -08:00
var $social _feeds = this . $s . $social _feeds ;
var $feeds = $ ( [ ] ) ;
2024-04-30 18:18:14 -04:00
$ ( '.feed' , $social _feeds ) . each ( function ( ) {
2012-02-10 19:33:31 -08:00
if ( $ ( this ) . data ( 'id' ) == feed _id ) {
2012-01-25 09:52:34 -08:00
$feeds . push ( $ ( this ) . get ( 0 ) ) ;
}
} ) ;
2024-04-30 18:18:14 -04:00
2012-01-26 08:43:46 -08:00
this . cache . $feed _in _social _feed _list [ feed _id ] = $feeds ;
2024-04-30 18:18:14 -04:00
2012-01-25 09:52:34 -08:00
return $feeds ;
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ==========================
// = Story Pane - All Views =
// ==========================
2024-04-30 18:18:14 -04:00
switch _to _correct _view : function ( options ) {
2013-02-13 11:40:12 -08:00
options = options || { } ;
// NEWSBLUR.log(['Found story', this.story_view, options.found_story_in_page, this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
2013-05-22 18:40:18 -07:00
2015-05-06 19:29:24 -07:00
if ( options . story _not _found ) {
2010-06-14 13:17:38 -04:00
// Story not found, show in feed view with link to page view
if ( this . story _view == 'page' && ! this . flags [ 'page_view_showing_feed_view' ] ) {
2012-07-10 15:26:34 -07:00
// NEWSBLUR.log(['turn on feed view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
2010-06-14 13:17:38 -04:00
this . flags [ 'page_view_showing_feed_view' ] = true ;
2010-12-07 18:52:01 -05:00
this . flags [ 'feed_view_showing_story_view' ] = false ;
2013-01-09 15:36:35 -08:00
this . flags [ 'temporary_story_view' ] = false ;
2024-04-30 18:18:14 -04:00
this . switch _taskbar _view ( 'feed' , { skip _save _type : 'page' } ) ;
2012-06-13 11:28:32 -07:00
NEWSBLUR . app . story _list . show _stories _preference _in _feed _view ( ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
} else if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
2015-05-06 19:29:24 -07:00
( this . story _view == 'page' || this . story _view == 'story' ) ) {
2024-04-30 18:18:14 -04:00
this . switch _taskbar _view ( 'feed' , { skip _save _type : 'layout' } ) ;
2013-05-22 18:40:18 -07:00
} else if ( this . story _view == 'page' && this . flags [ 'page_view_showing_feed_view' ] ) {
// NEWSBLUR.log(['turn off feed view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
this . flags [ 'page_view_showing_feed_view' ] = false ;
this . flags [ 'feed_view_showing_story_view' ] = false ;
this . flags [ 'temporary_story_view' ] = false ;
this . switch _taskbar _view ( 'page' ) ;
} else if ( this . flags [ 'feed_view_showing_story_view' ] ) {
// NEWSBLUR.log(['turn off story view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
this . flags [ 'page_view_showing_feed_view' ] = false ;
this . flags [ 'feed_view_showing_story_view' ] = false ;
this . flags [ 'temporary_story_view' ] = false ;
2024-04-30 18:18:14 -04:00
this . switch _taskbar _view ( this . story _view , { skip _save _type : true } ) ;
2013-05-22 18:40:18 -07:00
} else if ( this . flags [ 'temporary_story_view' ] ) {
// NEWSBLUR.log(['turn off story view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
this . flags [ 'page_view_showing_feed_view' ] = false ;
this . flags [ 'feed_view_showing_story_view' ] = false ;
this . flags [ 'temporary_story_view' ] = false ;
2024-04-30 18:18:14 -04:00
this . switch _taskbar _view ( this . story _view , { skip _save _type : true } ) ;
2010-06-08 11:19:41 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
mark _active _story _read : function ( ) {
2012-09-26 13:49:17 -07:00
if ( ! this . active _story ) return ;
var story _id = this . active _story . id ;
var story = this . model . get _story ( story _id ) ;
if ( this . active _story && ! this . active _story . get ( 'read_status' ) ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2012-09-26 13:49:17 -07:00
} else if ( this . active _story && this . active _story . get ( 'read_status' ) ) {
NEWSBLUR . assets . stories . mark _unread ( story ) ;
}
} ,
2024-04-30 18:18:14 -04:00
maybe _mark _all _as _read : function ( ) {
2015-02-10 18:03:16 -08:00
if ( _ . contains ( [ 'river:blurblogs' , 'river:global' ] , this . active _feed ) ) {
return ;
} else if ( this . flags . social _view ) {
this . mark _feed _as _read ( ) ;
} else if ( this . flags . river _view ) {
if ( this . active _feed == 'river:' && NEWSBLUR . assets . preference ( 'mark_read_river_confirm' ) ) {
2024-04-30 18:18:14 -04:00
this . open _mark _read _modal ( { days : 0 } ) ;
2015-02-10 18:03:16 -08:00
} else {
this . mark _folder _as _read ( ) ;
}
} else if ( ! this . flags . river _view && ! this . flags . social _view ) {
this . mark _feed _as _read ( ) ;
}
} ,
2024-04-30 18:18:14 -04:00
mark _feed _as _read : function ( feed _id , days _back , direction ) {
2010-07-24 00:04:14 -04:00
feed _id = feed _id || this . active _feed ;
2015-08-06 11:45:56 -07:00
2017-01-09 13:02:27 -08:00
this . mark _feeds _as _read ( [ feed _id ] , days _back , direction ) ;
2024-04-30 18:18:14 -04:00
if ( ! direction && NEWSBLUR . assets . preference ( 'markread_nextfeed' ) == 'nextfeed' &&
2015-08-06 11:45:56 -07:00
NEWSBLUR . reader . active _feed == feed _id ) {
this . show _next _feed ( 1 ) ;
}
2010-09-16 10:35:36 -04:00
} ,
2024-04-30 18:18:14 -04:00
mark _folder _as _read : function ( folder , days _back , direction ) {
2013-09-13 15:02:10 -07:00
var folder = folder || this . active _folder ;
2024-04-30 18:18:14 -04:00
var feeds = folder . feed _ids _in _folder ( { unreads _only : true } ) ;
2017-06-06 12:41:05 -07:00
if ( direction ) {
var order = NEWSBLUR . assets . view _setting ( this . active _feed , 'order' ) ;
if ( ( direction == "newer" && order == "oldest" ) || ( direction == "older" && order == "newest" ) ) {
var unread _counts = folder . unread _counts && folder . unread _counts ( ) || folder . folders . unread _counts ( ) ;
var total = unread _counts [ 'nt' ] + unread _counts [ 'ps' ] ;
if ( total > 100 ) {
if ( ! window . confirm ( "This will mark up to " + Inflector . commas ( total ) + " stories as read. Are you sure?" ) ) {
return ;
}
}
}
}
2024-04-30 18:18:14 -04:00
2017-01-09 13:02:27 -08:00
this . mark _feeds _as _read ( feeds , days _back , direction ) ;
2024-04-30 18:18:14 -04:00
2017-01-09 13:02:27 -08:00
if ( ! direction && NEWSBLUR . assets . preference ( 'markread_nextfeed' ) == 'nextfeed' &&
NEWSBLUR . reader . active _folder == folder ) {
this . show _next _feed ( 1 ) ;
}
} ,
2024-04-30 18:18:14 -04:00
mark _feeds _as _read : function ( feeds , days _back , direction ) {
2017-12-15 19:48:51 -08:00
var options = { } ;
2017-01-09 13:02:27 -08:00
var order = NEWSBLUR . assets . view _setting ( this . active _feed , 'order' ) ;
var stories _not _visible = true ;
var cutoff _timestamp = parseInt ( NEWSBLUR . utils . days _back _to _timestamp ( days _back ) || 0 , 10 ) ;
2024-04-30 18:18:14 -04:00
if ( ! days _back && this . model . stories . length &&
2013-09-13 15:02:10 -07:00
_ . contains ( feeds , this . model . stories . first ( ) . get ( 'story_feed_id' ) ) &&
2017-01-09 13:02:27 -08:00
order == 'newest' ) {
2013-09-13 15:02:10 -07:00
cutoff _timestamp = this . model . stories . first ( ) . get ( 'story_timestamp' ) ;
2010-09-16 10:35:36 -04:00
}
2024-04-30 18:18:14 -04:00
2017-01-09 15:17:00 -08:00
if ( ( order == 'newest' && direction == 'newer' ) || ( order == 'oldest' && direction == 'older' ) ) {
2024-04-30 18:18:14 -04:00
var stories = this . model . stories . select ( function ( story ) {
2017-01-09 15:17:00 -08:00
return direction == 'newer' ? story . get ( 'story_timestamp' ) >= cutoff _timestamp :
2024-04-30 18:18:14 -04:00
story . get ( 'story_timestamp' ) <= cutoff _timestamp ;
2017-01-09 15:17:00 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
feeds = _ . unique ( _ . map ( stories , function ( story ) { return story . get ( 'story_feed_id' ) ; } ) ) ;
2017-01-09 15:17:00 -08:00
}
2017-01-09 13:02:27 -08:00
2017-12-15 19:48:51 -08:00
if ( this . active _feed == 'river:infrequent' ) options . infrequent = NEWSBLUR . assets . preference ( 'infrequent_stories_per_month' ) ;
this . model . mark _feed _as _read ( feeds , cutoff _timestamp , direction , options ,
2024-04-30 18:18:14 -04:00
_ . bind ( function ( ) {
if ( feeds . length == 1 ) {
this . feed _unread _count ( feeds [ 0 ] ) ;
} else if ( ! this . socket || ! this . socket || ! this . socket . connected ) {
this . force _feeds _refresh ( null , false , feeds ) ;
}
} , this ) ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _story _trainer : function ( story _id , feed _id , options ) {
2012-09-07 19:14:01 -07:00
options = options || { } ;
2012-05-25 20:52:30 -07:00
story _id = story _id || this . active _story && this . active _story . id ;
feed _id = feed _id || ( story _id && this . model . get _story ( story _id ) . get ( 'story_feed_id' ) ) ;
2012-12-12 14:24:51 -08:00
var story = this . model . get _story ( story _id ) ;
2012-09-18 13:08:25 -07:00
// console.log(["open_story_trainer", story_id, feed_id, options]);
2024-04-30 18:18:14 -04:00
2011-10-30 22:15:04 -07:00
if ( story _id && feed _id ) {
2012-09-07 19:14:01 -07:00
options [ 'feed_loaded' ] = ! this . flags [ 'river_view' ] ;
2012-12-28 11:34:06 -08:00
if ( this . flags [ 'social_view' ] ) {
options [ 'feed_loaded' ] = true ;
}
2012-09-18 13:08:25 -07:00
if ( this . flags [ 'social_view' ] && ! _ . string . contains ( this . active _feed , 'river:' ) ) {
2012-09-07 19:14:01 -07:00
options [ 'social_feed_id' ] = this . active _feed ;
2012-12-12 14:24:51 -08:00
} else if ( this . flags [ 'social_view' ] && story . get ( 'friend_user_ids' ) ) {
options [ 'social_feed_id' ] = 'social:' + story . get ( 'friend_user_ids' ) [ 0 ] ;
2012-09-07 19:14:01 -07:00
}
NEWSBLUR . classifier = new NEWSBLUR . ReaderClassifierStory ( story _id , feed _id , options ) ;
2011-10-30 22:15:04 -07:00
}
2010-06-08 11:19:41 -04:00
} ,
2012-04-24 10:38:23 -07:00
2012-06-02 16:33:44 -07:00
// ===========
// = Send To =
// ===========
2024-04-30 18:18:14 -04:00
send _story _to _instapaper : function ( story _id ) {
2010-12-31 10:34:31 -05:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://www.instapaper.com/edit' ;
2011-01-07 16:36:46 -05:00
var instapaper _url = [
2024-04-30 18:18:14 -04:00
url ,
'?url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2011-01-07 16:36:46 -05:00
] . join ( '' ) ;
window . open ( instapaper _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _readitlater : function ( story _id ) {
2011-02-15 21:31:33 -05:00
var story = this . model . get _story ( story _id ) ;
2012-04-17 11:01:52 -07:00
var url = 'https://getpocket.com/save' ;
2011-02-15 21:31:33 -05:00
var readitlater _url = [
2024-04-30 18:18:14 -04:00
url ,
'?url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2011-02-15 21:31:33 -05:00
] . join ( '' ) ;
window . open ( readitlater _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-02-15 21:31:33 -05:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _tumblr : function ( story _id ) {
2012-01-13 10:46:56 -08:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://www.tumblr.com/share' ;
2012-01-13 10:46:56 -08:00
var tumblr _url = [
2024-04-30 18:18:14 -04:00
url ,
'?v=3&u=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&t=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2012-01-13 10:46:56 -08:00
] . join ( '' ) ;
window . open ( tumblr _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2012-01-13 10:46:56 -08:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _blogger : function ( story _id ) {
2015-07-23 12:48:00 -07:00
var story = this . model . get _story ( story _id ) ;
var url = 'https://www.blogger.com/blog-this.g' ;
var blogger _url = [
2024-04-30 18:18:14 -04:00
url ,
'?n=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&source=newsblur&b=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) )
2015-07-23 12:48:00 -07:00
] . join ( '' ) ;
window . open ( blogger _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2015-07-23 12:48:00 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _delicious : function ( story _id ) {
2012-05-06 16:26:54 -07:00
var story = this . model . get _story ( story _id ) ;
var url = 'http://www.delicious.com/save' ;
var delicious _url = [
2024-04-30 18:18:14 -04:00
url ,
'?v=6&url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2012-05-06 16:26:54 -07:00
] . join ( '' ) ;
window . open ( delicious _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2012-05-06 16:26:54 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _twitter : function ( story _id ) {
2011-02-04 00:22:58 -05:00
var story = this . model . get _story ( story _id ) ;
2024-11-13 23:18:09 -08:00
var url = 'https://x.com/intent/post' ;
2011-02-04 00:22:58 -05:00
var twitter _url = [
2024-04-30 18:18:14 -04:00
url ,
'?text=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&via=NewsBlur'
2011-02-04 00:22:58 -05:00
] . join ( '' ) ;
window . open ( twitter _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-02-04 00:22:58 -05:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _facebook : function ( story _id ) {
2011-02-04 00:22:58 -05:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://www.facebook.com/sharer/sharer.php' ;
2011-02-04 00:22:58 -05:00
var facebook _url = [
2024-04-30 18:18:14 -04:00
url ,
'?u=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&t=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2011-02-04 00:22:58 -05:00
] . join ( '' ) ;
window . open ( facebook _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-02-04 00:22:58 -05:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _pinboard : function ( story _id ) {
2011-11-07 18:21:38 -08:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://pinboard.in/add/?' ;
2011-11-07 18:21:38 -08:00
var pinboard _url = [
2024-04-30 18:18:14 -04:00
url ,
'url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&tags=' ,
encodeURIComponent ( story . get ( 'story_tags' ) . join ( ', ' ) )
2011-11-07 18:21:38 -08:00
] . join ( '' ) ;
window . open ( pinboard _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-11-07 18:21:38 -08:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _raindrop : function ( story _id ) {
2022-06-09 09:44:29 -07:00
var story = this . model . get _story ( story _id ) ;
var url = 'https://app.raindrop.io/add?' ;
var raindrop _url = [
2024-04-30 18:18:14 -04:00
url ,
'link=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&tags=' ,
encodeURIComponent ( story . get ( 'story_tags' ) . join ( ', ' ) )
2022-06-09 09:44:29 -07:00
] . join ( '' ) ;
window . open ( raindrop _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2022-06-09 09:44:29 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _pinterest : function ( story _id ) {
2013-10-16 11:49:49 -07:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://www.pinterest.com/pin/find/?' ;
2013-10-16 11:49:49 -07:00
var pinterest _url = [
2024-04-30 18:18:14 -04:00
url ,
'url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) )
2013-10-16 11:49:49 -07:00
] . join ( '' ) ;
window . open ( pinterest _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2013-10-16 11:49:49 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _buffer : function ( story _id ) {
2013-08-12 16:01:50 -07:00
var story = this . model . get _story ( story _id ) ;
var url = 'https://bufferapp.com/add?source=newsblur&' ;
var buffer _url = [
2024-04-30 18:18:14 -04:00
url ,
'url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&text=' ,
encodeURIComponent ( story . get ( 'story_title' ) )
2013-08-12 16:01:50 -07:00
] . join ( '' ) ;
window . open ( buffer _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2013-08-12 16:01:50 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _diigo : function ( story _id ) {
2012-06-27 12:49:40 -07:00
var story = this . model . get _story ( story _id ) ;
2018-09-05 20:13:26 +02:00
var url = 'https://www.diigo.com/post?' ;
2012-06-27 12:49:40 -07:00
var url = [
2024-04-30 18:18:14 -04:00
url ,
'url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&tags=' ,
encodeURIComponent ( story . get ( 'story_tags' ) . join ( ', ' ) )
2012-06-27 12:49:40 -07:00
] . join ( '' ) ;
window . open ( url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2012-06-27 12:49:40 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _evernote : function ( story _id ) {
2012-06-27 12:49:40 -07:00
var story = this . model . get _story ( story _id ) ;
var url = 'https://www.evernote.com/clip.action?' ;
var url = [
2024-04-30 18:18:14 -04:00
url ,
'url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&tags=' ,
encodeURIComponent ( story . get ( 'story_tags' ) . join ( ', ' ) )
2012-06-27 12:49:40 -07:00
] . join ( '' ) ;
window . open ( url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2012-06-27 12:49:40 -07:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _googleplus : function ( story _id ) {
2011-11-07 18:21:38 -08:00
var story = this . model . get _story ( story _id ) ;
2013-03-23 18:19:55 -07:00
var url = 'https://plus.google.com/share' ;
2011-11-07 18:21:38 -08:00
var googleplus _url = [
2024-04-30 18:18:14 -04:00
url ,
'?url=' ,
encodeURIComponent ( story . get ( 'story_permalink' ) ) ,
'&title=' ,
encodeURIComponent ( story . get ( 'story_title' ) ) ,
'&tags=' ,
encodeURIComponent ( story . get ( 'story_tags' ) . join ( ', ' ) )
2011-11-07 18:21:38 -08:00
] . join ( '' ) ;
window . open ( googleplus _url , '_blank' ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-11-07 18:21:38 -08:00
} ,
2024-04-30 18:18:14 -04:00
send _story _to _email : function ( story ) {
2012-08-01 18:52:54 -07:00
NEWSBLUR . reader _send _email = new NEWSBLUR . ReaderSendEmail ( story ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . stories . mark _read ( story , { skip _delay : true } ) ;
2011-05-03 11:40:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
2012-06-08 16:02:03 -07:00
// ===========
// = Stories =
// ===========
2024-04-30 18:18:14 -04:00
load _page _of _feed _stories : function ( options ) {
options = _ . extend ( { } , { 'scroll_to_loadbar' : true } , options ) ;
2010-06-14 13:17:38 -04:00
var $story _titles = this . $s . $story _titles ;
2012-05-25 16:42:41 -07:00
var feed _id = this . active _feed ;
var feed = this . model . get _feed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
2022-05-16 17:21:46 -04:00
// console.log(['load_page_of_feed_stories', this.flags['opening_feed'], this.counts['page']]);
2013-06-20 15:16:55 -07:00
if ( this . flags [ 'opening_feed' ] ) return ;
this . flags [ 'opening_feed' ] = true ;
this . counts [ 'page' ] += 1 ;
2015-02-06 13:28:55 -08:00
if ( NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) == 'full' ) {
2013-07-08 17:06:01 -07:00
NEWSBLUR . app . story _list . show _loading ( options ) ;
} else {
NEWSBLUR . app . story _titles . show _loading ( options ) ;
}
2024-04-30 18:18:14 -04:00
2017-11-05 14:01:25 -08:00
if ( this . active _feed == 'river:infrequent' ) options . infrequent = NEWSBLUR . assets . preference ( 'infrequent_stories_per_month' ) ;
2024-04-30 18:18:14 -04:00
2013-08-23 18:07:13 -07:00
if ( this . flags [ 'starred_view' ] ) {
2020-07-10 17:59:11 -04:00
this . model . fetch _starred _stories ( this . counts [ 'page' ] , this . flags [ 'starred_tag' ] , this . flags [ 'starred_tag' ] == 'highlights' , _ . bind ( this . post _open _starred _stories , this ) ,
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2013-12-05 16:08:45 -08:00
} else if ( this . active _feed == 'read' ) {
this . model . fetch _read _stories ( this . counts [ 'page' ] , _ . bind ( this . post _open _read _stories , this ) ,
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2013-06-20 15:16:55 -07:00
} else if ( this . flags [ 'social_view' ] && _ . contains ( [ 'river:blurblogs' , 'river:global' ] , this . active _feed ) ) {
this . model . fetch _river _blurblogs _stories ( this . active _feed ,
2024-04-30 18:18:14 -04:00
this . counts [ 'page' ] ,
{ 'global' : this . flags . global _blurblogs } ,
_ . bind ( this . post _open _river _blurblogs _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2013-06-20 15:16:55 -07:00
} else if ( this . flags [ 'social_view' ] ) {
this . model . fetch _social _stories ( this . active _feed ,
2024-04-30 18:18:14 -04:00
this . counts [ 'page' ] , _ . bind ( this . post _open _social _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2013-06-20 15:16:55 -07:00
} else if ( this . flags [ 'river_view' ] ) {
this . model . fetch _river _stories ( this . active _feed , this . cache [ 'river_feeds_with_unreads' ] ,
2024-04-30 18:18:14 -04:00
this . counts [ 'page' ] , { 'infrequent' : options . infrequent } ,
_ . bind ( this . post _open _river _stories , this ) ,
NEWSBLUR . app . taskbar _info . show _stories _error , false ) ;
2013-06-20 15:16:55 -07:00
} else {
2024-04-30 18:18:14 -04:00
this . model . load _feed ( feed _id , this . counts [ 'page' ] , false ,
$ . rescope ( this . post _open _feed , this ) , NEWSBLUR . app . taskbar _info . show _stories _error ) ;
2010-06-11 20:55:38 -04:00
}
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
make _feed _title _in _stories : function ( options ) {
2017-03-03 15:43:41 -05:00
NEWSBLUR . app . search _header . render ( ) ;
2024-04-30 18:18:14 -04:00
2013-07-25 17:05:32 -07:00
if ( ( this . flags . search || this . flags . searching )
2016-01-13 15:38:55 -08:00
&& NEWSBLUR . app . story _titles _header . search _has _focus ( ) ) {
console . log ( [ "make_feed_title_in_stories not destroying" , this . flags . search ] ) ;
2012-12-19 14:21:46 -08:00
return ;
}
2024-04-30 18:18:14 -04:00
2012-09-07 17:36:12 -07:00
if ( NEWSBLUR . app . story _titles _header ) {
2013-01-14 12:50:00 -08:00
NEWSBLUR . app . story _titles _header . remove ( ) ;
2012-06-11 21:25:17 -07:00
}
2012-12-19 14:21:46 -08:00
2013-09-17 12:18:34 -07:00
NEWSBLUR . app . story _titles _header . render ( {
2013-07-08 17:06:01 -07:00
feed _id : this . active _feed ,
2015-02-06 13:28:55 -08:00
layout : NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' )
2013-09-17 12:18:34 -07:00
} ) ;
2010-11-01 18:20:26 -04:00
} ,
2024-04-30 18:18:14 -04:00
feed _title : function ( feed _id ) {
2020-12-08 18:14:09 -05:00
if ( ! feed _id ) {
feed _id = this . active _feed ;
}
var feed _title ;
if ( feed _id == 'river:' ) {
feed _title = "All Site Stories" ;
} else if ( feed _id == 'river:global' ) {
feed _title = "Global Shared Stories" ;
} else if ( feed _id == 'river:blurblogs' ) {
feed _title = "All Shared Stories" ;
} else if ( feed _id == 'river:infrequent' ) {
feed _title = "Infrequent Site Stories" ;
} else if ( _ . string . startsWith ( feed _id , 'river:' ) ) {
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
if ( ! feed ) return ;
feed _title = feed . get ( 'folder_title' ) ;
} else if ( feed _id == "read" ) {
feed _title = "Read Stories" ;
} else if ( _ . string . startsWith ( feed _id , 'starred' ) ) {
feed _title = "Saved Stories" ;
var tag = feed _id . replace ( 'starred:' , '' ) ;
2024-04-30 18:18:14 -04:00
var model = NEWSBLUR . assets . starred _feeds . detect ( function ( feed ) {
2020-12-08 18:14:09 -05:00
return feed . tag _slug ( ) == tag || feed . get ( 'tag' ) == tag ;
} ) ;
if ( model && model . get ( 'tag' ) ) {
feed _title = feed _title + " - " + model . get ( 'tag' ) ;
} else if ( model && model . get ( 'feed_title' ) ) {
feed _title = feed _title + " - " + model . get ( 'feed_title' ) ;
2017-03-03 15:43:41 -05:00
}
2020-12-17 18:21:45 -05:00
} else if ( _ . string . startsWith ( feed _id , 'feed:' ) || _ . isNumber ( feed _id ) ) {
if ( ! _ . isNumber ( feed _id ) ) {
feed _id = parseInt ( feed _id . replace ( 'feed:' , '' ) , 10 ) ;
}
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
2020-12-08 18:14:09 -05:00
if ( ! feed ) return ;
2024-04-30 18:18:14 -04:00
2020-12-08 18:14:09 -05:00
feed _title = feed . get ( 'feed_title' ) ;
2024-04-30 18:18:14 -04:00
} else if ( _ . string . startsWith ( feed _id , 'social:' ) ) {
2020-12-08 18:14:09 -05:00
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
if ( ! feed ) return ;
2024-04-30 18:18:14 -04:00
2022-06-01 16:04:19 -04:00
feed _title = feed . get ( 'feed_title' ) ;
2024-04-30 18:18:14 -04:00
} else if ( _ . string . startsWith ( feed _id , 'search:' ) ) {
2022-06-01 16:04:19 -04:00
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
if ( ! feed ) return ;
2024-04-30 18:18:14 -04:00
2020-12-08 18:14:09 -05:00
feed _title = feed . get ( 'feed_title' ) ;
2017-03-03 15:43:41 -05:00
}
2024-04-30 18:18:14 -04:00
2020-12-08 18:14:09 -05:00
return feed _title ;
2017-03-03 15:43:41 -05:00
} ,
2024-04-30 18:18:14 -04:00
open _feed _intelligence _modal : function ( score , feed _id , feed _loaded ) {
2010-09-12 13:50:27 -04:00
feed _id = feed _id || this . active _feed ;
2024-04-30 18:18:14 -04:00
2011-10-30 22:17:16 -07:00
if ( feed _id ) {
NEWSBLUR . classifier = new NEWSBLUR . ReaderClassifierFeed ( feed _id , {
'score' : score ,
'feed_loaded' : feed _loaded
} ) ;
}
2010-08-01 23:47:40 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _trainer _modal : function ( score ) {
2010-08-01 23:47:40 -04:00
var feed _id = this . active _feed ;
2010-08-01 19:12:42 -04:00
// NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierFeed(feed_id, {'score': score});
2024-04-30 18:18:14 -04:00
NEWSBLUR . classifier = new NEWSBLUR . ReaderClassifierTrainer ( { 'score' : score } ) ;
} ,
open _friends _modal : function ( ) {
2012-10-18 11:11:26 -07:00
NEWSBLUR . assets . preference ( 'has_found_friends' , true ) ;
NEWSBLUR . reader . check _hide _getting _started ( ) ;
2011-12-23 18:28:16 -08:00
NEWSBLUR . reader _friends = new NEWSBLUR . ReaderFriends ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _profile _editor _modal : function ( ) {
2012-04-04 16:09:01 -07:00
NEWSBLUR . reader _profile _editor = new NEWSBLUR . ReaderProfileEditor ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _recommend _modal : function ( feed _id ) {
2011-04-07 10:30:05 -04:00
NEWSBLUR . recommend _feed = new NEWSBLUR . ReaderRecommendFeed ( feed _id ) ;
2011-03-28 10:08:10 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _tutorial _modal : function ( ) {
2011-05-10 18:30:35 -04:00
NEWSBLUR . tutorial = new NEWSBLUR . ReaderTutorial ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _intro _modal : function ( options ) {
2012-03-05 19:18:40 -08:00
NEWSBLUR . intro = new NEWSBLUR . ReaderIntro ( options ) ;
2012-03-02 17:51:28 -08:00
} ,
2024-04-30 18:18:14 -04:00
open _user _admin _modal : function ( options ) {
$ . modal . close ( function ( ) {
2013-05-10 14:37:47 -07:00
NEWSBLUR . user _admin = new NEWSBLUR . ReaderUserAdmin ( options ) ;
} ) ;
2013-05-10 12:05:24 -07:00
} ,
2024-04-30 18:18:14 -04:00
open _story _options _popover : function ( ) {
2014-04-07 19:52:26 -07:00
NEWSBLUR . StoryOptionsPopover . create ( {
anchor : this . $s . $taskbar _options
} ) ;
} ,
2024-04-30 18:18:14 -04:00
show _authentication _lost : function ( ) {
2016-12-29 18:40:44 -08:00
NEWSBLUR . auth _lost = new NEWSBLUR . ReaderAuthLost ( ) ;
} ,
2024-04-30 18:18:14 -04:00
check _hide _getting _started : function ( force ) {
2013-02-04 15:14:20 -08:00
var feeds = this . model . preference ( 'has_setup_feeds' ) ;
2012-03-19 14:15:38 -07:00
var friends = this . model . preference ( 'has_found_friends' ) ;
var trained = this . model . preference ( 'has_trained_intelligence' ) ;
2024-04-30 18:18:14 -04:00
2012-03-19 14:15:38 -07:00
if ( force ||
2013-02-04 15:14:20 -08:00
( friends && trained && feeds ) ) {
2011-12-24 00:30:37 -08:00
var $gettingstarted = $ ( '.NB-module-gettingstarted' ) ;
$gettingstarted . animate ( {
2024-04-30 18:18:14 -04:00
'opacity' : 0
} , {
'duration' : 380 ,
'complete' : function ( ) {
$gettingstarted . slideUp ( 350 ) ;
}
} ) ;
this . model . preference ( 'hide_getting_started' , true ) ;
2012-03-19 14:15:38 -07:00
} else {
2013-02-04 15:14:20 -08:00
var $progress = $ ( ".NB-intro-progress" ) ;
var $sites = $ ( '.NB-intro-goal-sites' ) ;
var $findfriends = $ ( '.NB-intro-goal-friends' ) ;
var $trainer = $ ( '.NB-intro-goal-train' ) ;
$sites . toggleClass ( 'NB-done' , feeds ) ;
$findfriends . toggleClass ( 'NB-done' , friends ) ;
$trainer . toggleClass ( 'NB-done' , trained ) ;
2024-04-30 18:18:14 -04:00
2013-02-04 15:14:20 -08:00
$sites . toggleClass ( 'NB-not-done' , ! feeds ) ;
$findfriends . toggleClass ( 'NB-not-done' , ! friends ) ;
$trainer . toggleClass ( 'NB-not-done' , ! trained ) ;
$ ( ".bar-first" , $progress ) . toggleClass ( 'bar-striped' , ! feeds ) ;
$ ( ".bar-second" , $progress ) . toggleClass ( 'bar-striped' , ! friends ) ;
2011-12-24 00:30:37 -08:00
}
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ==========================
// = Story Pane - Feed View =
// ==========================
2024-04-30 18:18:14 -04:00
apply _story _styling : function ( reset _stories ) {
2010-11-25 15:34:06 -05:00
var $body = this . $s . $body ;
2014-04-08 15:02:01 -07:00
$body . removeClass ( 'NB-theme-sans-serif' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-theme-serif' )
. removeClass ( 'NB-theme-gotham' )
. removeClass ( 'NB-theme-sentinel' )
. removeClass ( 'NB-theme-whitney' )
. removeClass ( 'NB-theme-chronicle' ) ;
$body . addClass ( 'NB-theme-' + NEWSBLUR . Preferences [ 'story_styling' ] ) ;
2013-01-06 16:44:15 -08:00
$body . removeClass ( 'NB-theme-size-xs' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-theme-size-s' )
. removeClass ( 'NB-theme-size-m' )
. removeClass ( 'NB-theme-size-l' )
. removeClass ( 'NB-theme-size-xl' ) ;
2013-01-06 16:44:15 -08:00
$body . addClass ( 'NB-theme-size-' + NEWSBLUR . Preferences [ 'story_size' ] ) ;
2014-07-18 17:07:05 -07:00
$body . removeClass ( 'NB-theme-feed-size-xs' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-theme-feed-size-s' )
. removeClass ( 'NB-theme-feed-size-m' )
. removeClass ( 'NB-theme-feed-size-l' )
. removeClass ( 'NB-theme-feed-size-xl' ) ;
2014-07-18 17:07:05 -07:00
$body . addClass ( 'NB-theme-feed-size-' + NEWSBLUR . Preferences [ 'feed_size' ] ) ;
2021-07-07 15:49:36 -04:00
$body . removeClass ( 'NB-theme-feed-font-whitney' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-theme-feed-font-lucida' )
. removeClass ( 'NB-theme-feed-font-gotham' ) ;
2021-07-07 15:49:36 -04:00
$body . addClass ( 'NB-theme-feed-font-' + NEWSBLUR . Preferences [ 'feed_font' ] ) ;
2024-04-30 18:18:14 -04:00
2014-04-08 16:49:11 -07:00
$body . removeClass ( 'NB-line-spacing-xs' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-line-spacing-s' )
. removeClass ( 'NB-line-spacing-m' )
. removeClass ( 'NB-line-spacing-l' )
. removeClass ( 'NB-line-spacing-xl' ) ;
2014-04-08 16:49:11 -07:00
$body . addClass ( 'NB-line-spacing-' + NEWSBLUR . Preferences [ 'story_line_spacing' ] ) ;
2021-01-14 20:13:57 -05:00
2021-07-02 16:11:44 -04:00
$body . removeClass ( 'NB-density-compact' )
. removeClass ( 'NB-density-comfortable' ) ;
$body . addClass ( 'NB-density-' + NEWSBLUR . Preferences [ 'density' ] ) ;
2021-01-14 20:13:57 -05:00
$body . removeClass ( 'NB-content-preview-title' )
. removeClass ( 'NB-content-preview-small' )
. removeClass ( 'NB-content-preview-medium' )
. removeClass ( 'NB-content-preview-large' ) ;
$body . addClass ( 'NB-content-preview-' + NEWSBLUR . Preferences [ 'show_content_preview' ] ) ;
2024-04-30 18:18:14 -04:00
2021-01-14 20:13:57 -05:00
$body . removeClass ( 'NB-image-preview-none' )
2021-04-06 12:15:56 -04:00
. removeClass ( 'NB-image-preview-small-left' )
. removeClass ( 'NB-image-preview-small-right' )
. removeClass ( 'NB-image-preview-large-left' )
. removeClass ( 'NB-image-preview-large-right' ) ;
$body . addClass ( 'NB-image-preview-' + NEWSBLUR . Preferences [ 'image_preview' ] ) ;
2024-04-30 18:18:14 -04:00
2010-11-25 15:34:06 -05:00
if ( reset _stories ) {
2021-01-14 20:13:57 -05:00
this . show _story _titles _above _intelligence _level ( { 'animate' : true , 'follow' : true } ) ;
NEWSBLUR . app . dashboard _rivers . left . redraw ( ) ;
NEWSBLUR . app . dashboard _rivers . right . redraw ( ) ;
2022-05-02 11:36:58 -04:00
NEWSBLUR . app . story _titles . render ( { "immediate" : true } ) ;
this . switch _story _layout ( null , true ) ;
2010-11-25 15:34:06 -05:00
}
2021-07-07 15:49:36 -04:00
this . load _theme ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ===================
// = Taskbar - Story =
// ===================
2024-04-30 18:18:14 -04:00
switch _taskbar _view : function ( view , options ) {
2012-07-23 16:51:27 -07:00
options = options || { } ;
2010-06-14 13:17:38 -04:00
var self = this ;
var $story _pane = this . $s . $story _pane ;
2016-12-08 16:32:59 -08:00
var feed _id = this . active _story _view ( ) ;
var feed = this . model . get _feed ( feed _id ) ;
view = view || this . story _view ;
2021-04-06 19:24:54 -04:00
// NEWSBLUR.log(['switch_taskbar_view', view, options.skip_save_type, feed]);
2024-04-30 18:18:14 -04:00
if ( view == 'page' && feed && feed . get ( 'has_exception' ) &&
2013-02-12 13:15:14 -08:00
feed . get ( 'exception_type' ) == 'page' ) {
2024-04-30 18:18:14 -04:00
this . open _feed _exception _modal ( ) ;
return ;
} else if ( _ . contains ( [ 'page' , 'story' ] , view ) &&
feed && ( feed . get ( 'disabled_page' ) ||
NEWSBLUR . utils . is _url _iframe _buster ( feed . get ( 'feed_link' ) ) ) ) {
2012-05-07 16:26:31 -07:00
view = 'feed' ;
2024-04-30 18:18:14 -04:00
} else if ( $ ( '.task_view_' + view ) . hasClass ( 'NB-disabled' ) ||
$ ( '.task_view_' + view ) . hasClass ( 'NB-hidden' ) ) {
2010-12-04 21:53:39 -05:00
return ;
2022-02-18 17:52:24 -05:00
} else if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
_ . contains ( [ 'page' , 'story' ] , view ) ) {
2013-02-12 13:15:14 -08:00
view = 'feed' ;
2010-12-04 21:53:39 -05:00
}
2024-04-30 18:18:14 -04:00
2013-02-08 11:26:29 -08:00
var $taskbar _buttons = $ ( '.NB-taskbar-view .NB-taskbar-button' ) ;
2010-06-14 13:17:38 -04:00
var $feed _view = this . $s . $feed _view ;
2010-12-06 10:41:24 -05:00
var $feed _iframe = this . $s . $feed _iframe ;
2013-01-10 12:06:57 -08:00
var $to _feed _arrow = $ ( '.NB-taskbar .NB-task-view-to-feed-arrow' ) ;
var $to _story _arrow = $ ( '.NB-taskbar .NB-task-view-to-story-arrow' ) ;
2013-01-09 11:57:47 -08:00
var $to _text _arrow = $ ( '.NB-taskbar .NB-task-view-to-text-arrow' ) ;
2024-04-30 18:18:14 -04:00
2012-07-23 16:51:27 -07:00
if ( ! options . skip _save _type && this . story _view != view ) {
2024-04-30 18:18:14 -04:00
this . model . view _setting ( feed _id , { 'view' : view } ) ;
2010-07-06 14:57:32 -04:00
}
2024-04-30 18:18:14 -04:00
2013-04-08 11:47:21 -07:00
NEWSBLUR . app . taskbar _info . hide _stories _error ( ) ;
2013-01-10 12:06:57 -08:00
$to _feed _arrow . hide ( ) ;
$to _story _arrow . hide ( ) ;
2013-01-09 11:57:47 -08:00
$to _text _arrow . hide ( ) ;
2010-12-06 10:41:24 -05:00
this . flags [ 'page_view_showing_feed_view' ] = false ;
2013-01-09 15:36:35 -08:00
this . flags [ 'feed_view_showing_story_view' ] = false ;
this . flags [ 'temporary_story_view' ] = false ;
2012-07-23 16:51:27 -07:00
if ( options . skip _save _type == 'page' ) {
2013-01-10 12:06:57 -08:00
$to _feed _arrow . show ( ) ;
2010-06-14 13:17:38 -04:00
this . flags [ 'page_view_showing_feed_view' ] = true ;
2012-07-23 16:51:27 -07:00
} else if ( options . skip _save _type == 'story' ) {
2013-01-10 12:06:57 -08:00
$to _story _arrow . show ( ) ;
2010-12-07 09:52:14 -05:00
this . flags [ 'feed_view_showing_story_view' ] = true ;
2013-01-09 11:57:47 -08:00
} else if ( options . skip _save _type == 'text' ) {
$to _text _arrow . show ( ) ;
this . flags [ 'temporary_story_view' ] = true ;
2010-06-14 13:17:38 -04:00
} else {
$taskbar _buttons . removeClass ( 'NB-active' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-taskbar-button.task_view_' + view ) . addClass ( 'NB-active' ) ;
2010-06-14 13:17:38 -04:00
this . story _view = view ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2012-06-11 18:23:59 -07:00
this . flags . scrolling _by _selecting _story _title = true ;
clearInterval ( this . locks . scrolling ) ;
2024-04-30 18:18:14 -04:00
this . locks . scrolling = setTimeout ( function ( ) {
2012-06-11 18:23:59 -07:00
self . flags . scrolling _by _selecting _story _title = false ;
} , 550 ) ;
2010-06-14 13:17:38 -04:00
if ( view == 'page' ) {
2012-07-31 13:04:33 -07:00
// NEWSBLUR.log(["iframe_prevented_from_loading", this.flags['iframe_prevented_from_loading']]);
2010-07-06 18:30:16 -04:00
if ( this . flags [ 'iframe_prevented_from_loading' ] ) {
2012-06-11 18:56:19 -07:00
NEWSBLUR . app . original _tab _view . load _feed _iframe ( ) ;
2010-07-06 18:30:16 -04:00
}
2012-07-23 16:51:27 -07:00
NEWSBLUR . app . original _tab _view . scroll _to _selected _story ( this . active _story , {
immediate : true ,
only _if _hidden : options . resize
} ) ;
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
$story _pane . animate ( {
'left' : 0
} , {
'easing' : 'easeInOutQuint' ,
2011-06-07 12:57:34 -04:00
'duration' : this . model . preference ( 'animations' ) ? 550 : 0 ,
2010-06-14 13:17:38 -04:00
'queue' : false
} ) ;
} else if ( view == 'feed' ) {
2012-07-23 16:51:27 -07:00
NEWSBLUR . app . story _list . scroll _to _selected _story ( this . active _story , {
immediate : true ,
only _if _hidden : options . resize
} ) ;
2012-06-13 11:28:32 -07:00
NEWSBLUR . app . story _list . show _stories _preference _in _feed _view ( ) ;
2013-02-13 16:26:47 -08:00
NEWSBLUR . app . story _titles . scroll _to _selected _story ( this . active _story ) ;
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
$story _pane . animate ( {
2010-12-06 10:41:24 -05:00
'left' : - 1 * $feed _iframe . width ( )
2010-06-14 13:17:38 -04:00
} , {
'easing' : 'easeInOutQuint' ,
2011-06-07 12:57:34 -04:00
'duration' : this . model . preference ( 'animations' ) ? 550 : 0 ,
2010-06-14 13:17:38 -04:00
'queue' : false
} ) ;
2024-04-30 18:18:14 -04:00
2012-06-18 23:51:03 -07:00
NEWSBLUR . app . story _list . reset _story _positions ( ) ;
2024-04-30 18:18:14 -04:00
if ( ! options . resize && this . active _story &&
_ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-02-12 12:07:16 -08:00
NEWSBLUR . app . text _tab _view . unload ( ) ;
2016-06-29 13:24:54 -07:00
if ( this . active _story . get ( 'selected' ) ) {
this . active _story . story _title _view . render _inline _story _detail ( ) ;
}
2013-02-12 12:07:16 -08:00
}
2013-01-10 12:06:57 -08:00
} else if ( view == 'text' ) {
2013-02-13 16:26:47 -08:00
NEWSBLUR . app . story _titles . scroll _to _selected _story ( this . active _story ) ;
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
$story _pane . animate ( {
2010-12-07 09:52:14 -05:00
'left' : - 2 * $feed _iframe . width ( )
2010-06-14 13:17:38 -04:00
} , {
'easing' : 'easeInOutQuint' ,
2011-06-07 12:57:34 -04:00
'duration' : this . model . preference ( 'animations' ) ? 550 : 0 ,
2010-06-14 13:17:38 -04:00
'queue' : false
2010-06-08 11:19:41 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'split' , 'full' ] ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-02-12 13:15:14 -08:00
NEWSBLUR . app . text _tab _view . fetch _and _render ( ) ;
2013-02-12 12:07:16 -08:00
if ( ! this . active _story ) {
2013-07-04 01:10:38 -07:00
NEWSBLUR . app . text _tab _view . show _explainer _single _story _mode ( ) ;
2013-02-12 12:07:16 -08:00
}
2024-04-30 18:18:14 -04:00
} else if ( ! options . resize && this . active _story &&
this . active _story . get ( 'selected' ) &&
_ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-02-12 12:07:16 -08:00
this . active _story . story _title _view . render _inline _story _detail ( ) ;
2011-02-09 19:24:35 -05:00
}
2013-01-10 12:06:57 -08:00
} else if ( view == 'story' ) {
2013-01-08 18:33:30 -08:00
$story _pane . animate ( {
'left' : - 3 * $feed _iframe . width ( )
} , {
'easing' : 'easeInOutQuint' ,
'duration' : this . model . preference ( 'animations' ) ? 550 : 0 ,
'queue' : false
} ) ;
if ( ! this . active _story ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . story _tab _view . show _explainer _single _story _mode ( ) ;
2014-10-30 13:24:24 -07:00
} else if ( ! options . resize ) {
2014-10-29 16:16:50 -07:00
NEWSBLUR . app . story _tab _view . open _story ( ) ;
2013-01-08 18:33:30 -08:00
}
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2012-07-12 13:43:39 -07:00
this . setup _mousemove _on _views ( ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
switch _taskbar _view _direction : function ( direction ) {
2013-01-31 18:24:53 -08:00
var $active = $ ( '.NB-taskbar-view .NB-active' ) ;
2010-06-14 13:17:38 -04:00
var view ;
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'list' , 'grid' , 'magazine' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-02-12 13:15:14 -08:00
if ( direction == - 1 ) {
if ( $active . hasClass ( 'task_view_feed' ) ) {
// view = 'page';
} else if ( $active . hasClass ( 'task_view_text' ) ) {
view = 'feed' ;
2024-04-30 18:18:14 -04:00
}
2013-02-12 13:15:14 -08:00
} else if ( direction == 1 ) {
if ( $active . hasClass ( 'task_view_feed' ) ) {
view = 'text' ;
} else if ( $active . hasClass ( 'task_view_text' ) ) {
// view = 'story';
2024-04-30 18:18:14 -04:00
}
}
2013-02-12 13:15:14 -08:00
} else {
if ( direction == - 1 ) {
if ( $active . hasClass ( 'task_view_page' ) ) {
// view = 'page';
} else if ( $active . hasClass ( 'task_view_feed' ) ) {
view = 'page' ;
} else if ( $active . hasClass ( 'task_view_text' ) ) {
view = 'feed' ;
} else if ( $active . hasClass ( 'task_view_story' ) ) {
view = 'text' ;
2024-04-30 18:18:14 -04:00
}
2013-02-12 13:15:14 -08:00
} else if ( direction == 1 ) {
if ( $active . hasClass ( 'task_view_page' ) ) {
view = 'feed' ;
} else if ( $active . hasClass ( 'task_view_feed' ) ) {
view = 'text' ;
} else if ( $active . hasClass ( 'task_view_text' ) ) {
view = 'story' ;
} else if ( $active . hasClass ( 'task_view_story' ) ) {
// view = 'text';
2024-04-30 18:18:14 -04:00
}
2013-02-12 13:15:14 -08:00
}
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
if ( view ) {
2024-04-30 18:18:14 -04:00
this . switch _taskbar _view ( view ) ;
2010-06-08 11:19:41 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ===================
// = Taskbar - Feeds =
// ===================
2024-04-30 18:18:14 -04:00
open _add _feed _modal : function ( options ) {
2010-06-14 13:17:38 -04:00
clearInterval ( this . flags [ 'bouncing_callout' ] ) ;
2010-08-30 19:57:27 -04:00
$ . modal . close ( ) ;
2024-04-30 18:18:14 -04:00
2020-06-08 20:26:06 -04:00
if ( NEWSBLUR . Globals . is _anonymous && NEWSBLUR . welcome ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . welcome . show _signin _form ( ) ;
2020-06-08 20:26:06 -04:00
} else {
2024-04-30 18:18:14 -04:00
NEWSBLUR . add _feed = NEWSBLUR . ReaderAddFeed . create ( options ) ;
2020-06-08 20:26:06 -04:00
}
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _manage _feed _modal : function ( feed _id ) {
2010-09-12 13:50:27 -04:00
feed _id = feed _id || this . active _feed ;
2024-04-30 18:18:14 -04:00
2010-07-25 23:13:27 -04:00
NEWSBLUR . manage _feed = new NEWSBLUR . ReaderManageFeed ( feed _id ) ;
2010-06-08 11:19:41 -04:00
} ,
2010-10-10 23:36:09 -04:00
2024-04-30 18:18:14 -04:00
open _mark _read _modal : function ( options ) {
2012-08-02 14:01:16 -07:00
NEWSBLUR . mark _read = new NEWSBLUR . ReaderMarkRead ( options ) ;
2010-06-08 11:19:41 -04:00
} ,
2010-10-10 23:36:09 -04:00
2024-04-30 18:18:14 -04:00
open _keyboard _shortcuts _modal : function ( ) {
2010-10-10 23:36:09 -04:00
NEWSBLUR . keyboard = new NEWSBLUR . ReaderKeyboard ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _goodies _modal : function ( ) {
2011-01-20 09:57:23 -05:00
NEWSBLUR . goodies = new NEWSBLUR . ReaderGoodies ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _notifications _modal : function ( feed _id ) {
2016-11-14 19:26:09 -08:00
NEWSBLUR . notifications = new NEWSBLUR . ReaderNotifications ( feed _id ) ;
} ,
2024-04-30 18:18:14 -04:00
open _newsletters _modal : function ( ) {
2016-05-12 14:54:22 -07:00
NEWSBLUR . newsletters = new NEWSBLUR . ReaderNewsletters ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _facebook _modal : function ( ) {
2018-12-24 19:39:42 -05:00
NEWSBLUR . facebook _dialog = new NEWSBLUR . ReaderFacebook ( this . active _story . get ( 'story_permalink' ) , this . active _story . get ( 'shared_comments' ) ) ;
} ,
2024-04-30 18:18:14 -04:00
open _preferences _modal : function ( ) {
2010-07-25 23:13:27 -04:00
NEWSBLUR . preferences = new NEWSBLUR . ReaderPreferences ( ) ;
} ,
2024-04-30 18:18:14 -04:00
open _account _modal : function ( options ) {
2011-09-21 17:49:26 -07:00
NEWSBLUR . account = new NEWSBLUR . ReaderAccount ( options ) ;
2011-07-27 09:33:34 -07:00
} ,
2024-04-30 18:18:14 -04:00
open _feedchooser _modal : function ( options ) {
2013-04-25 17:57:33 -07:00
NEWSBLUR . feedchooser = new NEWSBLUR . ReaderFeedchooser ( options ) ;
2010-09-24 01:08:03 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _organizer _modal : function ( options ) {
2014-07-07 13:22:56 -04:00
NEWSBLUR . organizer = new NEWSBLUR . ReaderOrganizer ( options ) ;
} ,
2024-04-30 18:18:14 -04:00
open _feed _exception _modal : function ( feed _id , options ) {
2012-01-16 17:55:13 -08:00
feed _id = feed _id || this . active _feed ;
2024-04-30 18:18:14 -04:00
2015-08-22 17:36:05 -07:00
NEWSBLUR . feed _exception = new NEWSBLUR . ReaderFeedException ( feed _id , options ) ;
2010-08-18 20:35:45 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _feed _statistics _modal : function ( feed _id ) {
2010-09-12 13:50:27 -04:00
feed _id = feed _id || this . active _feed ;
2024-04-30 18:18:14 -04:00
2010-07-25 23:13:27 -04:00
NEWSBLUR . statistics = new NEWSBLUR . ReaderStatistics ( feed _id ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
open _social _profile _modal : function ( user _id ) {
2012-07-28 19:53:38 -07:00
if ( ! user _id ) user _id = NEWSBLUR . Globals . user _id ;
2012-04-17 15:37:01 -07:00
if ( _ . string . contains ( user _id , 'social:' ) ) {
user _id = parseInt ( user _id . replace ( 'social:' , '' ) , 10 ) ;
}
2012-02-22 09:11:35 -08:00
NEWSBLUR . social _profile = new NEWSBLUR . ReaderSocialProfile ( user _id ) ;
} ,
2024-04-30 18:18:14 -04:00
close _social _profile : function ( ) {
2012-04-19 19:09:31 -07:00
if ( NEWSBLUR . social _profile ) {
NEWSBLUR . social _profile . close ( ) ;
}
} ,
2024-04-30 18:18:14 -04:00
switch _feed _font : function ( feed _font ) {
2021-07-07 15:49:36 -04:00
this . model . preference ( 'feed_font' , feed _font ) ;
this . apply _story _styling ( ) ;
} ,
2024-04-30 18:18:14 -04:00
switch _feed _font _size : function ( feed _size ) {
2021-07-07 15:49:36 -04:00
this . model . preference ( 'feed_size' , feed _size ) ;
this . apply _story _styling ( ) ;
} ,
2024-04-30 18:18:14 -04:00
switch _density : function ( density ) {
2022-06-10 09:44:16 -07:00
this . model . preference ( 'density' , density ) ;
this . apply _story _styling ( ) ;
} ,
2024-04-30 18:18:14 -04:00
switch _theme : function ( theme ) {
2020-06-11 19:25:03 -04:00
this . model . preference ( 'theme' , theme ) ;
2021-07-07 15:49:36 -04:00
this . apply _story _styling ( ) ;
2020-06-11 19:25:03 -04:00
} ,
2024-04-30 18:18:14 -04:00
load _theme : function ( ) {
2020-11-23 18:58:00 -05:00
var theme = NEWSBLUR . assets . theme ( ) ;
var auto _theme = NEWSBLUR . assets . preference ( 'theme' ) ; // Add auto
2024-04-30 18:18:14 -04:00
var feed _font = NEWSBLUR . assets . preference ( 'feed_font' ) ;
var feed _size = NEWSBLUR . assets . preference ( 'feed_size' ) ;
var density = NEWSBLUR . assets . preference ( 'density' ) ;
2020-06-19 11:50:27 -04:00
if ( ! this . flags . watching _system _theme && window . matchMedia ) {
2020-06-23 19:25:59 -04:00
var darkMediaQuery = window . matchMedia ( '(prefers-color-scheme: dark)' ) ;
2020-06-19 11:50:27 -04:00
try {
// Chrome & Firefox
2024-04-30 18:18:14 -04:00
darkMediaQuery . addEventListener ( 'change' , _ . bind ( function ( e ) {
2020-06-24 15:28:22 -04:00
console . log ( [ 'Chrome/FF switching themes' , e ] ) ;
2020-06-19 11:50:27 -04:00
this . load _theme ( ) ;
2020-06-24 15:28:22 -04:00
} , this ) ) ;
2020-06-19 11:50:27 -04:00
} catch ( e1 ) {
try {
// Safari
2024-04-30 18:18:14 -04:00
darkMediaQuery . addListener ( _ . bind ( function ( e ) {
2020-06-24 15:28:22 -04:00
console . log ( [ 'Safari switching themes' , e ] ) ;
2020-06-19 11:50:27 -04:00
this . load _theme ( ) ;
2020-06-24 15:28:22 -04:00
} , this ) ) ;
2020-06-19 11:50:27 -04:00
} catch ( e2 ) {
console . error ( e2 ) ;
}
}
2020-06-19 11:25:01 -04:00
this . flags . watching _system _theme = true ;
}
2024-04-30 18:18:14 -04:00
2021-07-07 15:49:36 -04:00
// Select theme options in manage menu on the dashboard
2020-06-11 19:25:03 -04:00
$ ( '.NB-theme-option' ) . removeClass ( 'NB-active' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-options-theme-' + auto _theme ) . addClass ( 'NB-active' ) ;
2021-07-07 15:49:36 -04:00
$ ( '.NB-feed-font-option' ) . removeClass ( 'NB-active' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-options-feed-font-' + feed _font ) . addClass ( 'NB-active' ) ;
2021-07-07 15:49:36 -04:00
$ ( '.NB-feed-size-option' ) . removeClass ( 'NB-active' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-options-feed-size-' + feed _size ) . addClass ( 'NB-active' ) ;
2022-06-10 09:44:16 -07:00
$ ( '.NB-density-option' ) . removeClass ( 'NB-active' ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-options-density-' + density ) . addClass ( 'NB-active' ) ;
2020-06-11 19:25:03 -04:00
$ ( "body" ) . addClass ( 'NB-theme-transitioning' ) ;
2024-04-30 18:18:14 -04:00
2020-06-11 19:25:03 -04:00
if ( theme == 'dark' ) {
$ ( "body" ) . addClass ( 'NB-dark' ) ;
} else {
$ ( "body" ) . removeClass ( 'NB-dark' ) ;
}
2024-04-30 18:18:14 -04:00
_ . delay ( function ( ) {
2020-06-11 19:25:03 -04:00
$ ( "body" ) . removeClass ( "NB-theme-transitioning" ) ;
} , 2000 ) ;
} ,
2024-04-30 18:18:14 -04:00
close _interactions _popover : function ( ) {
2013-01-30 12:09:58 -08:00
NEWSBLUR . InteractionsPopover . close ( ) ;
} ,
2024-04-30 18:18:14 -04:00
toggle _sidebar : function ( ) {
2012-09-17 11:52:11 -07:00
if ( this . flags [ 'sidebar_closed' ] ) {
this . open _sidebar ( ) ;
return true ;
} else {
this . close _sidebar ( ) ;
return false ;
}
} ,
2024-04-30 18:18:14 -04:00
close _sidebar : function ( ) {
2020-06-10 15:48:40 -04:00
this . layout . outerLayout . hide ( 'west' ) ;
2011-02-22 19:11:29 -05:00
this . resize _window ( ) ;
2011-02-23 18:09:09 -05:00
this . flags [ 'sidebar_closed' ] = true ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . story _titles _header . watch _toggled _sidebar ( ) ;
2011-02-22 19:11:29 -05:00
} ,
2024-04-30 18:18:14 -04:00
open _sidebar : function ( ) {
2020-06-10 15:48:40 -04:00
this . layout . outerLayout . open ( 'west' ) ;
2011-02-22 19:11:29 -05:00
this . resize _window ( ) ;
2011-02-23 18:09:09 -05:00
this . flags [ 'sidebar_closed' ] = false ;
2020-06-10 15:48:40 -04:00
NEWSBLUR . app . story _titles _header . watch _toggled _sidebar ( ) ;
2011-02-22 19:11:29 -05:00
} ,
2024-04-30 18:18:14 -04:00
toggle _story _titles _pane : function ( update _layout ) {
2012-09-07 16:17:28 -07:00
if ( this . flags [ 'story_titles_closed' ] ) {
this . open _story _titles _pane ( update _layout === true ) ;
} else {
this . close _story _titles _pane ( update _layout === true ) ;
}
} ,
2024-04-30 18:18:14 -04:00
close _story _titles _pane : function ( update _layout ) {
2012-08-31 18:46:12 -07:00
var story _anchor = this . model . preference ( 'story_pane_anchor' ) ;
2012-09-07 16:17:28 -07:00
if ( update _layout ) {
2013-03-29 10:58:20 -07:00
NEWSBLUR . reader . layout . contentLayout . hide ( story _anchor ) ;
2012-09-07 16:17:28 -07:00
}
2012-08-31 18:46:12 -07:00
this . resize _window ( ) ;
this . flags [ 'story_titles_closed' ] = true ;
} ,
2024-04-30 18:18:14 -04:00
open _story _titles _pane : function ( update _layout ) {
2012-08-31 18:46:12 -07:00
var story _anchor = this . model . preference ( 'story_pane_anchor' ) ;
2012-09-07 16:17:28 -07:00
if ( update _layout ) {
2013-03-26 12:18:39 -07:00
NEWSBLUR . reader . layout . contentLayout . open ( story _anchor ) ;
2012-09-07 16:17:28 -07:00
}
2012-08-31 18:46:12 -07:00
this . resize _window ( ) ;
this . flags [ 'story_titles_closed' ] = false ;
2024-04-30 18:18:14 -04:00
_ . defer ( function ( ) {
2012-09-07 16:17:28 -07:00
NEWSBLUR . app . story _titles . scroll _to _selected _story ( ) ;
} ) ;
2012-08-31 18:46:12 -07:00
} ,
2024-04-30 18:18:14 -04:00
2010-12-11 17:16:12 -05:00
// =======================
// = Sidebar Manage Menu =
// =======================
2010-10-10 20:14:31 -04:00
2024-04-30 18:18:14 -04:00
make _manage _menu : function ( type , feed _id , story _id , inverse , $item ) {
2010-09-12 13:50:27 -04:00
var $manage _menu ;
2012-07-10 15:26:34 -07:00
// NEWSBLUR.log(["make_manage_menu", type, feed_id, story_id, inverse, $item]);
2012-03-30 14:56:16 -07:00
2010-09-12 13:50:27 -04:00
if ( type == 'site' ) {
2010-10-05 19:05:01 -04:00
var show _chooser = ! NEWSBLUR . Globals . is _premium && NEWSBLUR . Globals . is _authenticated ;
2010-09-12 13:50:27 -04:00
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage' } , [
$ . make ( 'li' , { className : 'NB-menu-manage-site-info' } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2010-09-22 10:12:38 -04:00
$ . make ( 'span' , { className : 'NB-menu-manage-title' } , "Manage NewsBlur" )
2013-04-05 11:46:04 -07:00
] ) . corner ( 'top 8px' ) . corner ( 'bottom 0px' ) ,
2024-04-30 18:18:14 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-mark-read NB-menu-manage-site-mark-read' , role : "button" } , [
2011-07-27 09:33:34 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-05-11 10:06:05 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark everything as read' ) ,
2014-08-12 18:09:58 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'Choose how many days back' )
2012-04-04 16:09:01 -07:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-trainer' , role : "button" } , [
2012-04-04 16:09:01 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-05-11 10:06:05 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Intelligence Trainer' ) ,
2014-08-12 18:09:58 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'Accurate filters are happy filters' )
2012-04-04 16:09:01 -07:00
] ) ,
2021-05-13 15:37:33 -04:00
( show _chooser && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feedchooser' , role : "button" } , [
2011-07-27 22:17:34 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-03-17 10:28:26 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Choose Your 64 sites' ) ,
2014-08-12 18:09:58 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'Enable the sites you want' )
2012-05-11 10:06:05 -07:00
] ) ) ,
2021-05-13 15:37:33 -04:00
( NEWSBLUR . Globals . is _premium && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feedchooser' , role : "button" } , [
2014-06-08 20:42:45 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mute Sites' ) ,
2014-08-12 18:09:58 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'Temporarily turn off feeds' )
2014-06-08 20:42:45 -07:00
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-organizer' , role : "button" } , [
2014-07-07 13:22:56 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Organize Sites' ) ,
2014-08-12 18:09:58 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'Cleanup and rearrange feeds' )
2014-07-07 13:22:56 -04:00
] ) ,
2022-03-16 15:28:52 -04:00
2024-04-30 18:18:14 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-keyboard' , role : "button" } , [
2010-10-10 23:36:09 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Keyboard shortcuts' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-tutorial' , role : "button" } , [
2011-05-09 20:59:52 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-03-02 17:51:28 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Tips & Tricks' )
2011-05-09 20:59:52 -04:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-goodies' , role : "button" } , [
2012-07-05 18:29:38 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-10-23 12:44:10 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Goodies & Mobile Apps' )
2012-07-05 18:29:38 -07:00
] ) ,
2022-05-27 17:24:58 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-statistics' , role : "button" } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Statistics & History' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-notifications' , role : "button" } , [
2016-11-14 19:26:09 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Notifications' )
2017-06-12 17:32:18 -07:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-newsletters' , role : "button" } , [
2016-05-12 14:54:22 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Email Newsletters' )
] ) ,
2021-07-14 17:22:48 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-import' , role : "button" } , [
2013-03-19 13:42:56 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Import or upload sites' )
] ) ,
2024-04-30 18:18:14 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-account' , role : "button" } , [
2010-07-30 23:50:49 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-02-01 12:05:45 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-logout NB-modal-submit-green NB-modal-submit-button' } , 'Logout' ) ,
2012-05-11 10:06:05 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Account' )
2010-09-12 13:50:27 -04:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-profile-editor' , role : "button" } , [
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-10-18 11:11:26 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Profile & Blurblog' )
2010-09-12 13:50:27 -04:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-friends' , role : "button" } , [
2011-01-20 09:57:23 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-10-18 11:11:26 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Friends & Followers' )
2011-01-20 09:57:23 -05:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-preferences' , role : "button" } , [
2010-09-24 01:08:03 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2012-05-11 10:06:05 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Preferences' )
2020-06-10 19:24:02 -04:00
] ) ,
2024-04-30 18:18:14 -04:00
( show _chooser && $ . make ( 'li' , { className : 'NB-menu-separator' } ) ) ,
2022-03-16 15:28:52 -04:00
( show _chooser && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-premium' , role : "button" } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Upgrade to premium' )
] ) ) ,
2024-04-30 18:18:14 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-07-07 15:49:36 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-font' } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'ul' , { className : 'segmented-control NB-options-feed-font' } , [
$ . make ( 'li' , { className : 'NB-feed-font-option NB-options-feed-font-whitney NB-theme-feed-font-whitney' , role : "button" } , [
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Whitney'
] ) ,
$ . make ( 'li' , { className : 'NB-feed-font-option NB-options-feed-font-lucida NB-theme-feed-font-lucida' , role : "button" } , [
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Lucida Grande'
] ) ,
2021-07-07 15:53:58 -04:00
$ . make ( 'li' , { className : 'NB-feed-font-option NB-options-feed-font-gotham NB-theme-feed-font-gotham' , role : "button" } , [
2021-07-07 15:49:36 -04:00
$ . make ( 'div' , { className : 'NB-icon' } ) ,
2021-07-07 15:53:58 -04:00
'Gotham'
2021-07-07 15:49:36 -04:00
] )
] )
] ) ,
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-size' } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'ul' , { className : 'segmented-control NB-options-feed-size' } , [
$ . make ( 'li' , { className : 'NB-feed-size-option NB-options-feed-size-xs' , role : "button" } , 'XS' ) ,
$ . make ( 'li' , { className : 'NB-feed-size-option NB-options-feed-size-s' , role : "button" } , 'S' ) ,
$ . make ( 'li' , { className : 'NB-feed-size-option NB-options-feed-size-m' , role : "button" } , 'M' ) ,
$ . make ( 'li' , { className : 'NB-feed-size-option NB-options-feed-size-l' , role : "button" } , 'L' ) ,
$ . make ( 'li' , { className : 'NB-feed-size-option NB-options-feed-size-xl' , role : "button" } , 'XL' )
] )
] ) ,
2022-06-10 09:44:16 -07:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-density' } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'ul' , { className : 'segmented-control NB-menu-manage-options-density' } , [
$ . make ( 'li' , { className : 'NB-density-option NB-options-density-compact' , role : "button" } , 'Compact' ) ,
$ . make ( 'li' , { className : 'NB-density-option NB-options-density-comfortable NB-active' , role : "button" } , 'Comfortable' )
] )
] ) ,
2020-06-10 19:24:02 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-theme' } , [
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'ul' , { className : 'segmented-control NB-options-theme' } , [
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-theme-option NB-options-theme-light' , role : "button" } , [
2020-06-10 19:24:02 -04:00
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Light'
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-theme-option NB-options-theme-dark' , role : "button" } , [
2020-06-10 19:24:02 -04:00
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Dark'
2020-06-19 11:25:01 -04:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-theme-option NB-options-theme-auto' , role : "button" } , [
2020-06-19 11:25:01 -04:00
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Auto'
2020-06-10 19:24:02 -04:00
] )
] )
2012-05-11 10:06:05 -07:00
] )
2010-09-12 13:50:27 -04:00
] ) ;
$manage _menu . addClass ( 'NB-menu-manage-notop' ) ;
2020-06-16 18:06:19 -04:00
var theme = this . model . preference ( 'theme' ) ;
$ ( ".NB-options-theme-light" , $manage _menu ) . toggleClass ( 'NB-active' , theme == 'light' ) ;
$ ( ".NB-options-theme-dark" , $manage _menu ) . toggleClass ( 'NB-active' , theme == 'dark' ) ;
2020-06-19 11:25:01 -04:00
$ ( ".NB-options-theme-auto" , $manage _menu ) . toggleClass ( 'NB-active' , theme == 'auto' ) ;
2021-07-07 15:49:36 -04:00
var feed _font = this . model . preference ( 'feed_font' ) ;
$ ( ".NB-options-feed-font-whitney" , $manage _menu ) . toggleClass ( 'NB-active' , feed _font == 'whitney' ) ;
$ ( ".NB-options-feed-font-lucida" , $manage _menu ) . toggleClass ( 'NB-active' , feed _font == 'lucida' ) ;
2021-07-07 15:53:58 -04:00
$ ( ".NB-options-feed-font-gotham" , $manage _menu ) . toggleClass ( 'NB-active' , feed _font == 'gotham' ) ;
2021-07-07 15:49:36 -04:00
var feed _size = this . model . preference ( 'feed_size' ) ;
$ ( ".NB-options-feed-size-xs" , $manage _menu ) . toggleClass ( 'NB-active' , feed _size == 'xs' ) ;
$ ( ".NB-options-feed-size-s" , $manage _menu ) . toggleClass ( 'NB-active' , feed _size == 's' ) ;
$ ( ".NB-options-feed-size-m" , $manage _menu ) . toggleClass ( 'NB-active' , feed _size == 'm' ) ;
$ ( ".NB-options-feed-size-l" , $manage _menu ) . toggleClass ( 'NB-active' , feed _size == 'l' ) ;
$ ( ".NB-options-feed-size-xl" , $manage _menu ) . toggleClass ( 'NB-active' , feed _size == 'xl' ) ;
2022-06-10 09:44:16 -07:00
var density = this . model . preference ( 'density' ) ;
$ ( ".NB-options-density-compact" , $manage _menu ) . toggleClass ( 'NB-active' , density == 'compact' ) ;
$ ( ".NB-options-density-comfortable" , $manage _menu ) . toggleClass ( 'NB-active' , density == 'comfortable' ) ;
2010-09-12 13:50:27 -04:00
} else if ( type == 'feed' ) {
2010-09-13 00:38:25 -04:00
var feed = this . model . get _feed ( feed _id ) ;
2010-12-31 14:35:00 -05:00
if ( ! feed ) return ;
2013-07-11 15:09:00 -07:00
var unread _count = this . get _total _unread _count ( feed _id ) ;
2011-01-31 20:08:07 -05:00
var tab _unread _count = Math . min ( 25 , unread _count ) ;
2016-05-09 16:13:40 -07:00
var muted = ! feed . get ( 'active' ) ;
2012-07-18 20:19:54 -07:00
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-feed' } , [
2010-09-13 00:38:25 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ,
2021-05-13 15:37:33 -04:00
( feed . get ( 'has_exception' ) && feed . get ( 'exception_type' ) == 'feed' && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-exception' , role : "button" } , [
2010-09-13 00:38:25 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Fix this misbehaving site' )
] ) ) ,
2017-12-15 18:59:34 -08:00
( feed . get ( 'has_exception' ) && feed . get ( 'exception_type' ) == 'feed' && $ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ) ,
2021-05-13 15:37:33 -04:00
( feed . get ( 'exception_type' ) != 'feed' && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-mark-read NB-menu-manage-feed-mark-read' , role : "button" } , [
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark as read' )
2010-09-13 00:38:25 -04:00
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-reload' , role : "button" } , [
2010-10-10 20:14:31 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Insta-fetch stories' )
] ) ,
2012-07-18 18:34:19 -07:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-stats' , role : "button" } , [
2012-07-25 19:11:59 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Statistics' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-settings' , role : "button" } , [
2014-06-28 08:22:32 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Site settings' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-notifications' , role : "button" } , [
2016-11-14 19:26:09 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Notifications' )
2017-06-12 17:32:18 -07:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-train' , role : "button" } , [
2010-07-24 00:04:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2010-12-30 18:37:29 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Intelligence trainer' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'What you like and dislike.' )
2010-07-24 00:04:14 -04:00
] ) ,
2011-03-28 10:08:10 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
( NEWSBLUR . Globals . is _admin && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-recommend' , role : "button" } , [
2012-08-13 21:32:47 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Recommend this site' )
] ) ) ,
( NEWSBLUR . Globals . is _admin && $ . make ( 'li' , { className : 'NB-menu-separator' } ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-move NB-menu-manage-feed-move' , role : "button" } , [
2014-06-27 16:53:01 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-move-save NB-menu-manage-feed-move-save NB-modal-submit-green NB-modal-submit-button' } , 'Save' ) ,
2011-09-04 15:42:13 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-09-23 13:34:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Change folders' )
2011-09-04 15:42:13 -07:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-subitem NB-menu-manage-confirm NB-menu-manage-feed-move-confirm NB-modal-submit' , role : "button" } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-confirm-position' } , [
2014-06-27 16:53:01 -07:00
$ . make ( 'div' , { className : 'NB-change-folders' } )
2011-09-04 15:42:13 -07:00
] )
] ) ,
2021-05-13 15:37:33 -04:00
( muted && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-unmute NB-menu-manage-feed-unmute' , role : "button" } , [
2016-05-09 16:13:40 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Un-mute this site' )
] ) ) ,
2021-05-13 15:37:33 -04:00
( ! muted && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-mute NB-menu-manage-feed-mute' , role : "button" } , [
2015-11-10 21:06:30 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mute this site' )
2016-05-09 16:13:40 -07:00
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-rename NB-menu-manage-feed-rename' , role : "button" } , [
2010-12-11 11:26:21 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Rename this site' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-subitem NB-menu-manage-confirm NB-menu-manage-feed-rename-confirm NB-modal-submit' , role : "button" } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-confirm-position' } , [
2011-09-04 15:42:13 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-rename-save NB-menu-manage-feed-rename-save NB-modal-submit-green NB-modal-submit-button' } , 'Save' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-04-03 11:57:40 -07:00
$ . make ( 'input' , { name : 'new_title' , className : 'NB-menu-manage-title NB-input' , value : feed . get ( 'feed_title' ) } )
2011-09-04 15:42:13 -07:00
] )
2010-12-11 11:26:21 -05:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete NB-menu-manage-feed-delete' , role : "button" } , [
2010-07-21 23:22:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Delete this site' )
2010-07-21 23:22:27 -04:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete-confirm NB-menu-manage-feed-delete-confirm' , role : "button" } , [
2010-07-24 00:04:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Really delete?' )
2010-07-21 23:22:27 -04:00
] )
2010-09-12 13:50:27 -04:00
] ) ;
$manage _menu . data ( 'feed_id' , feed _id ) ;
2010-09-14 20:49:28 -04:00
$manage _menu . data ( '$feed' , $item ) ;
2011-01-31 20:08:07 -05:00
if ( feed _id && unread _count == 0 ) {
2010-09-12 13:50:27 -04:00
$ ( '.NB-menu-manage-feed-mark-read' , $manage _menu ) . addClass ( 'NB-disabled' ) ;
2010-06-14 13:17:38 -04:00
}
2012-03-30 14:56:16 -07:00
} else if ( type == 'socialfeed' ) {
var feed = this . model . get _feed ( feed _id ) ;
if ( ! feed ) return ;
2013-07-11 15:09:00 -07:00
var unread _count = this . get _total _unread _count ( feed _id ) ;
2012-03-30 14:56:16 -07:00
var tab _unread _count = Math . min ( 25 , unread _count ) ;
2012-07-18 20:19:54 -07:00
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-feed' } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ,
2021-05-13 15:37:33 -04:00
( feed . get ( 'has_exception' ) && feed . get ( 'exception_type' ) == 'feed' && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-exception' , role : "button" } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Fix this misbehaving site' )
] ) ) ,
2017-12-15 18:59:34 -08:00
( feed . get ( 'has_exception' ) && feed . get ( 'exception_type' ) == 'feed' && $ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-social-profile' , role : "button" } , [
2012-04-17 15:37:01 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'View profile' )
] ) ,
2012-07-25 19:11:59 -07:00
( feed . get ( 'exception_type' ) != 'feed' && $ . make ( 'li' , { className : 'NB-menu-separator' } ) ) ,
2021-05-13 15:37:33 -04:00
( feed . get ( 'exception_type' ) != 'feed' && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-mark-read NB-menu-manage-feed-mark-read' , role : "button" } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark as read' )
] ) ) ,
2012-11-16 12:03:13 -08:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-stats' , role : "button" } , [
2012-07-25 19:11:59 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Statistics' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-settings' , role : "button" } , [
2014-06-28 08:22:32 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Site settings' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-train' , role : "button" } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Intelligence trainer' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'What you like and dislike.' )
] ) ,
2012-07-18 20:19:54 -07:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
( feed . get ( 'user_id' ) != NEWSBLUR . Globals . user _id && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete NB-menu-manage-socialfeed-delete' , role : "button" } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Unfollow' )
2012-06-27 11:16:14 -07:00
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete-confirm NB-menu-manage-socialfeed-delete-confirm' , role : "button" } , [
2012-03-30 14:56:16 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Really unfollow?' )
] )
] ) ;
$manage _menu . data ( 'feed_id' , feed _id ) ;
$manage _menu . data ( '$feed' , $item ) ;
if ( feed _id && unread _count == 0 ) {
$ ( '.NB-menu-manage-feed-mark-read' , $manage _menu ) . addClass ( 'NB-disabled' ) ;
}
2013-12-19 11:08:22 -08:00
} else if ( type == 'starred' ) {
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-feed' } , [
$ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-feed-settings' , role : "button" } , [
2013-12-19 11:08:22 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Tag settings' )
] )
] ) ;
$manage _menu . data ( 'feed_id' , feed _id ) ;
$manage _menu . data ( '$feed' , $item ) ;
2017-03-07 12:20:20 -08:00
} else if ( type == 'search' ) {
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-feed' } , [
$ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete-search' , role : "button" } , [
2017-03-07 12:20:20 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Delete saved search' )
] )
] ) ;
$manage _menu . data ( 'feed_id' , feed _id ) ;
$manage _menu . data ( '$feed' , $item ) ;
2010-09-12 13:50:27 -04:00
} else if ( type == 'folder' ) {
2012-07-18 20:19:54 -07:00
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-folder' } , [
2010-09-13 17:32:41 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator-inverse' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-mark-read NB-menu-manage-folder-mark-read' , role : "button" } , [
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark folder as read' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-folder-subscribe' , role : "button" } , [
2012-05-24 11:54:10 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Add a site to this folder' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-folder-subfolder' , role : "button" } , [
2012-09-13 14:20:09 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Create a new subfolder' )
] ) ,
2010-09-22 10:12:38 -04:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-folder-settings' , role : "button" } , [
2015-08-22 17:36:05 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Folder settings' )
] ) ,
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-move NB-menu-manage-folder-move' , role : "button" } , [
2011-09-04 15:42:13 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Move to folder' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-subitem NB-menu-manage-confirm NB-menu-manage-folder-move-confirm NB-modal-submit' , role : "button" } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-confirm-position' } , [
2011-09-04 15:42:13 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-move-save NB-menu-manage-folder-move-save NB-modal-submit-green NB-modal-submit-button' } , 'Save' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-08-23 13:43:15 -07:00
$ . make ( 'div' , { className : 'NB-add-folders' } , NEWSBLUR . utils . make _folders ( ) )
2011-09-04 15:42:13 -07:00
] )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-rename NB-menu-manage-folder-rename' , role : "button" } , [
2010-12-11 12:41:24 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Rename this folder' )
] ) ,
2012-07-25 19:11:59 -07:00
$ . make ( 'li' , { className : 'NB-menu-subitem NB-menu-manage-confirm NB-menu-manage-folder-rename-confirm NB-modal-submit' } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-confirm-position' } , [
2011-09-04 15:42:13 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-rename-save NB-menu-manage-folder-rename-save NB-modal-submit-green NB-modal-submit-button' } , 'Save' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-04-03 11:57:40 -07:00
$ . make ( 'input' , { name : 'new_title' , className : 'NB-menu-manage-title NB-input' , value : feed _id } )
2011-09-04 15:42:13 -07:00
] )
2010-12-11 12:41:24 -05:00
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete NB-menu-manage-folder-delete' , role : "button" } , [
2010-09-22 10:12:38 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Delete this folder' )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-delete-confirm NB-menu-manage-folder-delete-confirm' , role : "button" } , [
2010-09-12 13:50:27 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Really delete?' )
2010-09-13 17:32:41 -04:00
] )
2010-09-12 13:50:27 -04:00
] ) ;
2010-09-14 20:49:28 -04:00
$manage _menu . data ( 'folder_name' , feed _id ) ;
$manage _menu . data ( '$folder' , $item ) ;
2010-12-30 18:37:29 -05:00
} else if ( type == 'story' ) {
2024-04-30 18:18:14 -04:00
var feed = this . model . get _feed ( feed _id ) ;
var story = this . model . get _story ( story _id ) ;
2012-05-25 18:54:04 -07:00
var starred _class = story . get ( 'starred' ) ? ' NB-story-starred ' : '' ;
2012-11-16 12:59:06 -08:00
var starred _title = story . get ( 'starred' ) ? 'Unsave this story' : 'Save this story' ;
2012-05-25 18:54:04 -07:00
var shared _class = story . get ( 'shared' ) ? ' NB-story-shared ' : '' ;
2012-08-30 18:31:44 -07:00
var shared _title = story . get ( 'shared' ) ? 'Shared' : 'Share to your Blurblog' ;
2024-04-30 18:18:14 -04:00
var order = NEWSBLUR . assets . view _setting ( this . active _feed , 'order' ) ;
2012-06-07 09:57:53 -07:00
story . story _share _menu _view = new NEWSBLUR . Views . StoryShareView ( {
model : story
} ) ;
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
$manage _menu = $ . make ( 'ul' , { className : 'NB-menu-manage NB-menu-manage-story ' + starred _class + shared _class } , [
2011-02-23 11:40:25 -05:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-open' , role : "button" } , [
2011-02-23 11:40:25 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2013-04-03 11:57:40 -07:00
$ . make ( 'input' , { name : 'story_permalink' , className : 'NB-menu-manage-open-input NB-input' , value : story . get ( 'story_permalink' ) } ) ,
2011-02-23 11:40:25 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Open' )
] ) ,
2010-12-31 10:34:31 -05:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
( story . get ( 'read_status' ) && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-unread' , role : "button" } , [
2011-11-08 13:48:54 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark as unread' )
] ) ) ,
2021-05-13 15:37:33 -04:00
( ! story . get ( 'read_status' ) && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-read' , role : "button" } , [
2015-10-21 21:31:44 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark as read' )
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-star' , role : "button" } , [
2013-04-30 17:08:25 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , starred _title )
] ) ,
2012-07-26 22:12:48 -07:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-thirdparty' } , [
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_facebook' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-facebook' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Facebook' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-facebook' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-facebook' ) ;
2011-02-16 20:45:37 -05:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_twitter' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-twitter' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Twitter' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-twitter' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-twitter' ) ;
2011-02-16 20:45:37 -05:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_readitlater' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-readitlater' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2012-04-17 10:58:32 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Pocket (RIL)' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-readitlater' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-readitlater' ) ;
2011-02-16 20:45:37 -05:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_tumblr' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-tumblr' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2012-01-13 10:46:56 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Tumblr' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-tumblr' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2012-01-13 10:46:56 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-tumblr' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_blogger' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-blogger' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2015-07-23 12:48:00 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Blogger' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-blogger' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2015-07-23 12:48:00 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-blogger' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_delicious' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-delicious' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2012-05-06 16:26:54 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Delicious' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-delicious' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2012-05-06 16:26:54 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-delicious' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_pinboard' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-pinboard' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-11-07 18:21:38 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Pinboard' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-pinboard' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-pinboard' ) ;
2011-11-07 18:21:38 -08:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_raindrop' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-raindrop' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2022-06-09 09:44:29 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Raindrop.io' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-raindrop' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2022-06-09 09:44:29 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-raindrop' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_pinterest' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-pinterest' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2013-10-16 11:49:49 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Pinterest' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-pinterest' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2013-10-16 11:49:49 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-pinterest' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_buffer' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-buffer' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2013-08-12 16:01:50 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Buffer' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-buffer' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2013-08-12 16:01:50 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-buffer' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_diigo' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-diigo' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2012-06-27 12:49:40 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Diigo' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-diigo' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2012-06-27 12:49:40 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-diigo' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_evernote' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-evernote' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2012-06-27 12:49:40 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Evernote' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-evernote' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2012-06-27 12:49:40 -07:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-evernote' ) ;
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_googleplus' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-googleplus' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-11-07 18:21:38 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Google+' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-googleplus' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-googleplus' ) ;
2011-11-07 18:21:38 -08:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
( NEWSBLUR . Preferences [ 'story_share_instapaper' ] && $ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-instapaper' } ) . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Instapaper' ) . parent ( ) . addClass ( 'NB-menu-manage-highlight-instapaper' ) ;
2024-04-30 18:18:14 -04:00
} , this ) ) . bind ( 'mouseleave' , _ . bind ( function ( e ) {
2011-11-09 18:38:00 -08:00
$ ( e . target ) . siblings ( '.NB-menu-manage-title' ) . text ( 'Email story' ) . parent ( ) . removeClass ( 'NB-menu-manage-highlight-instapaper' ) ;
2011-05-03 11:40:38 -04:00
} , this ) ) ) ,
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-email' , role : "button" } ) ,
2011-01-07 16:36:46 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2011-11-09 18:38:00 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Email story' )
2024-04-30 18:18:14 -04:00
] ) . bind ( 'click' , _ . bind ( function ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var $target = $ ( e . target ) ;
if ( $target . hasClass ( 'NB-menu-manage-thirdparty-facebook' ) ) {
this . send _story _to _facebook ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-twitter' ) ) {
this . send _story _to _twitter ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-readitlater' ) ) {
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-blogger' ) ) {
this . send _story _to _blogger ( 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-pinboard' ) ) {
this . send _story _to _pinboard ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-raindrop' ) ) {
this . send _story _to _raindrop ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-pinterest' ) ) {
this . send _story _to _pinterest ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-buffer' ) ) {
this . send _story _to _buffer ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-diigo' ) ) {
this . send _story _to _diigo ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-evernote' ) ) {
this . send _story _to _evernote ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-googleplus' ) ) {
this . send _story _to _googleplus ( story . id ) ;
} else if ( $target . hasClass ( 'NB-menu-manage-thirdparty-instapaper' ) ) {
this . send _story _to _instapaper ( story . id ) ;
} else {
this . send _story _to _email ( story ) ;
}
2011-01-07 16:36:46 -05:00
} , this ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story NB-menu-manage-story-share' , role : "button" } , [
2012-04-24 10:38:23 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , shared _title )
] ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-subitem NB-menu-manage-story NB-menu-manage-confirm NB-menu-manage-story-share-confirm NB-modal-submit' , role : "button" } , [
2012-04-24 10:38:23 -07:00
$ . make ( 'div' , { className : 'NB-menu-manage-confirm-position' } , [
2012-06-07 09:57:53 -07:00
story . story _share _menu _view . render ( ) . el
2012-04-24 10:38:23 -07:00
] )
] ) ,
2010-12-31 10:34:31 -05:00
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-train' , role : "button" } , [
2010-12-30 18:37:29 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
2010-12-31 10:34:31 -05:00
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Intelligence trainer' ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-subtitle' } , 'What you like and dislike.' )
2013-12-05 14:25:15 -08:00
] ) ,
$ . make ( 'li' , { className : 'NB-menu-separator' } ) ,
2021-05-13 15:37:33 -04:00
( order == "newest" && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-mark-read-newer NB-up' , role : "button" } , [
2013-12-05 14:25:15 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark newer stories read' )
] ) ) ,
2021-05-13 15:37:33 -04:00
$ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-mark-read-older ' + ( order == "oldest" ? "NB-up" : "NB-down" ) , role : "button" } , [
2013-12-05 14:25:15 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark older stories read' )
] ) ,
2021-05-13 15:37:33 -04:00
( order == "oldest" && $ . make ( 'li' , { className : 'NB-menu-item NB-menu-manage-story-mark-read-newer NB-down' , role : "button" } , [
2013-12-05 14:25:15 -08:00
$ . make ( 'div' , { className : 'NB-menu-manage-image' } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-title' } , 'Mark newer stories read' )
] ) )
2010-12-30 18:37:29 -05:00
] ) ;
$manage _menu . data ( 'feed_id' , feed _id ) ;
$manage _menu . data ( 'story_id' , story _id ) ;
$manage _menu . data ( '$story' , $item ) ;
2024-04-30 18:18:14 -04:00
2012-06-05 16:18:30 -07:00
// this.update_share_button_label($('.NB-sideoption-share-comments', $manage_menu));
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
return $manage _menu ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
show _manage _menu : function ( type , $item , options ) {
2010-06-08 11:19:41 -04:00
var self = this ;
2011-04-03 10:52:34 -04:00
var options = _ . extend ( {
2024-04-30 18:18:14 -04:00
'toplevel' : false ,
'inverse' : false
2011-04-03 10:52:34 -04:00
} , options ) ;
2010-06-14 13:17:38 -04:00
var $manage _menu _container = $ ( '.NB-menu-manage-container' ) ;
2012-03-30 14:56:16 -07:00
2010-06-14 13:17:38 -04:00
clearTimeout ( this . flags . closed _manage _menu ) ;
2012-05-17 13:22:00 -07:00
this . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
// If another menu is open, hide it first.
// If this menu is already open, then hide it instead.
2024-04-30 18:18:14 -04:00
if ( ( $item && $item [ 0 ] == $manage _menu _container . data ( 'item' ) ) &&
2010-09-12 13:50:27 -04:00
parseInt ( $manage _menu _container . css ( 'opacity' ) , 10 ) == 1 ) {
2012-05-11 10:06:05 -07:00
this . hide _manage _menu ( type , $item ) ;
2010-09-12 13:50:27 -04:00
return ;
2012-05-11 10:06:05 -07:00
} else {
this . hide _manage _menu ( type , $item ) ;
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
2011-02-02 08:05:31 -05:00
if ( $item . hasClass ( 'NB-empty' ) ) return ;
2024-04-30 18:18:14 -04:00
2011-02-08 22:07:59 -05:00
$item . addClass ( 'NB-showing-menu' ) ;
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
// Create menu, size and position it, then attach to the right place.
2010-12-30 18:37:29 -05:00
var feed _id , inverse , story _id ;
2010-09-14 20:49:28 -04:00
if ( type == 'folder' ) {
2012-05-25 18:54:04 -07:00
feed _id = options . folder _title ;
2012-07-06 11:07:19 -07:00
inverse = options . inverse || $item . hasClass ( "NB-hover-inverse" ) ;
2010-12-30 18:37:29 -05:00
} else if ( type == 'feed' ) {
2012-05-21 20:08:27 -07:00
feed _id = options . feed _id ;
2011-04-03 10:52:34 -04:00
inverse = options . inverse || $item . hasClass ( "NB-hover-inverse" ) ;
2012-03-30 14:56:16 -07:00
} else if ( type == 'socialfeed' ) {
2012-05-25 18:54:04 -07:00
feed _id = options . feed _id ;
2012-03-30 14:56:16 -07:00
inverse = options . inverse || $item . hasClass ( "NB-hover-inverse" ) ;
2013-12-19 11:08:22 -08:00
} else if ( type == 'starred' ) {
feed _id = options . feed _id ;
inverse = options . inverse || $item . hasClass ( "NB-hover-inverse" ) ;
2017-03-07 12:20:20 -08:00
} else if ( type == 'search' ) {
feed _id = options . feed _id ;
inverse = options . inverse || $item . hasClass ( "NB-hover-inverse" ) ;
2010-12-30 18:37:29 -05:00
} else if ( type == 'story' ) {
2012-05-25 18:54:04 -07:00
story _id = options . story _id ;
2024-04-30 18:18:14 -04:00
if ( $item . hasClass ( 'NB-hover-inverse' ) ) inverse = true ;
2010-12-30 18:37:29 -05:00
} else if ( type == 'site' ) {
2011-02-22 19:11:29 -05:00
$ ( '.NB-task-manage' ) . tipsy ( 'hide' ) ;
2011-02-22 19:45:29 -05:00
$ ( '.NB-task-manage' ) . tipsy ( 'disable' ) ;
2013-03-19 09:55:21 -07:00
if ( options . inverse ) inverse = true ;
2010-09-14 20:49:28 -04:00
}
2011-04-03 10:52:34 -04:00
var toplevel = options . toplevel || $item . hasClass ( "NB-toplevel" ) ||
2024-04-30 18:18:14 -04:00
$item . children ( '.folder_title' ) . hasClass ( "NB-toplevel" ) ;
2010-12-30 18:37:29 -05:00
var $manage _menu = this . make _manage _menu ( type , feed _id , story _id , inverse , $item ) ;
2010-06-14 13:17:38 -04:00
$manage _menu _container . empty ( ) . append ( $manage _menu ) ;
2010-09-12 13:50:27 -04:00
$manage _menu _container . data ( 'item' , $item && $item [ 0 ] ) ;
2010-06-14 13:17:38 -04:00
$ ( '.NB-task-manage' ) . parents ( '.NB-taskbar' ) . css ( 'z-index' , 2 ) ;
2010-09-12 13:50:27 -04:00
if ( type == 'site' ) {
2013-03-19 09:55:21 -07:00
if ( inverse ) {
2024-04-30 18:18:14 -04:00
$ ( 'li' , $manage _menu _container ) . each ( function ( ) {
2013-03-19 09:55:21 -07:00
$ ( this ) . prependTo ( $ ( this ) . parent ( ) ) ;
} ) ;
2013-04-05 11:46:04 -07:00
$manage _menu _container . corner ( 'bottom 8px' ) . corner ( 'top 0px' ) ;
2013-03-19 09:55:21 -07:00
$ ( '.NB-menu-manage-site-info' , $manage _menu _container ) . hide ( ) ;
} else {
2013-04-05 11:46:04 -07:00
$manage _menu _container . corner ( 'top 8px' ) . corner ( 'bottom 0px' ) ;
2013-03-19 09:55:21 -07:00
}
if ( $item . hasClass ( 'NB-task-manage' ) ) {
$manage _menu _container . align ( $item , 'top -left' , {
2024-04-30 18:18:14 -04:00
'top' : 0 ,
2013-03-19 09:55:21 -07:00
'left' : - 2
} ) ;
2013-04-11 16:50:18 -07:00
} else if ( options . right ) {
$manage _menu _container . align ( $item , '-top -left' , {
2024-04-30 18:18:14 -04:00
'top' : - 34 ,
2013-04-11 16:50:18 -07:00
'left' : 0
2024-04-30 18:18:14 -04:00
} ) ;
2013-03-19 09:55:21 -07:00
} else {
$manage _menu _container . align ( $item , '-top left' , {
2024-04-30 18:18:14 -04:00
'top' : - 24 ,
2013-03-19 09:55:21 -07:00
'left' : 20
} ) ;
}
2013-04-11 16:50:18 -07:00
if ( options . body ) {
$manage _menu _container . appendTo ( this . $s . $body ) ;
$manage _menu _container . css ( 'z-index' , $ ( "#simplemodal-container" ) . css ( 'z-index' ) ) ;
}
2010-09-12 13:50:27 -04:00
$ ( '.NB-task-manage' ) . addClass ( 'NB-hover' ) ;
2024-04-30 18:18:14 -04:00
} else if ( type == 'feed' || type == 'folder' || type == 'story' ||
type == 'socialfeed' || type == 'starred' || type == 'search' ) {
2010-12-12 20:06:32 -05:00
var left , top ;
2013-12-19 11:08:22 -08:00
// NEWSBLUR.log(['menu open', $item, inverse, toplevel, type]);
2010-09-13 00:38:25 -04:00
if ( inverse ) {
2011-09-27 23:06:49 -07:00
var $align = $item ;
2010-12-12 20:06:32 -05:00
if ( type == 'feed' ) {
2013-02-21 16:53:37 -08:00
left = toplevel ? 2 : - 22 ;
2022-05-04 16:44:45 -04:00
top = toplevel ? 1 : 5 ;
2017-03-07 12:20:20 -08:00
} else if ( type == 'socialfeed' || type == 'starred' || type == 'search' ) {
2022-05-04 16:44:45 -04:00
left = 2 ;
top = 4 ;
2010-12-12 20:06:32 -05:00
} else if ( type == 'folder' ) {
2022-05-04 16:44:45 -04:00
left = toplevel ? 8 : - 20 ;
top = toplevel ? 6 : 6 ;
2010-12-30 18:37:29 -05:00
} else if ( type == 'story' ) {
2013-02-21 16:53:37 -08:00
left = 7 ;
2014-04-09 15:17:48 -07:00
top = 3 ;
2011-09-27 23:06:49 -07:00
$align = $ ( '.NB-story-manage-icon,.NB-feed-story-manage-icon' , $item ) ;
2012-04-27 17:44:00 -07:00
if ( ! $align . is ( ':visible' ) ) {
2013-02-25 14:45:59 -08:00
$align = $ ( '.NB-storytitles-sentiment,.NB-feed-story-sentiment' , $item ) ;
2012-04-27 17:44:00 -07:00
}
2010-12-12 20:06:32 -05:00
}
2024-04-30 18:18:14 -04:00
2013-01-29 16:47:44 -08:00
$manage _menu _container . align ( $align , 'top -left' , {
2024-04-30 18:18:14 -04:00
'top' : - 1 * top ,
2010-09-13 00:38:25 -04:00
'left' : left
} ) ;
2012-04-27 17:44:00 -07:00
2013-04-05 11:46:04 -07:00
$manage _menu _container . corner ( 'br 8px' ) . corner ( 'bl top 0px' ) ;
2024-04-30 18:18:14 -04:00
$ ( 'li' , $manage _menu _container ) . each ( function ( ) {
2013-03-19 09:55:21 -07:00
$ ( this ) . prependTo ( $ ( this ) . parent ( ) ) ;
2010-09-13 00:38:25 -04:00
} ) ;
} else {
2011-09-27 23:06:49 -07:00
var $align = $item ;
2010-12-12 20:06:32 -05:00
if ( type == 'feed' ) {
2013-02-21 16:53:37 -08:00
left = toplevel ? 0 : - 2 ;
top = toplevel ? 20 : 19 ;
2011-09-27 23:06:49 -07:00
$align = $ ( '.NB-feedlist-manage-icon' , $item ) ;
2017-03-07 12:20:20 -08:00
} else if ( type == 'socialfeed' || type == 'starred' || type == 'search' ) {
2013-02-21 17:57:32 -08:00
left = toplevel ? 0 : - 18 ;
top = toplevel ? 20 : 21 ;
2012-03-30 14:56:16 -07:00
$align = $ ( '.NB-feedlist-manage-icon' , $item ) ;
2010-12-12 20:06:32 -05:00
} else if ( type == 'folder' ) {
2022-05-04 16:44:45 -04:00
left = toplevel ? 8 : - 22 ;
top = toplevel ? 24 : 21 ;
2011-01-12 22:45:52 -05:00
} else if ( type == 'story' ) {
2013-02-21 16:53:37 -08:00
left = 7 ;
top = 19 ;
2011-09-27 23:06:49 -07:00
$align = $ ( '.NB-story-manage-icon,.NB-feed-story-manage-icon' , $item ) ;
2012-04-27 17:44:00 -07:00
if ( ! $align . is ( ':visible' ) ) {
2013-02-25 14:45:59 -08:00
$align = $ ( '.NB-storytitles-sentiment,.NB-feed-story-sentiment' , $item ) ;
2012-04-27 17:44:00 -07:00
}
2010-12-12 20:06:32 -05:00
}
2013-01-24 18:23:10 -08:00
$manage _menu _container . align ( $align , '-bottom -left' , {
2024-04-30 18:18:14 -04:00
'top' : top ,
2010-09-13 00:38:25 -04:00
'left' : left
} ) ;
2013-04-05 11:46:04 -07:00
$manage _menu _container . corner ( 'tr 8px' ) . corner ( 'tl bottom 0px' ) ;
2010-09-13 00:38:25 -04:00
}
2010-09-12 13:50:27 -04:00
}
2024-04-30 18:18:14 -04:00
$manage _menu _container . stop ( ) . css ( { 'display' : 'block' , 'opacity' : 1 } ) ;
2010-09-12 13:50:27 -04:00
// Create and position the arrow tab
2024-04-30 18:18:14 -04:00
if ( type == 'feed' || type == 'folder' || type == 'story' ||
2017-03-07 12:20:20 -08:00
type == 'socialfeed' || type == 'starred' || type == 'search' ) {
2013-04-03 11:57:40 -07:00
var $arrow = $ . make ( 'div' , { className : 'NB-menu-manage-arrow' } , [
$ . make ( 'div' , { className : 'NB-icon' } )
] ) ;
2010-09-13 00:38:25 -04:00
if ( inverse ) {
2013-04-05 11:46:04 -07:00
$arrow . corner ( 'bottom 5px' ) . corner ( 'top 0px' ) ;
2010-09-13 00:38:25 -04:00
$manage _menu _container . append ( $arrow ) ;
2013-04-03 11:57:40 -07:00
$manage _menu _container . addClass ( 'NB-inverse' ) ;
2010-09-13 00:38:25 -04:00
} else {
2013-04-05 11:46:04 -07:00
$arrow . corner ( 'top 5px' ) . corner ( 'bottom 0px' ) ;
2010-09-13 00:38:25 -04:00
$manage _menu _container . prepend ( $arrow ) ;
2013-04-03 11:57:40 -07:00
$manage _menu _container . removeClass ( 'NB-inverse' ) ;
2010-09-13 00:38:25 -04:00
}
2010-09-12 13:50:27 -04:00
}
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
// Hide menu on click outside menu.
2024-04-30 18:18:14 -04:00
_ . defer ( function ( ) {
var close _menu _handler = function ( e ) {
_ . defer ( function ( ) {
$ ( document ) . bind ( 'click.menu' , function ( e ) {
2016-11-14 19:26:09 -08:00
// console.log(['click outside menu']);
2012-08-30 18:31:44 -07:00
self . hide _manage _menu ( type , $item , false ) ;
} ) ;
} ) ;
} ;
if ( options . rightclick ) {
2016-11-14 19:26:09 -08:00
// console.log(['mouseup.menu', close_menu_handler]);
2012-08-30 18:31:44 -07:00
$ ( document ) . one ( 'mouseup.menu' , close _menu _handler ) ;
} else {
2016-11-14 19:26:09 -08:00
// console.log(['close menu']);
2012-08-30 18:31:44 -07:00
close _menu _handler ( ) ;
}
2010-06-08 11:19:41 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
// Hide menu on mouseout (on a delay).
2024-04-30 18:18:14 -04:00
$manage _menu _container . hover ( function ( ) {
2010-06-14 13:17:38 -04:00
clearTimeout ( self . flags . closed _manage _menu ) ;
2024-04-30 18:18:14 -04:00
} , function ( ) {
2010-06-14 13:17:38 -04:00
clearTimeout ( self . flags . closed _manage _menu ) ;
2024-04-30 18:18:14 -04:00
self . flags . closed _manage _menu = setTimeout ( function ( ) {
2010-07-24 00:04:14 -04:00
if ( self . flags . closed _manage _menu ) {
2010-09-12 13:50:27 -04:00
self . hide _manage _menu ( type , $item , true ) ;
2010-07-24 00:04:14 -04:00
}
2010-06-14 13:17:38 -04:00
} , 1000 ) ;
2010-06-08 11:19:41 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
2012-04-27 17:44:00 -07:00
// Hide menu on esc.
2013-07-10 13:03:48 -07:00
$ ( document ) . add ( $ ( 'input,textarea' , $manage _menu _container ) )
. unbind ( 'keydown.manage_menu' )
2024-04-30 18:18:14 -04:00
. bind ( 'keydown.manage_menu' , 'esc' , function ( e ) {
e . preventDefault ( ) ;
self . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
self . hide _manage _menu ( type , $item , true ) ;
} ) ;
2012-04-27 17:44:00 -07:00
if ( type == 'story' ) {
2024-04-30 18:18:14 -04:00
var share = _ . bind ( function ( e ) {
2012-04-27 17:44:00 -07:00
e . preventDefault ( ) ;
2012-06-07 09:57:53 -07:00
var story = NEWSBLUR . assets . get _story ( story _id ) ;
2024-04-30 18:18:14 -04:00
story . story _share _menu _view . mark _story _as _shared ( { 'source' : 'menu' } ) ;
2012-04-27 17:44:00 -07:00
} , this ) ;
$ ( '.NB-sideoption-share-comments' , $manage _menu _container ) . bind ( 'keydown' , 'ctrl+return' , share ) ;
$ ( '.NB-sideoption-share-comments' , $manage _menu _container ) . bind ( 'keydown' , 'meta+return' , share ) ;
}
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
// Hide menu on scroll.
2010-12-30 18:37:29 -05:00
var $scroll ;
2010-09-12 13:50:27 -04:00
this . flags [ 'feed_list_showing_manage_menu' ] = true ;
2017-03-07 12:20:20 -08:00
if ( type == 'feed' || type == 'socialfeed' || type == 'starred' || type == 'search' ) {
2010-12-30 18:37:29 -05:00
$scroll = this . $s . $feed _list . parent ( ) ;
} else if ( type == 'story' ) {
2013-07-10 14:27:52 -07:00
$scroll = this . $s . $story _titles . add ( this . $s . $feed _scroll ) ;
2010-12-30 18:37:29 -05:00
}
2024-04-30 18:18:14 -04:00
$scroll && $scroll . unbind ( 'scroll.manage_menu' ) . bind ( 'scroll.manage_menu' , function ( e ) {
2010-09-12 13:50:27 -04:00
if ( self . flags [ 'feed_list_showing_manage_menu' ] ) {
self . hide _manage _menu ( type , $item , true ) ;
} else {
2011-01-12 22:45:52 -05:00
$scroll . unbind ( 'scroll.manage_menu' ) ;
2010-09-12 13:50:27 -04:00
}
} ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
hide _manage _menu : function ( type , $item , animate ) {
2010-06-14 13:17:38 -04:00
var $manage _menu _container = $ ( '.NB-menu-manage-container' ) ;
var height = $manage _menu _container . outerHeight ( ) ;
2011-09-04 15:42:13 -07:00
if ( this . flags [ 'showing_confirm_input_on_manage_menu' ] && animate ) return ;
2010-09-12 13:50:27 -04:00
// NEWSBLUR.log(['hide_manage_menu', type, $item, animate, $manage_menu_container.css('opacity')]);
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
clearTimeout ( this . flags . closed _manage _menu ) ;
2010-09-12 13:50:27 -04:00
this . flags [ 'feed_list_showing_manage_menu' ] = false ;
2012-08-30 18:31:44 -07:00
$ ( document ) . unbind ( 'click.menu' ) ;
$ ( document ) . unbind ( 'mouseup.menu' ) ;
2013-07-10 13:03:48 -07:00
$ ( document ) . add ( $ ( 'input,textarea' , $manage _menu _container ) )
2024-04-30 18:18:14 -04:00
. unbind ( 'keydown.manage_menu' ) ;
2013-07-10 13:03:48 -07:00
2011-05-01 20:22:54 -04:00
if ( this . model . preference ( 'show_tooltips' ) ) {
$ ( '.NB-task-manage' ) . tipsy ( 'enable' ) ;
}
2024-04-30 18:18:14 -04:00
2011-11-07 20:50:46 -08:00
if ( $item ) $item . removeClass ( 'NB-showing-menu' ) ;
2024-04-30 18:18:14 -04:00
2010-09-12 13:50:27 -04:00
if ( animate ) {
$manage _menu _container . stop ( ) . animate ( {
'opacity' : 0
} , {
2024-04-30 18:18:14 -04:00
'duration' : 250 ,
2010-09-12 13:50:27 -04:00
'queue' : false ,
2024-04-30 18:18:14 -04:00
'complete' : function ( ) {
$manage _menu _container . css ( { 'display' : 'none' , 'opacity' : 0 } ) ;
2010-09-12 13:50:27 -04:00
}
} ) ;
} else {
2024-04-30 18:18:14 -04:00
$manage _menu _container . css ( { 'display' : 'none' , 'opacity' : 0 } ) ;
2010-09-12 13:50:27 -04:00
}
2010-06-14 13:17:38 -04:00
$ ( '.NB-task-manage' ) . removeClass ( 'NB-hover' ) ;
2024-04-30 18:18:14 -04:00
this . blur _to _page ( { manage _menu : true } ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
2010-12-11 17:16:12 -05:00
// ========================
// = Manage menu - Delete =
// ========================
2024-04-30 18:18:14 -04:00
show _confirm _delete _menu _item : function ( ) {
2010-09-14 20:49:28 -04:00
var $delete = $ ( '.NB-menu-manage-feed-delete,.NB-menu-manage-folder-delete' ) ;
var $confirm = $ ( '.NB-menu-manage-feed-delete-confirm,.NB-menu-manage-folder-delete-confirm' ) ;
2024-04-30 18:18:14 -04:00
2010-07-01 00:29:26 -04:00
$delete . addClass ( 'NB-menu-manage-feed-delete-cancel' ) ;
2010-07-21 23:22:27 -04:00
$ ( '.NB-menu-manage-title' , $delete ) . text ( 'Cancel delete' ) ;
2010-07-01 00:29:26 -04:00
$confirm . slideDown ( 500 ) ;
} ,
2024-04-30 18:18:14 -04:00
hide _confirm _delete _menu _item : function ( ) {
2010-09-14 20:49:28 -04:00
var $delete = $ ( '.NB-menu-manage-feed-delete,.NB-menu-manage-folder-delete' ) ;
var $confirm = $ ( '.NB-menu-manage-feed-delete-confirm,.NB-menu-manage-folder-delete-confirm' ) ;
2024-04-30 18:18:14 -04:00
2010-07-01 00:29:26 -04:00
$delete . removeClass ( 'NB-menu-manage-feed-delete-cancel' ) ;
2010-12-11 11:26:21 -05:00
var text = $delete . hasClass ( 'NB-menu-manage-folder-delete' ) ?
2024-04-30 18:18:14 -04:00
'Delete this folder' :
'Delete this site' ;
2010-09-14 20:49:28 -04:00
$ ( '.NB-menu-manage-title' , $delete ) . text ( text ) ;
2010-07-01 00:29:26 -04:00
$confirm . slideUp ( 500 ) ;
} ,
2024-04-30 18:18:14 -04:00
manage _menu _delete _feed : function ( feed _id , $feed ) {
2010-07-01 00:29:26 -04:00
var self = this ;
2012-05-23 12:10:35 -07:00
feed _id = feed _id || this . active _feed ;
var feed = this . model . get _feed ( feed _id ) ;
var feed _view = feed . get _view ( $feed ) ;
2024-04-30 18:18:14 -04:00
feed . delete _feed ( { view : feed _view } ) ;
2010-09-14 20:49:28 -04:00
} ,
2017-03-07 12:20:20 -08:00
2024-04-30 18:18:14 -04:00
manage _menu _delete _search : function ( search _model _id , $feed ) {
2017-03-07 12:20:20 -08:00
var search _model = NEWSBLUR . assets . get _search _feeds ( search _model _id ) ;
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . delete _saved _search ( search _model . get ( 'feed_id' ) , search _model . get ( 'query' ) , _ . bind ( function ( e ) {
2017-03-07 12:20:20 -08:00
console . log ( [ 'Saved searches' , e ] ) ;
} , this ) ) ;
2024-04-30 18:18:14 -04:00
2017-03-07 12:20:20 -08:00
} ,
2024-04-30 18:18:14 -04:00
show _confirm _unfollow _menu _item : function ( ) {
2012-03-30 14:56:16 -07:00
var $unfollow = $ ( '.NB-menu-manage-socialfeed-delete' ) ;
var $confirm = $ ( '.NB-menu-manage-socialfeed-delete-confirm' ) ;
2024-04-30 18:18:14 -04:00
2012-03-30 14:56:16 -07:00
$unfollow . addClass ( 'NB-menu-manage-socialfeed-delete-cancel' ) ;
$ ( '.NB-menu-manage-title' , $unfollow ) . text ( 'Cancel unfollow' ) ;
$confirm . slideDown ( 500 ) ;
} ,
2024-04-30 18:18:14 -04:00
hide _confirm _unfollow _menu _item : function ( ) {
2012-03-30 14:56:16 -07:00
var $unfollow = $ ( '.NB-menu-manage-socialfeed-delete,.NB-menu-manage-folder-delete' ) ;
var $confirm = $ ( '.NB-menu-manage-socialfeed-delete-confirm,.NB-menu-manage-folder-delete-confirm' ) ;
2024-04-30 18:18:14 -04:00
2012-03-30 14:56:16 -07:00
$unfollow . removeClass ( 'NB-menu-manage-socialfeed-delete-cancel' ) ;
$ ( '.NB-menu-manage-title' , $unfollow ) . text ( 'Unfollow' ) ;
$confirm . slideUp ( 500 ) ;
} ,
2024-04-30 18:18:14 -04:00
manage _menu _unfollow _feed : function ( feed , $feed ) {
2012-03-30 14:56:16 -07:00
var self = this ;
var feed _id = feed || this . active _feed ;
2024-04-30 18:18:14 -04:00
this . model . unfollow _user ( feed _id , function ( ) {
2012-05-17 18:40:46 -07:00
NEWSBLUR . app . feed _list . make _social _feeds ( ) ;
2012-03-30 14:56:16 -07:00
} ) ;
} ,
2024-04-30 18:18:14 -04:00
manage _menu _delete _folder : function ( folder _title , $folder ) {
2010-09-14 20:49:28 -04:00
var self = this ;
2012-09-07 17:36:12 -07:00
var folder _view = NEWSBLUR . assets . folders . get _view ( $folder ) ||
2024-04-30 18:18:14 -04:00
this . active _folder . folder _view ;
2012-05-23 21:07:01 -07:00
folder _view . model . delete _folder ( ) ;
2010-12-11 14:02:37 -05:00
} ,
2024-04-30 18:18:14 -04:00
2011-09-04 15:42:13 -07:00
// ========================
// = Manage menu - Move =
// ========================
2024-04-30 18:18:14 -04:00
show _confirm _move _menu _item : function ( feed _id , $feed ) {
2011-09-04 15:42:13 -07:00
var self = this ;
var $move = $ ( '.NB-menu-manage-feed-move,.NB-menu-manage-folder-move' ) ;
var $confirm = $ ( '.NB-menu-manage-feed-move-confirm,.NB-menu-manage-folder-move-confirm' ) ;
var $position = $ ( '.NB-menu-manage-confirm-position' , $confirm ) ;
2014-06-27 16:53:01 -07:00
var $add = $ ( ".NB-add-folders,.NB-change-folders" , $confirm ) ;
var $save = $ ( ".NB-menu-manage-feed-move-save" ) ;
2011-09-04 15:42:13 -07:00
var $select = $ ( 'select' , $confirm ) ;
2014-06-27 16:53:01 -07:00
var isFeed = _ . isNumber ( feed _id ) ;
2024-04-30 18:18:14 -04:00
2014-06-27 16:53:01 -07:00
if ( isFeed ) {
2024-04-30 18:18:14 -04:00
var feed = this . model . get _feed ( feed _id ) ;
2012-07-18 18:34:19 -07:00
var feed _view = feed . get _view ( $feed , true ) ;
2012-05-23 20:10:28 -07:00
var in _folder = feed _view . options . folder _title ;
2024-04-30 18:18:14 -04:00
feed . set ( 'menu_folders' , null , { silent : true } ) ;
2013-09-23 13:34:16 -07:00
var $folders = this . make _folders _multiselect ( feed ) ;
$add . html ( $folders ) ;
2014-06-27 16:53:01 -07:00
$save . addClass ( "NB-disabled" ) . attr ( 'disabled' , "disabled" ) . text ( 'Select folders' ) ;
2012-05-23 20:10:28 -07:00
} else {
2022-05-13 02:48:54 +01:00
var folder _view = NEWSBLUR . assets . folders . get _view ( $feed ) ||
2024-04-30 18:18:14 -04:00
this . active _folder . folder _view ;
2012-05-23 20:10:28 -07:00
var in _folder = folder _view . collection . options . title ;
}
2024-04-30 18:18:14 -04:00
2011-09-04 15:42:13 -07:00
$move . addClass ( 'NB-menu-manage-feed-move-cancel' ) ;
2014-06-27 16:53:01 -07:00
$ ( '.NB-menu-manage-title' , $move ) . text ( 'Cancel' ) ;
2011-09-04 15:42:13 -07:00
$position . css ( 'position' , 'relative' ) ;
var height = $confirm . height ( ) ;
$position . css ( 'position' , 'absolute' ) ;
2024-04-30 18:18:14 -04:00
$confirm . css ( { 'height' : 0 , 'display' : 'block' } ) . animate ( { 'height' : height } , {
'duration' : 380 ,
2011-09-04 15:42:13 -07:00
'easing' : 'easeOutQuart'
} ) ;
2014-06-27 16:53:01 -07:00
if ( isFeed ) {
$save . fadeIn ( 380 ) ;
}
2011-09-04 15:42:13 -07:00
this . flags [ 'showing_confirm_input_on_manage_menu' ] = true ;
2024-04-30 18:18:14 -04:00
2013-09-23 13:34:16 -07:00
if ( ! _ . isNumber ( feed _id ) ) {
$ ( 'select' , $confirm ) . focus ( ) . select ( ) ;
2024-04-30 18:18:14 -04:00
$ ( 'option' , $select ) . each ( function ( ) {
2013-09-23 13:34:16 -07:00
if ( $ ( this ) . attr ( 'value' ) == in _folder ) {
2021-01-12 20:15:42 -05:00
$ ( this ) . prop ( 'selected' , 'selected' ) ;
2013-09-23 13:34:16 -07:00
return false ;
}
} ) ;
}
} ,
2024-04-30 18:18:14 -04:00
make _folders _multiselect : function ( feed , in _folders ) {
2013-09-23 13:34:16 -07:00
var folders = NEWSBLUR . assets . get _folders ( ) ;
2014-06-27 16:53:01 -07:00
if ( ! in _folders ) in _folders = feed . in _folders ( ) ;
in _folders = _ . unique ( in _folders . concat ( feed . get ( 'menu_folders' ) || [ ] ) ) ;
2024-04-30 18:18:14 -04:00
feed . set ( 'menu_folders' , in _folders , { silent : true } ) ;
2013-09-23 13:34:16 -07:00
var $options = $ . make ( 'div' , { className : 'NB-folders' } ) ;
2024-04-30 18:18:14 -04:00
var $option = this . make _folder _selectable ( 'Top Level' , '' , 0 , _ . any ( in _folders , function ( folder ) {
2013-09-23 13:34:16 -07:00
return ! folder ;
} ) ) ;
$options . append ( $option ) ;
2024-04-30 18:18:14 -04:00
2014-06-28 08:22:32 -07:00
$options = this . make _folders _multiselect _options ( $options , folders , 1 , in _folders ) ;
2012-04-25 12:18:26 -07:00
2013-09-23 13:34:16 -07:00
return $options ;
} ,
2024-04-30 18:18:14 -04:00
make _folders _multiselect _options : function ( $options , items , depth , in _folders ) {
2013-09-23 13:34:16 -07:00
var self = this ;
2024-04-30 18:18:14 -04:00
items . each ( function ( item ) {
2013-09-23 13:34:16 -07:00
if ( item . is _folder ( ) ) {
var title = item . get ( 'folder_title' ) ;
2014-06-27 16:53:01 -07:00
var $option = self . make _folder _selectable ( title , title , depth , _ . contains ( in _folders , title ) ) ;
2013-09-23 13:34:16 -07:00
$options . append ( $option ) ;
2024-04-30 18:18:14 -04:00
$options = self . make _folders _multiselect _options ( $options , item . folders , depth + 1 , in _folders ) ;
2011-09-04 15:42:13 -07:00
}
} ) ;
2024-04-30 18:18:14 -04:00
2013-09-23 13:34:16 -07:00
return $options ;
2011-09-04 15:42:13 -07:00
} ,
2024-04-30 18:18:14 -04:00
make _folder _selectable : function ( folder _title , folder _value , depth , selected ) {
return $ . make ( 'div' , {
2013-09-23 13:34:16 -07:00
className : "NB-folder-option " + ( selected ? "NB-folder-option-active" : "" ) ,
2024-04-30 18:18:14 -04:00
style : 'padding-left: ' + depth * 12 + 'px;'
2013-09-23 13:34:16 -07:00
} , [
2014-06-28 08:22:32 -07:00
$ . make ( 'div' , { className : 'NB-icon-add' } ) ,
2013-09-23 13:34:16 -07:00
$ . make ( 'div' , { className : 'NB-icon' } ) ,
$ . make ( 'div' , { className : 'NB-folder-option-title' } , folder _title )
] ) . data ( 'folder' , folder _value ) ;
2011-09-04 15:42:13 -07:00
} ,
2024-04-30 18:18:14 -04:00
switch _change _folder : function ( feed _id , folder _value ) {
var feed = this . model . get _feed ( feed _id ) ;
2014-06-27 16:53:01 -07:00
var in _folders = feed . get ( 'menu_folders' ) ;
if ( _ . contains ( in _folders , folder _value ) ) {
in _folders = _ . without ( in _folders , folder _value ) ;
} else {
in _folders = in _folders . concat ( folder _value ) ;
}
2024-04-30 18:18:14 -04:00
feed . set ( 'menu_folders' , in _folders , { silent : true } ) ;
2014-06-28 08:22:32 -07:00
this . render _change _folders ( feed , in _folders ) ;
} ,
2024-04-30 18:18:14 -04:00
render _change _folders : function ( feed , in _folders ) {
2011-09-04 15:42:13 -07:00
var $confirm = $ ( '.NB-menu-manage-feed-move-confirm,.NB-menu-manage-folder-move-confirm' ) ;
2014-06-28 08:22:32 -07:00
var $add = $ ( ".NB-add-folders,.NB-change-folders" , $confirm ) ;
var $save = $ ( ".NB-menu-manage-feed-move-save" ) ;
2014-06-27 16:53:01 -07:00
var $folders = this . make _folders _multiselect ( feed , in _folders ) ;
$add . html ( $folders ) ;
2024-04-30 18:18:14 -04:00
2014-06-28 08:28:38 -07:00
if ( _ . isEqual ( in _folders , feed . in _folders ( ) ) ) {
$save . addClass ( "NB-disabled" ) . attr ( 'disabled' , "disabled" ) . text ( 'Select folders' ) ;
2011-09-04 15:42:13 -07:00
} else {
2014-06-28 08:28:38 -07:00
$save . toggleClass ( "NB-disabled" , ! in _folders . length )
2024-04-30 18:18:14 -04:00
. attr ( 'disabled' , ! in _folders . length ? "disabled" : false ) ;
2011-09-04 15:42:13 -07:00
}
2024-04-30 18:18:14 -04:00
2014-06-27 16:53:01 -07:00
if ( ! in _folders . length ) {
$save . text ( 'Select a folder' ) ;
} else {
$save . text ( "Save " + Inflector . pluralize ( ' folder' , in _folders . length , true ) ) ;
}
} ,
2024-04-30 18:18:14 -04:00
show _add _folder _in _menu : function ( feed _id , $folder , folder ) {
2014-06-28 08:28:38 -07:00
var self = this ;
2024-04-30 18:18:14 -04:00
2014-06-28 08:22:32 -07:00
if ( $folder . siblings ( '.NB-add-folder-form' ) . length ) {
2024-04-30 18:18:14 -04:00
var feed = this . model . get _feed ( feed _id ) ;
2014-06-28 08:22:32 -07:00
var in _folders = feed . get ( 'menu_folders' ) ;
this . render _change _folders ( feed , in _folders ) ;
return ;
2011-09-04 15:42:13 -07:00
}
2024-04-30 18:18:14 -04:00
2014-06-28 08:22:32 -07:00
var $add = $ . make ( 'div' , { className : 'NB-add-folder-form' } , [
$ . make ( 'div' , { className : 'NB-icon' } ) ,
$ . make ( 'input' , { className : 'NB-input' , placeholder : "New folder name..." } ) ,
$ . make ( 'div' , { className : 'NB-menu-manage-add-folder-save NB-modal-submit-green NB-modal-submit-button' } , 'Add' )
2017-12-18 21:33:17 -08:00
] ) . data ( 'in_folder' , $folder . data ( 'folder' ) ) . data ( 'feed_id' , feed _id ) ;
2014-06-28 08:22:32 -07:00
$add . css ( 'paddingLeft' , parseInt ( $folder . css ( 'paddingLeft' ) , 10 ) + 12 ) ;
$folder . after ( $add ) ;
2024-04-30 18:18:14 -04:00
$ ( 'input' , $add ) . focus ( ) . bind ( 'keyup' , 'return' , function ( e ) {
2014-06-28 08:28:38 -07:00
self . add _folder _to _folder ( ) ;
2024-04-30 18:18:14 -04:00
} ) . bind ( 'keyup' , 'esc' , function ( e ) {
var feed = self . model . get _feed ( feed _id ) ;
2014-06-28 08:28:38 -07:00
var in _folders = feed . get ( 'menu_folders' ) ;
2017-12-18 21:33:17 -08:00
self . render _change _folders ( feed , in _folders ) ;
2014-06-28 08:28:38 -07:00
} ) ;
2014-06-28 08:22:32 -07:00
} ,
2024-04-30 18:18:14 -04:00
add _folder _to _folder : function ( ) {
2014-06-28 08:22:32 -07:00
var $form = $ ( '.NB-add-folder-form' ) ;
var folder _name = $ ( '.NB-input' , $form ) . val ( ) ;
var parent _folder = $form . data ( 'in_folder' ) ;
this . model . save _add _folder ( folder _name , parent _folder ,
2024-04-30 18:18:14 -04:00
$ . rescope ( this . post _add _folder _to _folder , this ) ) ;
2014-06-28 08:22:32 -07:00
} ,
2024-04-30 18:18:14 -04:00
post _add _folder _to _folder : function ( e , data ) {
2014-06-28 08:32:27 -07:00
if ( data . folders ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . assets . folders . reset ( _ . compact ( data . folders ) , { parse : true } ) ;
2014-06-28 08:32:27 -07:00
}
2024-04-30 18:18:14 -04:00
2017-12-18 21:33:17 -08:00
var $form = $ ( '.NB-add-folder-form' ) ;
2024-04-30 18:18:14 -04:00
var feed _id = $form . data ( 'feed_id' ) ;
var feed = this . model . get _feed ( feed _id ) ;
2014-06-28 08:22:32 -07:00
var in _folders = feed . get ( 'menu_folders' ) ;
NEWSBLUR . assets . feeds . trigger ( 'reset' ) ;
this . render _change _folders ( feed , in _folders ) ;
2011-09-04 15:42:13 -07:00
} ,
2024-04-30 18:18:14 -04:00
manage _menu _move _feed : function ( feed _id , $feed ) {
var self = this ;
var feed _id = feed _id || this . active _feed ;
var feed = this . model . get _feed ( feed _id ) ;
2014-06-28 08:22:32 -07:00
var in _folders = feed . get ( 'menu_folders' ) ;
2024-04-30 18:18:14 -04:00
var feed _view = feed . get _view ( $feed ) ;
2011-11-07 20:50:46 -08:00
2024-04-30 18:18:14 -04:00
var moved = feed . move _to _folders ( in _folders , { view : feed _view } ) ;
2012-05-23 17:21:06 -07:00
this . hide _confirm _move _menu _item ( moved ) ;
if ( moved ) {
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2012-05-23 17:21:06 -07:00
this . hide _manage _menu ( 'feed' , $feed , true ) ;
} , this ) , 500 ) ;
}
2011-09-04 15:42:13 -07:00
} ,
2024-04-30 18:18:14 -04:00
manage _menu _move _folder : function ( folder , $folder ) {
var self = this ;
var to _folder = $ ( '.NB-menu-manage-folder-move-confirm select' ) . val ( ) ;
var folder _view = NEWSBLUR . assets . folders . get _view ( $folder ) ||
this . active _folder . folder _view ;
var in _folder = folder _view . collection . options . title ;
2012-08-12 18:57:29 -07:00
var folder _name = folder _view . options . folder _title ;
2012-05-23 20:10:28 -07:00
var child _folders = folder _view . collection . child _folder _names ( ) ;
2024-04-30 18:18:14 -04:00
if ( to _folder == in _folder ||
2011-11-08 09:20:10 -08:00
to _folder == folder _name ||
2024-04-30 18:18:14 -04:00
_ . contains ( child _folders , to _folder ) ) {
2011-11-08 09:20:10 -08:00
return this . hide _confirm _move _menu _item ( ) ;
}
2024-04-30 18:18:14 -04:00
var moved = folder _view . model . move _to _folder ( to _folder , { view : folder _view } ) ;
2012-05-23 20:10:28 -07:00
this . hide _confirm _move _menu _item ( moved ) ;
if ( moved ) {
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2012-05-23 20:10:28 -07:00
this . hide _manage _menu ( 'folder' , $folder , true ) ;
} , this ) , 500 ) ;
}
2011-09-04 15:42:13 -07:00
} ,
2024-04-30 18:18:14 -04:00
hide _confirm _move _menu _item : function ( moved ) {
2014-06-28 08:22:32 -07:00
var $move _folder = $ ( '.NB-menu-manage-folder-move' ) ;
var $move _feed = $ ( '.NB-menu-manage-feed-move' ) ;
var $confirm _folder = $ ( '.NB-menu-manage-folder-move-confirm' ) ;
var $confirm _feed = $ ( '.NB-menu-manage-feed-move-confirm' ) ;
var $save = $ ( ".NB-menu-manage-feed-move-save" ) ;
$move _folder . removeClass ( 'NB-menu-manage-feed-move-cancel' ) ;
$move _feed . removeClass ( 'NB-menu-manage-feed-move-cancel' ) ;
var text _folder = 'Move to folder' ;
var text _feed = 'Change folders' ;
if ( moved ) {
text _folder = 'Moved' ;
text _feed = 'Moved' ;
$move _folder . addClass ( 'NB-active' ) ;
$move _feed . addClass ( 'NB-active' ) ;
} else {
$move _folder . removeClass ( 'NB-active' ) ;
$move _feed . removeClass ( 'NB-active' ) ;
}
$ ( '.NB-menu-manage-title' , $move _folder ) . text ( text _folder ) ;
$ ( '.NB-menu-manage-title' , $move _feed ) . text ( text _feed ) ;
$confirm _feed . slideUp ( 500 ) ;
$confirm _folder . slideUp ( 500 ) ;
$save . hide ( ) ;
this . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
} ,
2024-04-30 18:18:14 -04:00
manage _menu _mute _feed : function ( feed _id , unmute ) {
var approve _list = _ . pluck ( NEWSBLUR . assets . feeds . filter ( function ( feed ) {
2016-05-09 16:13:40 -07:00
if ( unmute ) {
return feed . get ( 'active' ) || feed . get ( 'id' ) == feed _id ;
}
2015-11-10 21:06:30 -08:00
return feed . get ( 'active' ) && feed . get ( 'id' ) != feed _id ;
} ) , 'id' ) ;
console . log ( [ "Saving" , approve _list , feed _id ] ) ;
NEWSBLUR . reader . flags [ 'reloading_feeds' ] = true ;
2024-04-30 18:18:14 -04:00
this . model . save _feed _chooser ( approve _list , _ . bind ( function ( ) {
2015-11-10 21:06:30 -08:00
this . flags [ 'has_saved' ] = true ;
NEWSBLUR . reader . flags [ 'reloading_feeds' ] = false ;
NEWSBLUR . reader . hide _feed _chooser _button ( ) ;
NEWSBLUR . assets . load _feeds ( ) ;
this . hide _manage _menu ( ) ;
} , this ) ) ;
} ,
2024-04-30 18:18:14 -04:00
2010-12-11 17:16:12 -05:00
// ========================
// = Manage menu - Rename =
// ========================
2024-04-30 18:18:14 -04:00
show _confirm _rename _menu _item : function ( ) {
2010-12-11 14:02:37 -05:00
var self = this ;
2010-12-11 11:26:21 -05:00
var $rename = $ ( '.NB-menu-manage-feed-rename,.NB-menu-manage-folder-rename' ) ;
var $confirm = $ ( '.NB-menu-manage-feed-rename-confirm,.NB-menu-manage-folder-rename-confirm' ) ;
2011-09-04 15:42:13 -07:00
var $position = $ ( '.NB-menu-manage-confirm-position' , $confirm ) ;
2024-04-30 18:18:14 -04:00
2010-12-11 11:26:21 -05:00
$rename . addClass ( 'NB-menu-manage-feed-rename-cancel' ) ;
$ ( '.NB-menu-manage-title' , $rename ) . text ( 'Cancel rename' ) ;
2011-09-04 15:42:13 -07:00
$position . css ( 'position' , 'relative' ) ;
2010-12-11 11:26:21 -05:00
var height = $confirm . height ( ) ;
2011-09-04 15:42:13 -07:00
$position . css ( 'position' , 'absolute' ) ;
2024-04-30 18:18:14 -04:00
$confirm . css ( { 'height' : 0 , 'display' : 'block' } ) . animate ( { 'height' : height } , {
'duration' : 380 ,
2011-09-04 15:42:13 -07:00
'easing' : 'easeOutQuart'
} ) ;
2010-12-11 12:41:24 -05:00
$ ( 'input' , $confirm ) . focus ( ) . select ( ) ;
2011-09-04 15:42:13 -07:00
this . flags [ 'showing_confirm_input_on_manage_menu' ] = true ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-menu-manage-feed-rename-confirm input.NB-menu-manage-title' ) . bind ( 'keyup' , 'return' , function ( e ) {
2010-12-11 14:02:37 -05:00
var $t = $ ( e . target ) ;
var feed _id = $t . closest ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . closest ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _rename _feed ( feed _id , $feed ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-menu-manage-folder-rename-confirm input.NB-menu-manage-title' ) . bind ( 'keyup' , 'return' , function ( e ) {
2010-12-11 14:02:37 -05:00
var $t = $ ( e . target ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
self . manage _menu _rename _folder ( folder _name , $folder ) ;
} ) ;
2010-12-11 11:26:21 -05:00
} ,
2024-04-30 18:18:14 -04:00
hide _confirm _rename _menu _item : function ( renamed ) {
2010-12-11 11:26:21 -05:00
var $rename = $ ( '.NB-menu-manage-feed-rename,.NB-menu-manage-folder-rename' ) ;
var $confirm = $ ( '.NB-menu-manage-feed-rename-confirm,.NB-menu-manage-folder-rename-confirm' ) ;
2024-04-30 18:18:14 -04:00
2010-12-11 11:26:21 -05:00
$rename . removeClass ( 'NB-menu-manage-feed-rename-cancel' ) ;
var text = $rename . hasClass ( 'NB-menu-manage-folder-rename' ) ?
2024-04-30 18:18:14 -04:00
'Rename this folder' :
'Rename this site' ;
2010-12-11 14:02:37 -05:00
if ( renamed ) {
text = 'Renamed' ;
$rename . addClass ( 'NB-active' ) ;
} else {
$rename . removeClass ( 'NB-active' ) ;
}
2010-12-11 11:26:21 -05:00
$ ( '.NB-menu-manage-title' , $rename ) . text ( text ) ;
$confirm . slideUp ( 500 ) ;
2011-09-04 15:42:13 -07:00
this . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
2010-12-11 11:26:21 -05:00
} ,
2024-04-30 18:18:14 -04:00
manage _menu _rename _feed : function ( feed _id ) {
var feed _id = feed _id || this . active _feed ;
2012-05-23 12:27:59 -07:00
var feed = this . model . get _feed ( feed _id ) ;
2010-12-11 14:02:37 -05:00
var new _title = $ ( '.NB-menu-manage-feed-rename-confirm .NB-menu-manage-title' ) . val ( ) ;
2024-04-30 18:18:14 -04:00
2012-05-23 12:27:59 -07:00
if ( new _title . length > 0 ) feed . rename ( new _title ) ;
2010-12-11 14:02:37 -05:00
this . hide _confirm _rename _menu _item ( true ) ;
2010-12-11 11:26:21 -05:00
} ,
2024-04-30 18:18:14 -04:00
manage _menu _rename _folder : function ( folder , $folder ) {
var self = this ;
2010-12-11 14:02:37 -05:00
var new _folder _name = $ ( '.NB-menu-manage-folder-rename-confirm .NB-menu-manage-title' ) . val ( ) ;
2012-09-07 17:36:12 -07:00
var folder _view = NEWSBLUR . assets . folders . get _view ( $folder ) ||
2024-04-30 18:18:14 -04:00
this . active _folder . folder _view ;
2012-05-23 20:20:11 -07:00
if ( new _folder _name . length > 0 ) folder _view . model . rename ( new _folder _name ) ;
2010-12-11 14:02:37 -05:00
this . hide _confirm _rename _menu _item ( true ) ;
2010-12-11 11:26:21 -05:00
} ,
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
// =============================
// = Manage Menu - Share Story =
// =============================
2024-04-30 18:18:14 -04:00
show _confirm _story _share _menu _item : function ( story _id ) {
2012-04-24 10:38:23 -07:00
var self = this ;
2012-06-07 09:57:53 -07:00
if ( ! story _id ) story _id = $ ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
var story = NEWSBLUR . assets . get _story ( story _id ) ;
2012-04-24 10:38:23 -07:00
var $share = $ ( '.NB-menu-manage-story-share' ) ;
var $confirm = $ ( '.NB-menu-manage-story-share-confirm' ) ;
2012-06-07 09:57:53 -07:00
var $story _share = story . story _share _menu _view . $el ;
2012-04-24 10:38:23 -07:00
var $position = $ ( '.NB-menu-manage-confirm-position' , $confirm ) ;
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
$share . addClass ( 'NB-menu-manage-story-share-cancel' ) ;
$ ( '.NB-menu-manage-title' , $share ) . text ( 'Cancel share' ) ;
2024-04-30 18:18:14 -04:00
$confirm . css ( { 'height' : 0 , 'display' : 'block' } ) ;
story . story _share _menu _view . toggle _feed _story _share _dialog ( { immediate : true } ) ;
2012-04-24 10:38:23 -07:00
$position . css ( 'position' , 'relative' ) ;
2012-06-07 09:57:53 -07:00
var height = $story _share . height ( ) ;
2012-04-24 10:38:23 -07:00
$position . css ( 'position' , 'absolute' ) ;
2024-04-30 18:18:14 -04:00
$confirm . css ( { 'height' : 0 , 'display' : 'block' } ) . animate ( { 'height' : height } , {
'duration' : 380 ,
2012-04-24 10:38:23 -07:00
'easing' : 'easeOutQuart'
} ) ;
$ ( 'textarea' , $confirm ) . focus ( ) . select ( ) ;
this . flags [ 'showing_confirm_input_on_manage_menu' ] = true ;
} ,
2024-04-30 18:18:14 -04:00
hide _confirm _story _share _menu _item : function ( shared ) {
2016-02-03 13:31:55 -08:00
var story _id = $ ( '.NB-menu-manage-container .NB-menu-manage' ) . data ( 'story_id' ) ;
2012-06-07 09:57:53 -07:00
var story = NEWSBLUR . assets . get _story ( story _id ) ;
2012-04-24 10:38:23 -07:00
var $share = $ ( '.NB-menu-manage-story-share' ) ;
var $confirm = $ ( '.NB-menu-manage-story-share-confirm' ) ;
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
$share . removeClass ( 'NB-menu-manage-story-share-cancel' ) ;
2012-08-30 18:31:44 -07:00
var text = 'Share to your Blurblog' ;
2012-04-24 10:38:23 -07:00
if ( shared ) {
text = 'Shared' ;
$share . addClass ( 'NB-active' ) ;
} else {
$share . removeClass ( 'NB-active' ) ;
}
$ ( '.NB-menu-manage-title' , $share ) . text ( text ) ;
2024-04-30 18:18:14 -04:00
$confirm . slideUp ( 500 , _ . bind ( function ( ) {
2013-02-05 17:46:53 -08:00
if ( shared && story ) {
2012-06-07 09:57:53 -07:00
this . hide _manage _menu ( 'story' , story . story _title _view . $el , true ) ;
2012-05-02 13:29:17 -07:00
}
} , this ) ) ;
2012-04-24 10:38:23 -07:00
this . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
} ,
2024-04-30 18:18:14 -04:00
2020-12-08 18:14:09 -05:00
// ====================
// = Dashboard Rivers =
// ====================
2020-12-10 18:33:43 -05:00
load _dashboard _rivers : function ( force ) {
2021-03-25 16:35:48 -04:00
if ( ! NEWSBLUR . Globals . is _authenticated ) return ;
2020-12-10 18:33:43 -05:00
if ( ! NEWSBLUR . assets . dashboard _rivers . length ) {
2021-01-13 15:40:31 -05:00
// Create dashboard rivers if none exist by choosing folders
2020-12-10 18:33:43 -05:00
this . choose _dashboard _rivers ( ) ;
return ;
}
if ( ! force && NEWSBLUR . app . dashboard _rivers ) return ;
2021-01-12 20:15:42 -05:00
NEWSBLUR . app . dashboard _rivers = {
'left' : new NEWSBLUR . Views . DashboardRivers ( { side : 'left' } ) ,
'right' : new NEWSBLUR . Views . DashboardRivers ( { side : 'right' } )
} ;
2020-12-10 18:33:43 -05:00
} ,
2024-04-30 18:18:14 -04:00
choose _dashboard _rivers : function ( ) {
2020-12-10 18:33:43 -05:00
var existing _rivers = NEWSBLUR . assets . dashboard _rivers ;
var sides = existing _rivers . count _sides ( ) ;
2024-04-30 18:18:14 -04:00
2020-12-10 18:33:43 -05:00
if ( ! existing _rivers . contains ( function ( river ) {
2020-12-11 18:47:37 -05:00
river . get ( 'river_id' ) == "river:" ;
2020-12-10 18:33:43 -05:00
} ) ) {
2021-01-13 15:40:31 -05:00
NEWSBLUR . assets . save _dashboard _river ( "river:" , "left" , 0 , _ . bind ( function ( ) {
NEWSBLUR . assets . save _dashboard _river ( "river:infrequent" , "left" , 1 , _ . bind ( function ( ) {
NEWSBLUR . assets . save _dashboard _river ( "river:global" , "left" , 2 , _ . bind ( function ( ) {
this . load _dashboard _rivers ( ) ;
2021-02-05 17:29:55 -05:00
} , this ) , function ( e ) {
2022-05-17 13:45:51 -04:00
console . log ( [ 'Error saving dashboard river' , e ] ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2021-02-05 17:29:55 -05:00
} , this ) , function ( e ) {
2022-05-17 13:45:51 -04:00
console . log ( [ 'Error saving dashboard river' , e ] ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2021-02-05 17:29:55 -05:00
} , this ) , function ( e ) {
2024-04-30 18:18:14 -04:00
console . log ( [ 'Error saving dashboard river' , e ] ) ;
2021-02-05 17:29:55 -05:00
} ) ;
2024-04-30 18:18:14 -04:00
}
2020-12-08 18:14:09 -05:00
} ,
2010-06-14 13:17:38 -04:00
// ==========================
// = Taskbar - Intelligence =
// ==========================
2024-04-30 18:18:14 -04:00
load _intelligence _slider : function ( ) {
2010-06-14 13:17:38 -04:00
var self = this ;
var $slider = this . $s . $intelligence _slider ;
2012-06-13 13:47:50 -07:00
var unread _view = this . get _unread _view _score ( ) ;
2024-04-30 18:18:14 -04:00
2012-07-26 18:24:41 -07:00
if ( unread _view == 0 && ! NEWSBLUR . assets . preference ( 'hide_read_feeds' ) ) {
unread _view = - 1 ;
}
this . slide _intelligence _slider ( unread _view , true ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
toggle _focus _in _slider : function ( ) {
2012-12-24 12:55:14 -08:00
var $slider = this . $s . $intelligence _slider ;
var $focus = $ ( ".NB-intelligence-slider-green" , $slider ) ;
2013-02-04 14:51:15 -08:00
var $unread = $ ( ".NB-intelligence-slider-yellow" , $slider ) ;
2014-05-29 19:20:13 -07:00
var unread _view = this . get _unread _view _name ( ) ;
2013-03-26 13:49:35 -07:00
var all _mode = ! NEWSBLUR . assets . preference ( 'hide_read_feeds' ) ;
2014-05-29 19:20:13 -07:00
var starred _mode = this . flags [ 'feed_list_showing_starred' ] ;
2013-03-26 13:49:35 -07:00
if ( ! NEWSBLUR . assets . feeds . size ( ) ) return ;
2024-04-30 18:18:14 -04:00
2013-03-26 13:49:35 -07:00
var view _not _empty ;
2014-05-29 19:20:13 -07:00
if ( unread _view == 'starred' ) {
2024-04-30 18:18:14 -04:00
view _not _empty = NEWSBLUR . assets . starred _feeds . any ( function ( feed ) {
2014-05-29 19:20:13 -07:00
return feed . get ( 'count' ) ;
} ) ;
} else if ( unread _view == 'positive' ) {
2024-04-30 18:18:14 -04:00
view _not _empty = NEWSBLUR . assets . feeds . any ( function ( feed ) {
2013-03-26 13:49:35 -07:00
return feed . get ( 'ps' ) ;
2024-04-30 18:18:14 -04:00
} ) || NEWSBLUR . assets . social _feeds . any ( function ( feed ) {
2013-04-22 11:45:06 -07:00
return feed . get ( 'ps' ) ;
2013-03-26 13:49:35 -07:00
} ) ;
2013-01-02 18:37:15 -08:00
} else {
2024-04-30 18:18:14 -04:00
view _not _empty = NEWSBLUR . assets . feeds . any ( function ( feed ) {
2013-03-26 13:49:35 -07:00
return feed . get ( 'ps' ) || feed . get ( 'nt' ) ;
2024-04-30 18:18:14 -04:00
} ) || NEWSBLUR . assets . social _feeds . any ( function ( feed ) {
2013-04-22 11:45:06 -07:00
return feed . get ( 'ps' ) || feed . get ( 'nt' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2013-03-26 13:49:35 -07:00
}
$ ( ".NB-feeds-list-empty" ) . remove ( ) ;
2015-02-10 17:04:32 -08:00
// console.log(["toggle_focus_in_slider", unread_view, view_not_empty, starred_mode]);
2014-05-29 19:20:13 -07:00
if ( ! view _not _empty && ! all _mode && ! starred _mode ) {
2013-03-26 13:49:35 -07:00
var $empty = $ . make ( "div" , { className : "NB-feeds-list-empty" } , [
'You have no unread stories' ,
2014-05-29 19:20:13 -07:00
unread _view == 'positive' ? " in Focus mode." : "." ,
$ . make ( 'br' ) ,
2013-03-26 13:49:35 -07:00
$ . make ( 'br' ) ,
2014-05-29 19:20:13 -07:00
unread _view == 'positive' ? 'Switch to All or Unread.' : ""
] ) ;
this . $s . $feed _list . after ( $empty ) ;
} else if ( ! view _not _empty && starred _mode ) {
var $empty = $ . make ( "div" , { className : "NB-feeds-list-empty" } , [
'You have no saved stories.' ,
2013-03-26 13:49:35 -07:00
$ . make ( 'br' ) ,
$ . make ( 'br' ) ,
2014-05-29 19:20:13 -07:00
'Switch to All or Unread.'
2013-03-26 13:49:35 -07:00
] ) ;
2013-11-19 10:05:21 -08:00
this . $s . $feed _list . after ( $empty ) ;
2012-12-24 12:55:14 -08:00
}
2013-03-26 13:49:35 -07:00
// $focus.css('display', show_focus ? 'block' : 'none');
// if (!show_focus) {
// $unread.addClass("NB-last");
// if (NEWSBLUR.assets.preference('unread_view') > 0) {
// this.slide_intelligence_slider(0);
// }
// } else {
// $unread.removeClass("NB-last");
// this.model.preference('lock_green_slider', true);
// }
2012-12-24 12:55:14 -08:00
} ,
2024-04-30 18:18:14 -04:00
slide _intelligence _slider : function ( value , initial _load ) {
2012-02-08 18:11:08 -08:00
var $slider = this . $s . $intelligence _slider ;
2012-07-26 18:24:41 -07:00
var real _value = value ;
2024-04-30 18:18:14 -04:00
2014-05-28 17:35:51 -07:00
var showing _starred = this . flags [ 'feed_list_showing_starred' ] ;
this . flags [ 'feed_list_showing_starred' ] = value == 2 ;
if ( value <= - 1 ) {
2012-07-26 18:24:41 -07:00
value = 0 ;
if ( ! initial _load ) {
NEWSBLUR . assets . preference ( 'hide_read_feeds' , 0 ) ;
}
NEWSBLUR . assets . preference ( 'unread_view' , 0 ) ;
} else if ( value == 0 ) {
if ( ! initial _load ) {
NEWSBLUR . assets . preference ( 'hide_read_feeds' , 1 ) ;
}
NEWSBLUR . assets . preference ( 'unread_view' , 0 ) ;
2014-05-28 17:35:51 -07:00
} else if ( value >= 2 ) {
if ( ! initial _load ) {
NEWSBLUR . assets . preference ( 'hide_read_feeds' , 1 ) ;
}
NEWSBLUR . assets . preference ( 'unread_view' , 2 ) ;
2012-07-26 18:24:41 -07:00
} else if ( value > 0 ) {
if ( ! initial _load ) {
NEWSBLUR . assets . preference ( 'hide_read_feeds' , 1 ) ;
}
NEWSBLUR . assets . preference ( 'unread_view' , 1 ) ;
2011-07-29 09:41:49 -07:00
}
2012-06-13 13:47:50 -07:00
this . flags [ 'unread_threshold_temporarily' ] = null ;
2011-07-29 09:41:49 -07:00
this . switch _feed _view _unread _view ( value ) ;
2021-04-06 19:24:54 -04:00
if ( NEWSBLUR . app . story _titles _header && this . model . active _feed ) {
2013-07-11 21:54:52 -07:00
NEWSBLUR . app . story _titles _header . show _feed _hidden _story _title _indicator ( true ) ;
2012-09-07 17:36:12 -07:00
}
2024-04-30 18:18:14 -04:00
this . show _story _titles _above _intelligence _level ( { 'animate' : true , 'follow' : true } ) ;
2013-03-26 13:49:35 -07:00
this . toggle _focus _in _slider ( ) ;
2014-05-28 18:06:52 -07:00
if ( ! initial _load && this . flags [ 'feed_list_showing_starred' ] != showing _starred ) {
this . reload _feed ( ) ;
}
2012-10-01 13:07:45 -07:00
NEWSBLUR . app . sidebar _header . toggle _hide _read _preference ( ) ;
2013-01-03 18:53:01 -08:00
NEWSBLUR . app . sidebar _header . count ( ) ;
2013-01-02 17:44:14 -08:00
NEWSBLUR . assets . folders . update _all _folder _visibility ( ) ;
2013-09-09 15:43:42 -07:00
NEWSBLUR . app . feed _list . scroll _to _selected ( ) ;
2022-05-16 17:21:46 -04:00
if ( NEWSBLUR . app . dashboard _rivers && ! initial _load ) {
2021-01-12 20:15:42 -05:00
NEWSBLUR . app . dashboard _rivers [ 'left' ] . load _all _stories ( ) ;
NEWSBLUR . app . dashboard _rivers [ 'right' ] . load _all _stories ( ) ;
2020-12-10 18:33:43 -05:00
}
2020-11-12 18:37:30 -05:00
this . force _feeds _refresh ( ) ;
2012-02-08 18:11:08 -08:00
$ ( '.NB-active' , $slider ) . removeClass ( 'NB-active' ) ;
2014-05-28 16:54:51 -07:00
if ( this . flags [ 'feed_list_showing_starred' ] ) {
$ ( '.NB-intelligence-slider-blue' , $slider ) . addClass ( 'NB-active' ) ;
} else if ( real _value < 0 ) {
2012-02-08 18:11:08 -08:00
$ ( '.NB-intelligence-slider-red' , $slider ) . addClass ( 'NB-active' ) ;
2012-07-26 18:24:41 -07:00
} else if ( real _value > 0 ) {
2012-02-08 18:11:08 -08:00
$ ( '.NB-intelligence-slider-green' , $slider ) . addClass ( 'NB-active' ) ;
} else {
$ ( '.NB-intelligence-slider-yellow' , $slider ) . addClass ( 'NB-active' ) ;
}
2011-07-29 09:41:49 -07:00
} ,
2024-04-30 18:18:14 -04:00
move _intelligence _slider : function ( direction ) {
2014-05-28 17:35:51 -07:00
var unread _view = this . model . preference ( 'unread_view' ) ;
if ( ! this . model . preference ( 'hide_read_feeds' ) ) unread _view = - 1 ;
var value = unread _view + direction ;
2011-07-29 09:41:49 -07:00
this . slide _intelligence _slider ( value ) ;
} ,
2024-04-30 18:18:14 -04:00
toggle _read _filter : function ( ) {
2015-08-24 11:36:28 -07:00
var read _filter = NEWSBLUR . assets . view _setting ( this . active _feed , 'read_filter' ) ;
var setting = {
'read_filter' : ( read _filter == 'unread' ? 'all' : 'unread' )
} ;
var changed = NEWSBLUR . assets . view _setting ( this . active _feed , setting ) ;
if ( ! changed ) return ;
2024-04-30 18:18:14 -04:00
2015-08-24 11:36:28 -07:00
NEWSBLUR . reader . reload _feed ( setting ) ;
} ,
2024-04-30 18:18:14 -04:00
switch _feed _view _unread _view : function ( unread _view ) {
2012-06-13 13:47:50 -07:00
if ( ! _ . isNumber ( unread _view ) ) unread _view = this . get _unread _view _score ( ) ;
2024-04-30 18:18:14 -04:00
var $sidebar = this . $s . $sidebar ;
var unread _view _name = this . get _unread _view _name ( unread _view ) ;
var $next _story _button = $ ( '.NB-task-story-next-unread' ) ;
2010-11-01 18:20:26 -04:00
var $story _title _indicator = $ ( '.NB-story-title-indicator' , this . $story _titles ) ;
2011-01-04 08:21:47 -05:00
2013-02-11 12:35:42 -08:00
this . $s . $body . removeClass ( 'NB-intelligence-positive' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-intelligence-neutral' )
. removeClass ( 'NB-intelligence-negative' )
. removeClass ( 'NB-intelligence-starred' )
. addClass ( 'NB-intelligence-' + unread _view _name ) ;
2012-10-01 13:07:45 -07:00
$sidebar . removeClass ( 'unread_view_positive' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'unread_view_neutral' )
. removeClass ( 'unread_view_negative' )
. removeClass ( 'unread_view_starred' )
. addClass ( 'unread_view_' + unread _view _name ) ;
2010-12-04 23:06:35 -05:00
2013-01-31 18:24:53 -08:00
$next _story _button . removeClass ( 'NB-task-story-next-positive' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'NB-task-story-next-neutral' )
. removeClass ( 'NB-task-story-next-negative' )
. removeClass ( 'NB-task-story-next-starred' )
. addClass ( 'NB-task-story-next-' + unread _view _name ) ;
2010-11-01 18:20:26 -04:00
$story _title _indicator . removeClass ( 'unread_threshold_positive' )
2024-04-30 18:18:14 -04:00
. removeClass ( 'unread_threshold_neutral' )
. removeClass ( 'unread_threshold_negative' )
. removeClass ( 'unread_threshold_starred' )
. addClass ( 'unread_threshold_' + unread _view _name ) ;
NEWSBLUR . assets . stories . each ( function ( story ) {
story . unset ( 'visible' ) ;
2013-04-25 13:01:36 -07:00
} ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
get _unread _view _score : function ( ignore _temp ) {
2014-05-28 17:35:51 -07:00
if ( this . flags [ 'feed_list_showing_starred' ] ) return - 1 ;
2015-11-26 13:37:06 -08:00
if ( this . flags [ 'unread_threshold_temporarily' ] && ! ignore _temp ) {
2012-06-13 13:47:50 -07:00
var score _name = this . flags [ 'unread_threshold_temporarily' ] ;
if ( score _name == 'neutral' ) {
return 0 ;
} else if ( score _name == 'negative' ) {
return - 1 ;
}
}
2024-04-30 18:18:14 -04:00
2012-06-13 13:47:50 -07:00
return this . model . preference ( 'unread_view' ) ;
} ,
2024-04-30 18:18:14 -04:00
get _unread _view _name : function ( unread _view , ignore _temp ) {
2015-11-23 10:42:20 -08:00
if ( this . flags [ 'unread_threshold_temporarily' ] && ! ignore _temp ) {
2012-06-13 13:47:50 -07:00
return this . flags [ 'unread_threshold_temporarily' ] ;
}
2024-04-30 18:18:14 -04:00
2015-11-26 13:37:06 -08:00
if ( typeof unread _view == 'undefined' || unread _view === null ) {
unread _view = this . get _unread _view _score ( ignore _temp ) ;
2010-07-21 00:47:55 -04:00
}
2024-04-30 18:18:14 -04:00
2014-05-28 16:54:51 -07:00
if ( this . flags [ 'feed_list_showing_starred' ] ) return 'starred' ;
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
return ( unread _view > 0
2024-04-30 18:18:14 -04:00
? 'positive'
: unread _view < 0
? 'negative'
: 'neutral' ) ;
2010-06-14 13:17:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
get _unread _count : function ( feed _id ) {
2010-06-14 13:17:38 -04:00
var total = 0 ;
2010-09-12 13:50:27 -04:00
feed _id = feed _id || this . active _feed ;
2012-06-14 17:53:39 -07:00
var feed = this . model . get _feed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
2013-12-05 16:08:45 -08:00
if ( _ . contains ( [ 'starred' , 'read' ] , feed _id ) ) {
2011-02-04 09:56:15 -05:00
// Umm, no. Not yet.
2017-03-06 16:23:03 -08:00
} else if ( feed && feed . unread _counts ) {
2013-07-11 15:09:00 -07:00
return feed . unread _counts ( ) ;
2012-08-08 12:15:10 -07:00
} else if ( this . flags [ 'river_view' ] && ! this . flags [ 'social_view' ] ) {
2013-04-22 12:43:13 -07:00
var collection ;
if ( ! this . active _folder . folder _view ) {
// River blurblog gets a special collection
collection = NEWSBLUR . assets . folders ;
} else {
collection = this . active _folder . folders ;
}
2013-07-11 15:09:00 -07:00
return collection . unread _counts ( ) ;
2012-08-08 12:15:10 -07:00
} else if ( this . flags [ 'river_view' ] && this . flags [ 'social_view' ] ) {
2013-07-11 15:09:00 -07:00
return NEWSBLUR . assets . social _feeds . unread _counts ( ) ;
}
2024-04-30 18:18:14 -04:00
2013-07-11 15:09:00 -07:00
return { } ;
} ,
2024-04-30 18:18:14 -04:00
get _total _unread _count : function ( feed _id ) {
2013-07-11 15:09:00 -07:00
var counts = this . get _unread _count ( feed _id ) ;
var unread _view _name = this . get _unread _view _name ( ) ;
if ( unread _view _name == 'positive' ) {
return counts [ 'ps' ] ;
} else if ( unread _view _name == 'neutral' ) {
return counts [ 'ps' ] + counts [ 'nt' ] ;
} else if ( unread _view _name == 'negative' ) {
return counts [ 'ps' ] + counts [ 'nt' ] + counts [ 'ng' ] ;
2014-05-28 19:17:44 -07:00
} else if ( unread _view _name == 'starred' ) {
return counts [ 'st' ] ;
2010-06-14 13:17:38 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
show _story _titles _above _intelligence _level : function ( opts ) {
2010-11-01 18:20:26 -04:00
var defaults = {
'unread_view_name' : null ,
'animate' : true ,
2013-02-11 13:17:49 -08:00
'follow' : false ,
2011-02-01 18:29:22 -05:00
'temporary' : false
2010-11-01 18:20:26 -04:00
} ;
var options = $ . extend ( { } , defaults , opts ) ;
2010-06-14 13:17:38 -04:00
var self = this ;
var $story _titles = this . $s . $story _titles ;
2010-11-01 18:20:26 -04:00
var unread _view _name = options [ 'unread_view_name' ] || this . get _unread _view _name ( ) ;
2024-04-30 18:18:14 -04:00
2012-04-19 22:38:00 -07:00
if ( this . model . stories . length > 18 ) {
2011-12-20 11:55:48 -08:00
options [ 'animate' ] = false ;
}
2024-04-30 18:18:14 -04:00
2011-01-04 19:27:00 -05:00
if ( this . flags [ 'unread_threshold_temporarily' ] ) {
2013-04-25 13:01:36 -07:00
options [ 'temporary' ] = true ;
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
2013-04-25 13:01:36 -07:00
NEWSBLUR . assets . stories . trigger ( 'render:intelligence' , options ) ;
2024-04-30 18:18:14 -04:00
2012-06-26 13:31:37 -07:00
if ( ! NEWSBLUR . assets . preference ( 'feed_view_single_story' ) ) {
2024-04-30 18:18:14 -04:00
_ . delay ( function ( ) {
2012-06-26 13:31:37 -07:00
NEWSBLUR . app . story _list . reset _story _positions ( ) ;
} , 500 ) ;
}
2013-07-11 15:09:00 -07:00
NEWSBLUR . app . story _list . show _correct _explainer ( ) ;
2013-04-25 13:01:36 -07:00
// NEWSBLUR.log(['Showing correct stories', this.story_view, unread_view_name, $stories_show.length, $stories_hide.length]);
2022-02-18 17:52:24 -05:00
if ( _ . contains ( [ 'split' , 'list' , 'grid' , 'magazine' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-07-11 15:09:00 -07:00
NEWSBLUR . app . story _titles . fill _out ( ) ;
} else {
NEWSBLUR . app . story _list . fill _out ( ) ;
}
2013-04-25 13:01:36 -07:00
if ( options . follow && this . active _story ) {
NEWSBLUR . app . story _list . scroll _to _selected _story ( self . active _story ) ;
NEWSBLUR . app . story _titles . scroll _to _selected _story ( self . active _story ) ;
2010-06-14 13:17:38 -04:00
}
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ===================
// = Feed Refreshing =
// ===================
2024-04-30 18:18:14 -04:00
force _instafetch _stories : function ( feed _id ) {
2010-12-24 11:00:30 -05:00
var self = this ;
feed _id = feed _id || this . active _feed ;
2012-05-22 17:39:21 -07:00
var feed = this . model . get _feed ( feed _id ) ;
2022-02-28 11:53:05 -05:00
if ( ! feed ) return ;
2012-05-22 17:39:21 -07:00
feed . set ( {
fetched _once : false ,
has _exception : false
} ) ;
2011-04-23 18:22:52 -04:00
2012-05-22 17:39:21 -07:00
this . model . save _exception _retry ( feed _id , _ . bind ( this . force _feed _refresh , this , feed _id ) ,
2024-04-30 18:18:14 -04:00
NEWSBLUR . app . taskbar _info . show _stories _error ) ;
2010-12-24 11:00:30 -05:00
} ,
2024-04-30 18:18:14 -04:00
setup _socket _realtime _unread _counts : function ( force ) {
2012-03-30 16:03:07 -07:00
if ( ! force && NEWSBLUR . Globals . is _anonymous ) return ;
2012-04-02 18:48:41 -07:00
// if (!force && !NEWSBLUR.Globals.is_premium) return;
2016-11-29 18:30:12 -08:00
if ( this . socket && ! this . socket . connected ) {
this . socket . connect ( ) ;
} else if ( force || ! this . socket || ! this . socket . connected ) {
2013-03-15 11:11:47 -07:00
var server = window . location . protocol + '//' + window . location . hostname ;
2013-03-25 13:30:57 -07:00
var https = _ . string . startsWith ( window . location . protocol , 'https' ) ;
2024-04-30 18:18:14 -04:00
var local = false && _ . any ( [ 'nb.local.com' ] , function ( hostname ) {
2013-04-01 12:40:15 -07:00
return _ . string . contains ( window . location . host , hostname ) ;
} ) ;
2013-03-25 13:30:57 -07:00
var port = https ? 443 : 80 ;
2013-04-01 12:40:15 -07:00
if ( local ) {
2013-03-25 13:30:57 -07:00
port = https ? 8889 : 8888 ;
}
2016-11-29 18:30:12 -08:00
this . socket = this . socket || io . connect ( server + ":" + port , {
2013-03-17 14:41:29 -07:00
"reconnection delay" : 2000 ,
"connect timeout" : 2000 ,
2021-01-04 17:55:47 -05:00
"path" : "/v3/socket.io" ,
2016-11-30 15:26:42 -08:00
"transports" : [ 'websocket' ] ,
"upgrade" : false
2013-03-15 12:11:29 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
2011-11-06 12:21:27 -08:00
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
2024-04-30 18:18:14 -04:00
this . socket . on ( 'connect' , _ . bind ( function ( ) {
2012-03-28 19:13:30 -07:00
var active _feeds = this . send _socket _active _feeds ( ) ;
2016-11-29 18:30:12 -08:00
NEWSBLUR . log ( [ "Connected to real-time pubsub with " + active _feeds . length + " feeds." ] ) ;
2011-11-06 12:21:27 -08:00
this . flags . feed _refreshing _in _realtime = true ;
this . setup _feed _refresh ( ) ;
2019-01-05 16:00:55 -05:00
NEWSBLUR . assets . stories . retry _failed _marked _read _stories ( ) ;
2024-04-30 18:18:14 -04:00
2012-07-28 16:41:17 -07:00
// $('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating in real-time'));
2013-04-18 16:19:53 -07:00
$ ( '.NB-module-content-account-realtime' ) . attr ( 'title' , 'Updating sites in real-time...' ) . removeClass ( 'NB-error' ) . addClass ( 'NB-active' ) ;
2013-04-18 16:32:42 -07:00
this . apply _tipsy _titles ( ) ;
2011-11-06 12:21:27 -08:00
} , this ) ) ;
2013-04-15 17:59:06 -07:00
this . socket . removeAllListeners ( 'feed:update' ) ;
2021-01-04 19:01:30 -05:00
this . socket . on ( 'feed:update' , _ . bind ( this . handle _realtime _update , this ) ) ;
2016-12-13 16:29:42 -08:00
this . socket . removeAllListeners ( 'feed:story:new' ) ;
2024-04-30 18:18:14 -04:00
this . socket . on ( 'feed:story:new' , _ . bind ( function ( feed _id , message ) {
2016-12-13 16:29:42 -08:00
var story _hash = message . split ( ',' ) [ 0 ] ;
var timestamp = message . split ( ',' ) [ 1 ] ;
2020-12-17 18:09:38 -05:00
NEWSBLUR . log ( [ 'Real-time new story' , feed _id , story _hash , timestamp , message ] ) ;
2020-12-10 18:33:43 -05:00
if ( NEWSBLUR . app . dashboard _rivers ) {
2021-01-12 20:15:42 -05:00
NEWSBLUR . app . dashboard _rivers [ 'left' ] . new _story ( story _hash , timestamp ) ;
NEWSBLUR . app . dashboard _rivers [ 'right' ] . new _story ( story _hash , timestamp ) ;
2020-12-10 18:33:43 -05:00
}
2016-12-13 16:29:42 -08:00
} , this ) ) ;
2013-04-15 17:59:06 -07:00
this . socket . removeAllListeners ( NEWSBLUR . Globals . username ) ;
2016-12-05 17:10:47 -08:00
this . socket . removeAllListeners ( "user:update" ) ;
2021-01-04 19:01:30 -05:00
this . socket . on ( 'user:update' , _ . bind ( this . handle _realtime _update , this ) ) ;
2013-04-15 18:00:00 -07:00
2024-04-30 18:18:14 -04:00
this . socket . on ( 'disconnect' , _ . bind ( function ( ) {
2012-07-10 15:26:34 -07:00
NEWSBLUR . log ( [ "Lost connection to real-time pubsub. Falling back to polling." ] ) ;
2012-04-02 18:48:41 -07:00
this . flags . feed _refreshing _in _realtime = false ;
2012-03-28 19:13:30 -07:00
this . setup _feed _refresh ( ) ;
2012-07-28 16:41:17 -07:00
// $('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
2013-04-18 16:19:53 -07:00
$ ( '.NB-module-content-account-realtime' ) . attr ( 'title' , 'Updating sites every ' + this . flags . refresh _interval + ' seconds...' ) . addClass ( 'NB-error' ) . removeClass ( 'NB-active' ) ;
2013-04-18 16:32:42 -07:00
this . apply _tipsy _titles ( ) ;
2012-04-02 18:48:41 -07:00
} , this ) ) ;
2024-04-30 18:18:14 -04:00
this . socket . on ( 'error' , _ . bind ( function ( ) {
2012-07-10 15:26:34 -07:00
NEWSBLUR . log ( [ "Can't connect to real-time pubsub." ] ) ;
2012-04-02 18:48:41 -07:00
this . flags . feed _refreshing _in _realtime = false ;
2013-04-18 16:19:53 -07:00
this . setup _feed _refresh ( ) ;
2012-07-28 16:41:17 -07:00
// $('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
2013-04-18 16:19:53 -07:00
$ ( '.NB-module-content-account-realtime' ) . attr ( 'title' , 'Updating sites every ' + this . flags . refresh _interval + ' seconds...' ) . addClass ( 'NB-error' ) . removeClass ( 'NB-active' ) ;
2013-04-18 16:32:42 -07:00
this . apply _tipsy _titles ( ) ;
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( this . setup _socket _realtime _unread _counts , this ) , Math . random ( ) * 60 * 1000 ) ;
2012-03-28 19:13:30 -07:00
} , this ) ) ;
2024-04-30 18:18:14 -04:00
this . socket . on ( 'reconnect_failed' , _ . bind ( function ( ) {
2014-02-12 10:42:12 -08:00
console . log ( [ "Socket.io reconnect failed" ] ) ;
} , this ) ) ;
2024-04-30 18:18:14 -04:00
this . socket . on ( 'reconnect' , _ . bind ( function ( ) {
2014-02-12 10:42:12 -08:00
console . log ( [ "Socket.io reconnected successfully!" ] ) ;
} , this ) ) ;
2024-04-30 18:18:14 -04:00
this . socket . on ( 'reconnecting' , _ . bind ( function ( ) {
2014-02-12 10:42:12 -08:00
console . log ( [ "Socket.io reconnecting..." ] ) ;
} , this ) ) ;
2011-11-06 12:21:27 -08:00
}
2024-04-30 18:18:14 -04:00
2019-02-07 15:02:01 -05:00
// this.watch_navigator_online();
2019-02-01 11:04:00 -05:00
} ,
2021-01-04 19:01:30 -05:00
handle _realtime _update : function ( username , message ) {
2021-02-26 18:01:28 -05:00
if ( _ . isNumber ( username ) || ! isNaN ( username ) ) {
2021-01-04 19:01:30 -05:00
var feed _id = username ;
NEWSBLUR . log ( [ 'Real-time feed update' , feed _id , message ] ) ;
var feed = this . model . get _feed ( feed _id ) ;
if ( feed && ! feed . get ( 'fetched_once' ) ) {
this . force _feed _refresh ( feed _id ) ;
} else {
this . feed _unread _count ( feed _id , {
realtime : true
} ) ;
}
} else {
NEWSBLUR . log ( [ 'Real-time user update' , username , message ] ) ;
if ( this . flags . social _view ) return ;
if ( _ . string . startsWith ( message , 'feed:' ) ) {
feed _id = parseInt ( message . replace ( 'feed:' , '' ) , 10 ) ;
var active _feed _ids = [ ] ;
if ( this . active _folder && this . active _folder . length ) {
active _feed _ids = this . active _folder . feed _ids _in _folder ( ) ;
}
if ( feed _id != this . active _feed &&
! _ . contains ( active _feed _ids , feed _id ) ) {
NEWSBLUR . log ( [ 'Real-time user update for feed' , username , feed _id ] ) ;
this . feed _unread _count ( feed _id ) ;
}
} else if ( _ . string . startsWith ( message , 'story:read' ) ) {
NEWSBLUR . log ( [ 'Real-time user update for read story' , username , message ] ) ;
var story _hash = message . replace ( 'story:read:' , '' ) ;
NEWSBLUR . assets . stories . mark _read _pubsub ( story _hash ) ;
2021-01-05 19:36:49 -05:00
if ( NEWSBLUR . app . dashboard _rivers ) {
2021-01-12 20:15:42 -05:00
NEWSBLUR . app . dashboard _rivers [ 'left' ] . mark _read _pubsub ( story _hash ) ;
NEWSBLUR . app . dashboard _rivers [ 'right' ] . mark _read _pubsub ( story _hash ) ;
2021-01-05 19:36:49 -05:00
}
2021-01-04 19:01:30 -05:00
} else if ( _ . string . startsWith ( message , 'story:unread' ) ) {
NEWSBLUR . log ( [ 'Real-time user update for unread story' , username , message ] ) ;
var story _hash = message . replace ( 'story:unread:' , '' ) ;
NEWSBLUR . assets . stories . mark _unread _pubsub ( story _hash ) ;
2021-01-05 19:36:49 -05:00
if ( NEWSBLUR . app . dashboard _rivers ) {
2021-01-12 20:15:42 -05:00
NEWSBLUR . app . dashboard _rivers [ 'left' ] . mark _unread _pubsub ( story _hash ) ;
NEWSBLUR . app . dashboard _rivers [ 'right' ] . mark _unread _pubsub ( story _hash ) ;
2021-01-05 19:36:49 -05:00
}
2021-01-04 19:01:30 -05:00
} else if ( _ . string . startsWith ( message , 'story:starred' ) ||
_ . string . startsWith ( message , 'story:unstarred' ) ) {
this . update _starred _counts ( ) ;
} else if ( _ . string . startsWith ( message , 'social:' ) ) {
if ( message != this . active _feed ) {
NEWSBLUR . log ( [ 'Real-time user update for social' , username , message ] ) ;
this . feed _unread _count ( message ) ;
}
} else if ( message == "interaction:new" ) {
this . update _interactions _count ( ) ;
} else if ( _ . string . startsWith ( message , "notification:setup:" ) ) {
message = message . replace ( 'notification:setup:' , '' ) ;
this . push _notification _setup ( parseInt ( message , 10 ) ) ;
} else if ( _ . string . startsWith ( message , "notification:" ) ) {
message = message . replace ( 'notification:' , '' ) ;
var story _hash = message . slice ( 0 , message . indexOf ( ',' ) ) ;
var story _title = message . slice ( message . indexOf ( ',' ) + 1 ) ;
this . push _notification ( story _hash , story _title ) ;
} else if ( _ . string . startsWith ( message , "search_index_complete:" ) ) {
message = message . replace ( 'search_index_complete:' , '' ) ;
if ( NEWSBLUR . app . active _search ) {
NEWSBLUR . app . active _search . update _indexing _progress ( message ) ;
}
} else if ( _ . string . startsWith ( message , "refresh:" ) ) {
var feeds = message . replace ( 'refresh:' , '' ) . split ( "," ) ;
this . force _feeds _refresh ( null , false , feeds ) ;
} else if ( _ . string . startsWith ( message , "reload:" ) ) {
if ( ! NEWSBLUR . reader . flags [ 'reloading_feeds' ] ) {
console . log ( [ "Reloading feeds due to server reload" , NEWSBLUR . reader . flags [ 'reloading_feeds' ] ] ) ;
NEWSBLUR . assets . load _feeds ( ) ;
}
}
}
} ,
2024-04-30 18:18:14 -04:00
watch _navigator _online : function ( ) {
2019-02-01 11:04:00 -05:00
window . removeEventListener ( 'online' , _ . bind ( this . setup _socket _realtime _unread _counts , this ) ) ;
window . removeEventListener ( 'offline' , _ . bind ( this . setup _socket _realtime _unread _counts , this ) ) ;
window . addEventListener ( 'online' , _ . bind ( this . setup _socket _realtime _unread _counts , this ) ) ;
window . addEventListener ( 'offline' , _ . bind ( this . setup _socket _realtime _unread _counts , this ) ) ;
2011-11-06 12:21:27 -08:00
} ,
2020-07-27 09:41:28 -04:00
2024-04-30 18:18:14 -04:00
send _socket _active _feeds : function ( ) {
2012-03-28 16:13:17 -07:00
if ( ! this . socket ) return ;
2024-04-30 18:18:14 -04:00
var active _feeds = _ . compact ( this . model . feeds . map ( function ( feed ) {
2012-05-21 14:36:54 -07:00
return feed . get ( 'active' ) && feed . id ;
2012-03-28 16:13:17 -07:00
} ) ) ;
2012-04-03 19:24:02 -07:00
active _feeds = active _feeds . concat ( this . model . social _feeds . pluck ( 'id' ) ) ;
2024-04-30 18:18:14 -04:00
2012-03-30 16:03:07 -07:00
if ( active _feeds . length ) {
this . socket . emit ( 'subscribe:feeds' , active _feeds , NEWSBLUR . Globals . username ) ;
}
2012-10-22 16:25:36 -07:00
2012-03-28 19:13:30 -07:00
return active _feeds ;
2012-03-28 16:13:17 -07:00
} ,
2024-04-30 18:18:14 -04:00
handle _wakeup : function ( ) {
2020-07-27 09:41:28 -04:00
$ . dreamOn ( ) ;
2024-04-30 18:18:14 -04:00
$ . wakeUp ( _ . bind ( function ( ) {
2020-07-27 09:41:28 -04:00
console . log ( [ "Wakeup, reconnecting to real-time socket.io..." , new Date ( ) ] ) ;
this . setup _socket _realtime _unread _counts ( ) ;
} , this ) , { } , 1 * 1000 ) ;
} ,
2024-04-30 18:18:14 -04:00
setup _feed _refresh : function ( new _feeds ) {
2011-04-12 11:02:02 -04:00
var refresh _interval = this . constants . FEED _REFRESH _INTERVAL ;
2012-05-22 17:39:21 -07:00
var feed _count = this . model . feeds . size ( ) ;
2024-04-30 18:18:14 -04:00
2011-02-08 22:07:59 -05:00
if ( ! NEWSBLUR . Globals . is _premium ) {
2011-04-12 18:23:04 -04:00
refresh _interval *= 2 ;
}
2011-11-01 15:31:25 -07:00
if ( feed _count > 250 ) {
2012-07-11 21:20:38 -07:00
refresh _interval *= 2 ;
2011-02-08 22:07:59 -05:00
}
2011-11-01 15:31:25 -07:00
if ( feed _count > 500 ) {
refresh _interval *= 1.5 ;
}
2012-04-02 18:48:41 -07:00
if ( this . flags [ 'feed_refreshing_in_realtime' ] && ! this . flags [ 'has_unfetched_feeds' ] &&
2016-11-29 18:30:12 -08:00
this . socket && this . socket . connected ) {
2012-07-11 21:20:38 -07:00
refresh _interval *= 10 ;
2011-11-06 12:21:27 -08:00
}
2011-11-01 00:20:06 -07:00
2011-11-01 15:31:25 -07:00
if ( new _feeds && feed _count < 250 ) {
2024-04-30 18:18:14 -04:00
refresh _interval = ( 1000 * 60 ) * 1 / 6 ;
2011-11-01 15:31:25 -07:00
} else if ( new _feeds && feed _count < 500 ) {
2024-04-30 18:18:14 -04:00
refresh _interval = ( 1000 * 60 ) * 1 / 4 ;
2011-01-30 21:48:17 -05:00
}
2024-04-30 18:18:14 -04:00
2012-04-23 17:02:50 -07:00
// 10 second minimum
2024-04-30 18:18:14 -04:00
refresh _interval = Math . max ( 10 * 1000 , refresh _interval ) ;
2013-04-15 18:19:27 -07:00
// Add 0-100% random delay
refresh _interval = parseInt ( refresh _interval * ( 1 + Math . random ( ) ) , 10 ) ;
2024-04-30 18:18:14 -04:00
2010-08-17 20:59:47 -04:00
clearInterval ( this . flags . feed _refresh ) ;
2024-04-30 18:18:14 -04:00
this . flags . feed _refresh = setInterval ( function ( ) {
2021-04-02 13:27:10 -04:00
if ( ! NEWSBLUR . reader . flags [ 'pause_feed_refreshing' ] ) {
NEWSBLUR . reader . force _feeds _refresh ( ) ;
2010-08-30 22:42:44 -04:00
}
2011-02-06 15:04:21 -05:00
} , refresh _interval ) ;
2014-02-12 10:42:12 -08:00
this . flags . refresh _interval = parseInt ( refresh _interval / 1000 , 10 ) ;
2016-11-29 18:30:12 -08:00
if ( ! this . socket || ! this . socket . connected ) {
2012-07-28 16:41:17 -07:00
$ ( '.NB-module-content-account-realtime' ) . attr ( 'title' , 'Updating sites every ' + this . flags . refresh _interval + ' seconds...' ) . addClass ( 'NB-error' ) ;
2013-04-18 16:32:42 -07:00
this . apply _tipsy _titles ( ) ;
2024-04-30 18:18:14 -04:00
}
2014-02-12 10:46:07 -08:00
NEWSBLUR . log ( [ "Setting refresh interval to every " + this . flags . refresh _interval + " seconds." ] ) ;
2016-11-29 18:30:12 -08:00
// if (this.socket && !this.socket.connected) {
// // force disconnected since it's probably in a bad reconnect state.
// console.log(["Forcing socket disconnection...", this.socket]);
// this.socket.disconnect();
// }
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
force _feed _refresh : function ( feed _id , new _feed _id ) {
feed _id = feed _id || this . active _feed ;
2012-12-28 22:18:41 -08:00
new _feed _id = _ . isNumber ( new _feed _id ) && new _feed _id || feed _id ;
console . log ( [ "force_feed_refresh" , feed _id , new _feed _id ] ) ;
2024-04-30 18:18:14 -04:00
this . force _feeds _refresh ( function ( ) {
2012-05-22 17:39:21 -07:00
// Open the feed back up if it is being refreshed and is still open.
2021-04-02 13:27:10 -04:00
if ( NEWSBLUR . reader . active _feed == feed _id || NEWSBLUR . reader . active _feed == new _feed _id ) {
2024-04-30 18:18:14 -04:00
NEWSBLUR . reader . open _feed ( new _feed _id , { force : true } ) ;
2011-03-17 18:33:59 -04:00
}
2024-04-30 18:18:14 -04:00
2021-04-02 13:27:10 -04:00
NEWSBLUR . reader . check _feed _fetch _progress ( ) ;
2013-04-08 11:47:21 -07:00
} , true , new _feed _id , NEWSBLUR . app . taskbar _info . show _stories _error ) ;
2011-03-17 18:33:59 -04:00
} ,
2024-04-30 18:18:14 -04:00
force _feeds _refresh : function ( callback , replace _active _feed , feed _id , error _callback ) {
2010-06-14 13:17:38 -04:00
if ( callback ) {
this . cache . refresh _callback = callback ;
} else {
delete this . cache . refresh _callback ;
2010-06-08 11:19:41 -04:00
}
2010-08-30 22:42:44 -04:00
this . flags [ 'pause_feed_refreshing' ] = true ;
2024-04-30 18:18:14 -04:00
this . model . refresh _feeds ( _ . bind ( function ( data ) {
2013-01-30 18:28:37 -08:00
this . post _feed _refresh ( data ) ;
2012-01-08 14:15:22 -08:00
} , this ) , this . flags [ 'has_unfetched_feeds' ] , feed _id , error _callback ) ;
2024-04-30 18:18:14 -04:00
2019-01-05 16:00:55 -05:00
if ( this . socket && this . socket . connected ) {
NEWSBLUR . assets . stories . retry _failed _marked _read _stories ( ) ;
}
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
post _feed _refresh : function ( data ) {
2010-06-14 13:17:38 -04:00
var feeds = this . model . feeds ;
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
if ( this . cache . refresh _callback && $ . isFunction ( this . cache . refresh _callback ) ) {
2010-10-10 23:36:09 -04:00
this . cache . refresh _callback ( feeds ) ;
2010-06-14 13:17:38 -04:00
delete this . cache . refresh _callback ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2013-01-30 18:28:37 -08:00
NEWSBLUR . app . sidebar _header . update _interactions _count ( data . interactions _count ) ;
2012-04-03 18:17:54 -07:00
this . flags [ 'refresh_inline_feed_delay' ] = false ;
2012-05-22 17:39:21 -07:00
this . flags [ 'pause_feed_refreshing' ] = false ;
2010-08-11 22:02:47 -04:00
this . check _feed _fetch _progress ( ) ;
2012-12-24 12:55:14 -08:00
this . toggle _focus _in _slider ( ) ;
2010-06-08 11:19:41 -04:00
} ,
2024-04-30 18:18:14 -04:00
feed _unread _count : function ( feed _id , options ) {
2013-04-22 16:20:14 -07:00
options = options || { } ;
2013-01-28 15:23:19 -08:00
feed _id = feed _id || this . active _feed ;
if ( ! feed _id ) return ;
2024-04-30 18:18:14 -04:00
2013-04-22 16:20:14 -07:00
var feed = this . model . get _feed ( feed _id ) ;
2021-01-04 17:00:28 -05:00
if ( ! feed ) return ;
2021-01-04 17:55:47 -05:00
2013-04-22 16:20:14 -07:00
var subs = feed . get ( 'num_subscribers' ) ;
var delay = options . realtime ? subs * 2 : 0 ; // 1,000 subs = 2 seconds
2024-04-30 18:18:14 -04:00
_ . delay ( _ . bind ( function ( ) {
2013-04-22 16:20:14 -07:00
this . model . feed _unread _count ( feed _id , options . callback ) ;
} , this ) , Math . random ( ) * delay ) ;
2012-10-22 17:07:57 -07:00
} ,
2024-04-30 18:18:14 -04:00
update _interactions _count : function ( ) {
this . model . interactions _count ( function ( data ) {
2013-02-04 16:16:03 -08:00
NEWSBLUR . app . sidebar _header . update _interactions _count ( data . interactions _count ) ;
} , $ . noop ) ;
} ,
2024-04-30 18:18:14 -04:00
push _notification _setup : function ( feed _id ) {
2016-11-15 20:45:59 -08:00
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
if ( ! feed ) {
console . log ( [ 'Notification setup failed, no feed!' , feed _id ] ) ;
}
Push . create ( "NewsBlur" , {
body : feed . get ( 'feed_title' ) + " notifications are setup" ,
icon : $ . favicon ( feed ) ,
timeout : 3000 ,
onClick : function ( ) {
window . focus ( ) ;
this . close ( ) ;
}
} ) ;
} ,
2024-04-30 18:18:14 -04:00
push _notification : function ( story _hash , story _title ) {
2016-11-15 20:45:59 -08:00
var feed _id = story _hash . slice ( 0 , story _hash . indexOf ( ':' ) ) ;
var feed = NEWSBLUR . assets . get _feed ( feed _id ) ;
if ( ! feed ) {
console . log ( [ 'Error: Couldn\'t find find for notification' , feed _id , story _hash , story _title ] ) ;
return ;
}
2024-04-30 18:18:14 -04:00
2016-11-15 20:45:59 -08:00
Push . create ( feed . get ( 'feed_title' ) , {
body : story _title ,
icon : $ . favicon ( feed ) ,
timeout : 4000 ,
onClick : function ( ) {
window . focus ( ) ;
this . close ( ) ;
2016-11-16 11:35:02 -08:00
console . log ( [ 'push open' , feed _id , story _hash , window . NEWSBLUR ] ) ;
2016-11-15 20:45:59 -08:00
window . NEWSBLUR . reader . open _feed ( feed _id , {
2016-11-16 11:35:02 -08:00
'story_id' : story _hash
2016-11-15 20:45:59 -08:00
} ) ;
}
} ) ;
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ===================
// = Mouse Indicator =
// ===================
2012-06-08 18:32:31 -07:00
2024-04-30 18:18:14 -04:00
setup _mousemove _on _views : function ( ) {
2012-06-08 18:32:31 -07:00
this . hide _mouse _indicator ( ) ;
2024-04-30 18:18:14 -04:00
2012-07-12 13:43:39 -07:00
if ( this . story _view == 'story' ||
2013-01-09 11:57:47 -08:00
this . story _view == 'text' ||
this . flags [ 'feed_view_showing_story_view' ] ||
this . flags [ 'temporary_story_view' ] ) {
2013-01-09 15:49:33 -08:00
this . hide _mouse _indicator ( ) ;
2012-07-12 13:43:39 -07:00
} else {
_ . delay ( _ . bind ( this . show _mouse _indicator , this ) , 350 ) ;
}
2012-06-08 18:32:31 -07:00
} ,
2024-04-30 18:18:14 -04:00
hide _mouse _indicator : function ( ) {
2010-06-08 11:19:41 -04:00
var self = this ;
2010-06-11 20:55:38 -04:00
2010-12-09 09:59:45 -05:00
if ( ! this . flags [ 'mouse_indicator_hidden' ] ) {
this . flags [ 'mouse_indicator_hidden' ] = true ;
2024-04-30 18:18:14 -04:00
this . $s . $mouse _indicator . animate ( { 'opacity' : 0 , 'left' : - 10 } , {
'duration' : 200 ,
'queue' : false ,
'complete' : function ( ) {
2010-12-09 09:59:45 -05:00
self . flags [ 'mouse_indicator_hidden' ] = true ;
}
} ) ;
2010-06-08 11:19:41 -04:00
}
2010-12-09 09:59:45 -05:00
} ,
2024-04-30 18:18:14 -04:00
show _mouse _indicator : function ( ) {
2010-12-09 09:59:45 -05:00
var self = this ;
2013-06-20 14:45:05 -07:00
if ( NEWSBLUR . assets . preference ( 'feed_view_single_story' ) ) return ;
2010-12-09 09:59:45 -05:00
if ( this . flags [ 'mouse_indicator_hidden' ] ) {
this . flags [ 'mouse_indicator_hidden' ] = false ;
2024-04-30 18:18:14 -04:00
this . $s . $mouse _indicator . animate ( { 'opacity' : 1 , 'left' : 0 } , {
'duration' : 200 ,
2010-12-09 09:59:45 -05:00
'queue' : false ,
2024-04-30 18:18:14 -04:00
'complete' : function ( ) {
2010-12-09 09:59:45 -05:00
self . flags [ 'mouse_indicator_hidden' ] = false ;
}
} ) ;
2010-06-08 11:19:41 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
handle _mouse _indicator _hover : function ( ) {
2010-06-11 16:55:07 -04:00
var self = this ;
var $callout = $ ( '.NB-callout-mouse-indicator' ) ;
$ ( '.NB-callout-text' , $callout ) . text ( 'Lock' ) ;
$callout . corner ( '5px' ) ;
2024-04-30 18:18:14 -04:00
this . $s . $mouse _indicator . hover ( function ( ) {
2012-07-02 16:24:41 -07:00
if ( self . model . preference ( 'lock_mouse_indicator' ) ) {
2010-06-11 20:55:38 -04:00
$ ( '.NB-callout-text' , $callout ) . text ( 'Unlock' ) ;
} else {
$ ( '.NB-callout-text' , $callout ) . text ( 'Lock' ) ;
}
2010-06-11 16:55:07 -04:00
self . flags [ 'still_hovering_on_mouse_indicator' ] = true ;
2024-04-30 18:18:14 -04:00
setTimeout ( function ( ) {
2010-06-11 16:55:07 -04:00
if ( self . flags [ 'still_hovering_on_mouse_indicator' ] ) {
$callout . css ( {
'display' : 'block'
} ) . animate ( {
'opacity' : 1 ,
'left' : '20px'
2024-04-30 18:18:14 -04:00
} , { 'duration' : 200 , 'queue' : false } ) ;
2010-06-11 16:55:07 -04:00
}
} , 50 ) ;
2024-04-30 18:18:14 -04:00
} , function ( ) {
2010-06-11 16:55:07 -04:00
self . flags [ 'still_hovering_on_mouse_indicator' ] = false ;
2024-04-30 18:18:14 -04:00
$callout . animate ( { 'opacity' : 0 , 'left' : '-100px' } , { 'duration' : 200 , 'queue' : false } ) ;
2010-06-11 16:55:07 -04:00
} ) ;
} ,
2024-04-30 18:18:14 -04:00
lock _mouse _indicator : function ( ) {
2010-06-11 20:55:38 -04:00
var self = this ;
var $callout = $ ( '.NB-callout-mouse-indicator' ) ;
2024-04-30 18:18:14 -04:00
2012-07-02 16:24:41 -07:00
if ( self . model . preference ( 'lock_mouse_indicator' ) ) {
2010-06-11 20:55:38 -04:00
self . model . preference ( 'lock_mouse_indicator' , 0 ) ;
$ ( '.NB-callout-text' , $callout ) . text ( 'Unlocked' ) ;
} else {
2024-04-30 18:18:14 -04:00
2013-07-07 22:38:24 -07:00
self . model . preference ( 'lock_mouse_indicator' , this . cache . mouse _position _y ) ;
2010-06-11 20:55:38 -04:00
$ ( '.NB-callout-text' , $callout ) . text ( 'Locked' ) ;
}
2024-04-30 18:18:14 -04:00
setTimeout ( function ( ) {
2010-06-11 20:55:38 -04:00
self . flags [ 'still_hovering_on_mouse_indicator' ] = true ;
$callout . fadeOut ( 200 ) ;
} , 500 ) ;
} ,
2024-04-30 18:18:14 -04:00
position _mouse _indicator : function ( ) {
if ( ! _ . contains ( [ 'split' , 'full' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) return ;
2024-04-30 18:18:14 -04:00
2012-07-02 16:24:41 -07:00
var position = this . model . preference ( 'lock_mouse_indicator' ) ;
var container = this . layout . contentLayout . state . container . innerHeight - 30 ;
if ( position <= 0 || position > container ) {
2013-07-07 22:38:24 -07:00
position = 20 ; // Start with a 20 offset
2010-06-11 20:55:38 -04:00
} else {
position = position - 8 ; // Compensate for mouse indicator height.
}
2012-07-02 16:24:41 -07:00
2010-06-14 13:17:38 -04:00
this . $s . $mouse _indicator . css ( 'top' , position ) ;
2012-10-23 14:47:28 -07:00
// console.log(["position_mouse_indicator", NEWSBLUR.reader.cache.mouse_position_y, position]);
2012-06-18 23:51:03 -07:00
this . cache . mouse _position _y = position ;
2010-06-11 20:55:38 -04:00
} ,
2024-04-30 18:18:14 -04:00
2010-07-05 16:05:54 -04:00
// ==========================
// = Login and Signup Forms =
// ==========================
2024-04-30 18:18:14 -04:00
handle _login _and _signup _forms : function ( ) {
2010-07-05 16:05:54 -04:00
var self = this ;
var $hidden _inputs = $ ( '.NB-signup-hidden' ) ;
2011-09-14 20:08:40 -07:00
var $signup _username = $ ( 'input[name=signup-username]' ) ;
2024-04-30 18:18:14 -04:00
$signup _username . bind ( 'focus' , function ( ) {
2010-07-05 16:05:54 -04:00
$hidden _inputs . slideDown ( 300 ) ;
2024-04-30 18:18:14 -04:00
} ) . bind ( 'blur' , function ( ) {
2011-04-02 19:41:22 -04:00
if ( $signup _username . val ( ) . length < 1 ) {
2010-07-05 16:05:54 -04:00
$hidden _inputs . slideUp ( 300 ) ;
}
} ) ;
} ,
2024-04-30 18:18:14 -04:00
2010-06-30 12:17:22 -04:00
// ==================
// = Features Board =
// ==================
2024-04-30 18:18:14 -04:00
load _feature _page : function ( direction ) {
2010-06-30 12:17:22 -04:00
var self = this ;
2011-03-04 12:45:31 -05:00
var $module = $ ( '.NB-module-features' ) ;
2010-07-07 16:22:26 -04:00
var $next = $ ( '.NB-module-features .NB-module-next-page' ) ;
var $previous = $ ( '.NB-module-features .NB-module-previous-page' ) ;
2011-03-04 12:45:31 -05:00
2011-03-13 16:24:49 -04:00
$module . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
2012-01-23 10:16:50 -08:00
if ( direction == - 1 && this . counts [ 'feature_page' ] <= 0 ) {
2011-03-13 16:24:49 -04:00
$module . removeClass ( 'NB-loading' ) ;
2012-01-23 10:16:50 -08:00
this . counts [ 'feature_page' ] = 0 ;
2010-06-30 12:17:22 -04:00
return ;
}
2010-06-30 21:57:24 -04:00
if ( direction == 1 && this . flags [ 'features_last_page' ] ) {
2011-03-13 16:24:49 -04:00
$module . removeClass ( 'NB-loading' ) ;
2010-06-30 16:18:55 -04:00
return ;
}
2024-04-30 18:18:14 -04:00
this . model . get _features _page ( this . counts [ 'feature_page' ] + direction , function ( features ) {
2011-03-13 16:24:49 -04:00
$module . removeClass ( 'NB-loading' ) ;
2015-10-07 17:37:17 -07:00
if ( ! features ) return ;
2024-04-30 18:18:14 -04:00
2010-08-11 11:43:48 -04:00
self . counts [ 'feature_page' ] += direction ;
2024-04-30 18:18:14 -04:00
2011-05-07 12:06:51 -04:00
var $table = $ . make ( 'table' , { className : 'NB-features' , cellSpacing : 0 , cellPadding : 0 } ) ;
2010-06-30 16:18:55 -04:00
for ( var f in features ) {
2010-06-30 22:13:24 -04:00
if ( f == 3 ) break ;
2010-06-30 16:18:55 -04:00
var feature = features [ f ] ;
var $tr = $ . make ( 'tr' , { className : 'NB-module-feature' } , [
2010-07-31 00:13:27 -04:00
$ . make ( 'td' , { className : 'NB-module-feature-date' } , feature . date ) ,
2010-06-30 16:18:55 -04:00
$ . make ( 'td' , { className : 'NB-module-feature-description' } , feature . description )
] ) ;
$table . append ( $tr ) ;
}
2024-04-30 18:18:14 -04:00
2011-05-07 12:06:51 -04:00
$ ( '.NB-module-features .NB-features' ) . replaceWith ( $table ) ;
2024-04-30 18:18:14 -04:00
2010-06-30 21:57:24 -04:00
var features _count = features . length ;
if ( features _count < 4 ) {
$next . addClass ( 'NB-disabled' ) ;
self . flags [ 'features_last_page' ] = true ;
} else {
$next . removeClass ( 'NB-disabled' ) ;
self . flags [ 'features_last_page' ] = false ;
}
2010-08-11 11:43:48 -04:00
if ( self . counts [ 'feature_page' ] > 0 ) {
2010-06-30 21:57:24 -04:00
$previous . removeClass ( 'NB-disabled' ) ;
} else {
$previous . addClass ( 'NB-disabled' ) ;
}
2024-04-30 18:18:14 -04:00
} , function ( ) {
2015-10-07 17:37:17 -07:00
$module . removeClass ( 'NB-loading' ) ;
2010-06-30 12:17:22 -04:00
} ) ;
} ,
2024-04-30 18:18:14 -04:00
setup _howitworks _hovers : function ( ) {
2011-03-29 21:56:15 -04:00
var $page _indicators = $ ( '.NB-module-howitworks .NB-module-page-indicator' ) ;
2024-04-30 18:18:14 -04:00
$page _indicators . bind ( 'mouseenter' , _ . bind ( function ( e ) {
2011-03-29 21:56:15 -04:00
var page = $ ( e . target ) . prevAll ( '.NB-module-page-indicator' ) . length ;
this . load _howitworks _page ( page ) ;
} , this ) ) ;
} ,
2024-04-30 18:18:14 -04:00
load _howitworks _page : function ( page ) {
2010-07-07 16:22:26 -04:00
var self = this ;
var $next = $ ( '.NB-module-howitworks .NB-module-next-page' ) ;
var $previous = $ ( '.NB-module-howitworks .NB-module-previous-page' ) ;
var $pages = $ ( '.NB-howitworks-page' ) ;
var $page _indicators = $ ( '.NB-module-howitworks .NB-module-page-indicator' ) ;
var pages _count = $pages . length ;
2024-04-30 18:18:14 -04:00
2010-07-07 16:22:26 -04:00
if ( page == - 1 ) {
return ;
}
if ( page >= pages _count ) {
return ;
}
2024-04-30 18:18:14 -04:00
2010-07-07 16:22:26 -04:00
$pages . removeClass ( "NB-active" ) ;
$page _indicators . removeClass ( "NB-active" ) ;
$pages . eq ( page ) . addClass ( "NB-active" ) ;
$page _indicators . eq ( page ) . addClass ( "NB-active" ) ;
2024-04-30 18:18:14 -04:00
2010-07-07 16:22:26 -04:00
if ( page >= pages _count - 1 ) {
$next . addClass ( 'NB-disabled' ) ;
} else {
$next . removeClass ( 'NB-disabled' ) ;
}
if ( page <= 0 ) {
$previous . addClass ( 'NB-disabled' ) ;
} else {
$previous . removeClass ( 'NB-disabled' ) ;
}
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ========
// = FTUX =
// ========
2024-04-30 18:18:14 -04:00
setup _ftux _add _feed _callout : function ( message ) {
2010-06-13 00:54:32 -04:00
var self = this ;
2012-03-19 14:15:38 -07:00
if ( this . flags [ 'bouncing_callout' ] ) return ;
2024-04-30 18:18:14 -04:00
2012-07-20 19:43:28 -07:00
$ ( '.NB-callout-ftux .NB-callout-text' ) . text ( message || 'First things first...' ) ;
2010-06-14 13:17:38 -04:00
$ ( '.NB-callout-ftux' ) . corner ( '5px' ) ;
$ ( '.NB-callout-ftux' ) . css ( {
'opacity' : 0 ,
'display' : 'block'
} ) . animate ( {
'opacity' : 1 ,
2013-02-26 10:00:35 -08:00
'bottom' : 36
2010-06-13 00:54:32 -04:00
} , {
2010-06-14 13:17:38 -04:00
'duration' : 750 ,
'easing' : 'easeInOutQuint'
2024-04-30 18:18:14 -04:00
} ) . each ( function ( ) {
2010-06-14 13:17:38 -04:00
var $this = $ ( this ) ;
2024-04-30 18:18:14 -04:00
self . flags [ 'bouncing_callout' ] = setInterval ( function ( ) {
$this . animate ( { 'bottom' : '+=2px' } , { 'duration' : 200 , 'easing' : 'easeInOutQuint' } )
. animate ( { 'bottom' : '+=0px' } , { 'duration' : 50 } )
. animate ( { 'bottom' : '-=2px' } , { 'duration' : 200 , 'easing' : 'easeInOutQuint' } ) ;
2010-06-13 18:57:20 -04:00
} , 1000 ) ;
} ) ;
2010-06-13 00:54:32 -04:00
} ,
2024-04-30 18:18:14 -04:00
setup _ftux _signup _callout : function ( ) {
2010-06-14 13:17:38 -04:00
var self = this ;
2024-04-30 18:18:14 -04:00
2012-07-02 10:15:17 -07:00
if ( ! this . flags [ 'bouncing_callout' ] ) {
2010-06-14 13:17:38 -04:00
$ ( '.NB-callout-ftux-signup .NB-callout-text' ) . text ( 'Signup' ) ;
$ ( '.NB-callout-ftux-signup' ) . corner ( '5px' ) ;
$ ( '.NB-callout-ftux-signup' ) . css ( {
'opacity' : 0 ,
'display' : 'block'
} ) . animate ( {
'opacity' : 1 ,
'bottom' : 36
} , {
'duration' : 750 ,
'easing' : 'easeInOutQuint'
2024-04-30 18:18:14 -04:00
} ) . each ( function ( ) {
2010-06-14 13:17:38 -04:00
var $this = $ ( this ) ;
2024-04-30 18:18:14 -04:00
self . flags [ 'bouncing_callout' ] = setInterval ( function ( ) {
$this . animate ( { 'bottom' : '+=2px' } , { 'duration' : 200 , 'easing' : 'easeInOutQuint' } )
. animate ( { 'bottom' : '+=0px' } , { 'duration' : 50 } )
. animate ( { 'bottom' : '-=2px' } , { 'duration' : 200 , 'easing' : 'easeInOutQuint' } ) ;
} , 10000 ) ;
2010-06-14 13:17:38 -04:00
} ) ;
2010-06-08 11:19:41 -04:00
}
} ,
2024-04-30 18:18:14 -04:00
2010-08-17 20:59:47 -04:00
// =============================
// = Import from Google Reader =
// =============================
2010-08-17 23:40:03 -04:00
2024-04-30 18:18:14 -04:00
start _count _unreads _after _import : function ( ) {
2010-08-17 23:40:03 -04:00
var self = this ;
var $progress = this . $s . $feeds _progress ;
var $bar = $ ( '.NB-progress-bar' , $progress ) ;
var percentage = 0 ;
2011-01-31 19:51:39 -05:00
var feeds _count = _ . keys ( this . model . feeds ) . length ;
2024-04-30 18:18:14 -04:00
2012-03-12 12:33:54 -07:00
if ( ! this . flags [ 'pause_feed_refreshing' ] || this . flags [ 'has_unfetched_feeds' ] ) return ;
2024-04-30 18:18:14 -04:00
2011-02-01 00:23:44 -05:00
this . flags [ 'count_unreads_after_import_working' ] = true ;
2024-04-30 18:18:14 -04:00
2010-08-17 23:40:03 -04:00
$ ( '.NB-progress-title' , $progress ) . text ( 'Counting is difficult' ) ;
$ ( '.NB-progress-counts' , $progress ) . hide ( ) ;
$ ( '.NB-progress-percentage' , $progress ) . hide ( ) ;
$bar . progressbar ( {
value : percentage
} ) ;
2024-04-30 18:18:14 -04:00
setTimeout ( function ( ) {
2011-02-01 00:23:44 -05:00
if ( self . flags [ 'count_unreads_after_import_working' ] ) {
2012-08-09 10:34:41 -07:00
self . animate _progress _bar ( $bar , feeds _count / 30 ) ;
2010-08-17 23:40:03 -04:00
self . show _progress _bar ( ) ;
}
} , 500 ) ;
2010-08-17 20:59:47 -04:00
} ,
2010-08-17 23:40:03 -04:00
2024-04-30 18:18:14 -04:00
finish _count _unreads _after _import : function ( data ) {
2013-04-02 15:41:50 -07:00
data = data || { } ;
2010-08-17 23:40:03 -04:00
$ ( '.NB-progress-bar' , this . $s . $feeds _progress ) . progressbar ( {
value : 100
} ) ;
2011-02-01 00:23:44 -05:00
this . flags [ 'count_unreads_after_import_working' ] = false ;
clearTimeout ( this . locks [ 'animate_progress_bar' ] ) ;
2010-08-17 23:40:03 -04:00
this . $s . $feed _link _loader . fadeOut ( 250 ) ;
2024-04-30 18:18:14 -04:00
this . $s . $feed _link _error . css ( { 'display' : 'none' } ) ;
2010-08-17 23:40:03 -04:00
this . setup _feed _refresh ( ) ;
if ( ! this . flags [ 'has_unfetched_feeds' ] ) {
this . hide _progress _bar ( ) ;
}
2010-08-17 20:59:47 -04:00
} ,
2024-04-30 18:18:14 -04:00
2011-03-02 12:05:58 -05:00
// =====================
// = Recommended Feeds =
// =====================
2024-04-30 18:18:14 -04:00
load _recommended _feeds : function ( ) {
// Reload recommended feeds every 60 minutes.
clearInterval ( this . locks . load _recommended _feed ) ;
this . locks . load _recommended _feed = setInterval ( _ . bind ( function ( ) {
this . load _recommended _feed ( 0 , true ) ;
} , this ) , 60 * 60 * 1000 ) ;
} ,
load _feed _in _tryfeed _view : function ( feed _id , options ) {
2012-04-19 22:38:00 -07:00
options = options || { } ;
2022-03-10 14:54:54 -05:00
var feed = _ . extend ( {
2024-04-30 18:18:14 -04:00
id : feed _id ,
feed _id : feed _id ,
feed _title : options . feed && options . feed . feed _title ,
temp : true
2012-06-14 17:21:51 -07:00
} , options . feed && options . feed . attributes ) ;
2011-03-15 23:42:27 -04:00
var $tryfeed _container = this . $s . $tryfeed _header . closest ( '.NB-feeds-header-container' ) ;
2011-03-15 10:21:47 -04:00
2012-09-17 13:24:00 -07:00
this . reset _feed ( options ) ;
2012-06-13 11:51:49 -07:00
feed = this . model . set _feed ( feed _id , feed ) ;
2011-03-15 23:42:27 -04:00
2012-06-13 11:51:49 -07:00
$ ( '.NB-feeds-header-title' , this . $s . $tryfeed _header ) . text ( feed . get ( 'feed_title' ) ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-feeds-header-icon' , this . $s . $tryfeed _header ) . attr ( 'src' , $ . favicon ( feed ) ) ;
2011-03-15 23:42:27 -04:00
2024-04-30 18:18:14 -04:00
$tryfeed _container . slideDown ( 350 , _ . bind ( function ( ) {
2012-04-19 22:38:00 -07:00
options . force = true ;
options . try _feed = true ;
this . open _feed ( feed _id , options ) ;
2011-03-15 23:42:27 -04:00
this . flags [ 'showing_feed_in_tryfeed_view' ] = true ;
this . $s . $tryfeed _header . addClass ( 'NB-selected' ) ;
} , this ) ) ;
} ,
2024-04-30 18:18:14 -04:00
load _social _feed _in _tryfeed _view : function ( social _feed , options ) {
2012-04-11 15:20:57 -07:00
options = options || { } ;
if ( _ . isNumber ( social _feed ) ) {
social _feed = this . model . get _feed ( 'social:' + social _feed ) ;
2012-04-30 12:20:04 -07:00
} else if ( _ . isString ( social _feed ) ) {
social _feed = this . model . get _feed ( social _feed ) ;
}
if ( ! social _feed ) {
social _feed = this . model . add _social _feed ( options . feed ) ;
2012-04-11 15:20:57 -07:00
}
2024-04-30 18:18:14 -04:00
2012-03-14 12:38:59 -07:00
var $tryfeed _container = this . $s . $tryfeed _header . closest ( '.NB-feeds-header-container' ) ;
this . reset _feed ( ) ;
2024-04-30 18:18:14 -04:00
2012-03-14 12:38:59 -07:00
$ ( '.NB-feeds-header-title' , this . $s . $tryfeed _header ) . text ( social _feed . get ( 'username' ) ) ;
2024-04-30 18:18:14 -04:00
$ ( '.NB-feeds-header-icon' , this . $s . $tryfeed _header ) . attr ( 'src' , $ . favicon ( social _feed ) ) ;
2012-03-14 12:38:59 -07:00
2024-04-30 18:18:14 -04:00
$tryfeed _container . slideDown ( 350 , _ . bind ( function ( ) {
2012-04-16 11:21:52 -07:00
this . open _social _stories ( social _feed . get ( 'id' ) , options ) ;
2012-03-14 12:38:59 -07:00
this . switch _taskbar _view ( 'feed' ) ;
2015-02-06 13:28:55 -08:00
this . switch _story _layout ( ) ;
2012-03-15 11:33:00 -07:00
this . flags [ 'showing_social_feed_in_tryfeed_view' ] = true ;
2012-03-14 12:38:59 -07:00
this . $s . $tryfeed _header . addClass ( 'NB-selected' ) ;
} , this ) ) ;
} ,
2024-04-30 18:18:14 -04:00
hide _tryfeed _view : function ( ) {
2011-03-15 23:42:27 -04:00
var $tryfeed _container = this . $s . $tryfeed _header . closest ( '.NB-feeds-header-container' ) ;
$tryfeed _container . slideUp ( 350 ) ;
this . $s . $story _taskbar . find ( '.NB-tryfeed-add' ) . remove ( ) ;
2012-03-15 11:33:00 -07:00
this . $s . $story _taskbar . find ( '.NB-tryfeed-follow' ) . remove ( ) ;
2011-03-15 23:42:27 -04:00
this . flags [ 'showing_feed_in_tryfeed_view' ] = false ;
2012-03-15 11:33:00 -07:00
this . flags [ 'showing_social_feed_in_tryfeed_view' ] = false ;
2011-03-15 23:42:27 -04:00
} ,
2024-04-30 18:18:14 -04:00
show _tryfeed _add _button : function ( ) {
2011-03-16 19:20:38 -04:00
if ( this . $s . $story _taskbar . find ( '.NB-tryfeed-add:visible' ) . length ) return ;
2024-04-30 18:18:14 -04:00
2011-03-15 23:42:27 -04:00
var $add = $ . make ( 'div' , { className : 'NB-modal-submit' } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-tryfeed-add NB-modal-submit-green NB-modal-submit-button' } , 'Subscribe' )
] ) . css ( { 'opacity' : 0 } ) ;
2013-02-05 13:54:25 -08:00
this . $s . $story _taskbar . append ( $add ) ;
2024-04-30 18:18:14 -04:00
$add . animate ( { 'opacity' : 1 } , { 'duration' : 600 } ) ;
2011-03-11 20:05:41 -05:00
} ,
2024-04-30 18:18:14 -04:00
correct _tryfeed _title : function ( ) {
2012-04-19 22:38:00 -07:00
var feed = this . model . get _feed ( this . active _feed ) ;
2012-05-21 14:36:54 -07:00
$ ( '.NB-feeds-header-title' , this . $s . $tryfeed _header ) . text ( feed . get ( 'feed_title' ) ) ;
2012-09-07 17:36:12 -07:00
this . make _feed _title _in _stories ( ) ;
2012-04-19 22:38:00 -07:00
} ,
2024-04-30 18:18:14 -04:00
show _tryfeed _follow _button : function ( ) {
2012-03-15 11:33:00 -07:00
if ( this . $s . $story _taskbar . find ( '.NB-tryfeed-follow:visible' ) . length ) return ;
2024-04-30 18:18:14 -04:00
2012-03-15 11:33:00 -07:00
var $add = $ . make ( 'div' , { className : 'NB-modal-submit' } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-tryfeed-follow NB-modal-submit-green NB-modal-submit-button' } , 'Follow' )
] ) . css ( { 'opacity' : 0 } ) ;
2013-02-05 13:54:25 -08:00
this . $s . $story _taskbar . append ( $add ) ;
2024-04-30 18:18:14 -04:00
$add . animate ( { 'opacity' : 1 } , { 'duration' : 600 } ) ;
2012-03-15 11:33:00 -07:00
} ,
2024-04-30 18:18:14 -04:00
show _tryout _signup _button : function ( ) {
2012-09-17 12:29:46 -07:00
if ( this . $s . $story _taskbar . find ( '.NB-tryout-signup:visible' ) . length ) return ;
2024-04-30 18:18:14 -04:00
2012-09-17 12:29:46 -07:00
var $add = $ . make ( 'div' , { className : 'NB-modal-submit' } , [
2024-04-30 18:18:14 -04:00
$ . make ( 'div' , { className : 'NB-tryout-signup NB-modal-submit-green NB-modal-submit-button' } , 'Sign Up' )
] ) . css ( { 'opacity' : 0 } ) ;
2013-02-01 12:05:45 -08:00
this . $s . $story _taskbar . append ( $add ) ;
2024-04-30 18:18:14 -04:00
$add . animate ( { 'opacity' : 1 } , { 'duration' : 600 } ) ;
2012-09-17 12:29:46 -07:00
} ,
2024-04-30 18:18:14 -04:00
hide _tryout _signup _button : function ( ) {
2012-09-17 12:29:46 -07:00
this . $s . $story _taskbar . find ( '.NB-tryout-signup:visible' ) . remove ( ) ;
} ,
2024-04-30 18:18:14 -04:00
add _recommended _feed : function ( feed _id ) {
2012-06-13 11:51:49 -07:00
feed _id = feed _id || this . active _feed ;
var feed _address = this . model . get _feed ( feed _id ) . get ( 'feed_address' ) ;
2024-04-30 18:18:14 -04:00
this . open _add _feed _modal ( { url : feed _address } ) ;
2011-03-11 20:05:41 -05:00
} ,
2024-04-30 18:18:14 -04:00
follow _user _in _tryfeed : function ( feed _id ) {
2012-03-15 14:00:44 -07:00
var self = this ;
2012-03-15 11:33:00 -07:00
var socialsub = this . model . get _feed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
this . model . follow _user ( socialsub . get ( 'user_id' ) , function ( data ) {
2012-05-17 18:40:46 -07:00
NEWSBLUR . app . feed _list . make _social _feeds ( ) ;
self . open _social _stories ( feed _id ) ;
2012-03-15 11:33:00 -07:00
} ) ;
} ,
2024-04-30 18:18:14 -04:00
approve _feed _in _moderation _queue : function ( feed _id ) {
2011-03-13 16:24:49 -04:00
var self = this ;
2011-07-11 18:22:28 -07:00
var $module = $ ( '.NB-module-recommended.NB-recommended-unmoderated' ) ;
$module . addClass ( 'NB-loading' ) ;
2011-07-11 18:44:47 -07:00
var date = $ ( '.NB-recommended-moderation-date' ) . val ( ) ;
2024-04-30 18:18:14 -04:00
this . model . approve _feed _in _moderation _queue ( feed _id , date , function ( resp ) {
2011-07-11 18:22:28 -07:00
if ( ! resp ) return ;
$module . removeClass ( 'NB-loading' ) ;
$module . replaceWith ( resp ) ;
self . load _javascript _elements _on _page ( ) ;
} ) ;
} ,
2024-04-30 18:18:14 -04:00
decline _feed _in _moderation _queue : function ( feed _id ) {
2011-07-11 18:22:28 -07:00
var self = this ;
var $module = $ ( '.NB-module-recommended.NB-recommended-unmoderated' ) ;
$module . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
this . model . decline _feed _in _moderation _queue ( feed _id , function ( resp ) {
2011-07-11 18:22:28 -07:00
if ( ! resp ) return ;
$module . removeClass ( 'NB-loading' ) ;
$module . replaceWith ( resp ) ;
self . load _javascript _elements _on _page ( ) ;
} ) ;
} ,
2024-04-30 18:18:14 -04:00
load _recommended _feed : function ( direction , refresh , unmoderated ) {
2011-03-13 16:24:49 -04:00
var self = this ;
2024-04-30 18:18:14 -04:00
var $module = unmoderated ?
$ ( '.NB-module-recommended.NB-recommended-unmoderated' ) :
$ ( '.NB-module-recommended:not(.NB-recommended-unmoderated)' ) ;
2015-03-13 18:07:00 -07:00
if ( ! refresh ) {
$module . addClass ( 'NB-loading' ) ;
}
2011-03-13 16:24:49 -04:00
direction = direction || 0 ;
2024-04-30 18:18:14 -04:00
this . model . load _recommended _feed ( this . counts [ 'recommended_feed_page' ] + direction ,
! ! refresh , unmoderated , function ( resp ) {
$module . removeClass ( 'NB-loading' ) ;
if ( ! resp ) return ;
$module . replaceWith ( resp ) ;
self . counts [ 'recommended_feed_page' ] += direction ;
self . load _javascript _elements _on _page ( ) ;
} , function ( ) {
$module . removeClass ( 'NB-loading' ) ;
} ) ;
2011-03-11 20:05:41 -05:00
} ,
2024-04-30 18:18:14 -04:00
2011-04-24 22:47:20 -04:00
// ====================
// = Dashboard Graphs =
// ====================
2024-04-30 18:18:14 -04:00
setup _dashboard _graphs : function ( ) {
2021-04-30 12:17:37 -04:00
// Reload dashboard graphs every 30 min in debug, 1 min for staff, 10 minutes otherwise.
2024-04-30 18:18:14 -04:00
var reload _interval = NEWSBLUR . Globals . debug ? 30 * 60 * 1000 : NEWSBLUR . Globals . is _staff ? 60 * 1000 : 10 * 60 * 1000 ;
2014-02-26 11:36:59 -08:00
clearInterval ( this . locks . load _dashboard _graphs ) ;
2024-04-30 18:18:14 -04:00
this . locks . load _dashboard _graphs = setInterval ( _ . bind ( function ( ) {
2014-02-26 11:36:59 -08:00
this . load _dashboard _graphs ( ) ;
} , this ) , reload _interval * ( Math . random ( ) * ( 1.25 - 0.75 ) + 0.75 ) ) ;
2011-04-24 22:47:20 -04:00
} ,
2024-04-30 18:18:14 -04:00
load _dashboard _graphs : function ( ) {
2011-04-24 22:47:20 -04:00
var self = this ;
2011-12-20 08:55:55 -08:00
var $module = $ ( '.NB-module-site-stats' ) ;
2011-04-24 22:47:20 -04:00
$module . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
this . model . load _dashboard _graphs ( function ( resp ) {
2011-04-24 22:47:20 -04:00
$module . removeClass ( 'NB-loading' ) ;
2012-04-12 11:18:56 -07:00
if ( ! resp ) return ;
2011-04-24 22:47:20 -04:00
$module . replaceWith ( resp ) ;
self . load _javascript _elements _on _page ( ) ;
2024-04-30 18:18:14 -04:00
} , function ( ) {
2012-04-12 11:18:56 -07:00
$module . removeClass ( 'NB-loading' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
} ,
setup _feedback _table : function ( ) {
2021-04-30 12:17:37 -04:00
// Reload feedback every 30 min in debug, 30 sec for staff, 10 minutes otherwise.
var reload _interval = NEWSBLUR . Globals . debug ? 30 * 60 * 1000 : NEWSBLUR . Globals . is _staff ? 0.5 * 60 * 1000 : 10 * 60 * 1000 ;
2024-04-30 18:18:14 -04:00
2014-02-26 11:36:59 -08:00
clearInterval ( this . locks . load _feedback _table ) ;
2024-04-30 18:18:14 -04:00
this . locks . load _feedback _table = setInterval ( _ . bind ( function ( ) {
2014-02-26 11:36:59 -08:00
this . load _feedback _table ( ) ;
2015-10-07 17:37:17 -07:00
this . load _feature _page ( 0 ) ;
2014-02-26 11:36:59 -08:00
} , this ) , reload _interval * ( Math . random ( ) * ( 1.25 - 0.75 ) + 0.75 ) ) ;
2011-12-18 18:03:40 -08:00
} ,
2024-04-30 18:18:14 -04:00
load _feedback _table : function ( ) {
2011-12-18 18:03:40 -08:00
var self = this ;
var $module = $ ( '.NB-feedback-table' ) ;
$module . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
this . model . load _feedback _table ( function ( resp ) {
2011-12-18 18:03:40 -08:00
$module . removeClass ( 'NB-loading' ) ;
2015-10-07 17:37:17 -07:00
if ( ! resp ) return ;
2011-04-24 22:47:20 -04:00
$module . replaceWith ( resp ) ;
self . load _javascript _elements _on _page ( ) ;
2024-04-30 18:18:14 -04:00
} , function ( ) {
2013-01-08 08:50:22 -08:00
$module . removeClass ( 'NB-loading' ) ;
} ) ;
2011-04-24 22:47:20 -04:00
} ,
2024-04-30 18:18:14 -04:00
2012-06-19 13:01:30 -07:00
// ===================
// = Unfetched Feeds =
// ===================
2024-04-30 18:18:14 -04:00
2021-04-05 14:22:36 -04:00
setup _unfetched _feed _check : function ( ) {
clearInterval ( this . locks . unfetched _feed _check ) ;
2024-04-30 18:18:14 -04:00
this . locks . unfetched _feed _check = setInterval ( _ . bind ( function ( ) {
2012-06-19 13:01:30 -07:00
var unfetched _feeds = NEWSBLUR . assets . unfetched _feeds ( ) ;
if ( unfetched _feeds . length ) {
2012-07-29 00:49:34 -07:00
this . force _instafetch _stories ( unfetched _feeds [ 0 ] . id ) ;
2012-06-19 13:01:30 -07:00
}
2024-04-30 18:18:14 -04:00
} , this ) , 60 * 1 * 1000 ) ;
2012-06-19 13:01:30 -07:00
} ,
2024-04-30 18:18:14 -04:00
2010-06-14 13:17:38 -04:00
// ==========
// = Events =
// ==========
2010-08-17 23:40:03 -04:00
2024-04-30 18:18:14 -04:00
handle _clicks : function ( elem , e ) {
2010-06-08 11:19:41 -04:00
var self = this ;
2010-09-12 13:50:27 -04:00
var stopPropagation = false ;
2024-04-30 18:18:14 -04:00
2012-10-01 13:07:45 -07:00
// NEWSBLUR.log(['click', e, e.button]);
2021-02-03 18:52:39 -05:00
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-feeds-list-retry' } , function ( $t , $p ) {
2021-02-03 18:52:39 -05:00
NEWSBLUR . app . feed _list . retry ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2021-02-03 18:52:39 -05:00
2010-09-12 13:50:27 -04:00
// = Taskbar ======================================================
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-task-add' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
self . open _add _feed _modal ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-task-manage' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2010-09-12 13:50:27 -04:00
self . show _manage _menu ( 'site' , $t ) ;
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-account-settings' } , function ( $t , $p ) {
2013-03-19 09:55:21 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
self . show _manage _menu ( 'site' , $t , { inverse : true } ) ;
2013-03-19 09:55:21 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-modal-title' } , function ( $t , $p ) {
2013-04-11 16:50:18 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var $item = $ ( ".NB-icon" , $t ) ;
if ( $item . length ) {
2024-04-30 18:18:14 -04:00
self . show _manage _menu ( 'site' , $item , { inverse : true , right : true , body : true } ) ;
2013-04-11 16:50:18 -07:00
}
}
2020-06-10 15:48:40 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-story-titles-expand-sidebar' } , function ( $t , $p ) {
2020-06-10 15:48:40 -04:00
e . preventDefault ( ) ;
self . open _sidebar ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2012-05-17 13:22:00 -07:00
// = Context Menu ================================================
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-open-input' } , function ( $t , $p ) {
2012-05-17 13:22:00 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
self . flags [ 'showing_confirm_input_on_manage_menu' ] = true ;
2024-04-30 18:18:14 -04:00
$t . select ( ) . blur ( function ( ) {
2012-05-17 13:22:00 -07:00
self . flags [ 'showing_confirm_input_on_manage_menu' ] = false ;
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-train' } , function ( $t , $p ) {
2010-07-24 00:04:14 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2010-09-12 13:50:27 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2010-09-17 12:40:42 -04:00
self . open _feed _intelligence _modal ( 1 , feed _id , false ) ;
2010-07-24 00:04:14 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-train' } , function ( $t , $p ) {
2013-12-13 22:06:49 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var story _id = $t . parents ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
self . open _story _trainer ( story _id , feed _id ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-recommend' } , function ( $t , $p ) {
2011-03-28 10:08:10 -04:00
e . preventDefault ( ) ;
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
self . open _recommend _modal ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-mark-read-newer' } , function ( $t , $p ) {
2010-12-30 19:24:52 -05:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var story _id = $t . closest ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
2013-12-05 14:25:15 -08:00
var story = NEWSBLUR . assets . get _story ( story _id ) ;
var timestamp = story . get ( 'story_timestamp' ) ;
2024-04-30 18:18:14 -04:00
2013-12-05 14:25:15 -08:00
if ( self . flags . river _view && ! self . flags . social _view ) {
self . mark _folder _as _read ( self . active _folder , timestamp , 'newer' ) ;
} else {
self . mark _feed _as _read ( self . active _feed , timestamp , 'newer' ) ;
}
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-mark-read-older' } , function ( $t , $p ) {
2013-12-05 14:25:15 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var story _id = $t . closest ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
var story = NEWSBLUR . assets . get _story ( story _id ) ;
var timestamp = story . get ( 'story_timestamp' ) ;
2024-04-30 18:18:14 -04:00
2013-12-05 14:25:15 -08:00
if ( self . flags . river _view && ! self . flags . social _view ) {
self . mark _folder _as _read ( self . active _folder , timestamp , 'older' ) ;
} else {
self . mark _feed _as _read ( self . active _feed , timestamp , 'older' ) ;
}
2010-12-30 19:24:52 -05:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-trainer' } , function ( $t , $p ) {
2010-08-01 23:47:40 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _trainer _modal ( ) ;
} ) ;
2010-08-01 23:47:40 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-tutorial' } , function ( $t , $p ) {
2011-05-10 18:30:35 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _tutorial _modal ( ) ;
} ) ;
2011-05-10 18:30:35 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-intro' } , function ( $t , $p ) {
2012-03-02 17:51:28 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
self . open _intro _modal ( { page _number : 1 } ) ;
2013-04-11 16:50:18 -07:00
} ) ;
2012-03-02 17:51:28 -08:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-stats' } , function ( $t , $p ) {
2010-07-24 00:04:14 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2010-09-12 13:50:27 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
NEWSBLUR . log ( [ 'statistics feed_id' , feed _id ] ) ;
self . open _feed _statistics _modal ( feed _id ) ;
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-settings' } , function ( $t , $p ) {
2011-09-26 09:22:46 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2012-01-16 17:55:13 -08:00
self . open _feed _exception _modal ( feed _id ) ;
2011-09-26 09:22:46 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-notifications' } , function ( $t , $p ) {
2016-11-14 19:26:09 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2016-11-14 19:26:09 -08:00
self . open _notifications _modal ( feed _id ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-settings' } , function ( $t , $p ) {
2015-08-22 17:36:05 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var folder _title = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
self . open _feed _exception _modal ( folder _title , {
2024-04-30 18:18:14 -04:00
folder _title : folder _title ,
2015-08-22 17:36:05 -07:00
$folder : $folder
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-reload' } , function ( $t , $p ) {
2010-10-10 20:14:31 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2010-12-24 11:00:30 -05:00
self . force _instafetch _stories ( feed _id ) ;
2010-10-10 20:14:31 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-delete' } , function ( $t , $p ) {
2010-07-01 00:29:26 -04:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2010-09-14 20:49:28 -04:00
if ( $t . hasClass ( 'NB-menu-manage-feed-delete-cancel' ) ||
$t . hasClass ( 'NB-menu-manage-folder-delete-cancel' ) ) {
2010-07-01 00:29:26 -04:00
self . hide _confirm _delete _menu _item ( ) ;
2012-03-30 14:56:16 -07:00
} else if ( $t . hasClass ( 'NB-menu-manage-feed-delete' ) ||
2024-04-30 18:18:14 -04:00
$t . hasClass ( 'NB-menu-manage-folder-delete' ) ) {
2010-07-01 00:29:26 -04:00
self . show _confirm _delete _menu _item ( ) ;
2012-03-30 14:56:16 -07:00
} else if ( $t . hasClass ( 'NB-menu-manage-socialfeed-delete-cancel' ) ) {
self . hide _confirm _unfollow _menu _item ( ) ;
} else if ( $t . hasClass ( 'NB-menu-manage-socialfeed-delete' ) ) {
self . show _confirm _unfollow _menu _item ( ) ;
2010-07-01 00:29:26 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-delete-confirm' } , function ( $t , $p ) {
2010-07-01 00:29:26 -04:00
e . preventDefault ( ) ;
2010-09-12 13:50:27 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2010-09-14 20:49:28 -04:00
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _delete _feed ( feed _id , $feed ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-delete-search' } , function ( $t , $p ) {
2017-03-07 12:20:20 -08:00
e . preventDefault ( ) ;
var search _model _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _delete _search ( search _model _id , $feed ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-socialfeed-delete-confirm' } , function ( $t , $p ) {
2012-03-30 14:56:16 -07:00
e . preventDefault ( ) ;
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _unfollow _feed ( feed _id , $feed ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-delete-confirm' } , function ( $t , $p ) {
2010-09-14 20:49:28 -04:00
e . preventDefault ( ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
self . manage _menu _delete _folder ( folder _name , $folder ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2014-06-28 08:22:32 -07:00
var adding _icon = false ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-icon-add' , childOf : '.NB-menu-manage' } , function ( $t , $p ) {
2014-06-28 08:22:32 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
adding _icon = true ;
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $folder = $t . parents ( '.NB-folder-option' ) ;
var folder = $folder . data ( 'folder' ) ;
self . show _add _folder _in _menu ( feed _id , $folder , folder || '' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-folder-option' , childOf : '.NB-menu-manage' } , function ( $t , $p ) {
2014-06-27 16:53:01 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2014-06-28 08:22:32 -07:00
if ( adding _icon ) return ;
2014-06-27 16:53:01 -07:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
self . switch _change _folder ( feed _id , $t . data ( 'folder' ) || '' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-move' } , function ( $t , $p ) {
2011-09-04 15:42:13 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
2011-09-04 15:42:13 -07:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
2024-04-30 18:18:14 -04:00
2011-09-04 15:42:13 -07:00
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
2024-04-30 18:18:14 -04:00
2011-09-04 15:42:13 -07:00
if ( $t . hasClass ( 'NB-menu-manage-feed-move-cancel' ) ||
$t . hasClass ( 'NB-menu-manage-folder-move-cancel' ) ) {
self . hide _confirm _move _menu _item ( ) ;
} else {
self . show _confirm _move _menu _item ( feed _id || folder _name , $feed || $folder ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-add-folder-save' } , function ( $t , $p ) {
2014-06-28 08:22:32 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
2014-06-28 08:22:32 -07:00
self . add _folder _to _folder ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-move-save' } , function ( $t , $p ) {
2011-09-04 15:42:13 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
2011-11-07 20:50:46 -08:00
self . manage _menu _move _folder ( folder _name , $folder ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-move-save' } , function ( $t , $p ) {
2011-09-04 15:42:13 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2014-06-27 16:53:01 -07:00
if ( $t . hasClass ( 'NB-disabled' ) ) return ;
2011-09-04 15:42:13 -07:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _move _feed ( feed _id , $feed ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-move-confirm' } , function ( $t , $p ) {
2011-09-04 15:42:13 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-move-confirm' } , function ( $t , $p ) {
2011-09-04 15:42:13 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-controls' } , function ( $t , $p ) {
2012-07-18 18:34:19 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2012-07-18 20:19:54 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-mute' } , function ( $t , $p ) {
2015-11-10 21:06:30 -08:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2016-05-09 16:13:40 -07:00
self . manage _menu _mute _feed ( $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) , false ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-unmute' } , function ( $t , $p ) {
2016-05-09 16:13:40 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
self . manage _menu _mute _feed ( $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) , true ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-rename' } , function ( $t , $p ) {
2010-12-11 11:26:21 -05:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
if ( $t . hasClass ( 'NB-menu-manage-feed-rename-cancel' ) ||
$t . hasClass ( 'NB-menu-manage-folder-rename-cancel' ) ) {
self . hide _confirm _rename _menu _item ( ) ;
} else {
self . show _confirm _rename _menu _item ( ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-rename-save' } , function ( $t , $p ) {
2010-12-11 12:41:24 -05:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
self . manage _menu _rename _folder ( folder _name , $folder ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-rename-save' } , function ( $t , $p ) {
2010-12-11 11:26:21 -05:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
var $feed = $t . parents ( '.NB-menu-manage' ) . data ( '$feed' ) ;
self . manage _menu _rename _feed ( feed _id , $feed ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-rename-confirm' } , function ( $t , $p ) {
2010-12-11 11:26:21 -05:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-rename-confirm' } , function ( $t , $p ) {
2010-12-11 11:26:21 -05:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-share' } , function ( $t , $p ) {
2012-04-24 10:38:23 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2016-02-03 13:31:55 -08:00
var story _id = $t . parents ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
2012-04-24 10:38:23 -07:00
if ( $t . hasClass ( 'NB-menu-manage-story-share-cancel' ) ) {
2016-02-03 13:31:55 -08:00
self . hide _confirm _story _share _menu _item ( story _id ) ;
2012-04-24 10:38:23 -07:00
} else {
2016-02-03 13:31:55 -08:00
self . show _confirm _story _share _menu _item ( story _id ) ;
2012-04-24 10:38:23 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-share-confirm' } , function ( $t , $p ) {
2012-04-24 10:38:23 -07:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-mark-read' } , function ( $t , $p ) {
2010-07-24 00:04:14 -04:00
e . preventDefault ( ) ;
2010-09-12 13:50:27 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
self . mark _feed _as _read ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-mark-read' } , function ( $t , $p ) {
2010-09-16 10:35:36 -04:00
e . preventDefault ( ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
2024-04-30 18:18:14 -04:00
var folder _view = NEWSBLUR . assets . folders . get _view ( $folder ) ||
self . active _folder . folder _view ;
2012-09-07 17:36:12 -07:00
self . mark _folder _as _read ( folder _view . model ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-subscribe' } , function ( $t , $p ) {
2012-05-24 11:54:10 -07:00
e . preventDefault ( ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
2024-04-30 18:18:14 -04:00
self . open _add _feed _modal ( { folder _title : folder _name } ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-folder-subfolder' } , function ( $t , $p ) {
2012-09-13 14:20:09 -07:00
e . preventDefault ( ) ;
var folder _name = $t . parents ( '.NB-menu-manage' ) . data ( 'folder_name' ) ;
var $folder = $t . parents ( '.NB-menu-manage' ) . data ( '$folder' ) ;
2024-04-30 18:18:14 -04:00
self . open _add _feed _modal ( { folder _title : folder _name , init _folder : true } ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-open' } , function ( $t , $p ) {
2012-05-17 13:22:00 -07:00
e . preventDefault ( ) ;
if ( ! self . flags [ 'showing_confirm_input_on_manage_menu' ] ) {
var story _id = $t . closest ( '.NB-menu-manage-story' ) . data ( 'story_id' ) ;
2012-05-25 20:52:30 -07:00
var story = self . model . get _story ( story _id ) ;
2013-06-16 14:12:01 -07:00
story . open _story _in _new _tab ( true ) ;
2012-05-17 13:22:00 -07:00
}
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-star' } , function ( $t , $p ) {
2012-05-17 13:22:00 -07:00
e . preventDefault ( ) ;
var story _id = $t . closest ( '.NB-menu-manage-story' ) . data ( 'story_id' ) ;
2013-02-12 13:15:14 -08:00
var story = NEWSBLUR . assets . get _story ( story _id ) ;
2013-08-13 13:15:36 -07:00
story . toggle _starred ( ) ;
2012-05-17 13:22:00 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feed-exception' } , function ( $t , $p ) {
2013-04-11 16:50:18 -07:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2013-04-11 16:50:18 -07:00
self . open _feed _exception _modal ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-site-mark-read' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _mark _read _modal ( ) ;
} ) ;
2010-06-14 13:17:38 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-social-profile' } , function ( $t , $p ) {
2012-04-17 15:37:01 -07:00
e . preventDefault ( ) ;
var feed _id = $t . parents ( '.NB-menu-manage' ) . data ( 'feed_id' ) ;
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _social _profile _modal ( feed _id ) ;
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2012-07-18 20:19:54 -07:00
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-keyboard' } , function ( $t , $p ) {
2010-10-10 23:36:09 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _keyboard _shortcuts _modal ( ) ;
} ) ;
2010-10-10 23:36:09 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-goodies' } , function ( $t , $p ) {
2011-01-20 09:57:23 -05:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _goodies _modal ( ) ;
} ) ;
2011-01-20 09:57:23 -05:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-statistics' } , function ( $t , $p ) {
2022-05-27 17:24:58 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2022-05-27 17:24:58 -04:00
self . open _feed _statistics _modal ( ) ;
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-notifications' } , function ( $t , $p ) {
2016-11-14 19:26:09 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2016-11-14 19:26:09 -08:00
self . open _notifications _modal ( ) ;
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-newsletters' } , function ( $t , $p ) {
2016-05-12 14:54:22 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2016-05-12 14:54:22 -07:00
self . open _newsletters _modal ( ) ;
} ) ;
2011-01-20 09:57:23 -05:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-import' } , function ( $t , $p ) {
2013-03-19 13:42:56 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
NEWSBLUR . reader . open _intro _modal ( {
'page_number' : 2 ,
'force_import' : true
} ) ;
2013-03-19 13:42:56 -07:00
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-friends' } , function ( $t , $p ) {
2011-12-22 13:36:03 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _friends _modal ( ) ;
} ) ;
2011-12-22 13:36:03 -08:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-profile-editor' } , function ( $t , $p ) {
2012-04-04 16:09:01 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _profile _editor _modal ( ) ;
} ) ;
2012-04-04 16:09:01 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-preferences' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _preferences _modal ( ) ;
} ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-theme' } , function ( $t , $p ) {
2020-06-10 19:24:02 -04:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-theme-light' } , function ( $t , $p ) {
2020-06-11 19:25:03 -04:00
e . preventDefault ( ) ;
self . switch _theme ( 'light' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-theme-dark' } , function ( $t , $p ) {
2020-06-11 19:25:03 -04:00
e . preventDefault ( ) ;
self . switch _theme ( 'dark' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-theme-auto' } , function ( $t , $p ) {
2020-06-19 11:25:01 -04:00
e . preventDefault ( ) ;
self . switch _theme ( 'auto' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-font' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-font-whitney' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font ( 'whitney' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-font-lucida' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font ( 'lucida' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-font-gotham' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
2021-07-07 15:53:58 -04:00
self . switch _feed _font ( 'gotham' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-size' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-size-xs' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font _size ( 'xs' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-size-s' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font _size ( 's' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-size-m' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font _size ( 'm' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-size-l' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font _size ( 'l' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-feed-size-xl' } , function ( $t , $p ) {
2021-07-07 15:49:36 -04:00
e . preventDefault ( ) ;
self . switch _feed _font _size ( 'xl' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-density-compact' } , function ( $t , $p ) {
2022-06-10 09:44:16 -07:00
e . preventDefault ( ) ;
self . switch _density ( 'compact' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-options-density-comfortable' } , function ( $t , $p ) {
2022-06-10 09:44:16 -07:00
e . preventDefault ( ) ;
self . switch _density ( 'comfortable' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-logout' } , function ( $t , $p ) {
2013-02-01 12:05:45 -08:00
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
2024-04-30 18:18:14 -04:00
2013-02-01 12:05:45 -08:00
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
self . logout ( ) ;
}
2022-04-08 15:07:58 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-account' } , function ( $t , $p ) {
2011-07-27 09:33:34 -07:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
2022-04-08 15:07:58 -04:00
if ( ! $t . hasClass ( 'NB-disabled' ) && ! $ ( $t . prevObject ) . hasClass ( 'NB-menu-manage-logout' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2013-04-11 16:50:18 -07:00
self . open _account _modal ( ) ;
} ) ;
2011-07-27 09:33:34 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-feedchooser' } , function ( $t , $p ) {
2010-09-24 01:08:03 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2014-06-10 12:14:22 -07:00
self . open _feedchooser _modal ( {
'chooser_only' : NEWSBLUR . Globals . is _premium
} ) ;
2013-04-11 16:50:18 -07:00
} ) ;
2010-09-24 01:08:03 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-organizer' } , function ( $t , $p ) {
2014-07-07 13:22:56 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
2014-07-07 13:22:56 -04:00
self . open _organizer _modal ( ) ;
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-premium' } , function ( $t , $p ) {
2013-04-25 17:57:33 -07:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
$ . modal . close ( function ( ) {
self . open _feedchooser _modal ( { 'premium_only' : true } ) ;
2013-04-25 17:57:33 -07:00
} ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-account-upgrade' } , function ( $t , $p ) {
2010-10-17 17:25:10 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
self . open _feedchooser _modal ( { 'premium_only' : true } ) ;
2010-10-17 17:25:10 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-account-train' } , function ( $t , $p ) {
2010-10-17 17:25:10 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
self . open _trainer _modal ( ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-friends-button' } , function ( $t , $p ) {
2011-12-21 18:23:53 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
self . open _friends _modal ( ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-launch-tutorial' } , function ( $t , $p ) {
2011-05-10 18:30:35 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
self . open _tutorial _modal ( ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-launch-intro' } , function ( $t , $p ) {
2012-03-02 17:51:28 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
self . open _intro _modal ( { page _number : 2 } ) ;
2012-03-02 17:51:28 -08:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-premium-button' } , function ( $t , $p ) {
2016-01-31 13:29:37 -08:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2024-04-30 18:18:14 -04:00
self . open _feedchooser _modal ( { 'premium_only' : true } ) ;
2016-01-31 13:29:37 -08:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-gettingstarted-hide' } , function ( $t , $p ) {
2011-05-13 10:15:56 -04:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2011-12-24 00:30:37 -08:00
self . check _hide _getting _started ( true ) ;
2011-05-13 10:15:56 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-unread' } , function ( $t , $p ) {
2010-12-30 19:24:52 -05:00
e . preventDefault ( ) ;
2012-05-25 20:52:30 -07:00
var story _id = $t . closest ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
var story = self . model . get _story ( story _id ) ;
NEWSBLUR . assets . stories . mark _unread ( story ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-menu-manage-story-read' } , function ( $t , $p ) {
2015-10-21 21:31:44 -07:00
e . preventDefault ( ) ;
var story _id = $t . closest ( '.NB-menu-manage' ) . data ( 'story_id' ) ;
var story = self . model . get _story ( story _id ) ;
NEWSBLUR . assets . stories . mark _read ( story ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.task_view_page:not(.NB-task-return)' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
2011-02-02 14:10:24 -05:00
self . switch _taskbar _view ( 'page' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.task_view_feed' } , function ( $t , $p ) {
2011-02-02 14:10:24 -05:00
e . preventDefault ( ) ;
self . switch _taskbar _view ( 'feed' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.task_view_story' } , function ( $t , $p ) {
2011-02-02 14:10:24 -05:00
e . preventDefault ( ) ;
self . switch _taskbar _view ( 'story' ) ;
2010-06-08 11:19:41 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.task_view_text' } , function ( $t , $p ) {
2013-01-08 18:33:30 -08:00
e . preventDefault ( ) ;
self . switch _taskbar _view ( 'text' ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-task-return' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
2012-06-11 18:56:19 -07:00
NEWSBLUR . app . original _tab _view . load _feed _iframe ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-story-next-unread' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
2011-04-30 22:09:43 -04:00
self . open _next _unread _story _across _feeds ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-story-next' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
self . show _next _story ( 1 ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-story-previous' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
2013-08-22 20:29:00 -07:00
self . show _next _story ( - 1 ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-layout-full' } , function ( $t , $p ) {
2013-07-08 17:06:01 -07:00
e . preventDefault ( ) ;
self . switch _story _layout ( 'full' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-layout-split' } , function ( $t , $p ) {
2013-02-08 11:26:29 -08:00
e . preventDefault ( ) ;
self . switch _story _layout ( 'split' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-layout-list' } , function ( $t , $p ) {
2013-02-08 11:26:29 -08:00
e . preventDefault ( ) ;
self . switch _story _layout ( 'list' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-layout-grid' } , function ( $t , $p ) {
2014-12-18 21:17:32 -08:00
e . preventDefault ( ) ;
self . switch _story _layout ( 'grid' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-button.NB-task-layout-magazine' } , function ( $t , $p ) {
2022-02-18 17:52:24 -05:00
e . preventDefault ( ) ;
self . switch _story _layout ( 'magazine' ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-taskbar-options' } , function ( $t , $p ) {
2014-04-07 19:52:26 -07:00
e . preventDefault ( ) ;
self . open _story _options _popover ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-intelligence-slider-control' } , function ( $t , $p ) {
2012-02-08 18:11:08 -08:00
e . preventDefault ( ) ;
var unread _value ;
if ( $t . hasClass ( 'NB-intelligence-slider-red' ) ) {
unread _value = - 1 ;
} else if ( $t . hasClass ( 'NB-intelligence-slider-yellow' ) ) {
unread _value = 0 ;
} else if ( $t . hasClass ( 'NB-intelligence-slider-green' ) ) {
unread _value = 1 ;
2014-05-28 16:54:51 -07:00
} else if ( $t . hasClass ( 'NB-intelligence-slider-blue' ) ) {
2014-05-28 17:35:51 -07:00
unread _value = 2 ;
2012-02-08 18:11:08 -08:00
}
2024-04-30 18:18:14 -04:00
2012-02-08 18:11:08 -08:00
self . slide _intelligence _slider ( unread _value ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2011-03-04 12:27:31 -05:00
// =====================
// = Recommended Feeds =
// =====================
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-recommended-statistics' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2011-03-04 12:45:31 -05:00
$ ( '.NB-module-recommended' ) . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
self . model . load _canonical _feed ( feed _id , function ( ) {
2011-03-04 12:45:31 -05:00
$ ( '.NB-module-recommended' ) . removeClass ( 'NB-loading' ) ;
2011-03-04 12:27:31 -05:00
self . open _feed _statistics _modal ( feed _id ) ;
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-recommended-intelligence' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2011-03-04 12:45:31 -05:00
$ ( '.NB-module-recommended' ) . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
self . model . load _canonical _feed ( feed _id , function ( ) {
2011-03-04 12:45:31 -05:00
$ ( '.NB-module-recommended' ) . removeClass ( 'NB-loading' ) ;
2011-03-04 12:27:31 -05:00
self . open _feed _intelligence _modal ( 1 , feed _id ) ;
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-recommended-try' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
2012-04-19 22:38:00 -07:00
var $recommended _feeds = $ ( '.NB-module-recommended' ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2024-04-30 18:18:14 -04:00
self . open _feed ( feed _id , {
'feed' : new NEWSBLUR . Models . Feed ( {
'feed_title' : $ ( '.NB-recommended-title' , $recommended _feeds ) . text ( ) ,
'favicon_url' : $ ( '.NB-recommended-favicon' , $recommended _feeds ) . attr ( 'src' ) ,
'temp' : true
} )
} ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-recommended-add' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2011-03-11 20:05:41 -05:00
$ ( '.NB-module-recommended' ) . addClass ( 'NB-loading' ) ;
2024-04-30 18:18:14 -04:00
self . model . load _canonical _feed ( feed _id , function ( ) {
2011-03-11 20:05:41 -05:00
$ ( '.NB-module-recommended' ) . removeClass ( 'NB-loading' ) ;
self . add _recommended _feed ( feed _id ) ;
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-recommended-decline' } , function ( $t , $p ) {
2011-07-11 18:22:28 -07:00
e . preventDefault ( ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2011-07-11 18:22:28 -07:00
self . decline _feed _in _moderation _queue ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-recommended-approve' } , function ( $t , $p ) {
2011-07-11 18:22:28 -07:00
e . preventDefault ( ) ;
2012-02-10 19:33:31 -08:00
var feed _id = $t . closest ( '.NB-recommended' ) . data ( 'feed-id' ) ;
2011-07-11 18:22:28 -07:00
self . approve _feed _in _moderation _queue ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-recommended .NB-module-next-page' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
2011-03-13 16:24:49 -04:00
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2011-07-11 18:22:28 -07:00
var unmoderated = $t . closest ( '.NB-module-recommended' ) . hasClass ( 'NB-recommended-unmoderated' ) ;
self . load _recommended _feed ( 1 , false , unmoderated ) ;
2011-03-13 16:24:49 -04:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-recommended .NB-module-previous-page' } , function ( $t , $p ) {
2011-03-04 12:27:31 -05:00
e . preventDefault ( ) ;
if ( ! $t . hasClass ( 'NB-disabled' ) ) {
2011-07-11 18:22:28 -07:00
var unmoderated = $t . closest ( '.NB-module-recommended' ) . hasClass ( 'NB-recommended-unmoderated' ) ;
self . load _recommended _feed ( - 1 , false , unmoderated ) ;
2011-03-04 12:27:31 -05:00
}
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-tryfeed-add' } , function ( $t , $p ) {
2011-03-15 23:42:27 -04:00
e . preventDefault ( ) ;
var feed _id = self . active _feed ;
self . add _recommended _feed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-tryfeed-follow' } , function ( $t , $p ) {
2012-03-15 11:33:00 -07:00
e . preventDefault ( ) ;
var feed _id = self . active _feed ;
self . follow _user _in _tryfeed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-tryout-signup' } , function ( $t , $p ) {
2012-09-17 12:29:46 -07:00
e . preventDefault ( ) ;
self . show _splash _page ( ) ;
if ( NEWSBLUR . welcome ) {
NEWSBLUR . welcome . show _signin _form ( ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
2012-04-10 17:28:00 -07:00
// = Interactions Module ==========================================
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-interaction-follow, .NB-activity-follow' } , function ( $t , $p ) {
2012-04-10 17:28:00 -07:00
e . preventDefault ( ) ;
var user _id = $t . data ( 'userId' ) ;
var username = $t . closest ( '.NB-interaction' ) . find ( '.NB-interaction-username' ) . text ( ) ;
2024-04-30 18:18:14 -04:00
2013-01-30 12:09:58 -08:00
self . close _interactions _popover ( ) ;
2024-04-30 18:18:14 -04:00
self . model . add _user _profiles ( [ { user _id : user _id , username : username } ] ) ;
2012-04-10 17:28:00 -07:00
self . open _social _profile _modal ( user _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-interaction-comment_reply, .NB-interaction-reply_reply, .NB-interaction-story_reshare, .NB-interaction-comment_like, .NB-activity-comment_reply, .NB-activity-comment_like, .NB-activity-sharedstory' } , function ( $t , $p ) {
2012-04-11 15:20:57 -07:00
e . preventDefault ( ) ;
2012-04-19 22:38:00 -07:00
var $interaction = $t . closest ( '.NB-interaction' ) ;
2012-07-23 18:12:05 -07:00
var feed _id = $interaction . data ( 'feedId' ) ;
2012-04-19 22:38:00 -07:00
var story _id = $interaction . data ( 'contentId' ) ;
2012-05-10 22:11:06 -07:00
var user _id = $interaction . data ( 'userId' ) ;
2012-04-19 22:38:00 -07:00
var username = $interaction . data ( 'username' ) ;
2012-07-28 16:41:17 -07:00
2013-01-30 12:09:58 -08:00
self . close _interactions _popover ( ) ;
2012-04-19 19:09:31 -07:00
self . close _social _profile ( ) ;
2012-04-16 11:21:52 -07:00
if ( self . model . get _feed ( feed _id ) ) {
2024-04-30 18:18:14 -04:00
self . open _social _stories ( feed _id , { 'story_id' : story _id } ) ;
2012-04-11 15:20:57 -07:00
} else {
2013-06-03 19:31:50 -07:00
var comment _user _matches = feed _id . match ( /social:(\d+)/ , '$1' ) ;
if ( comment _user _matches ) user _id = parseInt ( comment _user _matches [ 1 ] , 10 ) ;
2012-04-16 11:21:52 -07:00
var socialsub = self . model . add _social _feed ( {
2024-04-30 18:18:14 -04:00
id : feed _id ,
user _id : user _id ,
2012-04-16 11:21:52 -07:00
username : username
} ) ;
2024-04-30 18:18:14 -04:00
self . load _social _feed _in _tryfeed _view ( socialsub , { 'story_id' : story _id } ) ;
2012-04-11 15:20:57 -07:00
}
2024-04-30 18:18:14 -04:00
} ) ;
2012-04-11 15:53:53 -07:00
// = Activities Module ==========================================
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-activity-star' } , function ( $t , $p ) {
2012-04-11 15:53:53 -07:00
e . preventDefault ( ) ;
var story _id = $t . closest ( '.NB-interaction' ) . data ( 'contentId' ) ;
2024-04-30 18:18:14 -04:00
2013-01-30 12:09:58 -08:00
self . close _interactions _popover ( ) ;
2012-04-19 19:09:31 -07:00
self . close _social _profile ( ) ;
2024-04-30 18:18:14 -04:00
self . open _starred _stories ( { 'story_id' : story _id } ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-activity-feedsub' } , function ( $t , $p ) {
2012-04-11 15:53:53 -07:00
e . preventDefault ( ) ;
var feed _id = $t . closest ( '.NB-interaction' ) . data ( 'feedId' ) ;
2024-04-30 18:18:14 -04:00
2013-01-30 12:09:58 -08:00
self . close _interactions _popover ( ) ;
2012-04-19 19:09:31 -07:00
self . close _social _profile ( ) ;
2012-05-04 15:27:53 -07:00
self . open _feed ( feed _id ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-activity-opml_import' } , function ( $t , $p ) {
2022-03-14 11:06:01 -04:00
e . preventDefault ( ) ;
self . close _interactions _popover ( ) ;
self . close _social _profile ( ) ;
NEWSBLUR . reader . open _intro _modal ( {
'page_number' : 2 ,
'force_import' : true
} ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-activity-opml_export' } , function ( $t , $p ) {
2022-03-14 11:06:01 -04:00
e . preventDefault ( ) ;
self . close _interactions _popover ( ) ;
self . close _social _profile ( ) ;
self . open _account _modal ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
2010-09-12 13:50:27 -04:00
// = One-offs =====================================================
2024-04-30 18:18:14 -04:00
2010-07-07 16:22:26 -04:00
var clicked = false ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '#mouse-indicator' } , function ( $t , $p ) {
2010-06-14 13:17:38 -04:00
e . preventDefault ( ) ;
self . lock _mouse _indicator ( ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-load-user-profile img' } , function ( $t , $p ) {
2012-07-28 19:53:38 -07:00
e . preventDefault ( ) ;
self . open _social _profile _modal ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-progress-close' } , function ( $t , $p ) {
2010-08-11 22:02:47 -04:00
e . preventDefault ( ) ;
self . hide _unfetched _feed _progress ( true ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-module-next-page' , childOf : '.NB-module-features' } , function ( $t , $p ) {
2010-06-30 12:17:22 -04:00
e . preventDefault ( ) ;
self . load _feature _page ( 1 ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-previous-page' , childOf : '.NB-module-features' } , function ( $t , $p ) {
2010-06-30 12:17:22 -04:00
e . preventDefault ( ) ;
self . load _feature _page ( - 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-module-next-page' , childOf : '.NB-module-howitworks' } , function ( $t , $p ) {
2010-07-07 16:22:26 -04:00
e . preventDefault ( ) ;
var page = $ ( '.NB-howitworks-page.NB-active' ) . prevAll ( '.NB-howitworks-page' ) . length ;
2024-04-30 18:18:14 -04:00
self . load _howitworks _page ( page + 1 ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-module-previous-page' , childOf : '.NB-module-howitworks' } , function ( $t , $p ) {
2010-07-07 16:22:26 -04:00
e . preventDefault ( ) ;
var page = $ ( '.NB-howitworks-page.NB-active' ) . prevAll ( '.NB-howitworks-page' ) . length ;
2024-04-30 18:18:14 -04:00
self . load _howitworks _page ( page - 1 ) ;
2010-07-07 16:22:26 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$ . targetIs ( e , { tagSelector : '.NB-module-page-indicator' , childOf : '.NB-module-howitworks' } , function ( $t , $p ) {
2010-07-07 16:22:26 -04:00
e . preventDefault ( ) ;
var page = $t . prevAll ( '.NB-module-page-indicator' ) . length ;
self . load _howitworks _page ( page ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-splash-meta-about' } , function ( $t , $p ) {
e . preventDefault ( ) ;
NEWSBLUR . about = new NEWSBLUR . About ( ) ;
} ) ;
$ . targetIs ( e , { tagSelector : '.NB-splash-meta-faq' } , function ( $t , $p ) {
e . preventDefault ( ) ;
NEWSBLUR . faq = new NEWSBLUR . Faq ( ) ;
} ) ;
} ,
handle _keyup : function ( elem , e ) {
2012-04-24 10:38:23 -07:00
var self = this ;
2024-04-30 18:18:14 -04:00
2012-04-24 10:38:23 -07:00
} ,
2024-04-30 18:18:14 -04:00
handle _keystrokes : function ( ) {
2010-06-14 14:00:46 -04:00
var self = this ;
var $document = $ ( document ) ;
2024-04-30 18:18:14 -04:00
2010-12-14 17:08:52 -05:00
NEWSBLUR . hotkeys . initialize ( ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , '?' , function ( e ) {
2010-10-12 20:22:18 -04:00
e . preventDefault ( ) ;
self . open _keyboard _shortcuts _modal ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+/' , function ( e ) {
2010-10-12 20:23:03 -04:00
e . preventDefault ( ) ;
self . open _keyboard _shortcuts _modal ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'down' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
if ( NEWSBLUR . assets . preference ( 'keyboard_verticalarrows' ) == 'scroll' ) {
var amount = NEWSBLUR . assets . preference ( 'arrow_scroll_spacing' ) ;
self . scroll _in _story ( amount , 1 ) ;
} else {
self . show _next _story ( 1 ) ;
}
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'up' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
if ( NEWSBLUR . assets . preference ( 'keyboard_verticalarrows' ) == 'scroll' ) {
var amount = NEWSBLUR . assets . preference ( 'arrow_scroll_spacing' ) ;
self . scroll _in _story ( amount , - 1 ) ;
} else {
self . show _next _story ( - 1 ) ;
}
2024-04-30 18:18:14 -04:00
} ) ;
$document . bind ( 'keydown' , 'j' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2010-08-13 10:43:48 -04:00
self . show _next _story ( 1 ) ;
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'k' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2010-08-13 10:43:48 -04:00
self . show _next _story ( - 1 ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$document . bind ( 'keydown' , 'shift+j' , function ( e ) {
2010-10-21 18:52:25 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+k' , function ( e ) {
2010-10-21 18:52:25 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( - 1 ) ;
2013-06-30 15:20:05 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+n' , function ( e ) {
2013-06-30 15:20:05 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+p' , function ( e ) {
2013-06-30 15:20:05 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( - 1 ) ;
2024-04-30 18:18:14 -04:00
} ) ;
$document . bind ( 'keydown' , 'shift+down' , function ( e ) {
2010-10-21 19:36:03 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+up' , function ( e ) {
2010-10-21 19:36:03 -04:00
e . preventDefault ( ) ;
self . show _next _feed ( - 1 ) ;
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'left' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
if ( NEWSBLUR . assets . preference ( 'keyboard_horizontalarrows' ) == 'site' ) {
self . show _next _feed ( - 1 ) ;
} else {
self . switch _taskbar _view _direction ( - 1 ) ;
}
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'right' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
if ( NEWSBLUR . assets . preference ( 'keyboard_horizontalarrows' ) == 'site' ) {
self . show _next _feed ( 1 ) ;
} else {
self . switch _taskbar _view _direction ( 1 ) ;
}
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'h' , function ( e ) {
2010-10-25 20:20:59 -04:00
e . preventDefault ( ) ;
self . switch _taskbar _view _direction ( - 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'l' , function ( e ) {
2010-10-25 20:20:59 -04:00
e . preventDefault ( ) ;
self . switch _taskbar _view _direction ( 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'r' , function ( e ) {
2011-05-02 14:15:24 -07:00
e . preventDefault ( ) ;
2013-08-05 13:26:51 -07:00
if ( self . active _feed ) {
self . reload _feed ( ) ;
}
2011-05-02 14:15:24 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+r' , function ( e ) {
2020-06-04 16:57:04 -04:00
e . preventDefault ( ) ;
if ( self . active _feed ) {
self . force _instafetch _stories ( ) ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'enter' , function ( e ) {
2010-10-12 20:13:33 -04:00
e . preventDefault ( ) ;
2013-07-08 18:38:09 -07:00
if ( self . flags [ 'feed_view_showing_story_view' ] ) {
self . switch _to _correct _view ( ) ;
} else {
2014-10-29 16:16:50 -07:00
NEWSBLUR . app . story _tab _view . prepare _story ( null , true ) ;
NEWSBLUR . app . story _tab _view . open _story ( ) ;
2013-07-08 18:38:09 -07:00
}
2010-10-12 20:13:33 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'return' , function ( e ) {
2010-10-12 20:13:33 -04:00
e . preventDefault ( ) ;
2013-07-08 18:38:09 -07:00
if ( self . flags [ 'feed_view_showing_story_view' ] ) {
self . switch _to _correct _view ( ) ;
} else {
2014-10-29 16:16:50 -07:00
NEWSBLUR . app . story _tab _view . prepare _story ( null , true ) ;
NEWSBLUR . app . story _tab _view . open _story ( ) ;
2013-07-08 18:38:09 -07:00
}
2010-10-12 20:13:33 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+enter' , function ( e ) {
2013-01-09 11:57:47 -08:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'list' , 'grid' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-05-22 18:40:18 -07:00
if ( ! self . active _story ) NEWSBLUR . reader . show _next _story ( 1 ) ;
self . active _story . story _title _view . render _inline _story _detail ( true ) ;
2013-07-08 18:38:09 -07:00
} else if ( self . flags [ 'temporary_story_view' ] ) {
self . switch _to _correct _view ( ) ;
2013-05-22 18:40:18 -07:00
} else {
NEWSBLUR . app . text _tab _view . fetch _and _render ( null , true ) ;
}
2013-01-09 11:57:47 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+return' , function ( e ) {
2013-01-09 11:57:47 -08:00
e . preventDefault ( ) ;
2024-04-30 18:18:14 -04:00
if ( _ . contains ( [ 'list' , 'grid' ] ,
2015-02-06 13:28:55 -08:00
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) ) {
2013-05-22 18:40:18 -07:00
if ( ! self . active _story ) NEWSBLUR . reader . show _next _story ( 1 ) ;
self . active _story . story _title _view . render _inline _story _detail ( true ) ;
2013-07-08 18:38:09 -07:00
} else if ( self . flags [ 'temporary_story_view' ] ) {
self . switch _to _correct _view ( ) ;
2013-05-22 18:40:18 -07:00
} else {
NEWSBLUR . app . text _tab _view . fetch _and _render ( null , true ) ;
}
2013-01-09 11:57:47 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'space' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
var amount = NEWSBLUR . assets . preference ( 'space_scroll_spacing' ) ;
self . page _in _story ( amount , 1 ) ;
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+space' , function ( e ) {
2010-06-14 14:00:46 -04:00
e . preventDefault ( ) ;
2013-05-22 16:40:56 -07:00
var amount = NEWSBLUR . assets . preference ( 'space_scroll_spacing' ) ;
self . page _in _story ( amount , - 1 ) ;
2010-06-14 14:00:46 -04:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+u' , function ( e ) {
2011-02-23 18:09:09 -05:00
e . preventDefault ( ) ;
2012-09-17 11:52:11 -07:00
self . toggle _sidebar ( ) ;
2011-02-23 18:09:09 -05:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+f' , function ( e ) {
2013-05-24 12:16:41 -07:00
e . preventDefault ( ) ;
self . toggle _sidebar ( ) ;
self . toggle _story _titles _pane ( true ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'n' , function ( e ) {
2011-04-12 11:02:02 -04:00
e . preventDefault ( ) ;
self . open _next _unread _story _across _feeds ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'p' , function ( e ) {
2012-08-08 22:02:05 -07:00
e . preventDefault ( ) ;
self . show _previous _story ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'c' , function ( e ) {
2012-06-26 19:19:57 -07:00
e . preventDefault ( ) ;
NEWSBLUR . app . story _list . scroll _to _selected _story ( self . active _story , {
scroll _to _comments : true ,
scroll _offset : - 50
} ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'x' , function ( e ) {
2013-06-10 15:00:18 -07:00
e . preventDefault ( ) ;
var story = NEWSBLUR . reader . active _story ;
if ( story && story . get ( 'selected' ) ) {
2016-06-29 13:24:54 -07:00
NEWSBLUR . reader . active _story . set ( 'selected' , false ) ;
2013-06-10 15:00:18 -07:00
} else if ( story && ! story . get ( 'selected' ) ) {
NEWSBLUR . reader . active _story . set ( 'selected' , true ) ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+x' , function ( e ) {
2013-02-05 18:10:16 -08:00
e . preventDefault ( ) ;
NEWSBLUR . reader . active _story . story _view . expand _story ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+y' , function ( e ) {
2013-12-05 14:25:15 -08:00
e . preventDefault ( ) ;
if ( ! NEWSBLUR . reader . active _story ) return ;
var story = NEWSBLUR . assets . get _story ( NEWSBLUR . reader . active _story ) ;
var timestamp = story . get ( 'story_timestamp' ) ;
2017-01-09 13:02:27 -08:00
var direction = 'newer' ;
var order = NEWSBLUR . assets . view _setting ( self . active _feed , 'order' ) ;
if ( order == 'oldest' ) direction = 'older' ;
2024-04-30 18:18:14 -04:00
2013-12-05 14:25:15 -08:00
if ( self . flags . river _view && ! self . flags . social _view ) {
2017-01-09 13:02:27 -08:00
self . mark _folder _as _read ( self . active _folder , timestamp , direction ) ;
2013-12-05 14:25:15 -08:00
} else {
2017-01-09 13:02:27 -08:00
self . mark _feed _as _read ( self . active _feed , timestamp , direction ) ;
2013-12-05 14:25:15 -08:00
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+b' , function ( e ) {
2013-12-05 14:25:15 -08:00
e . preventDefault ( ) ;
if ( ! NEWSBLUR . reader . active _story ) return ;
var story = NEWSBLUR . assets . get _story ( NEWSBLUR . reader . active _story ) ;
var timestamp = story . get ( 'story_timestamp' ) ;
2017-01-09 13:02:27 -08:00
var direction = 'older' ;
var order = NEWSBLUR . assets . view _setting ( self . active _feed , 'order' ) ;
if ( order == 'oldest' ) direction = 'newer' ;
2013-12-05 14:25:15 -08:00
if ( self . flags . river _view && ! self . flags . social _view ) {
2017-01-09 14:19:19 -08:00
self . mark _folder _as _read ( self . active _folder , timestamp , direction ) ;
2013-12-05 14:25:15 -08:00
} else {
2017-01-09 14:19:19 -08:00
self . mark _feed _as _read ( self . active _feed , timestamp , direction ) ;
2013-12-05 14:25:15 -08:00
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'm' , function ( e ) {
2013-07-07 22:59:49 -07:00
e . preventDefault ( ) ;
// self.show_last_unread_story();
self . mark _active _story _read ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+m' , function ( e ) {
2011-11-02 09:43:06 -07:00
e . preventDefault ( ) ;
self . show _last _unread _story ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'b' , function ( e ) {
2011-05-01 00:03:13 -04:00
e . preventDefault ( ) ;
self . show _previous _story ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 's' , function ( e ) {
2011-07-29 09:41:49 -07:00
e . preventDefault ( ) ;
if ( self . active _story ) {
var story _id = self . active _story . id ;
2013-02-12 13:15:14 -08:00
var story = NEWSBLUR . assets . get _story ( story _id ) ;
2013-08-13 13:15:36 -07:00
story . toggle _starred ( ) ;
2011-07-29 09:41:49 -07:00
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , '+' , function ( e ) {
2011-07-29 09:41:49 -07:00
e . preventDefault ( ) ;
self . move _intelligence _slider ( 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , '-' , function ( e ) {
2011-07-29 09:41:49 -07:00
e . preventDefault ( ) ;
self . move _intelligence _slider ( - 1 ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'shift+l' , function ( e ) {
2015-08-24 11:36:28 -07:00
e . preventDefault ( ) ;
self . toggle _read _filter ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'shift+d' , function ( e ) {
2011-07-29 09:58:25 -07:00
e . preventDefault ( ) ;
self . show _splash _page ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'esc' , function ( e ) {
2012-07-28 20:12:12 -07:00
e . preventDefault ( ) ;
2022-12-21 19:51:09 -05:00
if ( NEWSBLUR . assets . preference ( "keyboard-ignore-esc" ) ) return ;
2024-04-30 18:18:14 -04:00
if ( ! _ . keys ( $ . modal . impl . d ) . length &&
! NEWSBLUR . ReaderPopover . is _open ( ) &&
2013-07-10 13:03:48 -07:00
! self . flags [ 'feed_list_showing_manage_menu' ] ) {
2012-07-30 11:12:58 -07:00
self . show _splash _page ( ) ;
}
2012-07-28 20:12:12 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 't' , function ( e ) {
2011-10-30 22:15:04 -07:00
e . preventDefault ( ) ;
self . open _story _trainer ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'shift+t' , function ( e ) {
2012-01-11 10:33:31 -08:00
e . preventDefault ( ) ;
2013-07-26 16:07:39 -07:00
self . open _feed _intelligence _modal ( 1 ) ;
2012-01-11 10:33:31 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'a' , function ( e ) {
2011-10-30 22:17:16 -07:00
e . preventDefault ( ) ;
2013-07-26 16:07:39 -07:00
self . open _add _feed _modal ( ) ;
2011-10-30 22:17:16 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'o' , function ( e ) {
2011-10-31 18:04:25 -07:00
e . preventDefault ( ) ;
2012-05-25 20:52:30 -07:00
var story _id = self . active _story ;
if ( ! story _id ) return ;
var story = self . model . get _story ( story _id ) ;
2013-06-16 14:12:01 -07:00
story . open _story _in _new _tab ( true ) ;
2011-10-31 18:04:25 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'v' , function ( e ) {
2013-06-16 09:12:15 -07:00
e . preventDefault ( ) ;
var story _id = self . active _story ;
if ( ! story _id ) return ;
var story = self . model . get _story ( story _id ) ;
2013-06-16 14:12:01 -07:00
story . open _story _in _new _tab ( true ) ;
2013-06-16 09:12:15 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'shift+v' , function ( e ) {
2013-06-16 09:12:15 -07:00
e . preventDefault ( ) ;
var story _id = self . active _story ;
if ( ! story _id ) return ;
var story = self . model . get _story ( story _id ) ;
2013-06-16 14:12:01 -07:00
story . open _story _in _new _tab ( ) ;
2013-06-16 09:12:15 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keypress' , 'e' , function ( e ) {
2012-07-01 14:20:21 -07:00
e . preventDefault ( ) ;
2012-08-01 18:52:54 -07:00
var story = self . active _story ;
if ( ! story ) return ;
self . send _story _to _email ( story ) ;
2012-07-01 14:20:21 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+a' , function ( e ) {
2011-10-31 18:40:07 -07:00
e . preventDefault ( ) ;
2015-02-10 18:03:16 -08:00
self . maybe _mark _all _as _read ( ) ;
2011-10-31 18:40:07 -07:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+e' , function ( e ) {
2011-11-06 14:44:20 -08:00
e . preventDefault ( ) ;
self . open _river _stories ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'u' , function ( e ) {
2012-01-04 14:09:40 -08:00
e . preventDefault ( ) ;
2012-09-26 13:49:17 -07:00
self . mark _active _story _read ( ) ;
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'g' , function ( e ) {
2012-09-26 13:49:17 -07:00
e . preventDefault ( ) ;
NEWSBLUR . app . feed _selector . toggle ( ) ;
2012-01-04 14:09:40 -08:00
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , '/' , function ( e ) {
2013-07-26 16:07:39 -07:00
e . preventDefault ( ) ;
if ( NEWSBLUR . app . story _titles _header . search _view ) {
NEWSBLUR . app . story _titles _header . search _view . focus ( ) ;
}
} ) ;
2024-04-30 18:18:14 -04:00
$document . bind ( 'keydown' , 'shift+s' , function ( e ) {
2012-04-27 17:44:00 -07:00
e . preventDefault ( ) ;
if ( self . active _story ) {
2013-04-03 13:25:17 -07:00
var view = 'feed' ;
2015-02-06 13:28:55 -08:00
if ( _ . contains ( [ 'split' , 'full' ] ,
NEWSBLUR . assets . view _setting ( NEWSBLUR . reader . active _feed , 'layout' ) ) &&
2013-04-03 13:25:17 -07:00
_ . contains ( [ 'page' , 'story' ] , self . story _view ) ) {
view = 'title' ;
}
self . active _story . open _share _dialog ( e , view ) ;
2012-04-27 17:44:00 -07:00
}
} ) ;
2010-06-08 11:19:41 -04:00
}
2024-04-30 18:18:14 -04:00
2012-05-17 18:40:46 -07:00
} ) ;
2010-06-08 11:19:41 -04:00
2013-07-05 09:31:49 +02:00
} ) ( jQuery ) ;