From 00dc7622fbb25458f82b8d81dffae6f843dadece Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 7 Mar 2015 22:52:03 +0100 Subject: change system for #1123 and keyboard arrows shortcuts --- themes/_global/js/keyboard.js | 27 +++++++++++++++++++++++++++ themes/baggy/_head.twig | 1 + themes/baggy/css/main.css | 28 ++++++++++++++++++++++++++++ themes/baggy/view.twig | 5 +++-- themes/default/_head.twig | 1 + themes/default/view.twig | 5 +++-- 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 themes/_global/js/keyboard.js diff --git a/themes/_global/js/keyboard.js b/themes/_global/js/keyboard.js new file mode 100644 index 00000000..26978cb2 --- /dev/null +++ b/themes/_global/js/keyboard.js @@ -0,0 +1,27 @@ +function navigateKeyboard(leftURL, rightURL) { + window.addEventListener("keypress", function (event) { + var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions + console.log("key pressed : " + key); + switch (key) { + case 37: + // left arrow + if (leftURL != "?view=view&id=") { + window.location = window.location.origin + window.location.pathname + leftURL; + } + break; + /* + case 38: + // top arrow + window.location = window.location.origin + window.location.pathname + window.location.search + "#top"; + break; + */ + case 39: + //right arrow + if (rightURL != "?view=view&id=") { + window.location = window.location.origin + window.location.pathname + rightURL; + } + break; + } + + }, false); +} \ No newline at end of file diff --git a/themes/baggy/_head.twig b/themes/baggy/_head.twig index d252130c..3799f8fb 100755 --- a/themes/baggy/_head.twig +++ b/themes/baggy/_head.twig @@ -36,4 +36,5 @@ + diff --git a/themes/baggy/css/main.css b/themes/baggy/css/main.css index 1b221021..5319fd68 100755 --- a/themes/baggy/css/main.css +++ b/themes/baggy/css/main.css @@ -873,6 +873,20 @@ blockquote { font-size: 1.5em; } +.leftPosF { + position: fixed; + right: 24%; + bottom: 2em; + font-size: 1.5em; +} + +.rightPosF { + position: fixed; + right: 16%; + bottom: 2em; + font-size: 1.5em; +} + #article_toolbar { margin-bottom: 1em; } @@ -970,6 +984,12 @@ pre code { .topPosF { right: 2.5em; } + .leftPosF { + right: 4.5em; + } + .rightPosF { + right: 0.5em; + } } @media screen and (max-width: 700px) { @@ -1063,6 +1083,14 @@ pre code { display: none; } + #article_toolbar .leftPosF { + display: none; + } + + #article_toolbar .rightPosF { + display: none; + } + #article { width: 100%; } diff --git a/themes/baggy/view.twig b/themes/baggy/view.twig index ae02ce48..68af03f5 100755 --- a/themes/baggy/view.twig +++ b/themes/baggy/view.twig @@ -8,7 +8,7 @@
@@ -103,5 +103,6 @@ retrievePercent({{ entry.id|e }}); }); }); + navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}'); {% endblock %} diff --git a/themes/default/_head.twig b/themes/default/_head.twig index 91a555cb..f3c9d886 100755 --- a/themes/default/_head.twig +++ b/themes/default/_head.twig @@ -33,4 +33,5 @@ + diff --git a/themes/default/view.twig b/themes/default/view.twig index 0d4ec174..9c9d1561 100755 --- a/themes/default/view.twig +++ b/themes/default/view.twig @@ -5,7 +5,7 @@ {% include '_pocheit-form.twig' %}
@@ -125,5 +125,6 @@ $('#article_toolbar .tool.top').parent().hide(); } }); + navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}'); {% endblock %} -- cgit v1.2.3