rails-jquery-fileupload 1.0.2
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 +7 -0
- data/README.md +67 -0
- data/Rakefile +15 -0
- data/lib/jquery/fileupload/rails/engine.rb +8 -0
- data/lib/jquery/fileupload/rails/middleware.rb +59 -0
- data/lib/jquery/fileupload/rails/upload.rb +3 -0
- data/lib/jquery/fileupload/rails/version.rb +7 -0
- data/lib/rails-jquery-fileupload.rb +8 -0
- data/vendor/assets/images/loading.gif +0 -0
- data/vendor/assets/javascripts/jquery-fileupload/all.js +13 -0
- data/vendor/assets/javascripts/jquery-fileupload/basic.js +4 -0
- data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js +117 -0
- data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js +87 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-audio.js +106 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-image.js +309 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js +172 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js +699 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js +119 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-video.js +106 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js +1420 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js +214 -0
- data/vendor/assets/javascripts/jquery-fileupload/locale.js +29 -0
- data/vendor/assets/javascripts/jquery-fileupload/vendor/canvas-to-blob.js +95 -0
- data/vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js +530 -0
- data/vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js +1446 -0
- data/vendor/assets/javascripts/jquery-fileupload/vendor/tmpl.js +87 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de2d65f67f81a96fb279b9aaa78422a319eaf9bd
|
4
|
+
data.tar.gz: 89300e864518d5c8fe70279fdc938d07c98765d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15a5912ad5a9e6bc76dde967e7011f7499af4ae164ca9f610370c34bbe448bd2543db1f99a02880a2c46eaba500b84769776aa757c7e47b623a03d9fbe18d28a
|
7
|
+
data.tar.gz: 45b5e29f82e66d95693113be77c278c9a5ddbc7e39c8ae2c17933b3fb7f523481faea8a98ef6e8a0a6e0dadf383b51b447c16ce87629b7151abaa5a5520dd492
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# jQuery File Upload for Rails
|
2
|
+
|
3
|
+
[jQuery-File-Plugin](https://github.com/blueimp/jQuery-File-Upload) is a file upload plugin written by [Sebastian Tschan](https://github.com/blueimp). jQuery File Upload features multiple file selection, drag&drop support, progress bars and preview images for jQuery. Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
|
4
|
+
|
5
|
+
rails-jquery-fileupload is a library that integrates jQuery File Upload for Rails >= 3.1 Asset Pipeline (Rails 4 supported).
|
6
|
+
|
7
|
+
## Plugin versions
|
8
|
+
|
9
|
+
* jQuery File Upload User Interface Plugin 6.11
|
10
|
+
* jQuery File Upload Plugin 5.19.3
|
11
|
+
* jQuery UI Widget 1.9.1+amd
|
12
|
+
|
13
|
+
## Installing Gem
|
14
|
+
|
15
|
+
gem "jquery-fileupload-rails"
|
16
|
+
|
17
|
+
## Using the javascripts
|
18
|
+
|
19
|
+
Require jquery-fileupload in your app/assets/application.js file.
|
20
|
+
|
21
|
+
//= require jquery-fileupload/all
|
22
|
+
|
23
|
+
The snippet above will add the complete set of js files (including UI) to the mainfest file.
|
24
|
+
|
25
|
+
//=require jquery-fileupload/vendor/jquery.ui.widget
|
26
|
+
//=require jquery-fileupload/vendor/tmpl
|
27
|
+
//=require jquery-fileupload/vendor/load-image
|
28
|
+
//=require jquery-fileupload/vendor/canvas-to-blob
|
29
|
+
//=require jquery-fileupload/jquery.iframe-transport
|
30
|
+
//=require jquery-fileupload/jquery.fileupload
|
31
|
+
//=require jquery-fileupload/jquery.fileupload-process
|
32
|
+
//=require jquery-fileupload/jquery.fileupload-image
|
33
|
+
//=require jquery-fileupload/jquery.fileupload-audio
|
34
|
+
//=require jquery-fileupload/jquery.fileupload-video
|
35
|
+
//=require jquery-fileupload/jquery.fileupload-validate
|
36
|
+
//=require jquery-fileupload/jquery.fileupload-ui
|
37
|
+
//=require jquery-fileupload/locale
|
38
|
+
|
39
|
+
If you only need the basic files, just add the code below to your application.js file. [Basic setup guide](https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin)
|
40
|
+
|
41
|
+
//= require jquery-fileupload/basic
|
42
|
+
|
43
|
+
The basic setup only includes the following files:
|
44
|
+
|
45
|
+
//= require jquery-fileupload/vendor/jquery.ui.widget
|
46
|
+
//= require jquery-fileupload/jquery.iframe-transport
|
47
|
+
//= require jquery-fileupload/jquery.fileupload
|
48
|
+
|
49
|
+
## Using the middleware
|
50
|
+
|
51
|
+
The `jquery.iframe-transport` fallback transport has some special caveats regarding the response data type, http status, and character encodings. `jquery-fileupload-rails` includes a middleware that handles these inconsistencies seamlessly. If you decide to use it, create an initializer that adds the middleware to your application's middleware stack.
|
52
|
+
|
53
|
+
Rails.application.config.middleware.use JQuery::FileUpload::Rails::Middleware
|
54
|
+
|
55
|
+
## Thanks
|
56
|
+
Thanks to [Sebastian Tschan](https://github.com/blueimp) for writing an awesome file upload plugin.
|
57
|
+
Thanks to [Tors Dalid](https://github.com/tors/jquery-fileupload-rails) for writing the rails gem from which this was based.
|
58
|
+
|
59
|
+
## Versioning
|
60
|
+
Since this represents a suite of js files, it is not possible to sync this gem version with the version of the javascript plug-in. I will try and update this periodically and bump the minor and patch versions depending on the updated js plug-ins.
|
61
|
+
|
62
|
+
## License
|
63
|
+
Copyright (c) 2013 Iorgulescu Dragos
|
64
|
+
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
66
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc "Bundle the gem"
|
6
|
+
task :bundle do
|
7
|
+
sh('bundle install')
|
8
|
+
sh 'gem build *.gemspec'
|
9
|
+
sh 'gem install *.gem'
|
10
|
+
sh 'rm *.gem'
|
11
|
+
end
|
12
|
+
|
13
|
+
task(:default).clear
|
14
|
+
task :default => :bundle
|
15
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module JQuery
|
2
|
+
module FileUpload
|
3
|
+
module Rails
|
4
|
+
class Middleware
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
dup._call(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
def _call(env)
|
14
|
+
@status, @headers, @response = @app.call(env)
|
15
|
+
@request = Rack::Request.new(env)
|
16
|
+
|
17
|
+
if iframe_transport?
|
18
|
+
@headers['Content-Type'] = 'text/html'
|
19
|
+
[@status, @headers, self]
|
20
|
+
else
|
21
|
+
[@status, @headers, @response]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&block)
|
26
|
+
block.call(html_document_left) if iframe_transport?
|
27
|
+
@response.each(&block)
|
28
|
+
block.call(html_document_right) if iframe_transport?
|
29
|
+
end
|
30
|
+
|
31
|
+
def iframe_transport?
|
32
|
+
@request.params['X-Requested-With'] == 'IFrame'
|
33
|
+
end
|
34
|
+
|
35
|
+
def html_document_left
|
36
|
+
"<!DOCTYPE html><html><body><textarea #{metadata}>"
|
37
|
+
end
|
38
|
+
|
39
|
+
def html_document_right
|
40
|
+
"</textarea></body></html>"
|
41
|
+
end
|
42
|
+
|
43
|
+
def metadata
|
44
|
+
meta = {}
|
45
|
+
meta['data-status'] = @response.status if @response.respond_to? :status
|
46
|
+
meta['data-statusText'] = @response.status_message if @response.respond_to? :status_message
|
47
|
+
meta['data-type'] = @headers['Content-Type'] if @headers.has_key?('Content-Type')
|
48
|
+
meta.map {|key,value| "#{key}='#{value}'" }.join(' ')
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def method_missing(method, *args)
|
54
|
+
@response.send(method.intern, *args)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
//=require jquery-fileupload/vendor/jquery.ui.widget
|
2
|
+
//=require jquery-fileupload/vendor/tmpl
|
3
|
+
//=require jquery-fileupload/vendor/load-image
|
4
|
+
//=require jquery-fileupload/vendor/canvas-to-blob
|
5
|
+
//=require jquery-fileupload/jquery.iframe-transport
|
6
|
+
//=require jquery-fileupload/jquery.fileupload
|
7
|
+
//=require jquery-fileupload/jquery.fileupload-process
|
8
|
+
//=require jquery-fileupload/jquery.fileupload-image
|
9
|
+
//=require jquery-fileupload/jquery.fileupload-audio
|
10
|
+
//=require jquery-fileupload/jquery.fileupload-video
|
11
|
+
//=require jquery-fileupload/jquery.fileupload-validate
|
12
|
+
//=require jquery-fileupload/jquery.fileupload-ui
|
13
|
+
//=require jquery-fileupload/locale
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery postMessage Transport Plugin 1.1.1
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2011, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/MIT
|
10
|
+
*/
|
11
|
+
|
12
|
+
/* global define, window, document */
|
13
|
+
|
14
|
+
(function (factory) {
|
15
|
+
'use strict';
|
16
|
+
if (typeof define === 'function' && define.amd) {
|
17
|
+
// Register as an anonymous AMD module:
|
18
|
+
define(['jquery'], factory);
|
19
|
+
} else {
|
20
|
+
// Browser globals:
|
21
|
+
factory(window.jQuery);
|
22
|
+
}
|
23
|
+
}(function ($) {
|
24
|
+
'use strict';
|
25
|
+
|
26
|
+
var counter = 0,
|
27
|
+
names = [
|
28
|
+
'accepts',
|
29
|
+
'cache',
|
30
|
+
'contents',
|
31
|
+
'contentType',
|
32
|
+
'crossDomain',
|
33
|
+
'data',
|
34
|
+
'dataType',
|
35
|
+
'headers',
|
36
|
+
'ifModified',
|
37
|
+
'mimeType',
|
38
|
+
'password',
|
39
|
+
'processData',
|
40
|
+
'timeout',
|
41
|
+
'traditional',
|
42
|
+
'type',
|
43
|
+
'url',
|
44
|
+
'username'
|
45
|
+
],
|
46
|
+
convert = function (p) {
|
47
|
+
return p;
|
48
|
+
};
|
49
|
+
|
50
|
+
$.ajaxSetup({
|
51
|
+
converters: {
|
52
|
+
'postmessage text': convert,
|
53
|
+
'postmessage json': convert,
|
54
|
+
'postmessage html': convert
|
55
|
+
}
|
56
|
+
});
|
57
|
+
|
58
|
+
$.ajaxTransport('postmessage', function (options) {
|
59
|
+
if (options.postMessage && window.postMessage) {
|
60
|
+
var iframe,
|
61
|
+
loc = $('<a>').prop('href', options.postMessage)[0],
|
62
|
+
target = loc.protocol + '//' + loc.host,
|
63
|
+
xhrUpload = options.xhr().upload;
|
64
|
+
return {
|
65
|
+
send: function (_, completeCallback) {
|
66
|
+
counter += 1;
|
67
|
+
var message = {
|
68
|
+
id: 'postmessage-transport-' + counter
|
69
|
+
},
|
70
|
+
eventName = 'message.' + message.id;
|
71
|
+
iframe = $(
|
72
|
+
'<iframe style="display:none;" src="' +
|
73
|
+
options.postMessage + '" name="' +
|
74
|
+
message.id + '"></iframe>'
|
75
|
+
).bind('load', function () {
|
76
|
+
$.each(names, function (i, name) {
|
77
|
+
message[name] = options[name];
|
78
|
+
});
|
79
|
+
message.dataType = message.dataType.replace('postmessage ', '');
|
80
|
+
$(window).bind(eventName, function (e) {
|
81
|
+
e = e.originalEvent;
|
82
|
+
var data = e.data,
|
83
|
+
ev;
|
84
|
+
if (e.origin === target && data.id === message.id) {
|
85
|
+
if (data.type === 'progress') {
|
86
|
+
ev = document.createEvent('Event');
|
87
|
+
ev.initEvent(data.type, false, true);
|
88
|
+
$.extend(ev, data);
|
89
|
+
xhrUpload.dispatchEvent(ev);
|
90
|
+
} else {
|
91
|
+
completeCallback(
|
92
|
+
data.status,
|
93
|
+
data.statusText,
|
94
|
+
{postmessage: data.result},
|
95
|
+
data.headers
|
96
|
+
);
|
97
|
+
iframe.remove();
|
98
|
+
$(window).unbind(eventName);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
});
|
102
|
+
iframe[0].contentWindow.postMessage(
|
103
|
+
message,
|
104
|
+
target
|
105
|
+
);
|
106
|
+
}).appendTo(document.body);
|
107
|
+
},
|
108
|
+
abort: function () {
|
109
|
+
if (iframe) {
|
110
|
+
iframe.remove();
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
}));
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery XDomainRequest Transport Plugin 1.1.3
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2011, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/MIT
|
10
|
+
*
|
11
|
+
* Based on Julian Aubourg's ajaxHooks xdr.js:
|
12
|
+
* https://github.com/jaubourg/ajaxHooks/
|
13
|
+
*/
|
14
|
+
|
15
|
+
/*jslint unparam: true */
|
16
|
+
/*global define, window, XDomainRequest */
|
17
|
+
|
18
|
+
(function (factory) {
|
19
|
+
'use strict';
|
20
|
+
if (typeof define === 'function' && define.amd) {
|
21
|
+
// Register as an anonymous AMD module:
|
22
|
+
define(['jquery'], factory);
|
23
|
+
} else {
|
24
|
+
// Browser globals:
|
25
|
+
factory(window.jQuery);
|
26
|
+
}
|
27
|
+
}(function ($) {
|
28
|
+
'use strict';
|
29
|
+
if (window.XDomainRequest && !$.support.cors) {
|
30
|
+
$.ajaxTransport(function (s) {
|
31
|
+
if (s.crossDomain && s.async) {
|
32
|
+
if (s.timeout) {
|
33
|
+
s.xdrTimeout = s.timeout;
|
34
|
+
delete s.timeout;
|
35
|
+
}
|
36
|
+
var xdr;
|
37
|
+
return {
|
38
|
+
send: function (headers, completeCallback) {
|
39
|
+
var addParamChar = /\?/.test(s.url) ? '&' : '?';
|
40
|
+
function callback(status, statusText, responses, responseHeaders) {
|
41
|
+
xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
|
42
|
+
xdr = null;
|
43
|
+
completeCallback(status, statusText, responses, responseHeaders);
|
44
|
+
}
|
45
|
+
xdr = new XDomainRequest();
|
46
|
+
// XDomainRequest only supports GET and POST:
|
47
|
+
if (s.type === 'DELETE') {
|
48
|
+
s.url = s.url + addParamChar + '_method=DELETE';
|
49
|
+
s.type = 'POST';
|
50
|
+
} else if (s.type === 'PUT') {
|
51
|
+
s.url = s.url + addParamChar + '_method=PUT';
|
52
|
+
s.type = 'POST';
|
53
|
+
} else if (s.type === 'PATCH') {
|
54
|
+
s.url = s.url + addParamChar + '_method=PATCH';
|
55
|
+
s.type = 'POST';
|
56
|
+
}
|
57
|
+
xdr.open(s.type, s.url);
|
58
|
+
xdr.onload = function () {
|
59
|
+
callback(
|
60
|
+
200,
|
61
|
+
'OK',
|
62
|
+
{text: xdr.responseText},
|
63
|
+
'Content-Type: ' + xdr.contentType
|
64
|
+
);
|
65
|
+
};
|
66
|
+
xdr.onerror = function () {
|
67
|
+
callback(404, 'Not Found');
|
68
|
+
};
|
69
|
+
if (s.xdrTimeout) {
|
70
|
+
xdr.ontimeout = function () {
|
71
|
+
callback(0, 'timeout');
|
72
|
+
};
|
73
|
+
xdr.timeout = s.xdrTimeout;
|
74
|
+
}
|
75
|
+
xdr.send((s.hasContent && s.data) || null);
|
76
|
+
},
|
77
|
+
abort: function () {
|
78
|
+
if (xdr) {
|
79
|
+
xdr.onerror = $.noop();
|
80
|
+
xdr.abort();
|
81
|
+
}
|
82
|
+
}
|
83
|
+
};
|
84
|
+
}
|
85
|
+
});
|
86
|
+
}
|
87
|
+
}));
|
@@ -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
|
+
/* jshint nomen:false */
|
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
|
+
}));
|