jquery.fileupload-rails 1.7.0 → 1.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcbb03c9c287f9c4c5dd7ccce39665a1ef12274e
4
- data.tar.gz: 6a722ff0944ea1f4a3328caa87e87767e47e310d
3
+ metadata.gz: 2bf21e6407433ab2910ed3579e010eca9f350626
4
+ data.tar.gz: 4879e8e4dfd53fa02cb9a5e92a87ee2798a5f75d
5
5
  SHA512:
6
- metadata.gz: 16b71a23180856a31a12c5835444614f770944a03051e0eea95f2a65ceb72474d424989734ec7d5a42429ef6eda8ae260183a63999cae23d6713943833700c02
7
- data.tar.gz: e51530ccaf3028d40db540b59a0388e0a5d054ec587ee6a95b434274d28e09b6fca0a3571bb92a041f73806d46b6e1ab70147243fdb907f216923ba98b93ca67
6
+ metadata.gz: a42d4ce5e2fb2cdccff283ecfb56628afc19f5b5fc57120fcb97cf9e753d1261890e6d5c31d6c493ccfe5838cace5a16ddf8b782316706a83079dc8382ab8bb7
7
+ data.tar.gz: 75d2ec6fa20bb3eefdda82cd079542a367f1e969d1cb1d3bd961cf2cbef770a6bd4e7e348aafc00b126c37329ec155d2770bd4c41edce626b7d55f1009a75fe6
data/Readme.md CHANGED
@@ -8,13 +8,11 @@ There are no instructions here on how to use the library itself.
8
8
 
9
9
  ## Usage
10
10
 
11
- Add the following to your Gemfile.
11
+ Add a line to your Gemfile.
12
12
 
13
- group :assets do
14
- gem 'jquery.fileupload-rails'
15
- end
13
+ gem 'jquery.fileupload-rails'
16
14
 
17
- Then you can require the javascript library in application.js:
15
+ Now you can require the javascript library in application.js:
18
16
 
19
17
  //= require jquery.fileupload
20
18
 
@@ -41,6 +39,8 @@ If you downloaded jquery.ui assets into your project, delete them and use [jquer
41
39
 
42
40
  ## Changelog
43
41
 
42
+ 1.8.0. Core 5.40.0, updated demo app.
43
+
44
44
  1.7.0. Core 5.34.0.
45
45
 
46
46
  1.6.1. Core 5.32.5, jQuery UI Rails 4 compatibility.
data/demo/.gitignore CHANGED
@@ -1,16 +1,3 @@
1
- # See http://help.github.com/ignore-files/ for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile ~/.gitignore_global
6
-
7
- # Ignore bundler config
8
1
  /.bundle
9
- /bin
10
-
11
- # Ignore the default SQLite database.
12
- /db/*.sqlite3
13
-
14
- # Ignore all logfiles and tempfiles.
15
2
  /log/*.log
16
3
  /tmp
data/demo/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '3.2.14'
3
+ gem 'rails', '4.0.1'
4
4
 
5
- gem 'coffee-rails', '~> 3.2.1'
5
+ gem 'coffee-rails', '~> 4.0.0'
6
6
  gem 'jquery-rails', '~> 3.0.0'
7
7
  gem 'jquery-ui-rails', '~> 4.0.0'
8
8
  gem 'jquery.fileupload-rails', path: '..'
data/demo/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require File.expand_path('../config/application', __FILE__)
2
+ Rails.application.load_tasks
@@ -6,4 +6,4 @@ $ ->
6
6
  $('#basic').fileupload
7
7
  done: (e, data)->
8
8
  console.log "Done", data.result
9
- $(data.result).appendTo(this)
9
+ $("body").append(data.result)
data/demo/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/demo/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/demo/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -2,14 +2,16 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'action_controller/railtie'
4
4
  require 'sprockets/railtie'
5
- Bundler.require(*Rails.groups(:assets => %w(development test)))
5
+ Bundler.require
6
6
 
7
7
  module Demo
8
8
  class Application < Rails::Application
9
9
  config.cache_classes = false
10
+ config.eager_load = false
10
11
  config.consider_all_requests_local = true
11
12
 
12
13
  config.session_store :disabled
14
+ config.secret_key_base = "no"
13
15
  config.active_support.deprecation = :log
14
16
  config.action_dispatch.best_standards_support = :builtin
15
17
 
@@ -2,5 +2,5 @@ Demo::Application.routes.draw do
2
2
  get '/' => 'application#basic'
3
3
  post '/' => 'application#create'
4
4
 
5
- match ':action', controller: "application"
5
+ get ':action', controller: "application"
6
6
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jquery.fileupload-rails"
5
- s.version = "1.7.0"
5
+ s.version = "1.8.0"
6
6
  s.author = "Semyon Perepelitsa"
7
7
  s.email = "sema@sema.in"
8
8
  s.homepage = "https://github.com/semaperepelitsa/jquery.fileupload-rails"
@@ -2,7 +2,7 @@
2
2
  //= require jquery.iframe-transport
3
3
 
4
4
  /*
5
- * jQuery File Upload Plugin 5.34.0
5
+ * jQuery File Upload Plugin 5.40.0
6
6
  * https://github.com/blueimp/jQuery-File-Upload
7
7
  *
8
8
  * Copyright 2010, Sebastian Tschan
@@ -12,8 +12,8 @@
12
12
  * http://www.opensource.org/licenses/MIT
13
13
  */
14
14
 
15
- /*jslint nomen: true, unparam: true, regexp: true */
16
- /*global define, window, document, location, File, Blob, FormData */
15
+ /* jshint nomen:false */
16
+ /* global define, window, document, location, Blob, FormData */
17
17
 
18
18
  (function (factory) {
19
19
  'use strict';
@@ -43,9 +43,11 @@
43
43
  $('<input type="file">').prop('disabled'));
44
44
 
45
45
  // The FileReader API is not actually used, but works as feature detection,
46
- // as e.g. Safari supports XHR file uploads via the FormData API,
47
- // but not non-multipart XHR file uploads:
48
- $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
46
+ // as some Safari versions (5?) support XHR file uploads via the FormData API,
47
+ // but not non-multipart XHR file uploads.
48
+ // window.XMLHttpRequestUpload is not available on IE10, so we check for
49
+ // window.ProgressEvent instead to detect XHR2 file upload capability:
50
+ $.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader);
49
51
  $.support.xhrFormDataFileUpload = !!window.FormData;
50
52
 
51
53
  // Detect support for Blob slicing (required for chunked uploads):
@@ -91,6 +93,14 @@
91
93
  // To limit the number of files uploaded with one XHR request,
92
94
  // set the following option to an integer greater than 0:
93
95
  limitMultiFileUploads: undefined,
96
+ // The following option limits the number of files uploaded with one
97
+ // XHR request to keep the request size under or equal to the defined
98
+ // limit in bytes:
99
+ limitMultiFileUploadSize: undefined,
100
+ // Multipart file uploads add a number of bytes to each uploaded file,
101
+ // therefore the following option adds an overhead for each file used
102
+ // in the limitMultiFileUploadSize configuration:
103
+ limitMultiFileUploadSizeOverhead: 512,
94
104
  // Set the following option to true to issue all file upload requests
95
105
  // in a sequential order:
96
106
  sequentialUploads: false,
@@ -286,7 +296,7 @@
286
296
 
287
297
  _getFormData: function (options) {
288
298
  var formData;
289
- if (typeof options.formData === 'function') {
299
+ if ($.type(options.formData) === 'function') {
290
300
  return options.formData(options.form);
291
301
  }
292
302
  if ($.isArray(options.formData)) {
@@ -412,7 +422,8 @@
412
422
  file = options.files[0],
413
423
  // Ignore non-multipart setting if not supported:
414
424
  multipart = options.multipart || !$.support.xhrFileUpload,
415
- paramName = options.paramName[0];
425
+ paramName = $.type(options.paramName) === 'array' ?
426
+ options.paramName[0] : options.paramName;
416
427
  options.headers = $.extend({}, options.headers);
417
428
  if (options.contentRange) {
418
429
  options.headers['Content-Range'] = options.contentRange;
@@ -422,7 +433,7 @@
422
433
  encodeURI(file.name) + '"';
423
434
  }
424
435
  if (!multipart) {
425
- options.contentType = file.type;
436
+ options.contentType = file.type || 'application/octet-stream';
426
437
  options.data = options.blob || file;
427
438
  } else if ($.support.xhrFormDataFileUpload) {
428
439
  if (options.postMessage) {
@@ -439,7 +450,8 @@
439
450
  } else {
440
451
  $.each(options.files, function (index, file) {
441
452
  formData.push({
442
- name: options.paramName[index] || paramName,
453
+ name: ($.type(options.paramName) === 'array' &&
454
+ options.paramName[index]) || paramName,
443
455
  value: file
444
456
  });
445
457
  });
@@ -462,9 +474,10 @@
462
474
  if (that._isInstanceOf('File', file) ||
463
475
  that._isInstanceOf('Blob', file)) {
464
476
  formData.append(
465
- options.paramName[index] || paramName,
477
+ ($.type(options.paramName) === 'array' &&
478
+ options.paramName[index]) || paramName,
466
479
  file,
467
- file.name
480
+ file.uploadName || file.name
468
481
  );
469
482
  }
470
483
  });
@@ -610,16 +623,23 @@
610
623
  // Adds convenience methods to the data callback argument:
611
624
  _addConvenienceMethods: function (e, data) {
612
625
  var that = this,
613
- getPromise = function (data) {
614
- return $.Deferred().resolveWith(that, [data]).promise();
626
+ getPromise = function (args) {
627
+ return $.Deferred().resolveWith(that, args).promise();
615
628
  };
616
629
  data.process = function (resolveFunc, rejectFunc) {
617
630
  if (resolveFunc || rejectFunc) {
618
631
  data._processQueue = this._processQueue =
619
- (this._processQueue || getPromise(this))
620
- .pipe(resolveFunc, rejectFunc);
632
+ (this._processQueue || getPromise([this])).pipe(
633
+ function () {
634
+ if (data.errorThrown) {
635
+ return $.Deferred()
636
+ .rejectWith(that, [data]).promise();
637
+ }
638
+ return getPromise(arguments);
639
+ }
640
+ ).pipe(resolveFunc, rejectFunc);
621
641
  }
622
- return this._processQueue || getPromise(this);
642
+ return this._processQueue || getPromise([this]);
623
643
  };
624
644
  data.submit = function () {
625
645
  if (this.state() !== 'pending') {
@@ -636,7 +656,9 @@
636
656
  if (this.jqXHR) {
637
657
  return this.jqXHR.abort();
638
658
  }
639
- return that._getXHRPromise();
659
+ this.errorThrown = 'abort';
660
+ that._trigger('fail', null, this);
661
+ return that._getXHRPromise(false);
640
662
  };
641
663
  data.state = function () {
642
664
  if (this.jqXHR) {
@@ -646,6 +668,10 @@
646
668
  return that._getDeferredState(this._processQueue);
647
669
  }
648
670
  };
671
+ data.processing = function () {
672
+ return !this.jqXHR && this._processQueue && that
673
+ ._getDeferredState(this._processQueue) === 'pending';
674
+ };
649
675
  data.progress = function () {
650
676
  return this._progress;
651
677
  };
@@ -923,32 +949,59 @@
923
949
  var that = this,
924
950
  result = true,
925
951
  options = $.extend({}, this.options, data),
952
+ files = data.files,
953
+ filesLength = files.length,
926
954
  limit = options.limitMultiFileUploads,
955
+ limitSize = options.limitMultiFileUploadSize,
956
+ overhead = options.limitMultiFileUploadSizeOverhead,
957
+ batchSize = 0,
927
958
  paramName = this._getParamName(options),
928
959
  paramNameSet,
929
960
  paramNameSlice,
930
961
  fileSet,
931
- i;
932
- if (!(options.singleFileUploads || limit) ||
962
+ i,
963
+ j = 0;
964
+ if (limitSize && (!filesLength || files[0].size === undefined)) {
965
+ limitSize = undefined;
966
+ }
967
+ if (!(options.singleFileUploads || limit || limitSize) ||
933
968
  !this._isXHRUpload(options)) {
934
- fileSet = [data.files];
969
+ fileSet = [files];
935
970
  paramNameSet = [paramName];
936
- } else if (!options.singleFileUploads && limit) {
971
+ } else if (!(options.singleFileUploads || limitSize) && limit) {
937
972
  fileSet = [];
938
973
  paramNameSet = [];
939
- for (i = 0; i < data.files.length; i += limit) {
940
- fileSet.push(data.files.slice(i, i + limit));
974
+ for (i = 0; i < filesLength; i += limit) {
975
+ fileSet.push(files.slice(i, i + limit));
941
976
  paramNameSlice = paramName.slice(i, i + limit);
942
977
  if (!paramNameSlice.length) {
943
978
  paramNameSlice = paramName;
944
979
  }
945
980
  paramNameSet.push(paramNameSlice);
946
981
  }
982
+ } else if (!options.singleFileUploads && limitSize) {
983
+ fileSet = [];
984
+ paramNameSet = [];
985
+ for (i = 0; i < filesLength; i = i + 1) {
986
+ batchSize += files[i].size + overhead;
987
+ if (i + 1 === filesLength ||
988
+ ((batchSize + files[i + 1].size + overhead) > limitSize) ||
989
+ (limit && i + 1 - j >= limit)) {
990
+ fileSet.push(files.slice(j, i + 1));
991
+ paramNameSlice = paramName.slice(j, i + 1);
992
+ if (!paramNameSlice.length) {
993
+ paramNameSlice = paramName;
994
+ }
995
+ paramNameSet.push(paramNameSlice);
996
+ j = i + 1;
997
+ batchSize = 0;
998
+ }
999
+ }
947
1000
  } else {
948
1001
  paramNameSet = paramName;
949
1002
  }
950
- data.originalFiles = data.files;
951
- $.each(fileSet || data.files, function (index, element) {
1003
+ data.originalFiles = files;
1004
+ $.each(fileSet || files, function (index, element) {
952
1005
  var newData = $.extend({}, data);
953
1006
  newData.files = fileSet ? element : [element];
954
1007
  newData.paramName = paramNameSet[index];
@@ -1,5 +1,5 @@
1
1
  /*
2
- * jQuery Iframe Transport Plugin 1.8.0
2
+ * jQuery Iframe Transport Plugin 1.8.2
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
5
  * Copyright 2011, Sebastian Tschan
@@ -9,8 +9,7 @@
9
9
  * http://www.opensource.org/licenses/MIT
10
10
  */
11
11
 
12
- /*jslint unparam: true, nomen: true */
13
- /*global define, window, document */
12
+ /* global define, window, document */
14
13
 
15
14
  (function (factory) {
16
15
  'use strict';
@@ -41,7 +40,9 @@
41
40
  if (options.async) {
42
41
  // javascript:false as initial iframe src
43
42
  // prevents warning popups on HTTPS in IE6:
43
+ /*jshint scripturl: true */
44
44
  var initialIframeSrc = options.initialIframeSrc || 'javascript:false;',
45
+ /*jshint scripturl: false */
45
46
  form,
46
47
  iframe,
47
48
  addParamChar;
@@ -141,6 +142,8 @@
141
142
  .prop('enctype', 'multipart/form-data')
142
143
  // enctype must be set as encoding for IE:
143
144
  .prop('encoding', 'multipart/form-data');
145
+ // Remove the HTML5 form attribute from the input(s):
146
+ options.fileInput.removeAttr('form');
144
147
  }
145
148
  form.submit();
146
149
  // Insert the file input fields at their original location
@@ -148,7 +151,10 @@
148
151
  if (fileInputClones && fileInputClones.length) {
149
152
  options.fileInput.each(function (index, input) {
150
153
  var clone = $(fileInputClones[index]);
151
- $(input).prop('name', clone.prop('name'));
154
+ // Restore the original name and form properties:
155
+ $(input)
156
+ .prop('name', clone.prop('name'))
157
+ .attr('form', clone.attr('form'));
152
158
  clone.replaceWith(input);
153
159
  });
154
160
  }
metadata CHANGED
@@ -1,47 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery.fileupload-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Semyon Perepelitsa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jquery-ui-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.0'
34
- - - <
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '5.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '3.0'
44
- - - <
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5.0'
47
47
  description: This gem packages jQuery File Upload plugin and it's dependencies for
@@ -51,13 +51,14 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - .gitignore
55
- - .gitmodules
54
+ - ".gitignore"
55
+ - ".gitmodules"
56
56
  - Gemfile
57
57
  - Rakefile
58
58
  - Readme.md
59
59
  - demo/.gitignore
60
60
  - demo/Gemfile
61
+ - demo/Rakefile
61
62
  - demo/Readme.md
62
63
  - demo/app/assets/javascripts/application.js.coffee
63
64
  - demo/app/controllers/application_controller.rb
@@ -65,13 +66,15 @@ files:
65
66
  - demo/app/views/application/create.html.erb
66
67
  - demo/app/views/application/ui.html.erb
67
68
  - demo/app/views/layouts/application.html.erb
69
+ - demo/bin/bundle
70
+ - demo/bin/rails
71
+ - demo/bin/rake
68
72
  - demo/config.ru
69
73
  - demo/config/application.rb
70
74
  - demo/config/boot.rb
71
75
  - demo/config/environment.rb
72
76
  - demo/config/routes.rb
73
77
  - demo/log/.gitkeep
74
- - demo/script/rails
75
78
  - dependencies.json
76
79
  - jquery.fileupload-rails.gemspec
77
80
  - lib/jquery.fileupload-rails.rb
@@ -93,17 +96,17 @@ require_paths:
93
96
  - lib
94
97
  required_ruby_version: !ruby/object:Gem::Requirement
95
98
  requirements:
96
- - - '>='
99
+ - - ">="
97
100
  - !ruby/object:Gem::Version
98
101
  version: '0'
99
102
  required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  requirements:
101
- - - '>='
104
+ - - ">="
102
105
  - !ruby/object:Gem::Version
103
106
  version: '0'
104
107
  requirements: []
105
108
  rubyforge_project:
106
- rubygems_version: 2.1.8
109
+ rubygems_version: 2.2.0
107
110
  signing_key:
108
111
  specification_version: 4
109
112
  summary: Use jQuery File Upload plugin with Rails 3
data/demo/script/rails DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'