Skip to content

Commit

Permalink
add fileInfo.responseMsg param to onEachUpload callback. closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbeefeater committed Oct 30, 2016
1 parent 1d27baa commit 48dbb67
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 50 deletions.
1 change: 1 addition & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
url: 'uploadAction.php',
maxFileSize: 6,
allowed: ['jpg', 'gif', 'txt', 'png', 'pdf']
,onEachUpload:function(file){alert(file.response)}
});
$('#ssi-upload2').ssi_uploader({url: 'uploadAction.php', preview: false});
$('#ssi-upload3').ssi_uploader({url: 'uploadAction.php', dropZone: false});
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ssi-uploader",
"version": "1.1.1",
"version": "1.1.3",
"main": "ssi-uploader/js/ssi-uploader.js",
"description": "An awesome jquery uploader",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions dist/ssi-uploader/js/ssi-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,11 @@
thisS.totalProgress[ii] = '';
thisS.inProgress--;
$clearBtn.prop("disabled", false);

if (typeof thisS.options.onEachUpload === 'function') {//execute the onEachUpload callback
try {
thisS.options.onEachUpload({//and return some info
uploadStatus: 'error',
responseMsg:thisS.language.serverError,
name: thisS.toUpload[ii].name,
size: (thisS.toUpload[ii].size / 1024).toFixed(2),
type: thisS.toUpload[ii].type
Expand All @@ -565,7 +565,6 @@
console.log('There is an error in onEachUpload callback. File name:' + thisS.toUpload[ii].name);
console.log(err);
}

}
}
if (getCompleteStatus(thisS)) {//if no more elements in progress
Expand Down Expand Up @@ -629,6 +628,7 @@
try {
thisS.options.onEachUpload({//and return some info
uploadStatus: dataType,
responseMsg:title,
name: thisS.toUpload[ii].name,
size: (thisS.toUpload[ii].size / 1024).toFixed(2),
type: thisS.toUpload[ii].type
Expand Down
55 changes: 28 additions & 27 deletions dist/ssi-uploader/js/ssi-uploader.min.js

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions dist/ssi-uploader/js/ssi-uploader.min.js.map

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var source = require('vinyl-source-stream');
var closureCompiler = require('gulp-closure-compiler');
var closure = require('gulp-closure-compiler-service');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
Expand Down Expand Up @@ -54,14 +54,12 @@ gulp.task('html', function () {
});
gulp.task('compile', function () {
gulp.src(config.paths.ssi_uploaderJs)
.pipe(closureCompiler({
compilerPath: './node_modules/google-closure-compiler/compiler.jar',
fileName: 'ssi-uploader.min.js',
compilerFlags: {
create_source_map: config.paths.dist + '/ssi-uploader/js/ssi-uploader.min.js.map'
}
})).on('error', console.error.bind(console))
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/js/'));
.pipe(sourcemaps.init())
.pipe(closure()).on('error', console.error.bind(console))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/js/'))
.on('error', console.error.bind(console));
});
gulp.task('js', function () {
gulp.src(config.paths.ssi_uploaderJs)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"browser-sync": "^2.11.2",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.0",
"gulp-closure-compiler": "^0.4.0",
"gulp-closure-compiler-service": "^0.6.0",
"gulp-concat": "^2.6.0",
"gulp-csso": "^2.0.0",
"gulp-if": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
url: 'uploadAction.php',
maxFileSize: 6,
allowed: ['jpg', 'gif', 'txt', 'png', 'pdf']
,onEachUpload:function(file){alert(file.response)}
});
$('#ssi-upload2').ssi_uploader({url: 'uploadAction.php', preview: false});
$('#ssi-upload3').ssi_uploader({url: 'uploadAction.php', dropZone: false});
Expand Down
4 changes: 2 additions & 2 deletions src/ssi-uploader/js/ssi-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,11 @@
thisS.totalProgress[ii] = '';
thisS.inProgress--;
$clearBtn.prop("disabled", false);

if (typeof thisS.options.onEachUpload === 'function') {//execute the onEachUpload callback
try {
thisS.options.onEachUpload({//and return some info
uploadStatus: 'error',
responseMsg:thisS.language.serverError,
name: thisS.toUpload[ii].name,
size: (thisS.toUpload[ii].size / 1024).toFixed(2),
type: thisS.toUpload[ii].type
Expand All @@ -565,7 +565,6 @@
console.log('There is an error in onEachUpload callback. File name:' + thisS.toUpload[ii].name);
console.log(err);
}

}
}
if (getCompleteStatus(thisS)) {//if no more elements in progress
Expand Down Expand Up @@ -629,6 +628,7 @@
try {
thisS.options.onEachUpload({//and return some info
uploadStatus: dataType,
responseMsg:title,
name: thisS.toUpload[ii].name,
size: (thisS.toUpload[ii].size / 1024).toFixed(2),
type: thisS.toUpload[ii].type
Expand Down

0 comments on commit 48dbb67

Please sign in to comment.