change system for #1123 and keyboard arrows shortcuts

This commit is contained in:
Thomas Citharel 2015-03-07 22:52:03 +01:00
parent 0ae1e652c9
commit 00dc7622fb
6 changed files with 63 additions and 4 deletions

View file

@ -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);
}

View file

@ -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>

View file

@ -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%;
}

View file

@ -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">
@ -103,5 +103,6 @@
retrievePercent({{ entry.id|e }});
});
});
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
</script>
{% endblock %}

View file

@ -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>

View file

@ -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">
@ -125,5 +125,6 @@
$('#article_toolbar .tool.top').parent().hide();
}
});
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
</script>
{% endblock %}