jquery-file-upload 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +14 -0
- data/LICENSE +21 -0
- data/README.md +12 -0
- data/app/assets/images/jquery-file-upload/loading.gif +0 -0
- data/app/assets/images/jquery-file-upload/progressbar.gif +0 -0
- data/app/assets/javascripts/jquery-file-upload/cors/jquery.postmessage-transport.js +120 -0
- data/app/assets/javascripts/jquery-file-upload/cors/jquery.xdr-transport.js +89 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-image.js +321 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-jquery-ui.js +155 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-process.js +175 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-ui.js +710 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-validate.js +122 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.fileupload.js +1466 -0
- data/app/assets/javascripts/jquery-file-upload/jquery.iframe-transport.js +217 -0
- data/app/assets/javascripts/jquery-file-upload/vendor/jquery.ui.widget.js +563 -0
- data/app/assets/javascripts/jquery-file-upload.js.coffee +1 -0
- data/app/assets/javascripts/jquery.fileupload-angular.js +429 -0
- data/app/assets/javascripts/jquery.fileupload-audio.js +112 -0
- data/app/assets/javascripts/jquery.fileupload-video.js +112 -0
- data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-noscript.css +22 -0
- data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui-noscript.css +17 -0
- data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui.css +57 -0
- data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload.css +36 -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.slim +38 -0
- data/app/views/jquery-file-upload/basic_plus_ui/_upload.html.erb +32 -0
- data/jquery-file-upload.gemspec +19 -0
- data/lib/jquery-file-upload/configuration.rb +13 -0
- data/lib/jquery-file-upload/engine.rb +6 -0
- data/lib/jquery-file-upload/version.rb +3 -0
- data/lib/jquery-file-upload.rb +15 -0
- metadata +89 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload jQuery UI Plugin 8.7.2
|
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, require, 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 if (typeof exports === 'object') {
|
21
|
+
// Node/CommonJS:
|
22
|
+
factory(require('jquery'));
|
23
|
+
} else {
|
24
|
+
// Browser globals:
|
25
|
+
factory(window.jQuery);
|
26
|
+
}
|
27
|
+
}(function ($) {
|
28
|
+
'use strict';
|
29
|
+
|
30
|
+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
|
31
|
+
|
32
|
+
options: {
|
33
|
+
processdone: function (e, data) {
|
34
|
+
data.context.find('.start').button('enable');
|
35
|
+
},
|
36
|
+
progress: function (e, data) {
|
37
|
+
if (data.context) {
|
38
|
+
data.context.find('.progress').progressbar(
|
39
|
+
'option',
|
40
|
+
'value',
|
41
|
+
parseInt(data.loaded / data.total * 100, 10)
|
42
|
+
);
|
43
|
+
}
|
44
|
+
},
|
45
|
+
progressall: function (e, data) {
|
46
|
+
var $this = $(this);
|
47
|
+
$this.find('.fileupload-progress')
|
48
|
+
.find('.progress').progressbar(
|
49
|
+
'option',
|
50
|
+
'value',
|
51
|
+
parseInt(data.loaded / data.total * 100, 10)
|
52
|
+
).end()
|
53
|
+
.find('.progress-extended').each(function () {
|
54
|
+
$(this).html(
|
55
|
+
($this.data('blueimp-fileupload') ||
|
56
|
+
$this.data('fileupload'))
|
57
|
+
._renderExtendedProgress(data)
|
58
|
+
);
|
59
|
+
});
|
60
|
+
}
|
61
|
+
},
|
62
|
+
|
63
|
+
_renderUpload: function (func, files) {
|
64
|
+
var node = this._super(func, files),
|
65
|
+
showIconText = $(window).width() > 480;
|
66
|
+
node.find('.progress').empty().progressbar();
|
67
|
+
node.find('.start').button({
|
68
|
+
icons: {primary: 'ui-icon-circle-arrow-e'},
|
69
|
+
text: showIconText
|
70
|
+
});
|
71
|
+
node.find('.cancel').button({
|
72
|
+
icons: {primary: 'ui-icon-cancel'},
|
73
|
+
text: showIconText
|
74
|
+
});
|
75
|
+
if (node.hasClass('fade')) {
|
76
|
+
node.hide();
|
77
|
+
}
|
78
|
+
return node;
|
79
|
+
},
|
80
|
+
|
81
|
+
_renderDownload: function (func, files) {
|
82
|
+
var node = this._super(func, files),
|
83
|
+
showIconText = $(window).width() > 480;
|
84
|
+
node.find('.delete').button({
|
85
|
+
icons: {primary: 'ui-icon-trash'},
|
86
|
+
text: showIconText
|
87
|
+
});
|
88
|
+
if (node.hasClass('fade')) {
|
89
|
+
node.hide();
|
90
|
+
}
|
91
|
+
return node;
|
92
|
+
},
|
93
|
+
|
94
|
+
_startHandler: function (e) {
|
95
|
+
$(e.currentTarget).button('disable');
|
96
|
+
this._super(e);
|
97
|
+
},
|
98
|
+
|
99
|
+
_transition: function (node) {
|
100
|
+
var deferred = $.Deferred();
|
101
|
+
if (node.hasClass('fade')) {
|
102
|
+
node.fadeToggle(
|
103
|
+
this.options.transitionDuration,
|
104
|
+
this.options.transitionEasing,
|
105
|
+
function () {
|
106
|
+
deferred.resolveWith(node);
|
107
|
+
}
|
108
|
+
);
|
109
|
+
} else {
|
110
|
+
deferred.resolveWith(node);
|
111
|
+
}
|
112
|
+
return deferred;
|
113
|
+
},
|
114
|
+
|
115
|
+
_create: function () {
|
116
|
+
this._super();
|
117
|
+
this.element
|
118
|
+
.find('.fileupload-buttonbar')
|
119
|
+
.find('.fileinput-button').each(function () {
|
120
|
+
var input = $(this).find('input:file').detach();
|
121
|
+
$(this)
|
122
|
+
.button({icons: {primary: 'ui-icon-plusthick'}})
|
123
|
+
.append(input);
|
124
|
+
})
|
125
|
+
.end().find('.start')
|
126
|
+
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
|
127
|
+
.end().find('.cancel')
|
128
|
+
.button({icons: {primary: 'ui-icon-cancel'}})
|
129
|
+
.end().find('.delete')
|
130
|
+
.button({icons: {primary: 'ui-icon-trash'}})
|
131
|
+
.end().find('.progress').progressbar();
|
132
|
+
},
|
133
|
+
|
134
|
+
_destroy: function () {
|
135
|
+
this.element
|
136
|
+
.find('.fileupload-buttonbar')
|
137
|
+
.find('.fileinput-button').each(function () {
|
138
|
+
var input = $(this).find('input:file').detach();
|
139
|
+
$(this)
|
140
|
+
.button('destroy')
|
141
|
+
.append(input);
|
142
|
+
})
|
143
|
+
.end().find('.start')
|
144
|
+
.button('destroy')
|
145
|
+
.end().find('.cancel')
|
146
|
+
.button('destroy')
|
147
|
+
.end().find('.delete')
|
148
|
+
.button('destroy')
|
149
|
+
.end().find('.progress').progressbar('destroy');
|
150
|
+
this._super();
|
151
|
+
}
|
152
|
+
|
153
|
+
});
|
154
|
+
|
155
|
+
}));
|
@@ -0,0 +1,175 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload Processing Plugin 1.3.1
|
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
|
+
/* jshint nomen:false */
|
13
|
+
/* global define, require, window */
|
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
|
+
'./jquery.fileupload'
|
22
|
+
], factory);
|
23
|
+
} else if (typeof exports === 'object') {
|
24
|
+
// Node/CommonJS:
|
25
|
+
factory(require('jquery'));
|
26
|
+
} else {
|
27
|
+
// Browser globals:
|
28
|
+
factory(
|
29
|
+
window.jQuery
|
30
|
+
);
|
31
|
+
}
|
32
|
+
}(function ($) {
|
33
|
+
'use strict';
|
34
|
+
|
35
|
+
var originalAdd = $.blueimp.fileupload.prototype.options.add;
|
36
|
+
|
37
|
+
// The File Upload Processing plugin extends the fileupload widget
|
38
|
+
// with file processing functionality:
|
39
|
+
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
|
40
|
+
|
41
|
+
options: {
|
42
|
+
// The list of processing actions:
|
43
|
+
processQueue: [
|
44
|
+
/*
|
45
|
+
{
|
46
|
+
action: 'log',
|
47
|
+
type: 'debug'
|
48
|
+
}
|
49
|
+
*/
|
50
|
+
],
|
51
|
+
add: function (e, data) {
|
52
|
+
var $this = $(this);
|
53
|
+
data.process(function () {
|
54
|
+
return $this.fileupload('process', data);
|
55
|
+
});
|
56
|
+
originalAdd.call(this, e, data);
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
processActions: {
|
61
|
+
/*
|
62
|
+
log: function (data, options) {
|
63
|
+
console[options.type](
|
64
|
+
'Processing "' + data.files[data.index].name + '"'
|
65
|
+
);
|
66
|
+
}
|
67
|
+
*/
|
68
|
+
},
|
69
|
+
|
70
|
+
_processFile: function (data, originalData) {
|
71
|
+
var that = this,
|
72
|
+
dfd = $.Deferred().resolveWith(that, [data]),
|
73
|
+
chain = dfd.promise();
|
74
|
+
this._trigger('process', null, data);
|
75
|
+
$.each(data.processQueue, function (i, settings) {
|
76
|
+
var func = function (data) {
|
77
|
+
if (originalData.errorThrown) {
|
78
|
+
return $.Deferred()
|
79
|
+
.rejectWith(that, [originalData]).promise();
|
80
|
+
}
|
81
|
+
return that.processActions[settings.action].call(
|
82
|
+
that,
|
83
|
+
data,
|
84
|
+
settings
|
85
|
+
);
|
86
|
+
};
|
87
|
+
chain = chain.pipe(func, settings.always && func);
|
88
|
+
});
|
89
|
+
chain
|
90
|
+
.done(function () {
|
91
|
+
that._trigger('processdone', null, data);
|
92
|
+
that._trigger('processalways', null, data);
|
93
|
+
})
|
94
|
+
.fail(function () {
|
95
|
+
that._trigger('processfail', null, data);
|
96
|
+
that._trigger('processalways', null, data);
|
97
|
+
});
|
98
|
+
return chain;
|
99
|
+
},
|
100
|
+
|
101
|
+
// Replaces the settings of each processQueue item that
|
102
|
+
// are strings starting with an "@", using the remaining
|
103
|
+
// substring as key for the option map,
|
104
|
+
// e.g. "@autoUpload" is replaced with options.autoUpload:
|
105
|
+
_transformProcessQueue: function (options) {
|
106
|
+
var processQueue = [];
|
107
|
+
$.each(options.processQueue, function () {
|
108
|
+
var settings = {},
|
109
|
+
action = this.action,
|
110
|
+
prefix = this.prefix === true ? action : this.prefix;
|
111
|
+
$.each(this, function (key, value) {
|
112
|
+
if ($.type(value) === 'string' &&
|
113
|
+
value.charAt(0) === '@') {
|
114
|
+
settings[key] = options[
|
115
|
+
value.slice(1) || (prefix ? prefix +
|
116
|
+
key.charAt(0).toUpperCase() + key.slice(1) : key)
|
117
|
+
];
|
118
|
+
} else {
|
119
|
+
settings[key] = value;
|
120
|
+
}
|
121
|
+
|
122
|
+
});
|
123
|
+
processQueue.push(settings);
|
124
|
+
});
|
125
|
+
options.processQueue = processQueue;
|
126
|
+
},
|
127
|
+
|
128
|
+
// Returns the number of files currently in the processsing queue:
|
129
|
+
processing: function () {
|
130
|
+
return this._processing;
|
131
|
+
},
|
132
|
+
|
133
|
+
// Processes the files given as files property of the data parameter,
|
134
|
+
// returns a Promise object that allows to bind callbacks:
|
135
|
+
process: function (data) {
|
136
|
+
var that = this,
|
137
|
+
options = $.extend({}, this.options, data);
|
138
|
+
if (options.processQueue && options.processQueue.length) {
|
139
|
+
this._transformProcessQueue(options);
|
140
|
+
if (this._processing === 0) {
|
141
|
+
this._trigger('processstart');
|
142
|
+
}
|
143
|
+
$.each(data.files, function (index) {
|
144
|
+
var opts = index ? $.extend({}, options) : options,
|
145
|
+
func = function () {
|
146
|
+
if (data.errorThrown) {
|
147
|
+
return $.Deferred()
|
148
|
+
.rejectWith(that, [data]).promise();
|
149
|
+
}
|
150
|
+
return that._processFile(opts, data);
|
151
|
+
};
|
152
|
+
opts.index = index;
|
153
|
+
that._processing += 1;
|
154
|
+
that._processingQueue = that._processingQueue.pipe(func, func)
|
155
|
+
.always(function () {
|
156
|
+
that._processing -= 1;
|
157
|
+
if (that._processing === 0) {
|
158
|
+
that._trigger('processstop');
|
159
|
+
}
|
160
|
+
});
|
161
|
+
});
|
162
|
+
}
|
163
|
+
return this._processingQueue;
|
164
|
+
},
|
165
|
+
|
166
|
+
_create: function () {
|
167
|
+
this._super();
|
168
|
+
this._processing = 0;
|
169
|
+
this._processingQueue = $.Deferred().resolveWith(this)
|
170
|
+
.promise();
|
171
|
+
}
|
172
|
+
|
173
|
+
});
|
174
|
+
|
175
|
+
}));
|