Sfoglia il codice sorgente

Demande rafraîchissement page quand nvx articles

Ajout d'une indication pour rafraîchir la page si de nouveaux articles
ont été détectés via le serveur
Voir #379
Marien Fressinaud 12 anni fa
parent
commit
2a6443a0f0

+ 1 - 0
app/i18n/en.php

@@ -241,6 +241,7 @@ return array (
 	'today'				=> 'Today',
 	'yesterday'			=> 'Yesterday',
 	'before_yesterday'		=> 'Before yesterday',
+	'new_article'			=> 'There are new available articles, click to refresh the page.',
 	'by_author'			=> 'By <em>%s</em>',
 	'related_tags'			=> 'Related tags',
 	'no_feed_to_display'		=> 'There is no article to show.',

+ 1 - 0
app/i18n/fr.php

@@ -241,6 +241,7 @@ return array (
 	'today'				=> 'Aujourd’hui',
 	'yesterday'			=> 'Hier',
 	'before_yesterday'		=> 'À partir d’avant-hier',
+	'new_article'			=> 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.',
 	'by_author'			=> 'Par <em>%s</em>',
 	'related_tags'			=> 'Tags associés',
 	'no_feed_to_display'		=> 'Il n’y a aucun article à afficher.',

+ 7 - 0
app/views/helpers/view/normal_view.phtml

@@ -63,6 +63,13 @@ if (!empty($this->entries)) {
 			$display_others = false;
 		}
 
+		if ($this->entries[0]->id () === $item->id ()) {
+			?><div id="new-article">
+				<a href="<?php echo _url(); ?>"><?php
+				echo Minz_Translate::t ('new_article');
+				?></a></div><?php
+		}
+
 	?><div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>">
 		<ul class="horizontal-list flux_header"><?php
 			if ($this->loginOk) {

+ 9 - 0
p/scripts/main.js

@@ -519,12 +519,21 @@ function init_notifications() {
 
 function refreshUnreads() {
 	$.getJSON('./?c=javascript&a=nbUnreadsPerFeed').done(function (data) {
+		var new_article = false;
 		$.each(data, function(feed_id, nbUnreads) {
 			feed_id = 'f_' + feed_id;
 			var elem = $('#' + feed_id + '>.feed').get(0),
 				feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
 			incUnreadsFeed(null, feed_id, nbUnreads - feed_unreads);
+
+			if (nbUnreads - feed_unreads > 0) {
+				new_article = true;
+			}
 		});
+
+		if (new_article) {
+			$('#new-article').show();
+		}
 	});
 }
 

+ 19 - 0
p/themes/Dark/freshrss.css

@@ -224,6 +224,25 @@
 		text-align: right;
 	}
 
+#new-article {
+	display: none;
+	min-height: 40px;
+	background: #26303F;
+	text-align: center;
+}
+	#new-article:hover {
+		background: #4A5D7A;
+	}
+	#new-article a {
+		display: block;
+		line-height: 40px;
+		color: #fff;
+		font-weight: bold;
+	}
+		#new-article a:hover {
+			text-decoration: none;
+		}
+
 .flux {
 	border-left: 3px solid #aaa;
 	background: #1c1c1c;

+ 19 - 0
p/themes/Flat/freshrss.css

@@ -217,6 +217,25 @@ body {
 		z-index: -10;
 	}
 
+#new-article {
+	display: none;
+	min-height: 40px;
+	background: #3498db;
+	text-align: center;
+}
+	#new-article:hover {
+		background: #2980b9;
+	}
+	#new-article a {
+		display: block;
+		line-height: 40px;
+		color: #fff;
+		font-weight: bold;
+	}
+		#new-article a:hover {
+			text-decoration: none;
+		}
+
 .flux {
 	border-left: 3px solid #ecf0f1;
 }

+ 19 - 0
p/themes/Origine/freshrss.css

@@ -230,6 +230,25 @@
 		text-align: right;
 	}
 
+#new-article {
+	display: none;
+	min-height: 40px;
+	background: #0084CC;
+	text-align: center;
+}
+	#new-article:hover {
+		background: #0066CC;
+	}
+	#new-article a {
+		display: block;
+		line-height: 40px;
+		color: #fff;
+		font-weight: bold;
+	}
+		#new-article a:hover {
+			text-decoration: none;
+		}
+
 .flux {
 	border-left: 3px solid #aaa;
 	background: #fafafa;