Skip to content

Commit

Permalink
2.6 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
sdturner02 committed Mar 14, 2017
1 parent 0c68f86 commit f2fc8d9
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 33 deletions.
12 changes: 12 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
Change Log
============================
### Version 2.6 ###
SimpleAjaxUploader.js:
* Added keyboard support for file button. Pressing Enter while focused on file select button now opens file dialog box - <a href="https://github.com/LPology/Simple-Ajax-Uploader/pull/183">#183</a> (Special thanks to <a href="https://github.com/phy25">phy25</a> for this.)
* Added new `multipleSelect` option to allow/disallow multiple file selection (default `false`)
* Modified `multiple` option to now only control whether multiple, concurrent uploads are permitted
* Added new `onDone( filename, status, statusText, response, uploadBtn, size )` method which fires after each individual upload finishes
* Added new `onAllDone()` method which fires when all active uploads finish
* Added JSHint comments to suppress "better written in dot notation" warnings

Uploader.php:
* Added `getFileNameWithoutExt` method - <a href="https://github.com/LPology/Simple-Ajax-Uploader/pull/182">#182</a> (Special thanks to <a href="https://github.com/sainrew">sainrew</a> for this)

### Version 2.5.5 ###
SimpleAjaxUploader.js:
* Improved drag detection to work around Firefox bug which causes `dragenter` to fire twice (https://bugzilla.mozilla.org/show_bug.cgi?id=804036)
Expand Down
70 changes: 49 additions & 21 deletions SimpleAjaxUploader.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Simple Ajax Uploader
* Version 2.5.5
* Version 2.6
* https://github.com/LPology/Simple-Ajax-Uploader
*
* Copyright 2012-2016 LPology, LLC
* Copyright 2012-2017 LPology, LLC
* Released under the MIT license
*/

Expand Down Expand Up @@ -45,6 +45,10 @@ var ss = window.ss || {},
// http://stackoverflow.com/a/9851769/1091949
isSafari = Object.prototype.toString.call( window.HTMLElement ).indexOf( 'Constructor' ) > 0,

// Detect IE7-9
isIE7to9 = ( navigator.userAgent.indexOf('MSIE') !== -1 &&
navigator.userAgent.indexOf('MSIE 1') === -1 ),

isIE7 = ( navigator.userAgent.indexOf('MSIE 7') !== -1 ),

// Check whether XHR uploads are supported
Expand Down Expand Up @@ -652,7 +656,8 @@ ss.SimpleUpload = function( options ) {
progressUrl: false,
sessionProgressUrl: false,
nginxProgressUrl: false,
multiple: false,
multiple: false, // allow multiple, concurrent file uploads
multipleSelect: false, // allow multiple file selection
maxUploads: 3,
queue: true,
checkProgressInterval: 500,
Expand Down Expand Up @@ -685,6 +690,8 @@ ss.SimpleUpload = function( options ) {
onProgress: function( pct ) {},
onUpdateFileSize: function( filesize ) {},
onComplete: function( filename, response, uploadBtn, size ) {},
onDone: function( filename, status, textStatus, response, uploadBtn, size ) {},
onAllDone: function() {},
onExtError: function( filename, extension ) {},
onSizeError: function( filename, fileSize ) {},
onError: function( filename, type, status, statusText, response, uploadBtn, size ) {},
Expand Down Expand Up @@ -1039,7 +1046,9 @@ ss.SimpleUpload.prototype = {
rerouteClicks: function( elem ) {
"use strict";

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

detachOver = ss.addEvent( elem, 'mouseover', function() {
if ( self._disabled ) {
Expand All @@ -1054,21 +1063,30 @@ 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();

detachClick = ss.addEvent( elem, 'click', function( e ) {
if ( e && e.preventDefault ) {
e.preventDefault();
}

if ( !self._input ) {
self._createInput();
}

self._overBtn = elem;
self._input.click();

if ( !isIE7to9 ) {
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();};
elem.off = function() {
detachOver();
detachClick();
};

if ( self._opts.autoCalibrate && !ss.isVisible( elem ) ) {
self.log('Upload button not visible');
Expand Down Expand Up @@ -1307,7 +1325,7 @@ ss.IframeUpload = {
self._errorFinish( fileObj, '', '', false, 'error', progBox, sizeBox, pctBox, abortBtn, removeAbort );
}

fileObj = opts = key = iframe = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
opts = key = iframe = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
}, 600);
}

Expand All @@ -1329,7 +1347,7 @@ ss.IframeUpload = {
self._errorFinish( fileObj, '', e.message, false, 'error', progBox, sizeBox, pctBox, abortBtn, removeAbort );
}

fileObj = opts = key = sizeBox = progBox = pctBox = null;
opts = key = sizeBox = progBox = pctBox = null;
}
});// end load

Expand Down Expand Up @@ -1362,7 +1380,7 @@ ss.IframeUpload = {

self.log('Upload aborted');
opts.onAbort.call( self, fileObj.name, fileObj.btn, fileObj.size );
self._last( sizeBox, progBox, pctBox, abortBtn, removeAbort );
self._last( sizeBox, progBox, pctBox, abortBtn, removeAbort, fileObj, 'abort' );
};

ss.addEvent( abortBtn, 'click', cancel );
Expand Down Expand Up @@ -1400,6 +1418,7 @@ ss.IframeUpload = {
*/
_getProg: function( key, progBar, sizeBox, pctBox, counter ) {
"use strict";
/*jshint sub:true*/

var self = this,
opts = this._opts,
Expand Down Expand Up @@ -1703,7 +1722,7 @@ ss.XhrUpload = {
}

opts.onAbort.call( self, fileObj.name, fileObj.btn, fileObj.size );
self._last( sizeBox, progBox, pctBox, abortBtn, removeAbort );
self._last( sizeBox, progBox, pctBox, abortBtn, removeAbort, fileObj, 'abort' );

} else {
if ( abortBtn ) {
Expand Down Expand Up @@ -1815,6 +1834,7 @@ ss.XhrUpload = {

_initUpload: function( fileObj ) {
"use strict";
/*jshint sub:true*/

var params = {},
headers = {},
Expand Down Expand Up @@ -1964,7 +1984,7 @@ ss.extendObj( ss.SimpleUpload.prototype, {

// Don't allow multiple file selection in Safari -- it has a nasty bug
// http://stackoverflow.com/q/7231054/1091949
if ( XhrOk && !isSafari && this._opts.multiple ) {
if ( XhrOk && !isSafari && this._opts.multipleSelect ) {
this._input.multiple = true;
}

Expand Down Expand Up @@ -2056,7 +2076,7 @@ ss.extendObj( ss.SimpleUpload.prototype, {
/**
* Final cleanup function after upload ends
*/
_last: function( sizeBox, progBox, pctBox, abortBtn, removeAbort ) {
_last: function( sizeBox, progBox, pctBox, abortBtn, removeAbort, fileObj, textStatus, status, response ) {
"use strict";

if ( sizeBox ) {
Expand Down Expand Up @@ -2098,8 +2118,16 @@ ss.extendObj( ss.SimpleUpload.prototype, {

// Otherwise just go to the next upload as usual
} else {
this._opts.onDone.call( this, fileObj.name, status, textStatus, response, fileObj.btn, fileObj.size );

this._cycleQueue();

if ( this._queue.length === 0 && this._active === 0 ) {
this._opts.onAllDone.call( this );
}
}

fileObj = textStatus = status = response = null;
},

/**
Expand All @@ -2110,9 +2138,9 @@ ss.extendObj( ss.SimpleUpload.prototype, {

this.log( 'Upload failed: ' + status + ' ' + statusText );
this._opts.onError.call( this, fileObj.name, errorType, status, statusText, response, fileObj.btn, fileObj.size );
this._last( sizeBox, progBox, pctBox, abortBtn, removeAbort );
this._last( sizeBox, progBox, pctBox, abortBtn, removeAbort, fileObj, 'error', status, response );

fileObj = status = statusText = response = errorType = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
statusText = errorType = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
},

/**
Expand All @@ -2133,8 +2161,8 @@ ss.extendObj( ss.SimpleUpload.prototype, {
}

this._opts.onComplete.call( this, fileObj.name, response, fileObj.btn, fileObj.size );
this._last( sizeBox, progBox, pctBox, abortBtn, removeAbort );
fileObj = status = statusText = response = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
this._last( sizeBox, progBox, pctBox, abortBtn, removeAbort, fileObj, 'success', status, response );
statusText = sizeBox = progBox = pctBox = abortBtn = removeAbort = null;
},

/**
Expand Down
4 changes: 2 additions & 2 deletions SimpleAjaxUploader.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-ajax-uploader",
"description": "A Javascript plugin for cross-browser Ajax file uploading. Supports drag and drop, CORS, and multiple file uploading with progress bars. Works in IE7-9, mobile, and all modern browsers.",
"version": "2.5.5",
"version": "2.6",
"main": "SimpleAjaxUploader.js",
"keywords": [
"ajax",
Expand Down
4 changes: 2 additions & 2 deletions extras/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/**
* Simple Ajax Uploader
* Version 2.5.5
* Version 2.6
* https://github.com/LPology/Simple-Ajax-Uploader
*
* Copyright 2012-2016 LPology, LLC
* Copyright 2012-2017 LPology, LLC
* Released under the MIT license
*
* View the documentation for an example of how to use this class.
Expand Down
4 changes: 2 additions & 2 deletions extras/cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/**
* Simple Ajax Uploader
* Version 2.5.5
* Version 2.6
* https://github.com/LPology/Simple-Ajax-Uploader
*
* Copyright 2012-2016 LPology, LLC
* Copyright 2012-2017 LPology, LLC
* Released under the MIT license
*
*/
Expand Down
4 changes: 2 additions & 2 deletions extras/sessionProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/**
* Simple Ajax Uploader
* Version 2.5.5
* Version 2.6
* https://github.com/LPology/Simple-Ajax-Uploader
*
* Copyright 2012-2016 LPology, LLC
* Copyright 2012-2017 LPology, LLC
* Released under the MIT license
*
* Returns upload progress updates for browsers that don't support the HTML5 File API.
Expand Down
4 changes: 2 additions & 2 deletions extras/uploadProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/**
* Simple Ajax Uploader
* Version 2.5.5
* Version 2.6
* https://github.com/LPology/Simple-Ajax-Uploader
*
* Copyright 2012-2016 LPology, LLC
* Copyright 2012-2017 LPology, LLC
* Released under the MIT license
*
* Returns upload progress updates for browsers that don't support the HTML5 File API.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-ajax-uploader",
"description": "A Javascript plugin for cross-browser Ajax file uploading. Supports drag and drop, CORS, and multiple file uploading with progress bars. Works in IE7-9, mobile, and all modern browsers.",
"version": "2.5.5",
"version": "2.6",
"main": "SimpleAjaxUploader.js",
"keywords": [
"ajax",
Expand Down

0 comments on commit f2fc8d9

Please sign in to comment.