From 6e84a25f9a882bc4c2cbd1e376416ac34ca9943b Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 08:53:57 +0800 Subject: [PATCH] Adds keyboard focus to file selector --- js/file-selector.js | 10 +++++++++- templates/post_form.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index e5451f1a..dbe8ea82 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -135,13 +135,21 @@ var dropHandlers = { $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { + e.stopPropagation(); + var file = $(e.target).parent().data('file-ref'); getThumbElement(file).remove(); removeFile(file); }); -$(document).on('click', '.dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { + e.stopPropagation(); + + // accept mosue click or Enter + if (e.which != 1 || e.which != 13) + return; + var $fileSelector = $(''); $fileSelector.on('change', function (e) { diff --git a/templates/post_form.html b/templates/post_form.html index 809230f0..7cdcc7d3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -100,7 +100,7 @@