diff options
| author | marktaiwan <mark.taiwan@gmail.com> | 2015-03-20 08:53:57 +0800 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2015-03-31 05:57:45 +0200 |
| commit | 6e84a25f9a882bc4c2cbd1e376416ac34ca9943b (patch) | |
| tree | dea05e389dbea2b43833a834600ecb689e0cad68 | |
| parent | 4da073b6e85aae15b8eed227b3b3b16798d2a99e (diff) | |
Adds keyboard focus to file selector
| -rw-r--r-- | js/file-selector.js | 10 | ||||
| -rw-r--r-- | 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 = $('<input type="file" multiple>'); $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 @@ <input type="file" name="file" id="upload_file"> <div class="dropzone-wrap" style="display: none;"> - <div class="dropzone"> + <div class="dropzone" tabindex="0"> <div class="file-hint">Select/drop/paste files here</div> <div class="file-thumbs"></div> </div> |
