Skip to content

Commit 4527e50

Browse files
committed
Add jQuery File Upload jQuery UI Plugin 8.7.0
1 parent 894e079 commit 4527e50

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
return node;
70+
},
71+
72+
_renderDownload: function (func, files) {
73+
var node = this._super(func, files),
74+
showIconText = $(window).width() > 480;
75+
node.find('.delete').button({
76+
icons: {primary: 'ui-icon-trash'},
77+
text: showIconText
78+
});
79+
return node;
80+
},
81+
82+
_transition: function (node) {
83+
var deferred = $.Deferred();
84+
if (node.hasClass('fade')) {
85+
node.fadeToggle(
86+
this.options.transitionDuration,
87+
this.options.transitionEasing,
88+
function () {
89+
deferred.resolveWith(node);
90+
}
91+
);
92+
} else {
93+
deferred.resolveWith(node);
94+
}
95+
return deferred;
96+
},
97+
98+
_create: function () {
99+
this._super();
100+
this.element
101+
.find('.fileupload-buttonbar')
102+
.find('.fileinput-button').each(function () {
103+
var input = $(this).find('input:file').detach();
104+
$(this)
105+
.button({icons: {primary: 'ui-icon-plusthick'}})
106+
.append(input);
107+
})
108+
.end().find('.start')
109+
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
110+
.end().find('.cancel')
111+
.button({icons: {primary: 'ui-icon-cancel'}})
112+
.end().find('.delete')
113+
.button({icons: {primary: 'ui-icon-trash'}})
114+
.end().find('.progress').progressbar();
115+
},
116+
117+
_destroy: function () {
118+
this.element
119+
.find('.fileupload-buttonbar')
120+
.find('.fileinput-button').each(function () {
121+
var input = $(this).find('input:file').detach();
122+
$(this)
123+
.button('destroy')
124+
.append(input);
125+
})
126+
.end().find('.start')
127+
.button('destroy')
128+
.end().find('.cancel')
129+
.button('destroy')
130+
.end().find('.delete')
131+
.button('destroy')
132+
.end().find('.progress').progressbar('destroy');
133+
this._super();
134+
}
135+
136+
});
137+
138+
}));

0 commit comments

Comments
 (0)