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

Merge pull request #408 from aledeg/shortcuts

Modification des raccourcis
Alexandre Alapetite 12 лет назад
Родитель
Сommit
a2c64ad896

+ 1 - 1
app/Controllers/configureController.php

@@ -286,7 +286,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 
 	public function shortcutAction () {
 		$list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter',
-		                    'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left',
+		                    'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left',
 		                    'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right',
 		                    's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y',
 		                    'z', '0', '1', '2', '3', '4', '5', '6', '7', '8',

+ 2 - 0
app/Models/Configuration.php

@@ -32,6 +32,8 @@ class FreshRSS_Configuration {
 			'go_website' => 'space',
 			'next_entry' => 'j',
 			'prev_entry' => 'k',
+			'first_entry' => 'home',
+			'last_entry' => 'end',
 			'collapse_entry' => 'c',
 			'load_more' => 'm',
 			'auto_share' => 's',

+ 10 - 5
app/i18n/en.php

@@ -78,6 +78,10 @@ return array (
 	'bad_opml_file'			=> 'Your OPML file is invalid',
 	'shortcuts_updated'		=> 'Shortcuts have been updated',
 	'shortcuts_management'		=> 'Shortcuts management',
+	'shortcuts_navigation'		=> 'Navigation',
+	'shortcuts_navigation_help'	=> 'With the "Shift" modifier, navigation shortcuts apply on feeds.<br/>With the "Ctrl" modifier, navigation shortcuts apply on categories.',
+	'shortcuts_article_action'	=> 'Article actions',
+	'shortcuts_other_action'	=> 'Other actions',
 	'feeds_marked_read'		=> 'Feeds have been marked as read',
 	'updated'			=> 'Modifications have been updated',
 
@@ -121,15 +125,16 @@ return array (
 	'javascript_for_shortcuts'	=> 'JavaScript must be enabled in order to use shortcuts',
 	'javascript_should_be_activated'=> 'JavaScript must be enabled',
 	'shift_for_all_read'		=> '+ <code>shift</code> to mark all articles as read',
-	'see_on_website'		=> 'See article on its original website',
+	'see_on_website'		=> 'See on original website',
 	'next_article'			=> 'Skip to the next article',
-	'shift_for_last'		=> '+ <code>shift</code> to skip to the last article of page',
+	'last_article'			=> 'Skip to the last article',
 	'previous_article'		=> 'Skip to the previous article',
-	'shift_for_first'		=> '+ <code>shift</code> to skip to the first article of page',
+	'first_article'			=> 'Skip to the first article',
 	'next_page'			=> 'Skip to the next page',
 	'previous_page'			=> 'Skip to the previous page',
-	'collapse_article'		=> 'Collapse current article',
-	'auto_share'			=> 'Share current article',
+	'collapse_article'		=> 'Collapse',
+	'auto_share'			=> 'Share',
+	'auto_share_help'		=> 'If there is only one sharing mode, it is used. Else modes are accessible by their number.',
 
 	'file_to_import'		=> 'File to import',
 	'import'			=> 'Import',

+ 10 - 5
app/i18n/fr.php

@@ -78,6 +78,10 @@ return array (
 	'bad_opml_file'			=> 'Votre fichier OPML n’est pas valide',
 	'shortcuts_updated'		=> 'Les raccourcis ont été mis à jour',
 	'shortcuts_management'		=> 'Gestion des raccourcis',
+	'shortcuts_navigation'		=> 'Navigation',
+	'shortcuts_navigation_help'	=> 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.<br/>Avec le modificateur "Ctrl", les raccourcis de navigation s’appliquent aux catégories.',
+	'shortcuts_article_action'	=> 'Actions associées à l’article courant',
+	'shortcuts_other_action'	=> 'Autres actions',
 	'feeds_marked_read'		=> 'Les flux ont été marqués comme lus',
 	'updated'			=> 'Modifications enregistrées',
 
@@ -121,15 +125,16 @@ return array (
 	'javascript_for_shortcuts'	=> 'Le JavaScript doit être activé pour pouvoir profiter des raccourcis',
 	'javascript_should_be_activated'=> 'Le JavaScript doit être activé',
 	'shift_for_all_read'		=> '+ <code>shift</code> pour marquer tous les articles comme lus',
-	'see_on_website'		=> 'Voir l’article sur le site d’origine',
+	'see_on_website'		=> 'Voir sur le site d’origine',
 	'next_article'			=> 'Passer à l’article suivant',
-	'shift_for_last'		=> '+ <code>shift</code> pour passer au dernier article de la page',
+	'last_article'			=> 'Passer au dernier article',
 	'previous_article'		=> 'Passer à l’article précédent',
-	'shift_for_first'		=> '+ <code>shift</code> pour passer au premier article de la page',
+	'first_article'			=> 'Passer au premier article',
 	'next_page'			=> 'Passer à la page suivante',
 	'previous_page'			=> 'Passer à la page précédente',
-	'collapse_article'		=> 'Refermer l’article courant',
-	'auto_share'			=> 'Partager l’article courant',
+	'collapse_article'		=> 'Refermer',
+	'auto_share'			=> 'Partager',
+	'auto_share_help'		=> 'Si il n’y a qu’un mode de partage, celui ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.',
 
 	'file_to_import'		=> 'Fichier à importer',
 	'import'			=> 'Importer',

+ 38 - 17
app/views/configure/shortcut.phtml

@@ -16,55 +16,59 @@
 
 		<noscript><p class="alert alert-error"><?php echo Minz_Translate::t ('javascript_for_shortcuts'); ?></p></noscript>
 
+		<legend><?php echo Minz_Translate::t ('shortcuts_navigation'); ?></legend>
+
 		<div class="form-group">
-			<label class="group-name" for="mark_read"><?php echo Minz_Translate::t ('mark_read'); ?></label>
+			<label class="group-name" for="next_entry"><?php echo Minz_Translate::t ('next_article'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" />
-				<?php echo Minz_Translate::t ('shift_for_all_read'); ?>
+				<input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" />
 			</div>
 		</div>
 
 		<div class="form-group">
-			<label class="group-name" for="mark_favorite"><?php echo Minz_Translate::t ('mark_favorite'); ?></label>
+			<label class="group-name" for="prev_entry"><?php echo Minz_Translate::t ('previous_article'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" />
+				<input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" />
 			</div>
 		</div>
 
 		<div class="form-group">
-			<label class="group-name" for="go_website"><?php echo Minz_Translate::t ('see_on_website'); ?></label>
+			<label class="group-name" for="first_entry"><?php echo Minz_Translate::t ('first_article'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="go_website" name="shortcuts[go_website]" list="keys" value="<?php echo $s['go_website']; ?>" />
+				<input type="text" id="first_entry" name="shortcuts[first_entry]" list="keys" value="<?php echo $s['first_entry']; ?>" />
 			</div>
 		</div>
 
 		<div class="form-group">
-			<label class="group-name" for="next_entry"><?php echo Minz_Translate::t ('next_article'); ?></label>
+			<label class="group-name" for="last_entry"><?php echo Minz_Translate::t ('last_article'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" />
-				<?php echo Minz_Translate::t ('shift_for_last'); ?>
+				<input type="text" id="last_entry" name="shortcuts[last_entry]" list="keys" value="<?php echo $s['last_entry']; ?>" />
 			</div>
 		</div>
 
+		<div><?php echo Minz_Translate::t ('shortcuts_navigation_help');?></div>
+
+		<legend><?php echo Minz_Translate::t ('shortcuts_article_action');?></legend>
+
 		<div class="form-group">
-			<label class="group-name" for="prev_entry"><?php echo Minz_Translate::t ('previous_article'); ?></label>
+			<label class="group-name" for="mark_read"><?php echo Minz_Translate::t ('mark_read'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" />
-				<?php echo Minz_Translate::t ('shift_for_first'); ?>
+				<input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" />
+				<?php echo Minz_Translate::t ('shift_for_all_read'); ?>
 			</div>
 		</div>
 
 		<div class="form-group">
-			<label class="group-name" for="collapse_entry"><?php echo Minz_Translate::t ('collapse_article'); ?></label>
+			<label class="group-name" for="mark_favorite"><?php echo Minz_Translate::t ('mark_favorite'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="collapse_entry" name="shortcuts[collapse_entry]" list="keys" value="<?php echo $s['collapse_entry']; ?>" />
+				<input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" />
 			</div>
 		</div>
 
 		<div class="form-group">
-			<label class="group-name" for="load_more_shortcut"><?php echo Minz_Translate::t ('load_more'); ?></label>
+			<label class="group-name" for="go_website"><?php echo Minz_Translate::t ('see_on_website'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="load_more_shortcut" name="shortcuts[load_more]" list="keys" value="<?php echo $s['load_more']; ?>" />
+				<input type="text" id="go_website" name="shortcuts[go_website]" list="keys" value="<?php echo $s['go_website']; ?>" />
 			</div>
 		</div>
 
@@ -72,6 +76,23 @@
 			<label class="group-name" for="auto_share_shortcut"><?php echo Minz_Translate::t ('auto_share'); ?></label>
 			<div class="group-controls">
 				<input type="text" id="auto_share_shortcut" name="shortcuts[auto_share]" list="keys" value="<?php echo $s['auto_share']; ?>" />
+				<?php echo Minz_Translate::t ('auto_share_help'); ?>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="collapse_entry"><?php echo Minz_Translate::t ('collapse_article'); ?></label>
+			<div class="group-controls">
+				<input type="text" id="collapse_entry" name="shortcuts[collapse_entry]" list="keys" value="<?php echo $s['collapse_entry']; ?>" />
+			</div>
+		</div>
+
+		<legend><?php echo Minz_Translate::t ('shortcuts_other_action');?></legend>
+
+		<div class="form-group">
+			<label class="group-name" for="load_more_shortcut"><?php echo Minz_Translate::t ('load_more'); ?></label>
+			<div class="group-controls">
+				<input type="text" id="load_more_shortcut" name="shortcuts[load_more]" list="keys" value="<?php echo $s['load_more']; ?>" />
 			</div>
 		</div>
 

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

@@ -19,6 +19,8 @@ echo ',shortcuts={',
 	'go_website:"', $s['go_website'], '",',
 	'prev_entry:"', $s['prev_entry'], '",',
 	'next_entry:"', $s['next_entry'], '",',
+	'first_entry:"', $s['first_entry'], '",',
+	'last_entry:"', $s['last_entry'], '",',
 	'collapse_entry:"', $s['collapse_entry'], '",',
 	'load_more:"', $s['load_more'], '",',
 	'auto_share:"', $s['auto_share'], '"',

+ 8 - 8
app/views/helpers/view/normal_view.phtml

@@ -147,49 +147,49 @@ if (!empty($this->entries)) {
 						<ul class="dropdown-menu">
 							<li class="dropdown-close"><a href="#close">❌</a></li>
 							<?php if ($shaarli) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&amp;title=' . $title . '&amp;source=FreshRSS'; ?>">
 									<?php echo Minz_Translate::t ('shaarli'); ?>
 								</a>
 							</li>
 							<?php } if ($wallabag) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="<?php echo $wallabag . '?action=add&amp;url=' . base64_encode (urldecode($link)); ?>">
 									<?php echo Minz_Translate::t ('wallabag'); ?>
 								</a>
 							</li>
 							<?php } if ($diaspora) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="<?php echo $diaspora . '/bookmarklet?url=' . $link . '&amp;title=' . $title; ?>">
 									<?php echo Minz_Translate::t ('diaspora'); ?>
 								</a>
 							</li>
 							<?php } if ($twitter) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="https://twitter.com/share?url=<?php echo $link; ?>&amp;text=<?php echo $title; ?>">
 									<?php echo Minz_Translate::t ('twitter'); ?>
 								</a>
 							</li>
 							<?php } if ($google_plus) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="https://plus.google.com/share?url=<?php echo $link; ?>">
 									<?php echo Minz_Translate::t ('g+'); ?>
 								</a>
 							</li>
 							<?php } if ($facebook) { ?>
-							<li class="item">
+							<li class="item share">
 								<a target="_blank" href="https://www.facebook.com/sharer.php?u=<?php echo $link; ?>&amp;t=<?php echo $title; ?>">
 									<?php echo Minz_Translate::t ('facebook'); ?>
 								</a>
 							</li>
 							<?php } if ($email) { ?>
-							<li class="item">
+							<li class="item share">
 								<a href="mailto:?subject=<?php echo urldecode($title); ?>&amp;body=<?php echo $link; ?>">
 									<?php echo Minz_Translate::t ('by_email'); ?>
 								</a>
 							</li>
 							<?php } if ($print) { ?>
-							<li class="item">
+							<li class="item share">
 								<a href="#" class="print-article">
 									<?php echo Minz_Translate::t ('print'); ?>
 								</a>

+ 123 - 10
p/scripts/main.js

@@ -259,19 +259,98 @@ function next_entry() {
 	}
 }
 
+function prev_feed() {
+	if ($('li.active').length > 0) {
+		var pf = $('li.active').prev().find('a.feed');
+		if (pf.length > 0) {
+			pf[0].click();
+		}
+	} else {
+		first_feed();
+	}
+}
+
+function next_feed() {
+	if ($('li.active').length > 0) {
+		var nf = $('li.active').next().find('a.feed');
+		if (nf.length > 0) {
+			nf[0].click();
+		}
+	} else {
+		last_feed();
+	}
+}
+
+function first_feed() {
+	$('.feeds.active li').first().find('a')[1].click();
+}
+
+function last_feed() {
+	$('.feeds.active li').last().find('a')[1].click();
+}
+
+function prev_category() {
+	if ($('div.active').length > 0) {
+		var pc = $('div.active').parent('li').prev().find('div.stick a.btn');
+		if (pc.length > 0) {
+			pc[0].click();
+			return;
+		}
+	} else {
+		first_category();
+	}
+}
+
+function next_category() {
+	if ($('div.active').length > 0) {
+		var nc = $('div.active').parent('li').next().find('div.stick a.btn');
+		if (nc.length > 0) {
+			nc[0].click();
+		}
+	} else {
+		last_category();
+	}
+}
+
+function first_category() {
+	$('div.category.stick').first().find('a.btn')[0].click();
+}
+
+function last_category() {
+	$('div.category.stick').last().find('a.btn')[0].click();
+}
+
 function collapse_entry() {
 	isCollapsed = !isCollapsed;
 	$(".flux.current").toggleClass("active");
 }
 
-function auto_share() {
-	var $share = $(".flux.current").find('.dropdown-target[id^="dropdown-share"]');
-	if ($share.length) {
-		window.location.hash = $share.attr('id');
-		var scroll = needsScroll($share.closest('.bottom'));
-		if (scroll != 0) {
+function auto_share(key) {
+	var share = $(".flux.current.active").find('.dropdown-target[id^="dropdown-share"]');
+	var shares = share.siblings('.dropdown-menu').find('.item a');
+	if (typeof key === "undefined") {
+		if (!share.length) {
+			return;
+		}
+		// Display the share div
+		window.location.hash = share.attr('id');
+		// Force scrolling to the share div
+		var scroll = needsScroll(share.closest('.bottom'));
+		if (scroll !== 0) {
 			$('html,body').scrollTop(scroll);
 		}
+		// Force the key value if there is only one action, so we can trigger it automatically
+		if (shares.length === 1) {
+			key = 1;
+		} else {
+			return;
+		}
+	}
+	// Trigger selected share action and hide the share div
+	key = parseInt(key);
+	if (key <= shares.length) {
+		shares[key - 1].click();
+		share.siblings('.dropdown-menu').find('.dropdown-close a')[0].click();
 	}
 }
 
@@ -406,12 +485,19 @@ function init_shortcuts() {
 	}, {
 		'disable_in_input': true
 	});
+	for(var i = 1; i < 10; i++){
+		shortcut.add(i.toString(), function (e) {
+			auto_share(String.fromCharCode(e.keyCode));
+		}, {
+			'disable_in_input': true
+		});
+	}
 
-	// Touches de navigation
+	// Touches de navigation pour les articles
 	shortcut.add(shortcuts.prev_entry, prev_entry, {
 		'disable_in_input': true
 	});
-	shortcut.add("shift+" + shortcuts.prev_entry, function () {
+	shortcut.add(shortcuts.first_entry, function () {
 		var old_active = $(".flux.current"),
 			first = $(".flux:first");
 
@@ -424,7 +510,7 @@ function init_shortcuts() {
 	shortcut.add(shortcuts.next_entry, next_entry, {
 		'disable_in_input': true
 	});
-	shortcut.add("shift+" + shortcuts.next_entry, function () {
+	shortcut.add(shortcuts.last_entry, function () {
 		var old_active = $(".flux.current"),
 			last = $(".flux:last");
 
@@ -434,8 +520,35 @@ function init_shortcuts() {
 	}, {
 		'disable_in_input': true
 	});
+	// Touches de navigation pour les flux
+	shortcut.add("shift+" + shortcuts.prev_entry, prev_feed, {
+		'disable_in_input': true
+	});
+	shortcut.add("shift+" + shortcuts.next_entry, next_feed, {
+		'disable_in_input': true
+	});
+	shortcut.add("shift+" + shortcuts.first_entry, first_feed, {
+		'disable_in_input': true
+	});
+	shortcut.add("shift+" + shortcuts.last_entry, last_feed, {
+		'disable_in_input': true
+	});
+	// Touches de navigation pour les categories
+	shortcut.add("ctrl+" + shortcuts.prev_entry, prev_category, {
+		'disable_in_input': true
+	});
+	shortcut.add("ctrl+" + shortcuts.next_entry, next_category, {
+		'disable_in_input': true
+	});
+	shortcut.add("ctrl+" + shortcuts.first_entry, first_category, {
+		'disable_in_input': true
+	});
+	shortcut.add("ctrl+" + shortcuts.last_entry, last_category, {
+		'disable_in_input': true
+	});
+
 	shortcut.add(shortcuts.go_website, function () {
-		var url_website = $(".flux.active .link a").attr("href");
+		var url_website = $(".flux.current .link a").attr("href");
 
 		if (auto_mark_site) {
 			$(".flux.current").each(function () {

+ 5 - 0
p/themes/Dark/global.css

@@ -407,6 +407,11 @@ input, select, textarea {
 				padding: 0 25px;
 				line-height: 30px;
 			}
+			.dropdown-menu > .item.share > a {
+				display: list-item;
+				list-style-position:inside;
+				list-style-type:decimal;
+			}
 			.dropdown-menu > .item:hover {
 				background: #26303F;
 				color: #888;

+ 5 - 0
p/themes/Flat/global.css

@@ -403,6 +403,11 @@ input, select, textarea {
 				padding: 0 25px;
 				line-height: 30px;
 			}
+			.dropdown-menu > .item.share > a {
+				display: list-item;
+				list-style-position:inside;
+				list-style-type:decimal;
+			}
 			.dropdown-menu > .item:hover > a {
 				background: #2980b9;
 				color: #fff;

+ 5 - 0
p/themes/Origine/global.css

@@ -419,6 +419,11 @@ input, select, textarea {
 				padding: 0 25px;
 				line-height: 30px;
 			}
+			.dropdown-menu > .item.share > a {
+				display: list-item;
+				list-style-position:inside;
+				list-style-type:decimal;
+			}
 			.dropdown-menu > .item:hover {
 				background: #0062BE;
 				color: #fff;