Просмотр исходного кода

Merge pull request #620 from plopoyop/dev

Ajout d'un timeout pour la notification HTML5
Alexandre Alapetite 11 лет назад
Родитель
Сommit
ca74b2fca3

+ 1 - 0
app/Controllers/configureController.php

@@ -157,6 +157,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 			$this->view->conf->_bottomline_tags(Minz_Request::param('bottomline_tags', false));
 			$this->view->conf->_bottomline_date(Minz_Request::param('bottomline_date', false));
 			$this->view->conf->_bottomline_link(Minz_Request::param('bottomline_link', false));
+			$this->view->conf->_html5_notif_timeout(Minz_Request::param('html5_notif_timeout', 0));
 			$this->view->conf->save();
 
 			Minz_Session::_param('language', $this->view->conf->language);

+ 7 - 0
app/Models/Configuration.php

@@ -60,6 +60,7 @@ class FreshRSS_Configuration {
 		'bottomline_link' => true,
 		'sharing' => array(),
 		'queries' => array(),
+		'html5_notif_timeout' => 0,
 	);
 
 	private $available_languages = array(
@@ -280,6 +281,12 @@ class FreshRSS_Configuration {
 			$this->data['content_width'] = 'thin';
 		}
 	}
+	
+	public function _html5_notif_timeout ($value) {
+		$value = intval($value);
+		$this->data['html5_notif_timeout'] = $value >= 0 ? $value : 0;
+	}
+	
 	public function _token($value) {
 		$this->data['token'] = $value;
 	}

+ 2 - 0
app/i18n/de.php

@@ -212,6 +212,8 @@ return array (
 	'reading_icons'			=> 'Lese Symbol',
 	'top_line'			=> 'Kopfzeile',
 	'bottom_line'			=> 'Fusszeile',
+	'html5_notif_timeout'		=> 'HTML5 notification timeout',
+	'seconds_(0_means_no_timeout)'	=> 'seconds (0 means no timeout)',
 	'img_with_lazyload'		=> 'Verwende die "träge laden" Methode zum laden von Bildern',
 	'auto_read_when'		=> 'Artikel als gelesen markieren…',
 	'article_selected'		=> 'wenn der Artikel ausgewählt ist',

+ 2 - 0
app/i18n/en.php

@@ -283,6 +283,8 @@ return array (
 	'article_icons'			=> 'Article icons',
 	'top_line'			=> 'Top line',
 	'bottom_line'			=> 'Bottom line',
+	'html5_notif_timeout'		=> 'HTML5 notification timeout',
+	'seconds_(0_means_no_timeout)'	=> 'seconds (0 means no timeout)',
 	'img_with_lazyload'		=> 'Use "lazy load" mode to load pictures',
 	'sticky_post'			=> 'Stick the article to the top when opened',
 	'reading_confirm'		=> 'Display a confirmation dialog on “mark all as read” actions',

+ 2 - 0
app/i18n/fr.php

@@ -283,6 +283,8 @@ return array (
 	'article_icons'			=> 'Icônes d’article',
 	'top_line'			=> 'Ligne du haut',
 	'bottom_line'			=> 'Ligne du bas',
+	'html5_notif_timeout'		=> 'Temps d\'affichage de la notification HTML5',
+	'seconds_(0_means_no_timeout)'	=> 'secondes (0 signifie aucun timeout ) ',
 	'img_with_lazyload'		=> 'Utiliser le mode “chargement différé” pour les images',
 	'sticky_post'			=> 'Aligner l’article en haut quand il est ouvert',
 	'reading_confirm'		=> 'Afficher une confirmation lors des actions “marquer tout comme lu”',

+ 7 - 0
app/views/configure/display.phtml

@@ -91,6 +91,13 @@
 				</tbody>
 			</table><br />
 		</div>
+		
+		<div class="form-group">
+			<label class="group-name" for="posts_per_page"><?php echo Minz_Translate::t ('html5_notif_timeout'); ?></label>
+			<div class="group-controls">
+				<input type="number" id="html5_notif_timeout" name="html5_notif_timeout" value="<?php echo $this->conf->html5_notif_timeout; ?>" /> <?php echo Minz_Translate::t ('seconds_(0_means_no_timeout)'); ?>
+			</div>
+		</div>
 
 		<div class="form-group form-actions">
 			<div class="group-controls">

+ 2 - 0
app/views/helpers/javascript_vars.phtml

@@ -54,6 +54,8 @@ echo 'authType="', $authType, '",',
 echo 'str_confirmation="', Minz_Translate::t('confirm_action'), '"', ",\n";
 echo 'str_notif_title_articles="', Minz_Translate::t('notif_title_new_articles'), '"', ",\n";
 echo 'str_notif_body_articles="', Minz_Translate::t('notif_body_new_articles'), '"', ",\n";
+echo 'html5_notif_timeout=', $this->conf->html5_notif_timeout,",\n";
+
 
 $autoActualise = Minz_Session::param('actualize_feeds', false);
 echo 'auto_actualize_feeds=', $autoActualise ? 'true' : 'false', ";\n";

+ 6 - 0
p/scripts/main.js

@@ -866,6 +866,12 @@ function notifs_html5_show(nb) {
 	notification.onclick = function() {
 		window.location.reload();
 	}
+
+	if (html5_notif_timeout !== 0){
+		setTimeout(function() {
+					notification.close();
+				}, html5_notif_timeout * 1000);
+	}
 }
 
 function init_notifs_html5() {