mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-04-09 10:15:44 +02:00
show unreadcount in title
This commit is contained in:
parent
82f0a877a0
commit
0675405a8c
js
templates
@ -369,16 +369,16 @@ var $__build_47_app__ = function () {
|
||||
return false;
|
||||
};
|
||||
this.isSubscriptionsActive = function () {
|
||||
return $route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS;
|
||||
return $route.current && $route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS;
|
||||
};
|
||||
this.isStarredActive = function () {
|
||||
return $route.current.$$route.type === FEED_TYPE.STARRED;
|
||||
return $route.current && $route.current.$$route.type === FEED_TYPE.STARRED;
|
||||
};
|
||||
this.isFolderActive = function (folderId) {
|
||||
return $route.current.$$route.type === FEED_TYPE.FOLDER && $route.current.params.id === folderId;
|
||||
return $route.current && $route.current.$$route.type === FEED_TYPE.FOLDER && $route.current.params.id === folderId;
|
||||
};
|
||||
this.isFeedActive = function (feedId) {
|
||||
return $route.current.$$route.type === FEED_TYPE.FEED && $route.current.params.id === feedId;
|
||||
return $route.current && $route.current.$$route.type === FEED_TYPE.FEED && $route.current.params.id === feedId;
|
||||
};
|
||||
this.isAddingFolder = function () {
|
||||
return true;
|
||||
@ -1750,6 +1750,25 @@ var $__build_47_app__ = function () {
|
||||
};
|
||||
}
|
||||
]);
|
||||
app.directive('newsTitleUnreadCount', [
|
||||
'$window',
|
||||
function ($window) {
|
||||
'use strict';
|
||||
var baseTitle = $window.document.title;
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: { unreadCount: '@' },
|
||||
link: function (scope, elem, attrs) {
|
||||
attrs.$observe('unreadCount', function (value) {
|
||||
var titles = baseTitle.split('-');
|
||||
if (value !== '0') {
|
||||
$window.document.title = titles[0] + '(' + value + ') - ' + titles[1];
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
app.directive('newsTooltip', function () {
|
||||
'use strict';
|
||||
return function (scope, elem) {
|
||||
|
@ -8,8 +8,8 @@
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('NavigationController',
|
||||
function ($route, FEED_TYPE,
|
||||
FeedResource, FolderResource, ItemResource, SettingsResource) {
|
||||
function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
|
||||
SettingsResource) {
|
||||
'use strict';
|
||||
|
||||
this.feedError = '';
|
||||
@ -88,20 +88,24 @@ function ($route, FEED_TYPE,
|
||||
};
|
||||
|
||||
this.isSubscriptionsActive = () => {
|
||||
return $route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS;
|
||||
return $route.current &&
|
||||
$route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS;
|
||||
};
|
||||
|
||||
this.isStarredActive = () => {
|
||||
return $route.current.$$route.type === FEED_TYPE.STARRED;
|
||||
return $route.current &&
|
||||
$route.current.$$route.type === FEED_TYPE.STARRED;
|
||||
};
|
||||
|
||||
this.isFolderActive = (folderId) => {
|
||||
return $route.current.$$route.type === FEED_TYPE.FOLDER &&
|
||||
return $route.current &&
|
||||
$route.current.$$route.type === FEED_TYPE.FOLDER &&
|
||||
$route.current.params.id === folderId;
|
||||
};
|
||||
|
||||
this.isFeedActive = (feedId) => {
|
||||
return $route.current.$$route.type === FEED_TYPE.FEED &&
|
||||
return $route.current &&
|
||||
$route.current.$$route.type === FEED_TYPE.FEED &&
|
||||
$route.current.params.id === feedId;
|
||||
};
|
||||
|
||||
|
32
js/directive/NewsTitleUnreadCount.js
Normal file
32
js/directive/NewsTitleUnreadCount.js
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* ownCloud - News
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.directive('newsTitleUnreadCount', ($window) => {
|
||||
'use strict';
|
||||
|
||||
let baseTitle = $window.document.title;
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
unreadCount: '@'
|
||||
},
|
||||
link: (scope, elem, attrs) => {
|
||||
attrs.$observe('unreadCount', (value) => {
|
||||
let titles = baseTitle.split('-');
|
||||
|
||||
if (value !== '0') {
|
||||
$window.document.title = titles[0] +
|
||||
'(' + value + ') - ' + titles[1];
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
});
|
@ -22,6 +22,7 @@
|
||||
|
||||
<!-- navigation -->
|
||||
<div id="app-navigation" ng-controller="NavigationController as Navigation" ng-hide="App.loading.isLoading('global')">
|
||||
<news-title-unread-count unread-count="{{ Navigation.getUnreadCount() }}"></news-title-unread-count>
|
||||
|
||||
<ul class="with-icon" data-folder-id="0" news-droppable>
|
||||
<?php print_unescaped($this->inc('part.addnew')) ?>
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
</div>
|
||||
<span class="utils">
|
||||
<span class="unread-counter" ng-show="getUnreadCount() > 0">
|
||||
<span class="unread-counter" ng-show="Navigation.getUnreadCount() > 0">
|
||||
{{ Navigation.getUnreadCount() | unreadCountFormatter }}
|
||||
</span>
|
||||
<!--
|
||||
|
Loading…
Reference in New Issue
Block a user