summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-02-01 11:40:20 -0500
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-02-02 10:07:30 -0500
commit6eb7828b628faecc314c7acfee0860fb24635737 (patch)
tree26f5d5044ad8178785010e2cf894ab47a6105c82
parent02d1dac0bb07884b79ddea20980bfcf21131f2d7 (diff)
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.
-rw-r--r--p/scripts/main.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index f0d2bbf7b..ee729b9e5 100644
--- a/p/scripts/main.js
+++ b/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, {