mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-01 14:49:15 +00:00
implement swipe gestures on mobile to go to next and previous articles
This commit is contained in:
parent
00dc7622fb
commit
c34a8956e1
6 changed files with 42 additions and 15 deletions
3
themes/_global/js/jquery.mobile.events.touch.min.js
vendored
Normal file
3
themes/_global/js/jquery.mobile.events.touch.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,27 +1,27 @@
|
||||||
function navigateKeyboard(leftURL, rightURL) {
|
function navigateKeyboard(leftURL, rightURL) {
|
||||||
window.addEventListener("keypress", function (event) {
|
window.addEventListener("keypress", function (event) {
|
||||||
var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions
|
var key = event.which || event.keyCode; // event.keyCode is used for IE8 and earlier versions
|
||||||
console.log("key pressed : " + key);
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 37:
|
case 37:
|
||||||
// left arrow
|
goLeft(leftURL);
|
||||||
if (leftURL != "?view=view&id=") {
|
|
||||||
window.location = window.location.origin + window.location.pathname + leftURL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case 38:
|
|
||||||
// top arrow
|
|
||||||
window.location = window.location.origin + window.location.pathname + window.location.search + "#top";
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case 39:
|
case 39:
|
||||||
//right arrow
|
goRight(rightURL);
|
||||||
if (rightURL != "?view=view&id=") {
|
|
||||||
window.location = window.location.origin + window.location.pathname + rightURL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goLeft(leftURL) {
|
||||||
|
if (leftURL != "?view=view&id=") {
|
||||||
|
window.location = window.location.origin + window.location.pathname + leftURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function goRight(rightURL) {
|
||||||
|
if (rightURL != "?view=view&id=") {
|
||||||
|
window.location = window.location.origin + window.location.pathname + rightURL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@
|
||||||
<link rel="stylesheet" href="{{ poche_url }}themes/{{theme}}/css/print.css" media="print">
|
<link rel="stylesheet" href="{{ poche_url }}themes/{{theme}}/css/print.css" media="print">
|
||||||
|
|
||||||
<script src="{{ poche_url }}themes/_global/js/jquery-2.1.3.min.js"></script>
|
<script src="{{ poche_url }}themes/_global/js/jquery-2.1.3.min.js"></script>
|
||||||
|
<script src="{{ poche_url }}themes/_global/js/jquery.mobile.events.touch.min.js"></script>
|
||||||
<script src="{{ poche_url }}themes/_global/js/autoClose.js"></script>
|
<script src="{{ poche_url }}themes/_global/js/autoClose.js"></script>
|
||||||
<script src="{{ poche_url }}themes/{{theme}}/js/jquery.cookie.js"></script>
|
<script src="{{ poche_url }}themes/{{theme}}/js/jquery.cookie.js"></script>
|
||||||
<script src="{{ poche_url }}themes/{{theme}}/js/init.js"></script>
|
<script src="{{ poche_url }}themes/{{theme}}/js/init.js"></script>
|
||||||
|
|
|
@ -103,6 +103,17 @@
|
||||||
retrievePercent({{ entry.id|e }});
|
retrievePercent({{ entry.id|e }});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Use left and right arrow to navigate on with keyboard
|
||||||
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
|
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
|
||||||
|
|
||||||
|
// swipe to right or left on mobile to navigate
|
||||||
|
$('article').on("swiperight", function(){
|
||||||
|
goLeft('?view=view&id={{ navigate.nextid|e }}');
|
||||||
|
});
|
||||||
|
$('article').on("swipeleft", function(){
|
||||||
|
goRight('?view=view&id={{ navigate.previousid|e }}');
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<link rel="stylesheet" href="{{ poche_url }}themes/default/css/messages.css" media="all">
|
<link rel="stylesheet" href="{{ poche_url }}themes/default/css/messages.css" media="all">
|
||||||
<link rel="stylesheet" href="{{ poche_url }}themes/default/css/print.css" media="print">
|
<link rel="stylesheet" href="{{ poche_url }}themes/default/css/print.css" media="print">
|
||||||
<script src="{{ poche_url }}themes/_global/js/jquery-2.1.3.min.js"></script>
|
<script src="{{ poche_url }}themes/_global/js/jquery-2.1.3.min.js"></script>
|
||||||
|
<script src="{{ poche_url }}themes/_global/js/jquery.mobile.events.touch.min.js"></script>
|
||||||
<script src="{{ poche_url }}themes/_global/js/autoClose.js"></script>
|
<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/default/js/closeMessage.js"></script>
|
||||||
<script src="{{ poche_url }}themes/_global/js/saveLink.js"></script>
|
<script src="{{ poche_url }}themes/_global/js/saveLink.js"></script>
|
||||||
|
|
|
@ -125,6 +125,17 @@
|
||||||
$('#article_toolbar .tool.top').parent().hide();
|
$('#article_toolbar .tool.top').parent().hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Use left and right arrow to navigate on with keyboard
|
||||||
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
|
navigateKeyboard('?view=view&id={{ navigate.nextid|e }}','?view=view&id={{ navigate.previousid|e }}');
|
||||||
|
|
||||||
|
// swipe to right or left on mobile to navigate
|
||||||
|
$('article').on("swiperight", function(){
|
||||||
|
goLeft('?view=view&id={{ navigate.nextid|e }}');
|
||||||
|
});
|
||||||
|
$('article').on("swipeleft", function(){
|
||||||
|
goRight('?view=view&id={{ navigate.previousid|e }}');
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue