Modification du partage au clavier

Le raccourci de partage a été modifié pour partager automatiquement un article s'il n'existe qu'un mode de partage.
Les modes de partage sont rendus accessibles au clavier en utilisant les chiffres de 1 à 9.
Quand un article est partagé, la liste des modes est cachée automatiquement.
pull/408/head
Alexis Degrugillier 11 years ago
parent 02d1dac0bb
commit 6eb7828b62
  1. 28
      p/scripts/main.js

@ -252,10 +252,27 @@ function collapse_entry() {
$(".flux.current").toggleClass("active");
}
function auto_share() {
function auto_share(key) {
var share = $(".flux.current.active").find('.dropdown-target[id^="dropdown-share"]');
if (share.length) {
var shares = share.siblings('.dropdown-menu').find('.item a');
if (typeof key === "undefined") {
if (!share.length) {
return;
}
// Display the share div
window.location.hash = share.attr('id');
// Force the key value if there is only one action, so we can trigger it automatically
if (shares.length === 1) {
key = 1;
} else {
return;
}
}
// Trigger selected share action and hide the share div
key = parseInt(key);
if (key <= shares.length) {
shares[key - 1].click();
share.siblings('.dropdown-menu').find('.dropdown-close a')[0].click();
}
}
@ -390,6 +407,13 @@ function init_shortcuts() {
}, {
'disable_in_input': true
});
for(var i = 1; i < 10; i++){
shortcut.add(i.toString(), function (e) {
auto_share(String.fromCharCode(e.keyCode));
}, {
'disable_in_input': true
});
}
// Touches de navigation
shortcut.add(shortcuts.prev_entry, prev_entry, {

Loading…
Cancel
Save