Parcourir la source

[Feature] 6975: Redirect to shortcut page on pressing '?' (#6981)

* [Feature] 6975: Redirect to shortcut page on pressing '?'

* [Feature] 6975: Redirect to shortcut page on pressing '?'

* Simplify code

* Re-order for performance

* Remove shift key

---------

Co-authored-by: Olexandr Shaposhnyk <oshaposhnyk@intelliboard.net>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Olexandr Shaposhnyk il y a 1 an
Parent
commit
846e19afde
2 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 1 0
      app/views/helpers/javascript_vars.phtml
  2. 5 2
      p/scripts/main.js

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

@@ -61,6 +61,7 @@ echo htmlspecialchars(json_encode(array(
 		'login' => Minz_Url::display(array('c' => 'auth', 'a' => 'login'), 'php'),
 		'logout' => Minz_Url::display(array('c' => 'auth', 'a' => 'logout'), 'php'),
 		'help' => FRESHRSS_WIKI,
+		'shortcuts' => Minz_Url::display(array('c' => 'configure', 'a' => 'shortcut'), 'php'),
 	),
 	'i18n' => array(
 		'confirmation_default' => _t('gen.js.confirm_action'),

+ 5 - 2
p/scripts/main.js

@@ -973,8 +973,7 @@ function init_shortcuts() {
 	});
 
 	document.addEventListener('keydown', ev => {
-		if (ev.target.closest('input, textarea') ||
-				ev.ctrlKey || ev.metaKey || (ev.altKey && ev.shiftKey)) {
+		if (ev.ctrlKey || ev.metaKey || (ev.altKey && ev.shiftKey) || ev.target.closest('input, select, textarea')) {
 			return;
 		}
 
@@ -1080,6 +1079,10 @@ function init_shortcuts() {
 			ev.preventDefault();
 			return;
 		}
+		if (ev.key === '?') {
+			window.location.href = context.urls.shortcuts.replace(/&amp;/g, '&');
+			return;
+		}
 
 		if (ev.altKey || ev.shiftKey) {
 			return;