Skip to content

Commit 0c68f86

Browse files
authored
Merge pull request #183 from phy25/patch-1
Add keyboard support with file button
2 parents cddfbcc + 5e92f84 commit 0c68f86

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

SimpleAjaxUploader.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,11 +1039,9 @@ ss.SimpleUpload.prototype = {
10391039
rerouteClicks: function( elem ) {
10401040
"use strict";
10411041

1042-
var self = this;
1042+
var self = this, detachOver, detachClick;
10431043

1044-
// ss.addEvent() returns a function to detach, which
1045-
// allows us to call elem.off() to remove mouseover listener
1046-
elem.off = ss.addEvent( elem, 'mouseover', function() {
1044+
detachOver = ss.addEvent( elem, 'mouseover', function() {
10471045
if ( self._disabled ) {
10481046
return;
10491047
}
@@ -1056,6 +1054,21 @@ ss.SimpleUpload.prototype = {
10561054
ss.copyLayout( elem, self._input.parentNode );
10571055
self._input.parentNode.style.visibility = 'visible';
10581056
});
1057+
1058+
// Support keyboard interaction
1059+
detachClick = ss.addEvent( elem, 'click', function( e ){
1060+
e.preventDefault();
1061+
1062+
if ( !self._input ) {
1063+
self._createInput();
1064+
}
1065+
self._overBtn = elem;
1066+
self._input.click();
1067+
});
1068+
1069+
// ss.addEvent() returns a function to detach, which
1070+
// allows us to call elem.off() to remove mouseover listener
1071+
elem.off = function(){detachOver();detachClick();};
10591072

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

0 commit comments

Comments
 (0)