diff --git a/media/css/darkmode.css b/media/css/darkmode.css index f87acc4f8..2d8775f07 100644 --- a/media/css/darkmode.css +++ b/media/css/darkmode.css @@ -21,6 +21,16 @@ /* = Global = */ /* ========== */ +.NB-theme-transitioning div, +.NB-theme-transitioning span, +.NB-theme-transitioning a, +.NB-theme-transitioning ul, +.NB-theme-transitioning li, +body.NB-theme-transitioning { + transition: color 1s ease-out, + background-color 1s ease-out, + border-color 1s ease-out; +} body.NB-dark { background-color: #191b1c; color: #ccc; @@ -197,7 +207,7 @@ color: #a85b40; /* Manage menu on splash page & cogwheel pop-up */ .NB-dark .NB-menu-manage-container, .NB-dark .NB-menu-manage .NB-menu-manage-site-info, /* Preferences title background */ -.NB-dark .NB-menu-item, /* Icon background */ +.NB-dark .NB-menu-manage li.NB-menu-item, /* Icon background */ .NB-dark .NB-menu-manage-title /* Title text background */ { background-color: #303739; border-radius: 4px; @@ -843,11 +853,6 @@ border-bottom-color: #303739; text-shadow: 0 1px 0 rgba(0,0,0,.8); } -/* Feed text for unread feeds*/ -.NB-dark .unread_view_neutral .unread_neutral { - font-weight: normal; -} - /* "All Site Stories" text*/ .NB-dark .NB-feeds-header { background: none; diff --git a/media/js/newsblur/reader/reader.js b/media/js/newsblur/reader/reader.js index e2a0f6df8..617a13330 100644 --- a/media/js/newsblur/reader/reader.js +++ b/media/js/newsblur/reader/reader.js @@ -148,6 +148,7 @@ this.setup_unfetched_feed_check(); this.switch_story_layout(); this.load_delayed_stylesheets(); + this.load_theme(); }, // ======== @@ -3262,6 +3263,29 @@ } }, + switch_theme: function(theme) { + this.model.preference('theme', theme); + this.load_theme(); + }, + + load_theme: function() { + var theme = this.model.preference('theme'); + + $('.NB-theme-option').removeClass('NB-active'); + $('.NB-options-theme-'+theme).addClass('NB-active'); + + $("body").addClass('NB-theme-transitioning'); + if (theme == 'dark') { + $("body").addClass('NB-dark'); + } else { + $("body").removeClass('NB-dark'); + } + + _.delay(function() { + $("body").removeClass("NB-theme-transitioning"); + }, 2000); + }, + close_interactions_popover: function() { NEWSBLUR.InteractionsPopover.close(); }, @@ -3410,11 +3434,11 @@ $.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' }, [ - $.make('li', { className: 'NB-single-story-option NB-options-theme-light NB-active' }, [ + $.make('li', { className: 'NB-theme-option NB-options-theme-light NB-active' }, [ $.make('div', { className: 'NB-icon' }), 'Light' ]), - $.make('li', { className: 'NB-single-story-option NB-options-theme-dark' }, [ + $.make('li', { className: 'NB-theme-option NB-options-theme-dark' }, [ $.make('div', { className: 'NB-icon' }), 'Dark' ]) @@ -6241,6 +6265,14 @@ $.targetIs(e, { tagSelector: '.NB-menu-manage-theme' }, function($t, $p){ e.preventDefault(); }); + $.targetIs(e, { tagSelector: '.NB-options-theme-light' }, function($t, $p){ + e.preventDefault(); + self.switch_theme('light'); + }); + $.targetIs(e, { tagSelector: '.NB-options-theme-dark' }, function($t, $p){ + e.preventDefault(); + self.switch_theme('dark'); + }); $.targetIs(e, { tagSelector: '.NB-menu-manage-logout' }, function($t, $p){ e.preventDefault(); e.stopPropagation(); diff --git a/templates/base.html b/templates/base.html index 8b18b4253..e37b3a41d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -92,7 +92,8 @@ 'story_share_facebook' : true, 'story_share_readitlater' : false, 'story_share_instapaper' : true, - 'story_share_email' : true + 'story_share_email' : true, + 'theme' : 'light' }; NEWSBLUR.URLs = { 'upload-avatar' : "{% url "upload-avatar" %}", diff --git a/templates/reader/manage_module.xhtml b/templates/reader/manage_module.xhtml index 58a44819a..db76eb9ee 100644 --- a/templates/reader/manage_module.xhtml +++ b/templates/reader/manage_module.xhtml @@ -11,11 +11,11 @@