]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
change system for #1123 and keyboard arrows shortcuts
authorThomas Citharel <tcit@tcit.fr>
Sat, 7 Mar 2015 21:52:03 +0000 (22:52 +0100)
committerThomas Citharel <tcit@tcit.fr>
Sat, 7 Mar 2015 21:52:03 +0000 (22:52 +0100)
themes/_global/js/keyboard.js [new file with mode: 0644]
themes/baggy/_head.twig
themes/baggy/css/main.css
themes/baggy/view.twig
themes/default/_head.twig
themes/default/view.twig

diff --git a/themes/_global/js/keyboard.js b/themes/_global/js/keyboard.js
new file mode 100644 (file)
index 0000000..26978cb
--- /dev/null
@@ -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
index d252130cae9999f0dfc2d324a4c25a9ac785b3d6..3799f8fb2390bd9cd37af30c59da8209def2d614 100755 (executable)
@@ -36,4 +36,5 @@
         <script src="{{ poche_url }}themes/{{theme}}/js/init.js"></script>
         <script src="{{ poche_url }}themes/_global/js/saveLink.js"></script>
         <script src="{{ poche_url }}themes/_global/js/popupForm.js"></script>
+        <script src="{{ poche_url }}themes/_global/js/keyboard.js"></script>
         <script src="{{ poche_url }}themes/{{theme}}/js/closeMessage.js"></script>
index 1b221021b72e6c6a7b6c31cddc4d0e92cf0f5ead..5319fd681a7c962768ea5fe5daddf71a760a1bd5 100755 (executable)
@@ -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%;
   }
index ae02ce484e13cc1ee6931bca0ff3b53932a22b14..68af03f5b6296859d671f73a8fd7a03db3107d42 100755 (executable)
@@ -8,7 +8,7 @@
         <div id="article_toolbar">
             <ul class="links">
                 <li class="topPosF"><a href="#top" title="{% trans "Back to top" %}" class="tool top icon icon-arrow-up-thick"><span>{% trans "Back to top" %}</span></a></li>
-                {% if navigate.previous %}<li><a href="./?view=view&amp;id={{ navigate.previousid|e }}" class="tool icon icon-previous"><span>{% trans "Previous Article" %}</span></a></li>{% endif %}
+                {% if navigate.next %}<li class="leftPosF"><a href="./?view=view&amp;id={{ navigate.nextid|e }}" class="top tool icon icon-previous"><span>{% trans "Next Article" %}</span></a></li>{% endif %}
                 <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.url | e | getDomain }}</span></a></li>
                 <li><a title="{% trans "Mark as read" %}" class="tool icon icon-check {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="javascript: void(null);" id="markAsRead"><span>{% trans "Toggle mark as read" %}</span></a></li>
                 {% if navigate.next %}<li><a title="{% trans "Mark as read and go to next article" %}" class="tool icon archiveandnext-icon" href="./?action=archive_and_next&amp;id={{ entry.id|e }}" id="markAsReadAndNext"><span>{% trans "Toggle mark as read and go to next article" %}</span></a></li>{% endif %}
@@ -27,7 +27,7 @@
                 {% if constant('MOBI') == 1 %}<li><a href="./?mobi&amp;method=id&amp;value={{ entry.id|e }}" title="Generate Mobi file">MOBI</a></li>{% endif %}
                 {% if constant('PDF') == 1 %}<li><a href="./?pdf&amp;method=id&amp;value={{ entry.id|e }}" title="Generate PDF file">PDF</a></li>{% endif %}
                 <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{% trans "Does this article appear wrong?" %}" class="tool bad-display icon icon-delete"><span>{% trans "Does this article appear wrong?" %}</span></a></li>
-                {% if navigate.next %}<li><a href="./?view=view&amp;id={{ navigate.nextid|e }}" class="tool icon icon-next"><span>{% trans "Next Article" %}</span></a></li>{% endif %}
+                {% if navigate.previous %}<li class="rightPosF"><a href="./?view=view&amp;id={{ navigate.previousid|e }}" class="tool icon icon-next"><span>{% trans "Previous Article" %}</span></a></li>{% endif %}
             </ul>
         </div>
         <div id="article">
                 retrievePercent({{ entry.id|e }});
             });
         });
+        navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
         </script>
 {% endblock %}
index 91a555cb0bedb9a4b6945215914d3480e3010a7a..f3c9d8867b471959ef58261029856a403b2081b2 100755 (executable)
@@ -33,4 +33,5 @@
         <script src="{{ poche_url }}themes/_global/js/autoClose.js"></script>
         <script src="{{ poche_url }}themes/default/js/closeMessage.js"></script>
         <script src="{{ poche_url }}themes/_global/js/saveLink.js"></script>
+        <script src="{{ poche_url }}themes/_global/js/keyboard.js"></script>
         <script src="{{ poche_url }}themes/_global/js/popupForm.js"></script>
index 0d4ec174457d03c35e49c0a49aaad8ca9da9c658..9c9d15615f31f4a49a32d58781d4696734ab6908 100755 (executable)
@@ -5,7 +5,7 @@
         {% include '_pocheit-form.twig' %}
         <div id="article_toolbar">
             <ul>
-                {% if navigate.previous %}<li><a href="./?view=view&amp;id={{ navigate.previousid|e }}" class="tool previous"><span>{% trans "Previous Article" %}</span></a></li>{% endif %}
+                {% if navigate.next %}<li><a href="./?view=view&amp;id={{ navigate.nextid|e }}" class="tool previous"><span>{% trans "Next Article" %}</span></a></li>{% endif %}
                 <li><a href="./" title="{% trans "Return home" %}" class="tool back"><span>{% trans "Return home" %}</span></a></li>
                 <li><a href="#top" title="{% trans "Back to top" %}" class="tool top"><span>{% trans "Back to top" %}</span></a></li>
                 <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.url | e | getDomain }}</span></a></li>
@@ -27,7 +27,7 @@
                 {% if constant('PDF') == 1 %}<li><a href="./?pdf&amp;method=id&amp;value={{ entry.id|e }}" title="Generate PDF file">PDF</a></li>{% endif %}
                 <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{% trans "Does this article appear wrong?" %}" class="tool bad-display"><span>{% trans "Does this article appear wrong?" %}</span></a></li>
                 {% if constant('SHOW_READPERCENT') == 1 %}<li><div id="readLeftPercent">0%</div></li>{% endif %}
-                {% if navigate.next %}<li><a href="./?view=view&amp;id={{ navigate.nextid|e }}" class="tool next"><span>{% trans "Next Article" %}</span></a></li>{% endif %}
+                {% if navigate.previous %}<li><a href="./?view=view&amp;id={{ navigate.previousid|e }}" class="tool next"><span>{% trans "Previous Article" %}</span></a></li>{% endif %}
             </ul>
         </div>
         <div id="article">
                 $('#article_toolbar .tool.top').parent().hide();
             }
         });
+        navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
         </script>
 {% endblock %}