From eaa44052fda39cb994b5ae604503fc2405bd4ae5 Mon Sep 17 00:00:00 2001 From: James Scott-Brown Date: Wed, 17 Jul 2013 22:16:07 +0100 Subject: [PATCH] Provide pop-up lisitng keyboard shortcuts Pressing the question-mark key (?) produces a pop-up listing the keyboard shortcuts. Pressing q whilst this window has focus closes it. I've provided crude translations for the additional ? and q shortcuts, obtained from Google Translate, but they should be checked by native speakers. --- assets/css/app.css | 4 ++++ assets/js/app.js | 6 ++++++ assets/js/popupHelp.js | 10 ++++++++++ locales/cs_CZ/translations.php | 4 +++- locales/de_DE/translations.php | 4 +++- locales/fr_FR/translations.php | 4 +++- locales/it_IT/translations.php | 4 +++- locales/zh_CN/translations.php | 4 +++- templates/app_header.php | 16 ++++++++++++++++ templates/config.php | 6 ++++-- 10 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 assets/js/popupHelp.js diff --git a/assets/css/app.css b/assets/css/app.css index 81f5792..b0d04ec 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -214,6 +214,10 @@ textarea.form-error { margin-bottom: 15px; } +.invisible { + display:none; +} + /* alerts */ .alert { padding: 8px 35px 8px 14px; diff --git a/assets/js/app.js b/assets/js/app.js index 2b34bd3..ae83958 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -452,6 +452,12 @@ case 108: // l open_next_page(); break; + case 63: // ? + var jsFile = document.URL.substr(0, document.URL.lastIndexOf('/') + 1) + "assets/js/popupHelp.js"; + var htmlHelp = document.getElementById("shortcuts").innerHTML; + var encodedHelp = "data:text/html;charset=utf-8," + htmlHelp; + var popup = open(encodedHelp, "Shortcuts", "width=300,height=300,location=no,scrollbars=no,status=no,toolbar=no"); + break; } }; diff --git a/assets/js/popupHelp.js b/assets/js/popupHelp.js new file mode 100644 index 0000000..b7727ef --- /dev/null +++ b/assets/js/popupHelp.js @@ -0,0 +1,10 @@ +document.title = "Keyboard Shortcuts"; + +document.onkeypress = function(e) { + switch (e.keyCode || e.which) { + case 81: // Q + case 113: // q + window.close(); + break; + } +}; diff --git a/locales/cs_CZ/translations.php b/locales/cs_CZ/translations.php index 197058c..4025599 100644 --- a/locales/cs_CZ/translations.php +++ b/locales/cs_CZ/translations.php @@ -105,5 +105,7 @@ return array( 'Do you really want to remove these items from your history?' => 'Opravdu chcete odstranit tyto články z historie?', 'Do you really want to remove this subscription: "%s"?' => 'Opravdu chcete odstranit tento odběr: "%s"?', 'Nothing to read, do you want to update your subscriptions?' => - 'Nic ke čtení, chete aktualizovat vaše odběry?' + 'Nic ke čtení, chete aktualizovat vaše odběry?', + 'Show shortcuts' => 'Ukázat zkratky', + 'Close shortcut list' => 'Zavřít seznam zkratek' ); diff --git a/locales/de_DE/translations.php b/locales/de_DE/translations.php index f86574d..5535181 100644 --- a/locales/de_DE/translations.php +++ b/locales/de_DE/translations.php @@ -101,5 +101,7 @@ return array( 'Do you really want to remove these items from your history?' => 'Willst du sicher alle Einträge aus dem Verlauf löschen?', 'Do you really want to remove this subscription: "%s"?' => 'Willst du dieses Abonnement wirklich löschen: "%s" ?', 'Nothing to read, do you want to update your subscriptions?' => - 'Nichts zu lesen, willst du alle Abonemments aktualisieren?' + 'Nichts zu lesen, willst du alle Abonemments aktualisieren?', + 'Show shortcuts' => 'Verknüpfungen anzeigen', + 'Close shortcut list' => 'Schließen Liste für Schnellzugriffe' ); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 4e6e5a4..65d08de 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -106,5 +106,7 @@ return array( 'Do you really want to remove these items from your history?' => 'Voulez-vous vraiment supprimer les éléments de votre historique ?', 'Do you really want to remove this subscription: "%s"?' => 'Voulez-vous vraiment supprimer cet abonnement : "%s" ?', 'Nothing to read, do you want to update your subscriptions?' => - 'Il n\'y a rien à lire, voulez-vous mettre à jour vos abonnements ?' + 'Il n\'y a rien à lire, voulez-vous mettre à jour vos abonnements ?', + 'Show shortcuts' => 'Afficher les raccourcis', + 'Close shortcut list' => 'Fermer la liste des raccourcis' ); diff --git a/locales/it_IT/translations.php b/locales/it_IT/translations.php index 5e99b0d..dbe5950 100644 --- a/locales/it_IT/translations.php +++ b/locales/it_IT/translations.php @@ -101,5 +101,7 @@ return array( 'Do you really want to remove these items from your history?' => 'Vuoi veramente cancellare questi articoli dalla cronologia?', 'Do you really want to remove this subscription: "%s"?' => 'Vuoi veramente cancellare la sottoscrizione a: "%s" ?', 'Nothing to read, do you want to update your subscriptions?' => - 'Niente da leggere, vuoi aggiornare tutte le sottoscrizioni?' + 'Niente da leggere, vuoi aggiornare tutte le sottoscrizioni?', + 'Show shortcuts' => 'Mostra tasti di scelta rapida', + 'Close shortcut list' => 'Ridurre la lista di scelta rapida' ); diff --git a/locales/zh_CN/translations.php b/locales/zh_CN/translations.php index ce0d429..c9dde04 100644 --- a/locales/zh_CN/translations.php +++ b/locales/zh_CN/translations.php @@ -101,5 +101,7 @@ return array( 'Do you really want to remove these items from your history?' => '你确认要移除这些历史记录吗?', 'Do you really want to remove this subscription: "%s"?' => '你确定要移除这个订阅源: "%s" ?', 'Nothing to read, do you want to update your subscriptions?' => - '空空如也,你想要更新订阅源嘛?' + '空空如也,你想要更新订阅源嘛?', + 'Show shortcuts' => '显示捷径', + 'Close shortcut list' => '关闭快捷键列表' ); diff --git a/templates/app_header.php b/templates/app_header.php index 9c14526..94bd50d 100644 --- a/templates/app_header.php +++ b/templates/app_header.php @@ -42,3 +42,19 @@
%s') ?> %s') ?> + + diff --git a/templates/config.php b/templates/config.php index a1c9aec..6dc106d 100644 --- a/templates/config.php +++ b/templates/config.php @@ -45,7 +45,7 @@
  • -
    +

    • = p j
    • @@ -55,7 +55,9 @@
    • = o
    • = f
    • = h
    • -
    • = l
    • +
    • = l

    • +
    • = ?
    • +
    • = q