jquery.fileupload-rails 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +2 -0
- data/jquery.fileupload-rails.gemspec +1 -1
- data/vendor/assets/javascripts/jquery.fileupload.js +56 -24
- metadata +2 -2
data/Readme.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
//= require jquery.iframe-transport
|
3
3
|
|
4
4
|
/*
|
5
|
-
* jQuery File Upload Plugin 5.
|
5
|
+
* jQuery File Upload Plugin 5.28.4
|
6
6
|
* https://github.com/blueimp/jQuery-File-Upload
|
7
7
|
*
|
8
8
|
* Copyright 2010, Sebastian Tschan
|
@@ -218,7 +218,7 @@
|
|
218
218
|
],
|
219
219
|
|
220
220
|
_BitrateTimer: function () {
|
221
|
-
this.timestamp =
|
221
|
+
this.timestamp = (new Date()).getTime();
|
222
222
|
this.loaded = 0;
|
223
223
|
this.bitrate = 0;
|
224
224
|
this.getBitrate = function (now, loaded, interval) {
|
@@ -246,7 +246,7 @@
|
|
246
246
|
if ($.isArray(options.formData)) {
|
247
247
|
return options.formData;
|
248
248
|
}
|
249
|
-
if (options.formData) {
|
249
|
+
if ($.type(options.formData) === 'object') {
|
250
250
|
formData = [];
|
251
251
|
$.each(options.formData, function (name, value) {
|
252
252
|
formData.push({name: name, value: value});
|
@@ -265,16 +265,34 @@
|
|
265
265
|
},
|
266
266
|
|
267
267
|
_initProgressObject: function (obj) {
|
268
|
-
|
268
|
+
var progress = {
|
269
269
|
loaded: 0,
|
270
270
|
total: 0,
|
271
271
|
bitrate: 0
|
272
272
|
};
|
273
|
+
if (obj._progress) {
|
274
|
+
$.extend(obj._progress, progress);
|
275
|
+
} else {
|
276
|
+
obj._progress = progress;
|
277
|
+
}
|
278
|
+
},
|
279
|
+
|
280
|
+
_initResponseObject: function (obj) {
|
281
|
+
var prop;
|
282
|
+
if (obj._response) {
|
283
|
+
for (prop in obj._response) {
|
284
|
+
if (obj._response.hasOwnProperty(prop)) {
|
285
|
+
delete obj._response[prop];
|
286
|
+
}
|
287
|
+
}
|
288
|
+
} else {
|
289
|
+
obj._response = {};
|
290
|
+
}
|
273
291
|
},
|
274
292
|
|
275
293
|
_onProgress: function (e, data) {
|
276
294
|
if (e.lengthComputable) {
|
277
|
-
var now =
|
295
|
+
var now = (new Date()).getTime(),
|
278
296
|
loaded;
|
279
297
|
if (data._time && data.progressInterval &&
|
280
298
|
(now - data._time < data.progressInterval) &&
|
@@ -544,7 +562,7 @@
|
|
544
562
|
if (this.jqXHR) {
|
545
563
|
return this.jqXHR.abort();
|
546
564
|
}
|
547
|
-
return
|
565
|
+
return that._getXHRPromise();
|
548
566
|
};
|
549
567
|
data.state = function () {
|
550
568
|
if (this.jqXHR) {
|
@@ -554,6 +572,9 @@
|
|
554
572
|
data.progress = function () {
|
555
573
|
return this._progress;
|
556
574
|
};
|
575
|
+
data.response = function () {
|
576
|
+
return this._response;
|
577
|
+
};
|
557
578
|
},
|
558
579
|
|
559
580
|
// Parses the Range header from the server response
|
@@ -682,9 +703,11 @@
|
|
682
703
|
this._progress.loaded = this._progress.total = 0;
|
683
704
|
this._progress.bitrate = 0;
|
684
705
|
}
|
685
|
-
|
686
|
-
|
687
|
-
|
706
|
+
// Make sure the container objects for the .response() and
|
707
|
+
// .progress() methods on the data object are available
|
708
|
+
// and reset to their initial state:
|
709
|
+
this._initResponseObject(data);
|
710
|
+
this._initProgressObject(data);
|
688
711
|
data._progress.loaded = data.loaded = data.uploadedBytes || 0;
|
689
712
|
data._progress.total = data.total = this._getTotal(data.files) || 1;
|
690
713
|
data._progress.bitrate = data.bitrate = 0;
|
@@ -695,7 +718,8 @@
|
|
695
718
|
},
|
696
719
|
|
697
720
|
_onDone: function (result, textStatus, jqXHR, options) {
|
698
|
-
var total = options._progress.total
|
721
|
+
var total = options._progress.total,
|
722
|
+
response = options._response;
|
699
723
|
if (options._progress.loaded < total) {
|
700
724
|
// Create a progress event if no final progress event
|
701
725
|
// with loaded equaling total has been triggered:
|
@@ -705,35 +729,30 @@
|
|
705
729
|
total: total
|
706
730
|
}), options);
|
707
731
|
}
|
708
|
-
options.result = result;
|
709
|
-
options.textStatus = textStatus;
|
710
|
-
options.jqXHR = jqXHR;
|
732
|
+
response.result = options.result = result;
|
733
|
+
response.textStatus = options.textStatus = textStatus;
|
734
|
+
response.jqXHR = options.jqXHR = jqXHR;
|
711
735
|
this._trigger('done', null, options);
|
712
736
|
},
|
713
737
|
|
714
738
|
_onFail: function (jqXHR, textStatus, errorThrown, options) {
|
715
|
-
|
716
|
-
options.textStatus = textStatus;
|
717
|
-
options.errorThrown = errorThrown;
|
718
|
-
this._trigger('fail', null, options);
|
739
|
+
var response = options._response;
|
719
740
|
if (options.recalculateProgress) {
|
720
741
|
// Remove the failed (error or abort) file upload from
|
721
742
|
// the global progress calculation:
|
722
743
|
this._progress.loaded -= options._progress.loaded;
|
723
744
|
this._progress.total -= options._progress.total;
|
724
745
|
}
|
746
|
+
response.jqXHR = options.jqXHR = jqXHR;
|
747
|
+
response.textStatus = options.textStatus = textStatus;
|
748
|
+
response.errorThrown = options.errorThrown = errorThrown;
|
749
|
+
this._trigger('fail', null, options);
|
725
750
|
},
|
726
751
|
|
727
752
|
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
|
728
753
|
// jqXHRorResult, textStatus and jqXHRorError are added to the
|
729
754
|
// options object via done and fail callbacks
|
730
|
-
this._active -= 1;
|
731
755
|
this._trigger('always', null, options);
|
732
|
-
if (this._active === 0) {
|
733
|
-
// The stop callback is triggered when all uploads have
|
734
|
-
// been completed, equivalent to the global ajaxStop event:
|
735
|
-
this._trigger('stop');
|
736
|
-
}
|
737
756
|
},
|
738
757
|
|
739
758
|
_onSend: function (e, data) {
|
@@ -759,13 +778,14 @@
|
|
759
778
|
}).fail(function (jqXHR, textStatus, errorThrown) {
|
760
779
|
that._onFail(jqXHR, textStatus, errorThrown, options);
|
761
780
|
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
|
762
|
-
that._sending -= 1;
|
763
781
|
that._onAlways(
|
764
782
|
jqXHRorResult,
|
765
783
|
textStatus,
|
766
784
|
jqXHRorError,
|
767
785
|
options
|
768
786
|
);
|
787
|
+
that._sending -= 1;
|
788
|
+
that._active -= 1;
|
769
789
|
if (options.limitConcurrentUploads &&
|
770
790
|
options.limitConcurrentUploads > that._sending) {
|
771
791
|
// Start the next queued upload,
|
@@ -779,6 +799,11 @@
|
|
779
799
|
nextSlot = that._slots.shift();
|
780
800
|
}
|
781
801
|
}
|
802
|
+
if (that._active === 0) {
|
803
|
+
// The stop callback is triggered when all uploads have
|
804
|
+
// been completed, equivalent to the global ajaxStop event:
|
805
|
+
that._trigger('stop');
|
806
|
+
}
|
782
807
|
});
|
783
808
|
return jqXHR;
|
784
809
|
};
|
@@ -844,6 +869,7 @@
|
|
844
869
|
var newData = $.extend({}, data);
|
845
870
|
newData.files = fileSet ? element : [element];
|
846
871
|
newData.paramName = paramNameSet[index];
|
872
|
+
that._initResponseObject(newData);
|
847
873
|
that._initProgressObject(newData);
|
848
874
|
that._addConvenienceMethods(e, newData);
|
849
875
|
result = that._trigger('add', e, newData);
|
@@ -1124,6 +1150,12 @@
|
|
1124
1150
|
this._initEventHandlers();
|
1125
1151
|
},
|
1126
1152
|
|
1153
|
+
// This method is exposed to the widget API and allows to query
|
1154
|
+
// the number of active uploads:
|
1155
|
+
active: function () {
|
1156
|
+
return this._active;
|
1157
|
+
},
|
1158
|
+
|
1127
1159
|
// This method is exposed to the widget API and allows to query
|
1128
1160
|
// the widget upload progress.
|
1129
1161
|
// It returns an object with loaded, total and bitrate properties
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: jquery.fileupload-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Semyon Perepelitsa
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|