jquery-file-upload-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +55 -0
- data/Rakefile +32 -0
- data/app/views/jquery_file_upload/basic_plus_ui/_download.html.erb +43 -0
- data/app/views/jquery_file_upload/basic_plus_ui/_form.html.haml +35 -0
- data/app/views/jquery_file_upload/basic_plus_ui/_upload.html.erb +32 -0
- data/config/locales/jquery_file_upload.cs.yml +16 -0
- data/config/locales/jquery_file_upload.en.yml +16 -0
- data/lib/jquery-file-upload-rails.rb +1 -0
- data/lib/jquery_file_upload/rails.rb +6 -0
- data/lib/jquery_file_upload/rails/version.rb +5 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +22 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/jquery_file_upload_rails_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/vendor/assets/images/jquery-file-upload/loading.gif +0 -0
- data/vendor/assets/images/jquery-file-upload/progressbar.gif +0 -0
- data/vendor/assets/javascripts/jquery-file-upload/app.js +101 -0
- data/vendor/assets/javascripts/jquery-file-upload/basic-plus-ui-no-widget.js.coffee +35 -0
- data/vendor/assets/javascripts/jquery-file-upload/basic-plus-ui.js.coffee +38 -0
- data/vendor/assets/javascripts/jquery-file-upload/cors/jquery.postmessage-transport.js +118 -0
- data/vendor/assets/javascripts/jquery-file-upload/cors/jquery.xdr-transport.js +87 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-angular.js +428 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-audio.js +106 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-image.js +295 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-jquery-ui.js +144 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-process.js +172 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-ui.js +699 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-validate.js +120 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload-video.js +106 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.fileupload.js +1416 -0
- data/vendor/assets/javascripts/jquery-file-upload/jquery.iframe-transport.js +210 -0
- data/vendor/assets/javascripts/jquery-file-upload/main.js.coffee +4 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/canvas-to-blob/canvas-to-blob.js +95 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/canvas-to-blob/canvas-to-blob.min.js +1 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/jquery.ui.widget.js +530 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/demo.js +138 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image-exif-map.js +384 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image-exif.js +299 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image-ios.js +181 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image-meta.js +137 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image-orientation.js +159 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image.js +276 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/load-image.min.js +1 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/load-image/vendor/jquery.Jcrop.js +1694 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/templates/compile.js +84 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/templates/demo.js +48 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/templates/runtime.js +47 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/templates/tmpl.js +87 -0
- data/vendor/assets/javascripts/jquery-file-upload/vendor/templates/tmpl.min.js +1 -0
- data/vendor/assets/stylesheets/jquery-file-upload/demo-ie8.css +21 -0
- data/vendor/assets/stylesheets/jquery-file-upload/demo.css +67 -0
- data/vendor/assets/stylesheets/jquery-file-upload/jquery.fileupload-noscript.css +22 -0
- data/vendor/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui-noscript.css +17 -0
- data/vendor/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui.css.scss +57 -0
- data/vendor/assets/stylesheets/jquery-file-upload/jquery.fileupload.css +36 -0
- data/vendor/assets/stylesheets/jquery-file-upload/style.css +15 -0
- metadata +196 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload Audio Preview Plugin 1.0.3
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2013, 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
|
+
'./jquery.fileupload-process'
|
23
|
+
], factory);
|
24
|
+
} else {
|
25
|
+
// Browser globals:
|
26
|
+
factory(
|
27
|
+
window.jQuery,
|
28
|
+
window.loadImage
|
29
|
+
);
|
30
|
+
}
|
31
|
+
}(function ($, loadImage) {
|
32
|
+
'use strict';
|
33
|
+
|
34
|
+
// Prepend to the default processQueue:
|
35
|
+
$.blueimp.fileupload.prototype.options.processQueue.unshift(
|
36
|
+
{
|
37
|
+
action: 'loadAudio',
|
38
|
+
// Use the action as prefix for the "@" options:
|
39
|
+
prefix: true,
|
40
|
+
fileTypes: '@',
|
41
|
+
maxFileSize: '@',
|
42
|
+
disabled: '@disableAudioPreview'
|
43
|
+
},
|
44
|
+
{
|
45
|
+
action: 'setAudio',
|
46
|
+
name: '@audioPreviewName',
|
47
|
+
disabled: '@disableAudioPreview'
|
48
|
+
}
|
49
|
+
);
|
50
|
+
|
51
|
+
// The File Upload Audio Preview plugin extends the fileupload widget
|
52
|
+
// with audio preview functionality:
|
53
|
+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
|
54
|
+
|
55
|
+
options: {
|
56
|
+
// The regular expression for the types of audio files to load,
|
57
|
+
// matched against the file type:
|
58
|
+
loadAudioFileTypes: /^audio\/.*$/
|
59
|
+
},
|
60
|
+
|
61
|
+
_audioElement: document.createElement('audio'),
|
62
|
+
|
63
|
+
processActions: {
|
64
|
+
|
65
|
+
// Loads the audio file given via data.files and data.index
|
66
|
+
// as audio element if the browser supports playing it.
|
67
|
+
// Accepts the options fileTypes (regular expression)
|
68
|
+
// and maxFileSize (integer) to limit the files to load:
|
69
|
+
loadAudio: function (data, options) {
|
70
|
+
if (options.disabled) {
|
71
|
+
return data;
|
72
|
+
}
|
73
|
+
var file = data.files[data.index],
|
74
|
+
url,
|
75
|
+
audio;
|
76
|
+
if (this._audioElement.canPlayType &&
|
77
|
+
this._audioElement.canPlayType(file.type) &&
|
78
|
+
($.type(options.maxFileSize) !== 'number' ||
|
79
|
+
file.size <= options.maxFileSize) &&
|
80
|
+
(!options.fileTypes ||
|
81
|
+
options.fileTypes.test(file.type))) {
|
82
|
+
url = loadImage.createObjectURL(file);
|
83
|
+
if (url) {
|
84
|
+
audio = this._audioElement.cloneNode(false);
|
85
|
+
audio.src = url;
|
86
|
+
audio.controls = true;
|
87
|
+
data.audio = audio;
|
88
|
+
return data;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
return data;
|
92
|
+
},
|
93
|
+
|
94
|
+
// Sets the audio element as a property of the file object:
|
95
|
+
setAudio: function (data, options) {
|
96
|
+
if (data.audio && !options.disabled) {
|
97
|
+
data.files[data.index][options.name || 'preview'] = data.audio;
|
98
|
+
}
|
99
|
+
return data;
|
100
|
+
}
|
101
|
+
|
102
|
+
}
|
103
|
+
|
104
|
+
});
|
105
|
+
|
106
|
+
}));
|
@@ -0,0 +1,295 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload Image Preview & Resize Plugin 1.6.0
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2013, 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, DataView, Blob, Uint8Array */
|
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
|
+
'load-image-meta',
|
23
|
+
'load-image-exif',
|
24
|
+
'load-image-ios',
|
25
|
+
'canvas-to-blob',
|
26
|
+
'./jquery.fileupload-process'
|
27
|
+
], factory);
|
28
|
+
} else {
|
29
|
+
// Browser globals:
|
30
|
+
factory(
|
31
|
+
window.jQuery,
|
32
|
+
window.loadImage
|
33
|
+
);
|
34
|
+
}
|
35
|
+
}(function ($, loadImage) {
|
36
|
+
'use strict';
|
37
|
+
|
38
|
+
// Prepend to the default processQueue:
|
39
|
+
$.blueimp.fileupload.prototype.options.processQueue.unshift(
|
40
|
+
{
|
41
|
+
action: 'loadImageMetaData',
|
42
|
+
disableImageHead: '@',
|
43
|
+
disableExif: '@',
|
44
|
+
disableExifThumbnail: '@',
|
45
|
+
disableExifSub: '@',
|
46
|
+
disableExifGps: '@',
|
47
|
+
disabled: '@disableImageMetaDataLoad'
|
48
|
+
},
|
49
|
+
{
|
50
|
+
action: 'loadImage',
|
51
|
+
// Use the action as prefix for the "@" options:
|
52
|
+
prefix: true,
|
53
|
+
fileTypes: '@',
|
54
|
+
maxFileSize: '@',
|
55
|
+
noRevoke: '@',
|
56
|
+
disabled: '@disableImageLoad'
|
57
|
+
},
|
58
|
+
{
|
59
|
+
action: 'resizeImage',
|
60
|
+
// Use "image" as prefix for the "@" options:
|
61
|
+
prefix: 'image',
|
62
|
+
maxWidth: '@',
|
63
|
+
maxHeight: '@',
|
64
|
+
minWidth: '@',
|
65
|
+
minHeight: '@',
|
66
|
+
crop: '@',
|
67
|
+
orientation: '@',
|
68
|
+
forceResize: '@',
|
69
|
+
disabled: '@disableImageResize'
|
70
|
+
},
|
71
|
+
{
|
72
|
+
action: 'saveImage',
|
73
|
+
quality: '@imageQuality',
|
74
|
+
type: '@imageType',
|
75
|
+
disabled: '@disableImageResize'
|
76
|
+
},
|
77
|
+
{
|
78
|
+
action: 'saveImageMetaData',
|
79
|
+
disabled: '@disableImageMetaDataSave'
|
80
|
+
},
|
81
|
+
{
|
82
|
+
action: 'resizeImage',
|
83
|
+
// Use "preview" as prefix for the "@" options:
|
84
|
+
prefix: 'preview',
|
85
|
+
maxWidth: '@',
|
86
|
+
maxHeight: '@',
|
87
|
+
minWidth: '@',
|
88
|
+
minHeight: '@',
|
89
|
+
crop: '@',
|
90
|
+
orientation: '@',
|
91
|
+
thumbnail: '@',
|
92
|
+
canvas: '@',
|
93
|
+
disabled: '@disableImagePreview'
|
94
|
+
},
|
95
|
+
{
|
96
|
+
action: 'setImage',
|
97
|
+
name: '@imagePreviewName',
|
98
|
+
disabled: '@disableImagePreview'
|
99
|
+
}
|
100
|
+
);
|
101
|
+
|
102
|
+
// The File Upload Resize plugin extends the fileupload widget
|
103
|
+
// with image resize functionality:
|
104
|
+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
|
105
|
+
|
106
|
+
options: {
|
107
|
+
// The regular expression for the types of images to load:
|
108
|
+
// matched against the file type:
|
109
|
+
loadImageFileTypes: /^image\/(gif|jpeg|png)$/,
|
110
|
+
// The maximum file size of images to load:
|
111
|
+
loadImageMaxFileSize: 10000000, // 10MB
|
112
|
+
// The maximum width of resized images:
|
113
|
+
imageMaxWidth: 1920,
|
114
|
+
// The maximum height of resized images:
|
115
|
+
imageMaxHeight: 1080,
|
116
|
+
// Defines the image orientation (1-8) or takes the orientation
|
117
|
+
// value from Exif data if set to true:
|
118
|
+
imageOrientation: false,
|
119
|
+
// Define if resized images should be cropped or only scaled:
|
120
|
+
imageCrop: false,
|
121
|
+
// Disable the resize image functionality by default:
|
122
|
+
disableImageResize: true,
|
123
|
+
// The maximum width of the preview images:
|
124
|
+
previewMaxWidth: 80,
|
125
|
+
// The maximum height of the preview images:
|
126
|
+
previewMaxHeight: 80,
|
127
|
+
// Defines the preview orientation (1-8) or takes the orientation
|
128
|
+
// value from Exif data if set to true:
|
129
|
+
previewOrientation: true,
|
130
|
+
// Create the preview using the Exif data thumbnail:
|
131
|
+
previewThumbnail: true,
|
132
|
+
// Define if preview images should be cropped or only scaled:
|
133
|
+
previewCrop: false,
|
134
|
+
// Define if preview images should be resized as canvas elements:
|
135
|
+
previewCanvas: true
|
136
|
+
},
|
137
|
+
|
138
|
+
processActions: {
|
139
|
+
|
140
|
+
// Loads the image given via data.files and data.index
|
141
|
+
// as img element, if the browser supports the File API.
|
142
|
+
// Accepts the options fileTypes (regular expression)
|
143
|
+
// and maxFileSize (integer) to limit the files to load:
|
144
|
+
loadImage: function (data, options) {
|
145
|
+
if (options.disabled) {
|
146
|
+
return data;
|
147
|
+
}
|
148
|
+
var that = this,
|
149
|
+
file = data.files[data.index],
|
150
|
+
dfd = $.Deferred();
|
151
|
+
if (($.type(options.maxFileSize) === 'number' &&
|
152
|
+
file.size > options.maxFileSize) ||
|
153
|
+
(options.fileTypes &&
|
154
|
+
!options.fileTypes.test(file.type)) ||
|
155
|
+
!loadImage(
|
156
|
+
file,
|
157
|
+
function (img) {
|
158
|
+
if (img.src) {
|
159
|
+
data.img = img;
|
160
|
+
}
|
161
|
+
dfd.resolveWith(that, [data]);
|
162
|
+
},
|
163
|
+
options
|
164
|
+
)) {
|
165
|
+
return data;
|
166
|
+
}
|
167
|
+
return dfd.promise();
|
168
|
+
},
|
169
|
+
|
170
|
+
// Resizes the image given as data.canvas or data.img
|
171
|
+
// and updates data.canvas or data.img with the resized image.
|
172
|
+
// Also stores the resized image as preview property.
|
173
|
+
// Accepts the options maxWidth, maxHeight, minWidth,
|
174
|
+
// minHeight, canvas and crop:
|
175
|
+
resizeImage: function (data, options) {
|
176
|
+
if (options.disabled || !(data.canvas || data.img)) {
|
177
|
+
return data;
|
178
|
+
}
|
179
|
+
options = $.extend({canvas: true}, options);
|
180
|
+
var that = this,
|
181
|
+
dfd = $.Deferred(),
|
182
|
+
img = (options.canvas && data.canvas) || data.img,
|
183
|
+
resolve = function (newImg) {
|
184
|
+
if (newImg && (newImg.width !== img.width ||
|
185
|
+
newImg.height !== img.height ||
|
186
|
+
options.forceResize)) {
|
187
|
+
data[newImg.getContext ? 'canvas' : 'img'] = newImg;
|
188
|
+
}
|
189
|
+
data.preview = newImg;
|
190
|
+
dfd.resolveWith(that, [data]);
|
191
|
+
},
|
192
|
+
thumbnail;
|
193
|
+
if (data.exif) {
|
194
|
+
if (options.orientation === true) {
|
195
|
+
options.orientation = data.exif.get('Orientation');
|
196
|
+
}
|
197
|
+
if (options.thumbnail) {
|
198
|
+
thumbnail = data.exif.get('Thumbnail');
|
199
|
+
if (thumbnail) {
|
200
|
+
loadImage(thumbnail, resolve, options);
|
201
|
+
return dfd.promise();
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
if (img) {
|
206
|
+
resolve(loadImage.scale(img, options));
|
207
|
+
return dfd.promise();
|
208
|
+
}
|
209
|
+
return data;
|
210
|
+
},
|
211
|
+
|
212
|
+
// Saves the processed image given as data.canvas
|
213
|
+
// inplace at data.index of data.files:
|
214
|
+
saveImage: function (data, options) {
|
215
|
+
if (!data.canvas || options.disabled) {
|
216
|
+
return data;
|
217
|
+
}
|
218
|
+
var that = this,
|
219
|
+
file = data.files[data.index],
|
220
|
+
dfd = $.Deferred();
|
221
|
+
if (data.canvas.toBlob) {
|
222
|
+
data.canvas.toBlob(
|
223
|
+
function (blob) {
|
224
|
+
if (!blob.name) {
|
225
|
+
if (file.type === blob.type) {
|
226
|
+
blob.name = file.name;
|
227
|
+
} else if (file.name) {
|
228
|
+
blob.name = file.name.replace(
|
229
|
+
/\..+$/,
|
230
|
+
'.' + blob.type.substr(6)
|
231
|
+
);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
// Don't restore invalid meta data:
|
235
|
+
if (file.type !== blob.type) {
|
236
|
+
delete data.imageHead;
|
237
|
+
}
|
238
|
+
// Store the created blob at the position
|
239
|
+
// of the original file in the files list:
|
240
|
+
data.files[data.index] = blob;
|
241
|
+
dfd.resolveWith(that, [data]);
|
242
|
+
},
|
243
|
+
options.type || file.type,
|
244
|
+
options.quality
|
245
|
+
);
|
246
|
+
} else {
|
247
|
+
return data;
|
248
|
+
}
|
249
|
+
return dfd.promise();
|
250
|
+
},
|
251
|
+
|
252
|
+
loadImageMetaData: function (data, options) {
|
253
|
+
if (options.disabled) {
|
254
|
+
return data;
|
255
|
+
}
|
256
|
+
var that = this,
|
257
|
+
dfd = $.Deferred();
|
258
|
+
loadImage.parseMetaData(data.files[data.index], function (result) {
|
259
|
+
$.extend(data, result);
|
260
|
+
dfd.resolveWith(that, [data]);
|
261
|
+
}, options);
|
262
|
+
return dfd.promise();
|
263
|
+
},
|
264
|
+
|
265
|
+
saveImageMetaData: function (data, options) {
|
266
|
+
if (!(data.imageHead && data.canvas &&
|
267
|
+
data.canvas.toBlob && !options.disabled)) {
|
268
|
+
return data;
|
269
|
+
}
|
270
|
+
var file = data.files[data.index],
|
271
|
+
blob = new Blob([
|
272
|
+
data.imageHead,
|
273
|
+
// Resized images always have a head size of 20 bytes,
|
274
|
+
// including the JPEG marker and a minimal JFIF header:
|
275
|
+
this._blobSlice.call(file, 20)
|
276
|
+
], {type: file.type});
|
277
|
+
blob.name = file.name;
|
278
|
+
data.files[data.index] = blob;
|
279
|
+
return data;
|
280
|
+
},
|
281
|
+
|
282
|
+
// Sets the resized version of the image as a property of the
|
283
|
+
// file object, must be called after "saveImage":
|
284
|
+
setImage: function (data, options) {
|
285
|
+
if (data.preview && !options.disabled) {
|
286
|
+
data.files[data.index][options.name || 'preview'] = data.preview;
|
287
|
+
}
|
288
|
+
return data;
|
289
|
+
}
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
});
|
294
|
+
|
295
|
+
}));
|
@@ -0,0 +1,144 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload jQuery UI Plugin 8.7.0
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2013, 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 */
|
13
|
+
/*global define, window */
|
14
|
+
|
15
|
+
(function (factory) {
|
16
|
+
'use strict';
|
17
|
+
if (typeof define === 'function' && define.amd) {
|
18
|
+
// Register as an anonymous AMD module:
|
19
|
+
define(['jquery', './jquery.fileupload-ui'], factory);
|
20
|
+
} else {
|
21
|
+
// Browser globals:
|
22
|
+
factory(window.jQuery);
|
23
|
+
}
|
24
|
+
}(function ($) {
|
25
|
+
'use strict';
|
26
|
+
|
27
|
+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
|
28
|
+
|
29
|
+
options: {
|
30
|
+
progress: function (e, data) {
|
31
|
+
if (data.context) {
|
32
|
+
data.context.find('.progress').progressbar(
|
33
|
+
'option',
|
34
|
+
'value',
|
35
|
+
parseInt(data.loaded / data.total * 100, 10)
|
36
|
+
);
|
37
|
+
}
|
38
|
+
},
|
39
|
+
progressall: function (e, data) {
|
40
|
+
var $this = $(this);
|
41
|
+
$this.find('.fileupload-progress')
|
42
|
+
.find('.progress').progressbar(
|
43
|
+
'option',
|
44
|
+
'value',
|
45
|
+
parseInt(data.loaded / data.total * 100, 10)
|
46
|
+
).end()
|
47
|
+
.find('.progress-extended').each(function () {
|
48
|
+
$(this).html(
|
49
|
+
($this.data('blueimp-fileupload') ||
|
50
|
+
$this.data('fileupload'))
|
51
|
+
._renderExtendedProgress(data)
|
52
|
+
);
|
53
|
+
});
|
54
|
+
}
|
55
|
+
},
|
56
|
+
|
57
|
+
_renderUpload: function (func, files) {
|
58
|
+
var node = this._super(func, files),
|
59
|
+
showIconText = $(window).width() > 480;
|
60
|
+
node.find('.progress').empty().progressbar();
|
61
|
+
node.find('.start').button({
|
62
|
+
icons: {primary: 'ui-icon-circle-arrow-e'},
|
63
|
+
text: showIconText
|
64
|
+
});
|
65
|
+
node.find('.cancel').button({
|
66
|
+
icons: {primary: 'ui-icon-cancel'},
|
67
|
+
text: showIconText
|
68
|
+
});
|
69
|
+
if (node.hasClass('fade')) {
|
70
|
+
node.hide();
|
71
|
+
}
|
72
|
+
return node;
|
73
|
+
},
|
74
|
+
|
75
|
+
_renderDownload: function (func, files) {
|
76
|
+
var node = this._super(func, files),
|
77
|
+
showIconText = $(window).width() > 480;
|
78
|
+
node.find('.delete').button({
|
79
|
+
icons: {primary: 'ui-icon-trash'},
|
80
|
+
text: showIconText
|
81
|
+
});
|
82
|
+
if (node.hasClass('fade')) {
|
83
|
+
node.hide();
|
84
|
+
}
|
85
|
+
return node;
|
86
|
+
},
|
87
|
+
|
88
|
+
_transition: function (node) {
|
89
|
+
var deferred = $.Deferred();
|
90
|
+
if (node.hasClass('fade')) {
|
91
|
+
node.fadeToggle(
|
92
|
+
this.options.transitionDuration,
|
93
|
+
this.options.transitionEasing,
|
94
|
+
function () {
|
95
|
+
deferred.resolveWith(node);
|
96
|
+
}
|
97
|
+
);
|
98
|
+
} else {
|
99
|
+
deferred.resolveWith(node);
|
100
|
+
}
|
101
|
+
return deferred;
|
102
|
+
},
|
103
|
+
|
104
|
+
_create: function () {
|
105
|
+
this._super();
|
106
|
+
this.element
|
107
|
+
.find('.fileupload-buttonbar')
|
108
|
+
.find('.fileinput-button').each(function () {
|
109
|
+
var input = $(this).find('input:file').detach();
|
110
|
+
$(this)
|
111
|
+
.button({icons: {primary: 'ui-icon-plusthick'}})
|
112
|
+
.append(input);
|
113
|
+
})
|
114
|
+
.end().find('.start')
|
115
|
+
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
|
116
|
+
.end().find('.cancel')
|
117
|
+
.button({icons: {primary: 'ui-icon-cancel'}})
|
118
|
+
.end().find('.delete')
|
119
|
+
.button({icons: {primary: 'ui-icon-trash'}})
|
120
|
+
.end().find('.progress').progressbar();
|
121
|
+
},
|
122
|
+
|
123
|
+
_destroy: function () {
|
124
|
+
this.element
|
125
|
+
.find('.fileupload-buttonbar')
|
126
|
+
.find('.fileinput-button').each(function () {
|
127
|
+
var input = $(this).find('input:file').detach();
|
128
|
+
$(this)
|
129
|
+
.button('destroy')
|
130
|
+
.append(input);
|
131
|
+
})
|
132
|
+
.end().find('.start')
|
133
|
+
.button('destroy')
|
134
|
+
.end().find('.cancel')
|
135
|
+
.button('destroy')
|
136
|
+
.end().find('.delete')
|
137
|
+
.button('destroy')
|
138
|
+
.end().find('.progress').progressbar('destroy');
|
139
|
+
this._super();
|
140
|
+
}
|
141
|
+
|
142
|
+
});
|
143
|
+
|
144
|
+
}));
|