jquery.fileupload-rails 1.0.0.beta → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md
CHANGED
@@ -23,9 +23,23 @@ Included (no need to require):
|
|
23
23
|
* jQuery Iframe Transport for IE support.
|
24
24
|
* jQuery UI widget from [jquery-ui-rails][2]
|
25
25
|
|
26
|
+
## Upgrading 0.1 to 1.0
|
27
|
+
|
28
|
+
You can remove all dependencies of the plugin from you manifest. Before:
|
29
|
+
|
30
|
+
//= require jquery.ui
|
31
|
+
//= require jquery.iframe-transport
|
32
|
+
//= require jquery.fileupload
|
33
|
+
|
34
|
+
After:
|
35
|
+
|
36
|
+
//= require jquery.fileupload
|
37
|
+
|
38
|
+
If you downloaded jquery.ui assets into your project, delete them and use [jquery-ui-rails][2] gem instead.
|
39
|
+
|
26
40
|
## Changelog
|
27
41
|
|
28
|
-
1.0.0.
|
42
|
+
1.0.0. Core 5.18.
|
29
43
|
|
30
44
|
Now rake task generates assets from official repo and adds dependencies automatically.
|
31
45
|
That means you can just require jquery.fileupload, no extra requires needed.
|
@@ -1,22 +1,15 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "jquery.fileupload-rails/version"
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = "jquery.fileupload-rails"
|
7
|
-
s.version =
|
8
|
-
s.
|
9
|
-
s.email =
|
5
|
+
s.version = "1.0.0"
|
6
|
+
s.author = "Semyon Perepelitsa"
|
7
|
+
s.email = "sema@sema.in"
|
10
8
|
s.homepage = "https://github.com/semaperepelitsa/jquery.fileupload-rails"
|
11
9
|
s.summary = %q{Use jQuery File Upload plugin with Rails 3}
|
12
10
|
s.description = %q{This gem packages jQuery File Upload plugin and it's dependencies for Rails asset pipeline.}
|
13
11
|
|
14
|
-
s.
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["lib"]
|
12
|
+
s.files = File.read('Manifest.txt').split("\n")
|
20
13
|
|
21
14
|
s.add_dependency 'sprockets', '~> 2.0'
|
22
15
|
s.add_dependency 'jquery-ui-rails'
|
@@ -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.18
|
6
6
|
* https://github.com/blueimp/jQuery-File-Upload
|
7
7
|
*
|
8
8
|
* Copyright 2010, Sebastian Tschan
|
@@ -308,29 +308,18 @@
|
|
308
308
|
// Ignore non-multipart setting if not supported:
|
309
309
|
multipart = options.multipart || !$.support.xhrFileUpload,
|
310
310
|
paramName = options.paramName[0];
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
// so we transmit this data as part of the HTTP headers.
|
315
|
-
// For cross domain requests, these headers must be allowed
|
316
|
-
// via Access-Control-Allow-Headers or removed using
|
317
|
-
// the beforeSend callback:
|
318
|
-
options.headers = $.extend(options.headers, {
|
319
|
-
'X-File-Name': file.name,
|
320
|
-
'X-File-Type': file.type,
|
321
|
-
'X-File-Size': file.size
|
322
|
-
});
|
323
|
-
if (!options.blob) {
|
324
|
-
// Non-chunked non-multipart upload:
|
325
|
-
options.contentType = file.type;
|
326
|
-
options.data = file;
|
327
|
-
} else if (!multipart) {
|
328
|
-
// Chunked non-multipart upload:
|
329
|
-
options.contentType = 'application/octet-stream';
|
330
|
-
options.data = options.blob;
|
331
|
-
}
|
311
|
+
options.headers = options.headers || {};
|
312
|
+
if (options.contentRange) {
|
313
|
+
options.headers['Content-Range'] = options.contentRange;
|
332
314
|
}
|
333
|
-
if (multipart
|
315
|
+
if (!multipart) {
|
316
|
+
// For cross domain requests, the X-File-Name header
|
317
|
+
// must be allowed via Access-Control-Allow-Headers
|
318
|
+
// or removed using the beforeSend callback:
|
319
|
+
options.headers['X-File-Name'] = file.name;
|
320
|
+
options.contentType = file.type;
|
321
|
+
options.data = options.blob || file;
|
322
|
+
} else if ($.support.xhrFormDataFileUpload) {
|
334
323
|
if (options.postMessage) {
|
335
324
|
// window.postMessage does not allow sending FormData
|
336
325
|
// objects, so we just add the File/Blob objects to
|
@@ -360,6 +349,11 @@
|
|
360
349
|
});
|
361
350
|
}
|
362
351
|
if (options.blob) {
|
352
|
+
// For cross domain requests, the X-File-* headers
|
353
|
+
// must be allowed via Access-Control-Allow-Headers
|
354
|
+
// or removed using the beforeSend callback:
|
355
|
+
options.headers['X-File-Name'] = file.name;
|
356
|
+
options.headers['X-File-Type'] = file.type;
|
363
357
|
formData.append(paramName, options.blob, file.name);
|
364
358
|
} else {
|
365
359
|
$.each(options.files, function (index, file) {
|
@@ -495,6 +489,16 @@
|
|
495
489
|
return this._enhancePromise(promise);
|
496
490
|
},
|
497
491
|
|
492
|
+
// Parses the Range header from the server response
|
493
|
+
// and returns the uploaded bytes:
|
494
|
+
_getUploadedBytes: function (jqXHR) {
|
495
|
+
var range = jqXHR.getResponseHeader('Range'),
|
496
|
+
parts = range && range.split('-'),
|
497
|
+
upperBytesPos = parts && parts.length > 1 &&
|
498
|
+
parseInt(parts[1], 10);
|
499
|
+
return upperBytesPos && upperBytesPos + 1;
|
500
|
+
},
|
501
|
+
|
498
502
|
// Uploads a file in multiple, sequential requests
|
499
503
|
// by splitting the file up in multiple blob chunks.
|
500
504
|
// If the second parameter is true, only tests if the file
|
@@ -507,10 +511,10 @@
|
|
507
511
|
ub = options.uploadedBytes = options.uploadedBytes || 0,
|
508
512
|
mcs = options.maxChunkSize || fs,
|
509
513
|
slice = file.slice || file.webkitSlice || file.mozSlice,
|
510
|
-
|
511
|
-
|
514
|
+
dfd = $.Deferred(),
|
515
|
+
promise = dfd.promise(),
|
512
516
|
jqXHR,
|
513
|
-
|
517
|
+
upload;
|
514
518
|
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
|
515
519
|
options.data) {
|
516
520
|
return false;
|
@@ -526,59 +530,63 @@
|
|
526
530
|
[null, 'error', file.error]
|
527
531
|
);
|
528
532
|
}
|
529
|
-
//
|
530
|
-
// calculated via filesize, uploaded bytes and max chunk size:
|
531
|
-
n = Math.ceil((fs - ub) / mcs);
|
532
|
-
// The chunk upload method accepting the chunk number as parameter:
|
533
|
+
// The chunk upload method:
|
533
534
|
upload = function (i) {
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
535
|
+
// Clone the options object for each chunk upload:
|
536
|
+
var o = $.extend({}, options);
|
537
|
+
o.blob = slice.call(
|
538
|
+
file,
|
539
|
+
ub,
|
540
|
+
ub + mcs
|
541
|
+
);
|
542
|
+
// Store the current chunk size, as the blob itself
|
543
|
+
// will be dereferenced after data processing:
|
544
|
+
o.chunkSize = o.blob.size;
|
545
|
+
// Expose the chunk bytes position range:
|
546
|
+
o.contentRange = 'bytes ' + ub + '-' +
|
547
|
+
(ub + o.chunkSize - 1) + '/' + fs;
|
548
|
+
// Process the upload data (the blob and potential form data):
|
549
|
+
that._initXHRData(o);
|
550
|
+
// Add progress listeners for this chunk upload:
|
551
|
+
that._initProgressListener(o);
|
552
|
+
jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context))
|
553
|
+
.done(function (result, textStatus, jqXHR) {
|
554
|
+
ub = that._getUploadedBytes(jqXHR) ||
|
555
|
+
(ub + o.chunkSize);
|
556
|
+
// Create a progress event if upload is done and
|
557
|
+
// no progress event has been invoked for this chunk:
|
558
|
+
if (!o.loaded) {
|
559
|
+
that._onProgress($.Event('progress', {
|
560
|
+
lengthComputable: true,
|
561
|
+
loaded: ub - o.uploadedBytes,
|
562
|
+
total: ub - o.uploadedBytes
|
563
|
+
}), o);
|
564
|
+
}
|
565
|
+
options.uploadedBytes = o.uploadedBytes = ub;
|
566
|
+
if (ub < fs) {
|
567
|
+
// File upload not yet complete,
|
568
|
+
// continue with the next chunk:
|
569
|
+
upload();
|
570
|
+
} else {
|
571
|
+
dfd.resolveWith(
|
572
|
+
o.context,
|
573
|
+
[result, textStatus, jqXHR]
|
574
|
+
);
|
575
|
+
}
|
576
|
+
})
|
577
|
+
.fail(function (jqXHR, textStatus, errorThrown) {
|
578
|
+
dfd.rejectWith(
|
579
|
+
o.context,
|
580
|
+
[jqXHR, textStatus, errorThrown]
|
581
|
+
);
|
582
|
+
});
|
573
583
|
};
|
574
|
-
|
575
|
-
|
576
|
-
// and jqXHR callbacks mapped to the equivalent Promise methods:
|
577
|
-
pipe = upload(n);
|
578
|
-
pipe.abort = function () {
|
584
|
+
this._enhancePromise(promise);
|
585
|
+
promise.abort = function () {
|
579
586
|
return jqXHR.abort();
|
580
587
|
};
|
581
|
-
|
588
|
+
upload();
|
589
|
+
return promise;
|
582
590
|
},
|
583
591
|
|
584
592
|
_beforeSend: function (e, data) {
|
@@ -860,8 +868,10 @@
|
|
860
868
|
var entry;
|
861
869
|
if (item.webkitGetAsEntry) {
|
862
870
|
entry = item.webkitGetAsEntry();
|
863
|
-
|
864
|
-
|
871
|
+
if (entry) {
|
872
|
+
// Workaround for Chrome bug #149735:
|
873
|
+
entry._file = item.getAsFile();
|
874
|
+
}
|
865
875
|
return entry;
|
866
876
|
}
|
867
877
|
return item.getAsEntry();
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery.fileupload-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Semyon Perepelitsa
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
@@ -45,8 +45,7 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
description: This gem packages jQuery File Upload plugin and it's dependencies for
|
47
47
|
Rails asset pipeline.
|
48
|
-
email:
|
49
|
-
- sema@sema.in
|
48
|
+
email: sema@sema.in
|
50
49
|
executables: []
|
51
50
|
extensions: []
|
52
51
|
extra_rdoc_files: []
|
@@ -108,7 +107,6 @@ files:
|
|
108
107
|
- dependencies.json
|
109
108
|
- jquery.fileupload-rails.gemspec
|
110
109
|
- lib/jquery.fileupload-rails.rb
|
111
|
-
- lib/jquery.fileupload-rails/version.rb
|
112
110
|
- vendor/assets/javascripts/jquery.fileupload.js
|
113
111
|
- vendor/assets/javascripts/jquery.iframe-transport.js
|
114
112
|
- vendor/legacy_assets/javascripts/jquery.fileupload-fp.js
|
@@ -132,11 +130,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
131
|
none: false
|
134
132
|
requirements:
|
135
|
-
- - ! '
|
133
|
+
- - ! '>='
|
136
134
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
135
|
+
version: '0'
|
138
136
|
requirements: []
|
139
|
-
rubyforge_project:
|
137
|
+
rubyforge_project:
|
140
138
|
rubygems_version: 1.8.23
|
141
139
|
signing_key:
|
142
140
|
specification_version: 3
|