Skip to content

Commit

Permalink
Merge pull request #183 from phy25/patch-1
Browse files Browse the repository at this point in the history
Add keyboard support with file button
  • Loading branch information
LPology authored Mar 14, 2017
2 parents cddfbcc + 5e92f84 commit 0c68f86
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions SimpleAjaxUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,9 @@ ss.SimpleUpload.prototype = {
rerouteClicks: function( elem ) {
"use strict";

var self = this;
var self = this, detachOver, detachClick;

// ss.addEvent() returns a function to detach, which
// allows us to call elem.off() to remove mouseover listener
elem.off = ss.addEvent( elem, 'mouseover', function() {
detachOver = ss.addEvent( elem, 'mouseover', function() {
if ( self._disabled ) {
return;
}
Expand All @@ -1056,6 +1054,21 @@ ss.SimpleUpload.prototype = {
ss.copyLayout( elem, self._input.parentNode );
self._input.parentNode.style.visibility = 'visible';
});

// Support keyboard interaction
detachClick = ss.addEvent( elem, 'click', function( e ){
e.preventDefault();

if ( !self._input ) {
self._createInput();
}
self._overBtn = elem;
self._input.click();
});

// ss.addEvent() returns a function to detach, which
// allows us to call elem.off() to remove mouseover listener
elem.off = function(){detachOver();detachClick();};

if ( self._opts.autoCalibrate && !ss.isVisible( elem ) ) {
self.log('Upload button not visible');
Expand Down

0 comments on commit 0c68f86

Please sign in to comment.