jquery.fileupload-rails 1.0.0 → 1.1.1

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
@@ -39,6 +39,8 @@ If you downloaded jquery.ui assets into your project, delete them and use [jquer
39
39
 
40
40
  ## Changelog
41
41
 
42
+ 1.1.1. Core 5.19.4, jQuery UI 1.9, added licensing info.
43
+
42
44
  1.0.0. Core 5.18.
43
45
 
44
46
  Now rake task generates assets from official repo and adds dependencies automatically.
@@ -54,3 +56,6 @@ That means you can just require jquery.fileupload, no extra requires needed.
54
56
 
55
57
  [1]: https://github.com/blueimp/jQuery-File-Upload
56
58
  [2]: https://github.com/joliss/jquery-ui-rails
59
+
60
+ ## License
61
+ jQuery File Upload as well as this gem are released under the [MIT license](http://www.opensource.org/licenses/MIT).
data/demo/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  # Ignore bundler config
8
8
  /.bundle
9
+ /bin
9
10
 
10
11
  # Ignore the default SQLite database.
11
12
  /db/*.sqlite3
@@ -2,15 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jquery.fileupload-rails"
5
- s.version = "1.0.0"
5
+ s.version = "1.1.1"
6
6
  s.author = "Semyon Perepelitsa"
7
7
  s.email = "sema@sema.in"
8
8
  s.homepage = "https://github.com/semaperepelitsa/jquery.fileupload-rails"
9
9
  s.summary = %q{Use jQuery File Upload plugin with Rails 3}
10
10
  s.description = %q{This gem packages jQuery File Upload plugin and it's dependencies for Rails asset pipeline.}
11
+ s.license = "MIT"
11
12
 
12
13
  s.files = File.read('Manifest.txt').split("\n")
13
14
 
14
15
  s.add_dependency 'sprockets', '~> 2.0'
15
- s.add_dependency 'jquery-ui-rails'
16
+ s.add_dependency 'jquery-ui-rails', '~> 3.0'
16
17
  end
@@ -2,7 +2,7 @@
2
2
  //= require jquery.iframe-transport
3
3
 
4
4
  /*
5
- * jQuery File Upload Plugin 5.18
5
+ * jQuery File Upload Plugin 5.19.7
6
6
  * https://github.com/blueimp/jQuery-File-Upload
7
7
  *
8
8
  * Copyright 2010, Sebastian Tschan
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  /*jslint nomen: true, unparam: true, regexp: true */
16
- /*global define, window, document, Blob, FormData, location */
16
+ /*global define, window, document, File, Blob, FormData, location */
17
17
 
18
18
  (function (factory) {
19
19
  'use strict';
@@ -47,10 +47,6 @@
47
47
  $.widget('blueimp.fileupload', {
48
48
 
49
49
  options: {
50
- // The namespace used for event handler binding on the fileInput,
51
- // dropZone and pasteZone document nodes.
52
- // If not set, the name of the widget ("fileupload") is used.
53
- namespace: undefined,
54
50
  // The drop target element(s), by the default the complete document.
55
51
  // Set to null to disable drag & drop support:
56
52
  dropZone: $(document),
@@ -183,7 +179,6 @@
183
179
 
184
180
  // A list of options that require a refresh after assigning a new value:
185
181
  _refreshOptionsList: [
186
- 'namespace',
187
182
  'fileInput',
188
183
  'dropZone',
189
184
  'pasteZone',
@@ -217,10 +212,10 @@
217
212
  if (typeof options.formData === 'function') {
218
213
  return options.formData(options.form);
219
214
  }
220
- if ($.isArray(options.formData)) {
215
+ if ($.isArray(options.formData)) {
221
216
  return options.formData;
222
217
  }
223
- if (options.formData) {
218
+ if (options.formData) {
224
219
  formData = [];
225
220
  $.each(options.formData, function (name, value) {
226
221
  formData.push({name: name, value: value});
@@ -313,10 +308,8 @@
313
308
  options.headers['Content-Range'] = options.contentRange;
314
309
  }
315
310
  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;
311
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
312
+ encodeURI(file.name) + '"';
320
313
  options.contentType = file.type;
321
314
  options.data = options.blob || file;
322
315
  } else if ($.support.xhrFormDataFileUpload) {
@@ -349,18 +342,17 @@
349
342
  });
350
343
  }
351
344
  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;
345
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
346
+ encodeURI(file.name) + '"';
357
347
  formData.append(paramName, options.blob, file.name);
358
348
  } else {
359
349
  $.each(options.files, function (index, file) {
360
- // File objects are also Blob instances.
350
+ // Files are also Blob instances, but some browsers
351
+ // (Firefox 3.6) support the File API but not Blobs.
361
352
  // This check allows the tests to run with
362
353
  // dummy objects:
363
- if (file instanceof Blob) {
354
+ if ((window.Blob && file instanceof Blob) ||
355
+ (window.File && file instanceof File)) {
364
356
  formData.append(
365
357
  options.paramName[index] || paramName,
366
358
  file,
@@ -537,7 +529,8 @@
537
529
  o.blob = slice.call(
538
530
  file,
539
531
  ub,
540
- ub + mcs
532
+ ub + mcs,
533
+ file.type
541
534
  );
542
535
  // Store the current chunk size, as the blob itself
543
536
  // will be dereferenced after data processing:
@@ -656,18 +649,18 @@
656
649
  _onSend: function (e, data) {
657
650
  var that = this,
658
651
  jqXHR,
652
+ aborted,
659
653
  slot,
660
654
  pipe,
661
655
  options = that._getAJAXSettings(data),
662
- send = function (resolve, args) {
656
+ send = function () {
663
657
  that._sending += 1;
664
658
  // Set timer for bitrate progress calculation:
665
659
  options._bitrateTimer = new that._BitrateTimer();
666
660
  jqXHR = jqXHR || (
667
- (resolve !== false &&
668
- that._trigger('send', e, options) !== false &&
669
- (that._chunkedUpload(options) || $.ajax(options))) ||
670
- that._getXHRPromise(false, options.context, args)
661
+ ((aborted || that._trigger('send', e, options) === false) &&
662
+ that._getXHRPromise(false, options.context, aborted)) ||
663
+ that._chunkedUpload(options) || $.ajax(options)
671
664
  ).done(function (result, textStatus, jqXHR) {
672
665
  that._onDone(result, textStatus, jqXHR, options);
673
666
  }).fail(function (jqXHR, textStatus, errorThrown) {
@@ -717,12 +710,12 @@
717
710
  // which is delegated to the jqXHR object of the current upload,
718
711
  // and jqXHR callbacks mapped to the equivalent Promise methods:
719
712
  pipe.abort = function () {
720
- var args = [undefined, 'abort', 'abort'];
713
+ aborted = [undefined, 'abort', 'abort'];
721
714
  if (!jqXHR) {
722
715
  if (slot) {
723
- slot.rejectWith(pipe, args);
716
+ slot.rejectWith(options.context, aborted);
724
717
  }
725
- return send(false, args);
718
+ return send();
726
719
  }
727
720
  return jqXHR.abort();
728
721
  };
@@ -770,7 +763,8 @@
770
763
  that._onSend(e, this);
771
764
  return this.jqXHR;
772
765
  };
773
- return (result = that._trigger('add', e, newData));
766
+ result = that._trigger('add', e, newData);
767
+ return result;
774
768
  });
775
769
  return result;
776
770
  },
@@ -902,6 +896,12 @@
902
896
  // support the File API and we add a pseudo File object with
903
897
  // the input value as name with path information removed:
904
898
  files = [{name: value.replace(/^.*\\/, '')}];
899
+ } else if (files[0].name === undefined && files[0].fileName) {
900
+ // File normalization for Safari 4 and Firefox 3:
901
+ $.each(files, function (index, file) {
902
+ file.name = file.fileName;
903
+ file.size = file.fileSize;
904
+ });
905
905
  }
906
906
  return $.Deferred().resolve(files).promise();
907
907
  },
@@ -922,12 +922,12 @@
922
922
  },
923
923
 
924
924
  _onChange: function (e) {
925
- var that = e.data.fileupload,
925
+ var that = this,
926
926
  data = {
927
927
  fileInput: $(e.target),
928
928
  form: $(e.target.form)
929
929
  };
930
- that._getFileInputFiles(data.fileInput).always(function (files) {
930
+ this._getFileInputFiles(data.fileInput).always(function (files) {
931
931
  data.files = files;
932
932
  if (that.options.replaceFileInput) {
933
933
  that._replaceFileInput(data.fileInput);
@@ -939,8 +939,7 @@
939
939
  },
940
940
 
941
941
  _onPaste: function (e) {
942
- var that = e.data.fileupload,
943
- cbd = e.originalEvent.clipboardData,
942
+ var cbd = e.originalEvent.clipboardData,
944
943
  items = (cbd && cbd.items) || [],
945
944
  data = {files: []};
946
945
  $.each(items, function (index, item) {
@@ -949,18 +948,20 @@
949
948
  data.files.push(file);
950
949
  }
951
950
  });
952
- if (that._trigger('paste', e, data) === false ||
953
- that._onAdd(e, data) === false) {
951
+ if (this._trigger('paste', e, data) === false ||
952
+ this._onAdd(e, data) === false) {
954
953
  return false;
955
954
  }
956
955
  },
957
956
 
958
957
  _onDrop: function (e) {
959
- e.preventDefault();
960
- var that = e.data.fileupload,
958
+ var that = this,
961
959
  dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
962
960
  data = {};
963
- that._getDroppedFiles(dataTransfer).always(function (files) {
961
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
962
+ e.preventDefault();
963
+ }
964
+ this._getDroppedFiles(dataTransfer).always(function (files) {
964
965
  data.files = files;
965
966
  if (that._trigger('drop', e, data) !== false) {
966
967
  that._onAdd(e, data);
@@ -969,39 +970,35 @@
969
970
  },
970
971
 
971
972
  _onDragOver: function (e) {
972
- var that = e.data.fileupload,
973
- dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
974
- if (that._trigger('dragover', e) === false) {
973
+ var dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
974
+ if (this._trigger('dragover', e) === false) {
975
975
  return false;
976
976
  }
977
- if (dataTransfer) {
977
+ if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1) {
978
978
  dataTransfer.dropEffect = 'copy';
979
+ e.preventDefault();
979
980
  }
980
- e.preventDefault();
981
981
  },
982
982
 
983
983
  _initEventHandlers: function () {
984
- var ns = this.options.namespace;
985
984
  if (this._isXHRUpload(this.options)) {
986
- this.options.dropZone
987
- .bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
988
- .bind('drop.' + ns, {fileupload: this}, this._onDrop);
989
- this.options.pasteZone
990
- .bind('paste.' + ns, {fileupload: this}, this._onPaste);
985
+ this._on(this.options.dropZone, {
986
+ dragover: this._onDragOver,
987
+ drop: this._onDrop
988
+ });
989
+ this._on(this.options.pasteZone, {
990
+ paste: this._onPaste
991
+ });
991
992
  }
992
- this.options.fileInput
993
- .bind('change.' + ns, {fileupload: this}, this._onChange);
993
+ this._on(this.options.fileInput, {
994
+ change: this._onChange
995
+ });
994
996
  },
995
997
 
996
998
  _destroyEventHandlers: function () {
997
- var ns = this.options.namespace;
998
- this.options.dropZone
999
- .unbind('dragover.' + ns, this._onDragOver)
1000
- .unbind('drop.' + ns, this._onDrop);
1001
- this.options.pasteZone
1002
- .unbind('paste.' + ns, this._onPaste);
1003
- this.options.fileInput
1004
- .unbind('change.' + ns, this._onChange);
999
+ this._off(this.options.dropZone, 'dragover drop');
1000
+ this._off(this.options.pasteZone, 'paste');
1001
+ this._off(this.options.fileInput, 'change');
1005
1002
  },
1006
1003
 
1007
1004
  _setOption: function (key, value) {
@@ -1009,7 +1006,7 @@
1009
1006
  if (refresh) {
1010
1007
  this._destroyEventHandlers();
1011
1008
  }
1012
- $.Widget.prototype._setOption.call(this, key, value);
1009
+ this._super(key, value);
1013
1010
  if (refresh) {
1014
1011
  this._initSpecialOptions();
1015
1012
  this._initEventHandlers();
@@ -1036,7 +1033,6 @@
1036
1033
  var options = this.options;
1037
1034
  // Initialize options set via HTML5 data-attributes:
1038
1035
  $.extend(options, $(this.element[0].cloneNode(false)).data());
1039
- options.namespace = options.namespace || this.widgetName;
1040
1036
  this._initSpecialOptions();
1041
1037
  this._slots = [];
1042
1038
  this._sequence = this._getXHRPromise(true);
@@ -1044,27 +1040,8 @@
1044
1040
  this._initEventHandlers();
1045
1041
  },
1046
1042
 
1047
- destroy: function () {
1043
+ _destroy: function () {
1048
1044
  this._destroyEventHandlers();
1049
- $.Widget.prototype.destroy.call(this);
1050
- },
1051
-
1052
- enable: function () {
1053
- var wasDisabled = false;
1054
- if (this.options.disabled) {
1055
- wasDisabled = true;
1056
- }
1057
- $.Widget.prototype.enable.call(this);
1058
- if (wasDisabled) {
1059
- this._initEventHandlers();
1060
- }
1061
- },
1062
-
1063
- disable: function () {
1064
- if (!this.options.disabled) {
1065
- this._destroyEventHandlers();
1066
- }
1067
- $.Widget.prototype.disable.call(this);
1068
1045
  },
1069
1046
 
1070
1047
  // This method is exposed to the widget API and allows adding files
@@ -1,5 +1,5 @@
1
1
  /*
2
- * jQuery Iframe Transport Plugin 1.5
2
+ * jQuery Iframe Transport Plugin 1.6
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
5
  * Copyright 2011, Sebastian Tschan
@@ -155,16 +155,16 @@
155
155
  $.ajaxSetup({
156
156
  converters: {
157
157
  'iframe text': function (iframe) {
158
- return $(iframe[0].body).text();
158
+ return iframe && $(iframe[0].body).text();
159
159
  },
160
160
  'iframe json': function (iframe) {
161
- return $.parseJSON($(iframe[0].body).text());
161
+ return iframe && $.parseJSON($(iframe[0].body).text());
162
162
  },
163
163
  'iframe html': function (iframe) {
164
- return $(iframe[0].body).html();
164
+ return iframe && $(iframe[0].body).html();
165
165
  },
166
166
  'iframe script': function (iframe) {
167
- return $.globalEval($(iframe[0].body).text());
167
+ return iframe && $.globalEval($(iframe[0].body).text());
168
168
  }
169
169
  }
170
170
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery.fileupload-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-16 00:00:00.000000000 Z
12
+ date: 2012-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: '3.0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: '3.0'
46
46
  description: This gem packages jQuery File Upload plugin and it's dependencies for
47
47
  Rails asset pipeline.
48
48
  email: sema@sema.in
@@ -116,7 +116,8 @@ files:
116
116
  - vendor/legacy_assets/javascripts/jquery.xdr-transport.js
117
117
  - vendor/legacy_assets/stylesheets/jquery.fileupload-ui.css
118
118
  homepage: https://github.com/semaperepelitsa/jquery.fileupload-rails
119
- licenses: []
119
+ licenses:
120
+ - MIT
120
121
  post_install_message:
121
122
  rdoc_options: []
122
123
  require_paths:
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  requirements: []
137
138
  rubyforge_project:
138
- rubygems_version: 1.8.23
139
+ rubygems_version: 1.8.24
139
140
  signing_key:
140
141
  specification_version: 3
141
142
  summary: Use jQuery File Upload plugin with Rails 3