jquery.fileupload-rails 0.1.2 → 1.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/Rakefile +40 -1
- data/Readme.md +8 -2
- data/dependencies.json +4 -0
- data/jquery.fileupload-rails.gemspec +1 -0
- data/lib/jquery.fileupload-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.fileupload.js +232 -60
- data/vendor/assets/javascripts/jquery.iframe-transport.js +2 -1
- metadata +24 -11
- data/vendor/assets/javascripts/jquery.fileupload-fp.js +0 -219
- data/vendor/assets/javascripts/jquery.fileupload-ip.js +0 -160
- data/vendor/assets/javascripts/jquery.fileupload-ui.js +0 -702
- data/vendor/assets/javascripts/jquery.postmessage-transport.js +0 -117
- data/vendor/assets/javascripts/jquery.xdr-transport.js +0 -85
- data/vendor/assets/stylesheets/jquery.fileupload-ui.css +0 -84
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery Iframe Transport Plugin 1.
|
2
|
+
* jQuery Iframe Transport Plugin 1.5
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2011, Sebastian Tschan
|
@@ -42,6 +42,7 @@
|
|
42
42
|
return {
|
43
43
|
send: function (_, completeCallback) {
|
44
44
|
form = $('<form style="display:none;"></form>');
|
45
|
+
form.attr('accept-charset', options.formAcceptCharset);
|
45
46
|
// javascript:false as initial iframe src
|
46
47
|
// prevents warning popups on HTTPS in IE6.
|
47
48
|
// IE versions below IE8 cannot set the name property of
|
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: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0.alpha
|
5
|
+
prerelease: 6
|
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-09-
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jquery-ui-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: This gem packages jQuery File Upload plugin and it's dependencies for
|
31
47
|
Rails asset pipeline.
|
32
48
|
email:
|
@@ -36,20 +52,16 @@ extensions: []
|
|
36
52
|
extra_rdoc_files: []
|
37
53
|
files:
|
38
54
|
- .gitignore
|
55
|
+
- .gitmodules
|
39
56
|
- Gemfile
|
40
57
|
- Rakefile
|
41
58
|
- Readme.md
|
59
|
+
- dependencies.json
|
42
60
|
- jquery.fileupload-rails.gemspec
|
43
61
|
- lib/jquery.fileupload-rails.rb
|
44
62
|
- lib/jquery.fileupload-rails/version.rb
|
45
|
-
- vendor/assets/javascripts/jquery.fileupload-fp.js
|
46
|
-
- vendor/assets/javascripts/jquery.fileupload-ip.js
|
47
|
-
- vendor/assets/javascripts/jquery.fileupload-ui.js
|
48
63
|
- vendor/assets/javascripts/jquery.fileupload.js
|
49
64
|
- vendor/assets/javascripts/jquery.iframe-transport.js
|
50
|
-
- vendor/assets/javascripts/jquery.postmessage-transport.js
|
51
|
-
- vendor/assets/javascripts/jquery.xdr-transport.js
|
52
|
-
- vendor/assets/stylesheets/jquery.fileupload-ui.css
|
53
65
|
homepage: https://github.com/semaperepelitsa/jquery.fileupload-rails
|
54
66
|
licenses: []
|
55
67
|
post_install_message:
|
@@ -65,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
78
|
none: false
|
67
79
|
requirements:
|
68
|
-
- - ! '
|
80
|
+
- - ! '>'
|
69
81
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
82
|
+
version: 1.3.1
|
71
83
|
requirements: []
|
72
84
|
rubyforge_project: jquery.fileupload-rails
|
73
85
|
rubygems_version: 1.8.23
|
@@ -75,3 +87,4 @@ signing_key:
|
|
75
87
|
specification_version: 3
|
76
88
|
summary: Use jQuery File Upload plugin with Rails 3
|
77
89
|
test_files: []
|
90
|
+
has_rdoc:
|
@@ -1,219 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery File Upload File Processing Plugin 1.0
|
3
|
-
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
-
*
|
5
|
-
* Copyright 2012, Sebastian Tschan
|
6
|
-
* https://blueimp.net
|
7
|
-
*
|
8
|
-
* Licensed under the MIT license:
|
9
|
-
* http://www.opensource.org/licenses/MIT
|
10
|
-
*/
|
11
|
-
|
12
|
-
/*jslint nomen: true, unparam: true, regexp: true */
|
13
|
-
/*global define, window, document */
|
14
|
-
|
15
|
-
(function (factory) {
|
16
|
-
'use strict';
|
17
|
-
if (typeof define === 'function' && define.amd) {
|
18
|
-
// Register as an anonymous AMD module:
|
19
|
-
define([
|
20
|
-
'jquery',
|
21
|
-
'load-image',
|
22
|
-
'canvas-to-blob',
|
23
|
-
'./jquery.fileupload'
|
24
|
-
], factory);
|
25
|
-
} else {
|
26
|
-
// Browser globals:
|
27
|
-
factory(
|
28
|
-
window.jQuery,
|
29
|
-
window.loadImage
|
30
|
-
);
|
31
|
-
}
|
32
|
-
}(function ($, loadImage) {
|
33
|
-
'use strict';
|
34
|
-
|
35
|
-
// The File Upload IP version extends the basic fileupload widget
|
36
|
-
// with file processing functionality:
|
37
|
-
$.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
|
38
|
-
|
39
|
-
options: {
|
40
|
-
// The list of file processing actions:
|
41
|
-
process: [
|
42
|
-
/*
|
43
|
-
{
|
44
|
-
action: 'load',
|
45
|
-
fileTypes: /^image\/(gif|jpeg|png)$/,
|
46
|
-
maxFileSize: 20000000 // 20MB
|
47
|
-
},
|
48
|
-
{
|
49
|
-
action: 'resize',
|
50
|
-
maxWidth: 1920,
|
51
|
-
maxHeight: 1200,
|
52
|
-
minWidth: 800,
|
53
|
-
minHeight: 600
|
54
|
-
},
|
55
|
-
{
|
56
|
-
action: 'save'
|
57
|
-
}
|
58
|
-
*/
|
59
|
-
],
|
60
|
-
|
61
|
-
// The add callback is invoked as soon as files are added to the
|
62
|
-
// fileupload widget (via file input selection, drag & drop or add
|
63
|
-
// API call). See the basic file upload widget for more information:
|
64
|
-
add: function (e, data) {
|
65
|
-
$(this).fileupload('process', data).done(function () {
|
66
|
-
data.submit();
|
67
|
-
});
|
68
|
-
}
|
69
|
-
},
|
70
|
-
|
71
|
-
processActions: {
|
72
|
-
// Loads the image given via data.files and data.index
|
73
|
-
// as canvas element.
|
74
|
-
// Accepts the options fileTypes (regular expression)
|
75
|
-
// and maxFileSize (integer) to limit the files to load:
|
76
|
-
load: function (data, options) {
|
77
|
-
var that = this,
|
78
|
-
file = data.files[data.index],
|
79
|
-
dfd = $.Deferred();
|
80
|
-
if (window.HTMLCanvasElement &&
|
81
|
-
window.HTMLCanvasElement.prototype.toBlob &&
|
82
|
-
($.type(options.maxFileSize) !== 'number' ||
|
83
|
-
file.size < options.maxFileSize) &&
|
84
|
-
(!options.fileTypes ||
|
85
|
-
options.fileTypes.test(file.type))) {
|
86
|
-
loadImage(
|
87
|
-
file,
|
88
|
-
function (canvas) {
|
89
|
-
data.canvas = canvas;
|
90
|
-
dfd.resolveWith(that, [data]);
|
91
|
-
},
|
92
|
-
{canvas: true}
|
93
|
-
);
|
94
|
-
} else {
|
95
|
-
dfd.rejectWith(that, [data]);
|
96
|
-
}
|
97
|
-
return dfd.promise();
|
98
|
-
},
|
99
|
-
// Resizes the image given as data.canvas and updates
|
100
|
-
// data.canvas with the resized image.
|
101
|
-
// Accepts the options maxWidth, maxHeight, minWidth and
|
102
|
-
// minHeight to scale the given image:
|
103
|
-
resize: function (data, options) {
|
104
|
-
if (data.canvas) {
|
105
|
-
var canvas = loadImage.scale(data.canvas, options);
|
106
|
-
if (canvas.width !== data.canvas.width ||
|
107
|
-
canvas.height !== data.canvas.height) {
|
108
|
-
data.canvas = canvas;
|
109
|
-
data.processed = true;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
return data;
|
113
|
-
},
|
114
|
-
// Saves the processed image given as data.canvas
|
115
|
-
// inplace at data.index of data.files:
|
116
|
-
save: function (data, options) {
|
117
|
-
// Do nothing if no processing has happened:
|
118
|
-
if (!data.canvas || !data.processed) {
|
119
|
-
return data;
|
120
|
-
}
|
121
|
-
var that = this,
|
122
|
-
file = data.files[data.index],
|
123
|
-
name = file.name,
|
124
|
-
dfd = $.Deferred(),
|
125
|
-
callback = function (blob) {
|
126
|
-
if (!blob.name) {
|
127
|
-
if (file.type === blob.type) {
|
128
|
-
blob.name = file.name;
|
129
|
-
} else if (file.name) {
|
130
|
-
blob.name = file.name.replace(
|
131
|
-
/\..+$/,
|
132
|
-
'.' + blob.type.substr(6)
|
133
|
-
);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
// Store the created blob at the position
|
137
|
-
// of the original file in the files list:
|
138
|
-
data.files[data.index] = blob;
|
139
|
-
dfd.resolveWith(that, [data]);
|
140
|
-
};
|
141
|
-
// Use canvas.mozGetAsFile directly, to retain the filename, as
|
142
|
-
// Gecko doesn't support the filename option for FormData.append:
|
143
|
-
if (data.canvas.mozGetAsFile) {
|
144
|
-
callback(data.canvas.mozGetAsFile(
|
145
|
-
(/^image\/(jpeg|png)$/.test(file.type) && name) ||
|
146
|
-
((name && name.replace(/\..+$/, '')) ||
|
147
|
-
'blob') + '.png',
|
148
|
-
file.type
|
149
|
-
));
|
150
|
-
} else {
|
151
|
-
data.canvas.toBlob(callback, file.type);
|
152
|
-
}
|
153
|
-
return dfd.promise();
|
154
|
-
}
|
155
|
-
},
|
156
|
-
|
157
|
-
// Resizes the file at the given index and stores the created blob at
|
158
|
-
// the original position of the files list, returns a Promise object:
|
159
|
-
_processFile: function (files, index, options) {
|
160
|
-
var that = this,
|
161
|
-
dfd = $.Deferred().resolveWith(that, [{
|
162
|
-
files: files,
|
163
|
-
index: index
|
164
|
-
}]),
|
165
|
-
chain = dfd.promise();
|
166
|
-
that._processing += 1;
|
167
|
-
$.each(options.process, function (i, settings) {
|
168
|
-
chain = chain.pipe(function (data) {
|
169
|
-
return that.processActions[settings.action]
|
170
|
-
.call(this, data, settings);
|
171
|
-
});
|
172
|
-
});
|
173
|
-
chain.always(function () {
|
174
|
-
that._processing -= 1;
|
175
|
-
if (that._processing === 0) {
|
176
|
-
that.element
|
177
|
-
.removeClass('fileupload-processing');
|
178
|
-
}
|
179
|
-
});
|
180
|
-
if (that._processing === 1) {
|
181
|
-
that.element.addClass('fileupload-processing');
|
182
|
-
}
|
183
|
-
return chain;
|
184
|
-
},
|
185
|
-
|
186
|
-
// Processes the files given as files property of the data parameter,
|
187
|
-
// returns a Promise object that allows to bind a done handler, which
|
188
|
-
// will be invoked after processing all files (inplace) is done:
|
189
|
-
process: function (data) {
|
190
|
-
var that = this,
|
191
|
-
options = $.extend({}, this.options, data);
|
192
|
-
if (options.process && options.process.length &&
|
193
|
-
this._isXHRUpload(options)) {
|
194
|
-
$.each(data.files, function (index, file) {
|
195
|
-
that._processingQueue = that._processingQueue.pipe(
|
196
|
-
function () {
|
197
|
-
var dfd = $.Deferred();
|
198
|
-
that._processFile(data.files, index, options)
|
199
|
-
.always(function () {
|
200
|
-
dfd.resolveWith(that);
|
201
|
-
});
|
202
|
-
return dfd.promise();
|
203
|
-
}
|
204
|
-
);
|
205
|
-
});
|
206
|
-
}
|
207
|
-
return this._processingQueue;
|
208
|
-
},
|
209
|
-
|
210
|
-
_create: function () {
|
211
|
-
$.blueimp.fileupload.prototype._create.call(this);
|
212
|
-
this._processing = 0;
|
213
|
-
this._processingQueue = $.Deferred().resolveWith(this)
|
214
|
-
.promise();
|
215
|
-
}
|
216
|
-
|
217
|
-
});
|
218
|
-
|
219
|
-
}));
|
@@ -1,160 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery File Upload Image Processing Plugin 1.0.6
|
3
|
-
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
-
*
|
5
|
-
* Copyright 2012, Sebastian Tschan
|
6
|
-
* https://blueimp.net
|
7
|
-
*
|
8
|
-
* Licensed under the MIT license:
|
9
|
-
* http://www.opensource.org/licenses/MIT
|
10
|
-
*/
|
11
|
-
|
12
|
-
/*jslint nomen: true, unparam: true, regexp: true */
|
13
|
-
/*global define, window, document */
|
14
|
-
|
15
|
-
(function (factory) {
|
16
|
-
'use strict';
|
17
|
-
if (typeof define === 'function' && define.amd) {
|
18
|
-
// Register as an anonymous AMD module:
|
19
|
-
define([
|
20
|
-
'jquery',
|
21
|
-
'load-image',
|
22
|
-
'canvas-to-blob',
|
23
|
-
'./jquery.fileupload'
|
24
|
-
], factory);
|
25
|
-
} else {
|
26
|
-
// Browser globals:
|
27
|
-
factory(
|
28
|
-
window.jQuery,
|
29
|
-
window.loadImage,
|
30
|
-
window.canvasToBlob
|
31
|
-
);
|
32
|
-
}
|
33
|
-
}(function ($, loadImage, canvasToBlob) {
|
34
|
-
'use strict';
|
35
|
-
|
36
|
-
// The File Upload IP version extends the basic fileupload widget
|
37
|
-
// with image processing functionality:
|
38
|
-
$.widget('blueimpIP.fileupload', $.blueimp.fileupload, {
|
39
|
-
|
40
|
-
options: {
|
41
|
-
// The regular expression to define which image files are to be
|
42
|
-
// resized, given that the browser supports the operation:
|
43
|
-
resizeSourceFileTypes: /^image\/(gif|jpeg|png)$/,
|
44
|
-
// The maximum file size of images that are to be resized:
|
45
|
-
resizeSourceMaxFileSize: 20000000, // 20MB
|
46
|
-
// The maximum width of the resized images:
|
47
|
-
resizeMaxWidth: undefined,
|
48
|
-
// The maximum height of the resized images:
|
49
|
-
resizeMaxHeight: undefined,
|
50
|
-
// The minimum width of the resized images:
|
51
|
-
resizeMinWidth: undefined,
|
52
|
-
// The minimum height of the resized images:
|
53
|
-
resizeMinHeight: undefined,
|
54
|
-
|
55
|
-
// The add callback is invoked as soon as files are added to the fileupload
|
56
|
-
// widget (via file input selection, drag & drop or add API call).
|
57
|
-
// See the basic file upload widget for more information:
|
58
|
-
add: function (e, data) {
|
59
|
-
$(this).fileupload('resize', data).done(function () {
|
60
|
-
data.submit();
|
61
|
-
});
|
62
|
-
}
|
63
|
-
},
|
64
|
-
|
65
|
-
// Resizes the image file at the given index and stores the created blob
|
66
|
-
// at the original position of the files list, returns a Promise object:
|
67
|
-
_resizeImage: function (files, index, options) {
|
68
|
-
var that = this,
|
69
|
-
file = files[index],
|
70
|
-
deferred = $.Deferred(),
|
71
|
-
canvas,
|
72
|
-
blob;
|
73
|
-
options = options || this.options;
|
74
|
-
loadImage(
|
75
|
-
file,
|
76
|
-
function (img) {
|
77
|
-
var width = img.width,
|
78
|
-
height = img.height;
|
79
|
-
canvas = loadImage.scale(img, {
|
80
|
-
maxWidth: options.resizeMaxWidth,
|
81
|
-
maxHeight: options.resizeMaxHeight,
|
82
|
-
minWidth: options.resizeMinWidth,
|
83
|
-
minHeight: options.resizeMinHeight,
|
84
|
-
canvas: true
|
85
|
-
});
|
86
|
-
if (width !== canvas.width || height !== canvas.height) {
|
87
|
-
canvasToBlob(canvas, function (blob) {
|
88
|
-
if (!blob.name) {
|
89
|
-
if (file.type === blob.type) {
|
90
|
-
blob.name = file.name;
|
91
|
-
} else if (file.name) {
|
92
|
-
blob.name = file.name.replace(
|
93
|
-
/\..+$/,
|
94
|
-
'.' + blob.type.substr(6)
|
95
|
-
);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
files[index] = blob;
|
99
|
-
deferred.resolveWith(that);
|
100
|
-
}, file);
|
101
|
-
} else {
|
102
|
-
deferred.resolveWith(that);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
);
|
106
|
-
return deferred.promise();
|
107
|
-
},
|
108
|
-
|
109
|
-
// Resizes the images given as files property of the data parameter,
|
110
|
-
// returns a Promise object that allows to bind a done handler, which
|
111
|
-
// will be invoked after processing all images is done:
|
112
|
-
resize: function (data) {
|
113
|
-
var that = this,
|
114
|
-
options = $.extend({}, this.options, data),
|
115
|
-
resizeAll = $.type(options.resizeSourceMaxFileSize) !== 'number',
|
116
|
-
isXHRUpload = this._isXHRUpload(options);
|
117
|
-
$.each(data.files, function (index, file) {
|
118
|
-
if (isXHRUpload && that._resizeSupport &&
|
119
|
-
(options.resizeMaxWidth || options.resizeMaxHeight ||
|
120
|
-
options.resizeMinWidth || options.resizeMinHeight) &&
|
121
|
-
(resizeAll || file.size < options.resizeSourceMaxFileSize) &&
|
122
|
-
options.resizeSourceFileTypes.test(file.type)) {
|
123
|
-
that._processing += 1;
|
124
|
-
if (that._processing === 1) {
|
125
|
-
that.element.addClass('fileupload-processing');
|
126
|
-
}
|
127
|
-
that._processingQueue = that._processingQueue.pipe(function () {
|
128
|
-
var deferred = $.Deferred();
|
129
|
-
that._resizeImage(
|
130
|
-
data.files,
|
131
|
-
index,
|
132
|
-
options
|
133
|
-
).done(function () {
|
134
|
-
that._processing -= 1;
|
135
|
-
if (that._processing === 0) {
|
136
|
-
that.element
|
137
|
-
.removeClass('fileupload-processing');
|
138
|
-
}
|
139
|
-
deferred.resolveWith(that);
|
140
|
-
});
|
141
|
-
return deferred.promise();
|
142
|
-
});
|
143
|
-
}
|
144
|
-
});
|
145
|
-
return this._processingQueue;
|
146
|
-
},
|
147
|
-
|
148
|
-
_create: function () {
|
149
|
-
$.blueimp.fileupload.prototype._create.call(this);
|
150
|
-
this._processing = 0;
|
151
|
-
this._processingQueue = $.Deferred().resolveWith(this).promise();
|
152
|
-
this._resizeSupport = canvasToBlob && canvasToBlob(
|
153
|
-
document.createElement('canvas'),
|
154
|
-
$.noop
|
155
|
-
);
|
156
|
-
}
|
157
|
-
|
158
|
-
});
|
159
|
-
|
160
|
-
}));
|