plupload-rails 1.1.0 → 1.2.0
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 +4 -4
- data/README.md +34 -35
- data/lib/plupload/rails/version.rb +2 -2
- data/vendor/assets/images/jquery.plupload.queue/backgrounds.gif +0 -0
- data/vendor/assets/images/jquery.plupload.queue/buttons-disabled.png +0 -0
- data/vendor/assets/images/jquery.plupload.queue/buttons.png +0 -0
- data/vendor/assets/images/jquery.plupload.queue/delete.gif +0 -0
- data/vendor/assets/images/jquery.plupload.queue/done.gif +0 -0
- data/vendor/assets/images/jquery.plupload.queue/error.gif +0 -0
- data/vendor/assets/images/jquery.plupload.queue/throbber.gif +0 -0
- data/vendor/assets/images/jquery.plupload.queue/transp50.png +0 -0
- data/vendor/assets/images/jquery.ui.plupload/loading.gif +0 -0
- data/vendor/assets/images/jquery.ui.plupload/plupload.png +0 -0
- data/vendor/assets/javascripts/jquery.plupload.queue.js +27 -17
- data/vendor/assets/javascripts/jquery.ui.plupload.js +308 -217
- data/vendor/assets/javascripts/moxie.js +906 -661
- data/vendor/assets/javascripts/plupload.dev.js +727 -537
- data/vendor/assets/javascripts/plupload/i18n/ar.js +2 -0
- data/vendor/assets/javascripts/plupload/i18n/bs.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/ca.js +2 -0
- data/vendor/assets/javascripts/plupload/i18n/cs.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/cy.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/da.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/de.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/el.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/en.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/es.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/et.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/fa.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/fi.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/fr.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/he.js +2 -0
- data/vendor/assets/javascripts/plupload/i18n/hr.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/hu.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/hy.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/id.js +2 -0
- data/vendor/assets/javascripts/plupload/i18n/it.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/ja.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/ka.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/kk.js +2 -0
- data/vendor/assets/javascripts/plupload/i18n/ko.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/lt.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/lv.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/nl.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/pl.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/pt_BR.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/ro.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/ru.js +2 -1
- data/vendor/assets/javascripts/plupload/i18n/sk.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/sr.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/sv.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/th_TH.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/tr.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/uk_UA.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/zh_CN.js +1 -0
- data/vendor/assets/javascripts/plupload/i18n/zh_TW.js +2 -0
- data/vendor/assets/misc/Moxie.swf +0 -0
- data/vendor/assets/misc/Moxie.xap +0 -0
- data/vendor/assets/stylesheets/{jquery.plupload.queue.scss → jquery.plupload.queue.css.erb} +15 -11
- data/vendor/assets/stylesheets/{jquery.ui.plupload.scss → jquery.ui.plupload.css.erb} +3 -3
- metadata +18 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0a4b034445c763d70d1ac0ed530bd21f3847bca
|
4
|
+
data.tar.gz: 4183a59bcb2e0edd678057a3852c7c12418379ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dadab599c2c00f1fb5a5ff0fabf8dda446011e9ad939eb4b69144ddbfa31f0a5f0b4ac3407bf1e926860cf516b05b9ed3b89b9bcac626a846fa64128e99a623
|
7
|
+
data.tar.gz: 35557515d0e32c73fdcc0c662d226fb0faa66b6735fcc91df8a8d9771445bab23dcd2c1c10b9d001f9e5ed3ce968f642b7fff1189adb749d7bd2975c63ec9489
|
data/README.md
CHANGED
@@ -9,9 +9,9 @@ Install
|
|
9
9
|
|
10
10
|
Just add it got your Gemfile:
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
```ruby
|
13
|
+
gem 'plupload-rails'
|
14
|
+
```
|
15
15
|
|
16
16
|
Quick Start
|
17
17
|
--
|
@@ -31,45 +31,44 @@ Add to your application.js:
|
|
31
31
|
//= require jquery.plupload.queue
|
32
32
|
|
33
33
|
|
34
|
-
Add to your application
|
35
|
-
|
36
|
-
@import "jquery.plupload.queue";
|
34
|
+
Add to your application stylesheet:
|
37
35
|
|
36
|
+
//= require jquery.plupload.queue
|
38
37
|
|
39
|
-
Alternatively (if you're not using SASS or SCSS), add the require to your application.css:
|
40
|
-
|
41
|
-
= require jquery.plupload.queue
|
42
38
|
|
43
39
|
Simple example Haml for your views:
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
41
|
+
```haml
|
42
|
+
div#uploader
|
43
|
+
:javascript
|
44
|
+
$(function(){
|
45
|
+
$("#uploader").pluploadQueue({
|
46
|
+
runtimes: 'gears,flash,silverlight,browserplus,html5',
|
47
|
+
url: '#{images_path}',
|
48
|
+
multipart_params: {
|
49
|
+
'#{request_forgery_protection_token}': '#{form_authenticity_token}',
|
50
|
+
'#{Rails.application.config.session_options[:key]}': '#{request.session_options[:id]}'
|
51
|
+
}
|
52
|
+
});
|
53
|
+
});
|
54
|
+
```
|
57
55
|
|
58
56
|
And the same in ERB:
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
```erb
|
59
|
+
<script>
|
60
|
+
$(function(){
|
61
|
+
$("#uploader").pluploadQueue({
|
62
|
+
runtimes: 'html5,flash,silverlight',
|
63
|
+
url: '<%= sink_hole_path %>',
|
64
|
+
multipart_params: {
|
65
|
+
'<%= request_forgery_protection_token %>': '<%= form_authenticity_token %>',
|
66
|
+
'<%= Rails.application.config.session_options[:key] %>': '<%= request.session_options[:id] %>'
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
</script>
|
71
|
+
```
|
73
72
|
|
74
73
|
Updating
|
75
74
|
--
|
@@ -81,4 +80,4 @@ License
|
|
81
80
|
|
82
81
|
Dual licensed under the [GPLv2 license](GPL-LICENSE.txt) and the [MIT license](MIT-LICENSE.txt). Plupload itself (including the JS, CSS, images, the Silverlight and Flash components) is licensed under GPLv2, unless you have acquired a [commercial license](http://plupload.com/license.php).
|
83
82
|
|
84
|
-
Copyright © 2011-2013 Corin Langosch and contributors
|
83
|
+
Copyright © 2011-2013 [Corin Langosch](http://www.corinlangosch.com) and contributors
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -39,7 +39,7 @@ used as it is.
|
|
39
39
|
var uploader = $('#uploader').pluploadQueue();
|
40
40
|
|
41
41
|
uploader.bind('FilesAdded', function() {
|
42
|
-
|
42
|
+
|
43
43
|
// Autostart
|
44
44
|
setTimeout(uploader.start, 1); // "detach" from the main thread
|
45
45
|
});
|
@@ -73,7 +73,7 @@ used as it is.
|
|
73
73
|
@param {Boolean} [settings.rename=false] Enable ability to rename files in the queue.
|
74
74
|
@param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure.
|
75
75
|
*/
|
76
|
-
(function(
|
76
|
+
(function($, o) {
|
77
77
|
var uploaders = {};
|
78
78
|
|
79
79
|
function _(str) {
|
@@ -154,11 +154,18 @@ used as it is.
|
|
154
154
|
contents_bak = target.html();
|
155
155
|
renderUI(id, target);
|
156
156
|
|
157
|
-
|
157
|
+
settings = $.extend({
|
158
158
|
dragdrop : true,
|
159
159
|
browse_button : id + '_browse',
|
160
160
|
container : id
|
161
|
-
}, settings)
|
161
|
+
}, settings);
|
162
|
+
|
163
|
+
// Enable drag/drop (see PostInit handler as well)
|
164
|
+
if (settings.dragdrop) {
|
165
|
+
settings.drop_element = id + '_filelist';
|
166
|
+
}
|
167
|
+
|
168
|
+
uploader = new plupload.Uploader(settings);
|
162
169
|
|
163
170
|
uploaders[id] = uploader;
|
164
171
|
|
@@ -183,7 +190,7 @@ used as it is.
|
|
183
190
|
|
184
191
|
var icon = $('#' + file.id).attr('class', actionClass).find('a').css('display', 'block');
|
185
192
|
if (file.hint) {
|
186
|
-
icon.attr('title', file.hint);
|
193
|
+
icon.attr('title', file.hint);
|
187
194
|
}
|
188
195
|
}
|
189
196
|
|
@@ -191,7 +198,7 @@ used as it is.
|
|
191
198
|
$('span.plupload_total_status', target).html(uploader.total.percent + '%');
|
192
199
|
$('div.plupload_progress_bar', target).css('width', uploader.total.percent + '%');
|
193
200
|
$('span.plupload_upload_status', target).html(
|
194
|
-
_('Uploaded %d/%d files')
|
201
|
+
o.sprintf(_('Uploaded %d/%d files'), uploader.total.uploaded, uploader.files.length)
|
195
202
|
);
|
196
203
|
}
|
197
204
|
|
@@ -208,7 +215,7 @@ used as it is.
|
|
208
215
|
|
209
216
|
inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_name" value="' + plupload.xmlEncode(file.name) + '" />';
|
210
217
|
inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_status" value="' + (file.status == plupload.DONE ? 'done' : 'failed') + '" />';
|
211
|
-
|
218
|
+
|
212
219
|
inputCount++;
|
213
220
|
|
214
221
|
$('#' + id + '_count').val(inputCount);
|
@@ -240,7 +247,7 @@ used as it is.
|
|
240
247
|
if (uploader.total.queued === 0) {
|
241
248
|
$('span.plupload_add_text', target).html(_('Add Files'));
|
242
249
|
} else {
|
243
|
-
$('span.plupload_add_text', target).html(_('%d files queued')
|
250
|
+
$('span.plupload_add_text', target).html(o.sprintf(_('%d files queued'), uploader.total.queued));
|
244
251
|
}
|
245
252
|
|
246
253
|
$('a.plupload_start', target).toggleClass('plupload_disabled', uploader.files.length == (uploader.total.uploaded + uploader.total.failed));
|
@@ -301,12 +308,6 @@ used as it is.
|
|
301
308
|
});
|
302
309
|
}
|
303
310
|
|
304
|
-
|
305
|
-
// Enable drag/drop (see PostInit handler as well)
|
306
|
-
if (up.settings.dragdrop) {
|
307
|
-
up.settings.drop_element = id + '_filelist';
|
308
|
-
}
|
309
|
-
|
310
311
|
$('#' + id + '_container').attr('title', 'Using runtime: ' + res.runtime);
|
311
312
|
|
312
313
|
$('a.plupload_start', target).click(function(e) {
|
@@ -342,7 +343,7 @@ used as it is.
|
|
342
343
|
if (err.code == plupload.FILE_EXTENSION_ERROR) {
|
343
344
|
alert(_("Error: Invalid file extension:") + " " + file.name);
|
344
345
|
}
|
345
|
-
|
346
|
+
|
346
347
|
file.hint = message;
|
347
348
|
$('#' + file.id).attr('class', 'plupload_failed').find('a').css('display', 'block').attr('title', message);
|
348
349
|
}
|
@@ -385,7 +386,16 @@ used as it is.
|
|
385
386
|
}
|
386
387
|
});
|
387
388
|
|
388
|
-
uploader.bind('
|
389
|
+
uploader.bind('FilesAdded', updateList);
|
390
|
+
|
391
|
+
uploader.bind('FilesRemoved', function() {
|
392
|
+
// since the whole file list is redrawn for every change in the queue
|
393
|
+
// we need to scroll back to the file removal point to avoid annoying
|
394
|
+
// scrolling to the bottom bug (see #926)
|
395
|
+
var scrollTop = $('#' + id + '_filelist').scrollTop();
|
396
|
+
updateList();
|
397
|
+
$('#' + id + '_filelist').scrollTop(scrollTop);
|
398
|
+
});
|
389
399
|
|
390
400
|
uploader.bind('FileUploaded', function(up, file) {
|
391
401
|
handleStatus(file);
|
@@ -411,4 +421,4 @@ used as it is.
|
|
411
421
|
return uploaders[$(this[0]).attr('id')];
|
412
422
|
}
|
413
423
|
};
|
414
|
-
})(jQuery);
|
424
|
+
})(jQuery, mOxie);
|
@@ -12,7 +12,7 @@
|
|
12
12
|
* jquery.ui.widget.js
|
13
13
|
* jquery.ui.button.js
|
14
14
|
* jquery.ui.progressbar.js
|
15
|
-
*
|
15
|
+
*
|
16
16
|
* Optionally:
|
17
17
|
* jquery.ui.sortable.js
|
18
18
|
*/
|
@@ -22,11 +22,11 @@
|
|
22
22
|
/**
|
23
23
|
jQuery UI based implementation of the Plupload API - multi-runtime file uploading API.
|
24
24
|
|
25
|
-
To use the widget you must include _jQuery_ and _jQuery UI_ bundle (including `ui.core`, `ui.widget`, `ui.button`,
|
25
|
+
To use the widget you must include _jQuery_ and _jQuery UI_ bundle (including `ui.core`, `ui.widget`, `ui.button`,
|
26
26
|
`ui.progressbar` and `ui.sortable`).
|
27
27
|
|
28
|
-
In general the widget is designed the way that you do not usually need to do anything to it after you instantiate it.
|
29
|
-
But! You still can intervenue, to some extent, in case you need to. Although, due to the fact that widget is based on
|
28
|
+
In general the widget is designed the way that you do not usually need to do anything to it after you instantiate it.
|
29
|
+
But! You still can intervenue, to some extent, in case you need to. Although, due to the fact that widget is based on
|
30
30
|
_jQuery UI_ widget factory, there are some specifics. See examples below for more details.
|
31
31
|
|
32
32
|
@example
|
@@ -58,7 +58,7 @@ _jQuery UI_ widget factory, there are some specifics. See examples below for mor
|
|
58
58
|
@example
|
59
59
|
// Subscribing to the events...
|
60
60
|
// ... on initialization:
|
61
|
-
$('#uploader').plupload({
|
61
|
+
$('#uploader').plupload({
|
62
62
|
...
|
63
63
|
viewchanged: function(event, args) {
|
64
64
|
// stuff ...
|
@@ -98,10 +98,10 @@ _jQuery UI_ widget factory, there are some specifics. See examples below for mor
|
|
98
98
|
@param {Boolean} [settings.dragdrop=true] Enable ability to add file to the queue by drag'n'dropping them from the desktop.
|
99
99
|
@param {Boolean} [settings.rename=false] Enable ability to rename files in the queue.
|
100
100
|
@param {Boolean} [settings.sortable=false] Enable ability to sort files in the queue, changing their uploading priority.
|
101
|
-
@param {Object} [settings.buttons] Control the visibility of functional buttons.
|
101
|
+
@param {Object} [settings.buttons] Control the visibility of functional buttons.
|
102
102
|
@param {Boolean} [settings.buttons.browse=true] Display browse button.
|
103
103
|
@param {Boolean} [settings.buttons.start=true] Display start button.
|
104
|
-
@param {Boolean} [settings.buttons.stop=true] Display stop button.
|
104
|
+
@param {Boolean} [settings.buttons.stop=true] Display stop button.
|
105
105
|
@param {Object} [settings.views] Control various views of the file queue.
|
106
106
|
@param {Boolean} [settings.views.list=true] Enable list view.
|
107
107
|
@param {Boolean} [settings.views.thumbs=false] Enable thumbs view.
|
@@ -110,7 +110,7 @@ _jQuery UI_ widget factory, there are some specifics. See examples below for mor
|
|
110
110
|
@param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure.
|
111
111
|
@param {Number} [settings.max_file_count=0] Limit the number of files user is able to upload in one go, autosets _multiple_queues_ to _false_ (default is 0 - no limit).
|
112
112
|
*/
|
113
|
-
(function(window, document, plupload, $) {
|
113
|
+
(function(window, document, plupload, o, $) {
|
114
114
|
|
115
115
|
/**
|
116
116
|
Dispatched when the widget is initialized and ready.
|
@@ -195,13 +195,13 @@ Dispatched when error of some kind is detected.
|
|
195
195
|
@param {Enum} status Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE.
|
196
196
|
*/
|
197
197
|
|
198
|
-
var uploaders = {};
|
199
|
-
|
198
|
+
var uploaders = {};
|
199
|
+
|
200
200
|
function _(str) {
|
201
201
|
return plupload.translate(str) || str;
|
202
202
|
}
|
203
203
|
|
204
|
-
function renderUI(obj) {
|
204
|
+
function renderUI(obj) {
|
205
205
|
obj.id = obj.attr('id');
|
206
206
|
|
207
207
|
obj.html(
|
@@ -213,8 +213,8 @@ function renderUI(obj) {
|
|
213
213
|
'<div class="plupload_header_title">' + _('Select files') + '</div>' +
|
214
214
|
'<div class="plupload_header_text">' + _('Add files to the upload queue and click the start button.') + '</div>' +
|
215
215
|
'<div class="plupload_view_switch">' +
|
216
|
-
'<input type="radio" id="'+obj.id+'_view_list" name="view_mode_'+obj.id+'" checked="checked"
|
217
|
-
'<input type="radio" id="'+obj.id+'_view_thumbs" name="view_mode_'+obj.id+'"
|
216
|
+
'<input type="radio" id="'+obj.id+'_view_list" name="view_mode_'+obj.id+'" checked="checked" /><label class="plupload_button" for="'+obj.id+'_view_list" data-view="list">' + _('List') + '</label>' +
|
217
|
+
'<input type="radio" id="'+obj.id+'_view_thumbs" name="view_mode_'+obj.id+'" /><label class="plupload_button" for="'+obj.id+'_view_thumbs" data-view="thumbs">' + _('Thumbnails') + '</label>' +
|
218
218
|
'</div>' +
|
219
219
|
'</div>' +
|
220
220
|
'</div>' +
|
@@ -233,7 +233,7 @@ function renderUI(obj) {
|
|
233
233
|
'<ul class="plupload_filelist_content"> </ul>' +
|
234
234
|
'<div class="plupload_clearer"> </div>' +
|
235
235
|
'</div>' +
|
236
|
-
|
236
|
+
|
237
237
|
'<table class="plupload_filelist plupload_filelist_footer ui-widget-header">' +
|
238
238
|
'<tr>' +
|
239
239
|
'<td class="plupload_cell plupload_file_name">' +
|
@@ -269,22 +269,20 @@ function renderUI(obj) {
|
|
269
269
|
$.widget("ui.plupload", {
|
270
270
|
|
271
271
|
widgetEventPrefix: '',
|
272
|
-
|
273
|
-
imgs: {},
|
274
|
-
|
272
|
+
|
275
273
|
contents_bak: '',
|
276
|
-
|
274
|
+
|
277
275
|
options: {
|
278
276
|
browse_button_hover: 'ui-state-hover',
|
279
277
|
browse_button_active: 'ui-state-active',
|
280
|
-
|
278
|
+
|
281
279
|
// widget specific
|
282
|
-
dragdrop : true,
|
280
|
+
dragdrop : true,
|
283
281
|
multiple_queues: true, // re-use widget by default
|
284
282
|
buttons: {
|
285
283
|
browse: true,
|
286
284
|
start: true,
|
287
|
-
stop: true
|
285
|
+
stop: true
|
288
286
|
},
|
289
287
|
views: {
|
290
288
|
list: true,
|
@@ -297,9 +295,9 @@ $.widget("ui.plupload", {
|
|
297
295
|
rename: false,
|
298
296
|
max_file_count: 0 // unlimited
|
299
297
|
},
|
300
|
-
|
298
|
+
|
301
299
|
FILE_COUNT_ERROR: -9001,
|
302
|
-
|
300
|
+
|
303
301
|
_create: function() {
|
304
302
|
var id = this.element.attr('id');
|
305
303
|
if (!id) {
|
@@ -307,30 +305,30 @@ $.widget("ui.plupload", {
|
|
307
305
|
this.element.attr('id', id);
|
308
306
|
}
|
309
307
|
this.id = id;
|
310
|
-
|
308
|
+
|
311
309
|
// backup the elements initial state
|
312
310
|
this.contents_bak = this.element.html();
|
313
311
|
renderUI(this.element);
|
314
|
-
|
312
|
+
|
315
313
|
// container, just in case
|
316
|
-
this.container = $('.plupload_container', this.element).attr('id', id + '_container');
|
314
|
+
this.container = $('.plupload_container', this.element).attr('id', id + '_container');
|
317
315
|
|
318
316
|
this.content = $('.plupload_content', this.element);
|
319
|
-
|
317
|
+
|
320
318
|
if ($.fn.resizable) {
|
321
|
-
this.container.resizable({
|
319
|
+
this.container.resizable({
|
322
320
|
handles: 's',
|
323
321
|
minHeight: 300
|
324
322
|
});
|
325
323
|
}
|
326
|
-
|
324
|
+
|
327
325
|
// list of files, may become sortable
|
328
326
|
this.filelist = $('.plupload_filelist_content', this.container)
|
329
327
|
.attr({
|
330
328
|
id: id + '_filelist',
|
331
329
|
unselectable: 'on'
|
332
330
|
});
|
333
|
-
|
331
|
+
|
334
332
|
|
335
333
|
// buttons
|
336
334
|
this.browse_button = $('.plupload_add', this.container).attr('id', id + '_browse');
|
@@ -338,22 +336,22 @@ $.widget("ui.plupload", {
|
|
338
336
|
this.stop_button = $('.plupload_stop', this.container).attr('id', id + '_stop');
|
339
337
|
this.thumbs_switcher = $('#' + id + '_view_thumbs');
|
340
338
|
this.list_switcher = $('#' + id + '_view_list');
|
341
|
-
|
339
|
+
|
342
340
|
if ($.ui.button) {
|
343
341
|
this.browse_button.button({
|
344
342
|
icons: { primary: 'ui-icon-circle-plus' },
|
345
343
|
disabled: true
|
346
344
|
});
|
347
|
-
|
345
|
+
|
348
346
|
this.start_button.button({
|
349
347
|
icons: { primary: 'ui-icon-circle-arrow-e' },
|
350
348
|
disabled: true
|
351
349
|
});
|
352
|
-
|
350
|
+
|
353
351
|
this.stop_button.button({
|
354
352
|
icons: { primary: 'ui-icon-circle-close' }
|
355
353
|
});
|
356
|
-
|
354
|
+
|
357
355
|
this.list_switcher.button({
|
358
356
|
text: false,
|
359
357
|
icons: { secondary: "ui-icon-grip-dotted-horizontal" }
|
@@ -364,21 +362,21 @@ $.widget("ui.plupload", {
|
|
364
362
|
icons: { secondary: "ui-icon-image" }
|
365
363
|
});
|
366
364
|
}
|
367
|
-
|
365
|
+
|
368
366
|
// progressbar
|
369
|
-
this.progressbar = $('.plupload_progress_container', this.container);
|
370
|
-
|
367
|
+
this.progressbar = $('.plupload_progress_container', this.container);
|
368
|
+
|
371
369
|
if ($.ui.progressbar) {
|
372
370
|
this.progressbar.progressbar();
|
373
371
|
}
|
374
|
-
|
372
|
+
|
375
373
|
// counter
|
376
374
|
this.counter = $('.plupload_count', this.element)
|
377
375
|
.attr({
|
378
376
|
id: id + '_count',
|
379
377
|
name: id + '_count'
|
380
378
|
});
|
381
|
-
|
379
|
+
|
382
380
|
// initialize uploader instance
|
383
381
|
this._initUploader();
|
384
382
|
},
|
@@ -387,7 +385,7 @@ $.widget("ui.plupload", {
|
|
387
385
|
var self = this
|
388
386
|
, id = this.id
|
389
387
|
, uploader
|
390
|
-
, options = {
|
388
|
+
, options = {
|
391
389
|
container: id + '_buttons',
|
392
390
|
browse_button: id + '_browse'
|
393
391
|
}
|
@@ -400,51 +398,48 @@ $.widget("ui.plupload", {
|
|
400
398
|
options.drop_element = this.id + '_dropbox';
|
401
399
|
}
|
402
400
|
|
401
|
+
uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend(this.options, options));
|
402
|
+
|
403
403
|
if (self.options.views.thumbs) {
|
404
|
-
|
405
|
-
self.options.required_features += ",display_media";
|
406
|
-
} else {
|
407
|
-
self.options.required_features = "display_media";
|
408
|
-
}
|
404
|
+
uploader.settings.required_features.display_media = true;
|
409
405
|
}
|
410
406
|
|
411
|
-
uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend(this.options, options));
|
412
407
|
|
413
|
-
uploader.bind('Error', function(up, err) {
|
408
|
+
uploader.bind('Error', function(up, err) {
|
414
409
|
var message, details = "";
|
415
410
|
|
416
411
|
message = '<strong>' + err.message + '</strong>';
|
417
|
-
|
412
|
+
|
418
413
|
switch (err.code) {
|
419
414
|
case plupload.FILE_EXTENSION_ERROR:
|
420
415
|
details = o.sprintf(_("File: %s"), err.file.name);
|
421
416
|
break;
|
422
|
-
|
417
|
+
|
423
418
|
case plupload.FILE_SIZE_ERROR:
|
424
|
-
details = o.sprintf(_("File: %
|
419
|
+
details = o.sprintf(_("File: %s, size: %d, max file size: %d"), err.file.name, err.file.size, plupload.parseSize(self.options.max_file_size));
|
425
420
|
break;
|
426
421
|
|
427
422
|
case plupload.FILE_DUPLICATE_ERROR:
|
428
423
|
details = o.sprintf(_("%s already present in the queue."), err.file.name);
|
429
424
|
break;
|
430
|
-
|
425
|
+
|
431
426
|
case self.FILE_COUNT_ERROR:
|
432
427
|
details = o.sprintf(_("Upload element accepts only %d file(s) at a time. Extra files were stripped."), self.options.max_file_count);
|
433
428
|
break;
|
434
|
-
|
429
|
+
|
435
430
|
case plupload.IMAGE_FORMAT_ERROR :
|
436
431
|
details = _("Image format either wrong or not supported.");
|
437
|
-
break;
|
438
|
-
|
432
|
+
break;
|
433
|
+
|
439
434
|
case plupload.IMAGE_MEMORY_ERROR :
|
440
435
|
details = _("Runtime ran out of available memory.");
|
441
436
|
break;
|
442
|
-
|
437
|
+
|
443
438
|
/* // This needs a review
|
444
439
|
case plupload.IMAGE_DIMENSIONS_ERROR :
|
445
440
|
details = o.sprintf(_('Resoultion out of boundaries! <b>%s</b> runtime supports images only up to %wx%hpx.'), up.runtime, up.features.maxWidth, up.features.maxHeight);
|
446
441
|
break; */
|
447
|
-
|
442
|
+
|
448
443
|
case plupload.HTTP_ERROR:
|
449
444
|
details = _("Upload URL might be wrong or doesn't exist.");
|
450
445
|
break;
|
@@ -464,8 +459,8 @@ $.widget("ui.plupload", {
|
|
464
459
|
}
|
465
460
|
});
|
466
461
|
|
467
|
-
|
468
|
-
uploader.bind('PostInit', function(up) {
|
462
|
+
|
463
|
+
uploader.bind('PostInit', function(up) {
|
469
464
|
// all buttons are optional, so they can be disabled and hidden
|
470
465
|
if (!self.options.buttons.browse) {
|
471
466
|
self.browse_button.button('disable').hide();
|
@@ -473,17 +468,17 @@ $.widget("ui.plupload", {
|
|
473
468
|
} else {
|
474
469
|
self.browse_button.button('enable');
|
475
470
|
}
|
476
|
-
|
471
|
+
|
477
472
|
if (!self.options.buttons.start) {
|
478
473
|
self.start_button.button('disable').hide();
|
479
|
-
}
|
480
|
-
|
474
|
+
}
|
475
|
+
|
481
476
|
if (!self.options.buttons.stop) {
|
482
477
|
self.stop_button.button('disable').hide();
|
483
478
|
}
|
484
|
-
|
479
|
+
|
485
480
|
if (!self.options.unique_names && self.options.rename) {
|
486
|
-
self._enableRenaming();
|
481
|
+
self._enableRenaming();
|
487
482
|
}
|
488
483
|
|
489
484
|
if (self.options.dragdrop && up.features.dragdrop) {
|
@@ -491,7 +486,7 @@ $.widget("ui.plupload", {
|
|
491
486
|
}
|
492
487
|
|
493
488
|
self._enableViewSwitcher();
|
494
|
-
|
489
|
+
|
495
490
|
self.start_button.click(function(e) {
|
496
491
|
if (!$(this).button('option', 'disabled')) {
|
497
492
|
self.start();
|
@@ -506,8 +501,8 @@ $.widget("ui.plupload", {
|
|
506
501
|
|
507
502
|
self._trigger('ready', null, { up: up });
|
508
503
|
});
|
509
|
-
|
510
|
-
|
504
|
+
|
505
|
+
|
511
506
|
// check if file count doesn't exceed the limit
|
512
507
|
if (self.options.max_file_count) {
|
513
508
|
self.options.multiple_queues = false; // one go only
|
@@ -516,10 +511,10 @@ $.widget("ui.plupload", {
|
|
516
511
|
var selectedCount = selectedFiles.length
|
517
512
|
, extraCount = up.files.length + selectedCount - self.options.max_file_count
|
518
513
|
;
|
519
|
-
|
514
|
+
|
520
515
|
if (extraCount > 0) {
|
521
516
|
selectedFiles.splice(selectedCount - extraCount, extraCount);
|
522
|
-
|
517
|
+
|
523
518
|
up.trigger('Error', {
|
524
519
|
code : self.FILE_COUNT_ERROR,
|
525
520
|
message : _('File count error.')
|
@@ -527,14 +522,24 @@ $.widget("ui.plupload", {
|
|
527
522
|
}
|
528
523
|
});
|
529
524
|
}
|
530
|
-
|
531
|
-
// uploader internal events must run first
|
525
|
+
|
526
|
+
// uploader internal events must run first
|
532
527
|
uploader.init();
|
533
528
|
|
529
|
+
uploader.bind('FileFiltered', function(up, file) {
|
530
|
+
self._addFiles(file);
|
531
|
+
});
|
532
|
+
|
534
533
|
uploader.bind('FilesAdded', function(up, files) {
|
535
|
-
self._addFiles(files);
|
536
534
|
self._trigger('selected', null, { up: up, files: files } );
|
537
535
|
|
536
|
+
// re-enable sortable
|
537
|
+
if (self.options.sortable && $.ui.sortable) {
|
538
|
+
self._enableSortingList();
|
539
|
+
}
|
540
|
+
|
541
|
+
self._trigger('updatelist', null, { filelist: self.filelist });
|
542
|
+
|
538
543
|
if (self.options.autostart) {
|
539
544
|
// set a little delay to make sure that QueueChanged triggered by the core has time to complete
|
540
545
|
setTimeout(function() {
|
@@ -542,48 +547,43 @@ $.widget("ui.plupload", {
|
|
542
547
|
}, 10);
|
543
548
|
}
|
544
549
|
});
|
545
|
-
|
550
|
+
|
546
551
|
uploader.bind('FilesRemoved', function(up, files) {
|
547
552
|
self._trigger('removed', null, { up: up, files: files } );
|
548
553
|
});
|
549
|
-
|
550
|
-
uploader.bind('QueueChanged', function() {
|
551
|
-
self._handleState();
|
552
|
-
self._updateTotalProgress();
|
553
|
-
});
|
554
|
-
|
555
|
-
uploader.bind('StateChanged', function() {
|
554
|
+
|
555
|
+
uploader.bind('QueueChanged StateChanged', function() {
|
556
556
|
self._handleState();
|
557
557
|
});
|
558
|
-
|
558
|
+
|
559
559
|
uploader.bind('UploadFile', function(up, file) {
|
560
560
|
self._handleFileStatus(file);
|
561
561
|
});
|
562
|
-
|
562
|
+
|
563
563
|
uploader.bind('FileUploaded', function(up, file) {
|
564
564
|
self._handleFileStatus(file);
|
565
565
|
self._trigger('uploaded', null, { up: up, file: file } );
|
566
566
|
});
|
567
|
-
|
567
|
+
|
568
568
|
uploader.bind('UploadProgress', function(up, file) {
|
569
569
|
self._handleFileStatus(file);
|
570
570
|
self._updateTotalProgress();
|
571
571
|
self._trigger('progress', null, { up: up, file: file } );
|
572
572
|
});
|
573
|
-
|
573
|
+
|
574
574
|
uploader.bind('UploadComplete', function(up, files) {
|
575
|
-
self._addFormFields();
|
575
|
+
self._addFormFields();
|
576
576
|
self._trigger('complete', null, { up: up, files: files } );
|
577
577
|
});
|
578
578
|
},
|
579
579
|
|
580
|
-
|
580
|
+
|
581
581
|
_setOption: function(key, value) {
|
582
582
|
var self = this;
|
583
583
|
|
584
|
-
if (key == 'buttons' && typeof(value) == 'object') {
|
584
|
+
if (key == 'buttons' && typeof(value) == 'object') {
|
585
585
|
value = $.extend(self.options.buttons, value);
|
586
|
-
|
586
|
+
|
587
587
|
if (!value.browse) {
|
588
588
|
self.browse_button.button('disable').hide();
|
589
589
|
self.uploader.disableBrowse(true);
|
@@ -591,24 +591,24 @@ $.widget("ui.plupload", {
|
|
591
591
|
self.browse_button.button('enable').show();
|
592
592
|
self.uploader.disableBrowse(false);
|
593
593
|
}
|
594
|
-
|
594
|
+
|
595
595
|
if (!value.start) {
|
596
596
|
self.start_button.button('disable').hide();
|
597
597
|
} else {
|
598
598
|
self.start_button.button('enable').show();
|
599
599
|
}
|
600
|
-
|
600
|
+
|
601
601
|
if (!value.stop) {
|
602
602
|
self.stop_button.button('disable').hide();
|
603
603
|
} else {
|
604
|
-
self.start_button.button('enable').show();
|
604
|
+
self.start_button.button('enable').show();
|
605
605
|
}
|
606
606
|
}
|
607
|
-
|
608
|
-
self.uploader.settings[key] = value;
|
607
|
+
|
608
|
+
self.uploader.settings[key] = value;
|
609
609
|
},
|
610
610
|
|
611
|
-
|
611
|
+
|
612
612
|
/**
|
613
613
|
Start upload. Triggers `start` event.
|
614
614
|
|
@@ -619,7 +619,7 @@ $.widget("ui.plupload", {
|
|
619
619
|
this._trigger('start', null, { up: this.uploader });
|
620
620
|
},
|
621
621
|
|
622
|
-
|
622
|
+
|
623
623
|
/**
|
624
624
|
Stop upload. Triggers `stop` event.
|
625
625
|
|
@@ -652,7 +652,7 @@ $.widget("ui.plupload", {
|
|
652
652
|
this.uploader.disableBrowse(true);
|
653
653
|
},
|
654
654
|
|
655
|
-
|
655
|
+
|
656
656
|
/**
|
657
657
|
Retrieve file by it's unique id.
|
658
658
|
|
@@ -662,18 +662,18 @@ $.widget("ui.plupload", {
|
|
662
662
|
*/
|
663
663
|
getFile: function(id) {
|
664
664
|
var file;
|
665
|
-
|
665
|
+
|
666
666
|
if (typeof id === 'number') {
|
667
|
-
file = this.uploader.files[id];
|
667
|
+
file = this.uploader.files[id];
|
668
668
|
} else {
|
669
|
-
file = this.uploader.getFile(id);
|
669
|
+
file = this.uploader.getFile(id);
|
670
670
|
}
|
671
671
|
return file;
|
672
672
|
},
|
673
673
|
|
674
674
|
/**
|
675
675
|
Return array of files currently in the queue.
|
676
|
-
|
676
|
+
|
677
677
|
@method getFiles
|
678
678
|
@return {Array} Array of files in the queue represented by plupload.File objects
|
679
679
|
*/
|
@@ -681,7 +681,7 @@ $.widget("ui.plupload", {
|
|
681
681
|
return this.uploader.files;
|
682
682
|
},
|
683
683
|
|
684
|
-
|
684
|
+
|
685
685
|
/**
|
686
686
|
Remove the file from the queue.
|
687
687
|
|
@@ -695,7 +695,7 @@ $.widget("ui.plupload", {
|
|
695
695
|
this._removeFiles(file);
|
696
696
|
},
|
697
697
|
|
698
|
-
|
698
|
+
|
699
699
|
/**
|
700
700
|
Clear the file queue.
|
701
701
|
|
@@ -739,12 +739,12 @@ $.widget("ui.plupload", {
|
|
739
739
|
*/
|
740
740
|
notify: function(type, message) {
|
741
741
|
var popup = $(
|
742
|
-
'<div class="plupload_message">' +
|
742
|
+
'<div class="plupload_message">' +
|
743
743
|
'<span class="plupload_message_close ui-icon ui-icon-circle-close" title="'+_('Close')+'"></span>' +
|
744
744
|
'<p><span class="ui-icon"></span>' + message + '</p>' +
|
745
745
|
'</div>'
|
746
746
|
);
|
747
|
-
|
747
|
+
|
748
748
|
popup
|
749
749
|
.addClass('ui-state-' + (type === 'error' ? 'error' : 'highlight'))
|
750
750
|
.find('p .ui-icon')
|
@@ -752,14 +752,14 @@ $.widget("ui.plupload", {
|
|
752
752
|
.end()
|
753
753
|
.find('.plupload_message_close')
|
754
754
|
.click(function() {
|
755
|
-
popup.remove();
|
755
|
+
popup.remove();
|
756
756
|
})
|
757
757
|
.end();
|
758
|
-
|
758
|
+
|
759
759
|
$('.plupload_header', this.container).append(popup);
|
760
760
|
},
|
761
761
|
|
762
|
-
|
762
|
+
|
763
763
|
/**
|
764
764
|
Destroy the widget, the uploader, free associated resources and bring back original html.
|
765
765
|
|
@@ -767,29 +767,29 @@ $.widget("ui.plupload", {
|
|
767
767
|
*/
|
768
768
|
destroy: function() {
|
769
769
|
this._removeFiles([].slice.call(this.uploader.files));
|
770
|
-
|
770
|
+
|
771
771
|
// destroy uploader instance
|
772
772
|
this.uploader.destroy();
|
773
773
|
|
774
774
|
// unbind all button events
|
775
775
|
$('.plupload_button', this.element).unbind();
|
776
|
-
|
776
|
+
|
777
777
|
// destroy buttons
|
778
778
|
if ($.ui.button) {
|
779
779
|
$('.plupload_add, .plupload_start, .plupload_stop', this.container)
|
780
780
|
.button('destroy');
|
781
781
|
}
|
782
|
-
|
782
|
+
|
783
783
|
// destroy progressbar
|
784
784
|
if ($.ui.progressbar) {
|
785
|
-
this.progressbar.progressbar('destroy');
|
785
|
+
this.progressbar.progressbar('destroy');
|
786
786
|
}
|
787
|
-
|
787
|
+
|
788
788
|
// destroy sortable behavior
|
789
789
|
if ($.ui.sortable && this.options.sortable) {
|
790
790
|
$('tbody', this.filelist).sortable('destroy');
|
791
791
|
}
|
792
|
-
|
792
|
+
|
793
793
|
// restore the elements initial state
|
794
794
|
this.element
|
795
795
|
.empty()
|
@@ -798,19 +798,19 @@ $.widget("ui.plupload", {
|
|
798
798
|
|
799
799
|
$.Widget.prototype.destroy.apply(this);
|
800
800
|
},
|
801
|
-
|
802
|
-
|
801
|
+
|
802
|
+
|
803
803
|
_handleState: function() {
|
804
804
|
var up = this.uploader;
|
805
|
-
|
805
|
+
|
806
806
|
if (up.state === plupload.STARTED) {
|
807
807
|
$(this.start_button).button('disable');
|
808
|
-
|
808
|
+
|
809
809
|
$([])
|
810
810
|
.add(this.stop_button)
|
811
811
|
.add('.plupload_started')
|
812
812
|
.removeClass('plupload_hidden');
|
813
|
-
|
813
|
+
|
814
814
|
$('.plupload_upload_status', this.element).html(o.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length));
|
815
815
|
$('.plupload_header_content', this.element).addClass('plupload_header_content_bw');
|
816
816
|
} else if (up.state === plupload.STOPPED) {
|
@@ -818,7 +818,7 @@ $.widget("ui.plupload", {
|
|
818
818
|
.add(this.stop_button)
|
819
819
|
.add('.plupload_started')
|
820
820
|
.addClass('plupload_hidden');
|
821
|
-
|
821
|
+
|
822
822
|
if (this.options.multiple_queues) {
|
823
823
|
$('.plupload_header_content', this.element).removeClass('plupload_header_content_bw');
|
824
824
|
} else {
|
@@ -847,22 +847,22 @@ $.widget("ui.plupload", {
|
|
847
847
|
|
848
848
|
up.refresh();
|
849
849
|
},
|
850
|
-
|
851
|
-
|
850
|
+
|
851
|
+
|
852
852
|
_handleFileStatus: function(file) {
|
853
853
|
var self = this, actionClass, iconClass;
|
854
|
-
|
854
|
+
|
855
855
|
// since this method might be called asynchronously, file row might not yet be rendered
|
856
856
|
if (!$('#' + file.id).length) {
|
857
|
-
return;
|
857
|
+
return;
|
858
858
|
}
|
859
859
|
|
860
860
|
switch (file.status) {
|
861
|
-
case plupload.DONE:
|
861
|
+
case plupload.DONE:
|
862
862
|
actionClass = 'plupload_done';
|
863
863
|
iconClass = 'ui-icon ui-icon-circle-check';
|
864
864
|
break;
|
865
|
-
|
865
|
+
|
866
866
|
case plupload.FAILED:
|
867
867
|
actionClass = 'ui-state-error plupload_failed';
|
868
868
|
iconClass = 'ui-icon ui-icon-alert';
|
@@ -876,17 +876,17 @@ $.widget("ui.plupload", {
|
|
876
876
|
case plupload.UPLOADING:
|
877
877
|
actionClass = 'ui-state-highlight plupload_uploading';
|
878
878
|
iconClass = 'ui-icon ui-icon-circle-arrow-w';
|
879
|
-
|
879
|
+
|
880
880
|
// scroll uploading file into the view if its bottom boundary is out of it
|
881
881
|
var scroller = $('.plupload_scroll', this.container)
|
882
882
|
, scrollTop = scroller.scrollTop()
|
883
883
|
, scrollerHeight = scroller.height()
|
884
884
|
, rowOffset = $('#' + file.id).position().top + $('#' + file.id).height()
|
885
885
|
;
|
886
|
-
|
886
|
+
|
887
887
|
if (scrollerHeight < rowOffset) {
|
888
888
|
scroller.scrollTop(scrollTop + rowOffset - scrollerHeight);
|
889
|
-
}
|
889
|
+
}
|
890
890
|
|
891
891
|
// Set file specific progress
|
892
892
|
$('#' + file.id)
|
@@ -897,7 +897,7 @@ $.widget("ui.plupload", {
|
|
897
897
|
.css('width', file.percent + '%')
|
898
898
|
.end()
|
899
899
|
.find('.plupload_file_size')
|
900
|
-
.html(plupload.formatSize(file.size));
|
900
|
+
.html(plupload.formatSize(file.size));
|
901
901
|
break;
|
902
902
|
}
|
903
903
|
actionClass += ' ui-state-default plupload_file';
|
@@ -914,16 +914,16 @@ $.widget("ui.plupload", {
|
|
914
914
|
e.preventDefault();
|
915
915
|
});
|
916
916
|
},
|
917
|
-
|
918
|
-
|
917
|
+
|
918
|
+
|
919
919
|
_updateTotalProgress: function() {
|
920
920
|
var up = this.uploader;
|
921
921
|
|
922
922
|
// Scroll to end of file list
|
923
923
|
this.filelist[0].scrollTop = this.filelist[0].scrollHeight;
|
924
|
-
|
924
|
+
|
925
925
|
this.progressbar.progressbar('value', up.total.percent);
|
926
|
-
|
926
|
+
|
927
927
|
this.element
|
928
928
|
.find('.plupload_total_status')
|
929
929
|
.html(up.total.percent + '%')
|
@@ -936,14 +936,145 @@ $.widget("ui.plupload", {
|
|
936
936
|
},
|
937
937
|
|
938
938
|
|
939
|
+
_displayThumbs: function() {
|
940
|
+
var self = this
|
941
|
+
, tw, th // thumb width/height
|
942
|
+
, cols
|
943
|
+
, num = 0 // number of simultaneously visible thumbs
|
944
|
+
, thumbs = [] // array of thumbs to preload at any given moment
|
945
|
+
, loading = false
|
946
|
+
;
|
947
|
+
|
948
|
+
if (!this.options.views.thumbs) {
|
949
|
+
return;
|
950
|
+
}
|
951
|
+
|
952
|
+
|
953
|
+
function onLast(el, eventName, cb) {
|
954
|
+
var timer;
|
955
|
+
|
956
|
+
el.on(eventName, function() {
|
957
|
+
clearTimeout(timer);
|
958
|
+
timer = setTimeout(function() {
|
959
|
+
clearTimeout(timer);
|
960
|
+
cb();
|
961
|
+
}, 300);
|
962
|
+
});
|
963
|
+
}
|
964
|
+
|
965
|
+
|
966
|
+
// calculate number of simultaneously visible thumbs
|
967
|
+
function measure() {
|
968
|
+
if (!tw || !th) {
|
969
|
+
var wrapper = $('.plupload_file:eq(0)', self.filelist);
|
970
|
+
tw = wrapper.outerWidth(true);
|
971
|
+
th = wrapper.outerHeight(true);
|
972
|
+
}
|
973
|
+
|
974
|
+
var aw = self.content.width(), ah = self.content.height();
|
975
|
+
cols = Math.floor(aw / tw);
|
976
|
+
num = cols * (Math.ceil(ah / th) + 1);
|
977
|
+
}
|
978
|
+
|
979
|
+
|
980
|
+
function pickThumbsToLoad() {
|
981
|
+
// calculate index of virst visible thumb
|
982
|
+
var startIdx = Math.floor(self.content.scrollTop() / th) * cols;
|
983
|
+
// get potentially visible thumbs that are not yet visible
|
984
|
+
thumbs = $('.plupload_file', self.filelist)
|
985
|
+
.slice(startIdx, startIdx + num)
|
986
|
+
.filter(':not(.plupload_file_thumb_loaded)')
|
987
|
+
.get();
|
988
|
+
}
|
989
|
+
|
990
|
+
|
991
|
+
function init() {
|
992
|
+
function mpl() {
|
993
|
+
if (self.view_mode !== 'thumbs') {
|
994
|
+
return;
|
995
|
+
}
|
996
|
+
measure();
|
997
|
+
pickThumbsToLoad();
|
998
|
+
lazyLoad();
|
999
|
+
}
|
1000
|
+
|
1001
|
+
if ($.fn.resizable) {
|
1002
|
+
onLast(self.container, 'resize', mpl);
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
onLast(self.window, 'resize', mpl);
|
1006
|
+
onLast(self.content, 'scroll', mpl);
|
1007
|
+
|
1008
|
+
self.element.on('viewchanged selected', mpl);
|
1009
|
+
|
1010
|
+
mpl();
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
|
1014
|
+
function preloadThumb(file, cb) {
|
1015
|
+
var img = new o.Image();
|
1016
|
+
|
1017
|
+
img.onload = function() {
|
1018
|
+
var thumb = $('#' + file.id + ' .plupload_file_thumb', self.filelist).html('');
|
1019
|
+
this.embed(thumb[0], {
|
1020
|
+
width: 100,
|
1021
|
+
height: 60,
|
1022
|
+
crop: true,
|
1023
|
+
swf_url: o.resolveUrl(self.options.flash_swf_url),
|
1024
|
+
xap_url: o.resolveUrl(self.options.silverlight_xap_url)
|
1025
|
+
});
|
1026
|
+
};
|
1027
|
+
|
1028
|
+
img.bind("embedded error", function() {
|
1029
|
+
$('#' + file.id, self.filelist).addClass('plupload_file_thumb_loaded');
|
1030
|
+
this.destroy();
|
1031
|
+
setTimeout(cb, 1); // detach, otherwise ui might hang (in SilverLight for example)
|
1032
|
+
});
|
1033
|
+
|
1034
|
+
img.load(file.getSource());
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
|
1038
|
+
function lazyLoad() {
|
1039
|
+
if (self.view_mode !== 'thumbs' || loading) {
|
1040
|
+
return;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
pickThumbsToLoad();
|
1044
|
+
if (!thumbs.length) {
|
1045
|
+
return;
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
loading = true;
|
1049
|
+
|
1050
|
+
preloadThumb(self.getFile($(thumbs.shift()).attr('id')), function() {
|
1051
|
+
loading = false;
|
1052
|
+
lazyLoad();
|
1053
|
+
});
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
// this has to run only once to measure structures and bind listeners
|
1057
|
+
this.element.on('selected', function onselected() {
|
1058
|
+
self.element.off('selected', onselected);
|
1059
|
+
init();
|
1060
|
+
});
|
1061
|
+
},
|
1062
|
+
|
1063
|
+
|
939
1064
|
_addFiles: function(files) {
|
940
|
-
var self = this, file_html
|
1065
|
+
var self = this, file_html;
|
941
1066
|
|
942
1067
|
file_html = '<li class="plupload_file ui-state-default" id="%id%">' +
|
943
|
-
'<div class="plupload_file_thumb">
|
944
|
-
|
1068
|
+
'<div class="plupload_file_thumb">' +
|
1069
|
+
'<div class="plupload_file_dummy ui-widget-content"><span class="ui-state-disabled">%ext%</span></div>' +
|
1070
|
+
'</div>' +
|
1071
|
+
'<div class="plupload_file_name" title="%name%"><span class="plupload_file_namespan">%name%</span></div>' +
|
945
1072
|
'<div class="plupload_file_action"><div class="ui-icon"> </div></div>' +
|
946
1073
|
'<div class="plupload_file_size">%size% </div>' +
|
1074
|
+
'<div class="plupload_file_status">' +
|
1075
|
+
'<div class="plupload_file_progress ui-widget-header" style="width: 0%"> </div>' +
|
1076
|
+
'<span class="plupload_file_percent">%percent% </span>' +
|
1077
|
+
'</div>' +
|
947
1078
|
'<div class="plupload_file_fields"> </div>' +
|
948
1079
|
'</li>';
|
949
1080
|
|
@@ -951,66 +1082,21 @@ $.widget("ui.plupload", {
|
|
951
1082
|
files = [files];
|
952
1083
|
}
|
953
1084
|
|
954
|
-
// destroy sortable if enabled
|
955
|
-
if ($.ui.sortable && this.options.sortable) {
|
956
|
-
$('tbody', self.filelist).sortable('destroy');
|
957
|
-
}
|
958
|
-
|
959
|
-
// loop over files to add
|
960
1085
|
$.each(files, function(i, file) {
|
1086
|
+
var ext = o.Mime.getFileExtension(file.name) || 'none';
|
961
1087
|
|
962
1088
|
self.filelist.append(file_html.replace(/%(\w+)%/g, function($0, $1) {
|
963
1089
|
if ('size' === $1) {
|
964
1090
|
return plupload.formatSize(file.size);
|
1091
|
+
} else if ('ext' === $1) {
|
1092
|
+
return ext;
|
965
1093
|
} else {
|
966
1094
|
return file[$1] || '';
|
967
1095
|
}
|
968
1096
|
}));
|
969
1097
|
|
970
|
-
if (self.options.views.thumbs) {
|
971
|
-
queue.push(function(cb) {
|
972
|
-
var img = new o.Image();
|
973
|
-
|
974
|
-
img.onload = function() {
|
975
|
-
this.embed($('#' + file.id + ' .plupload_file_thumb', self.filelist)[0], {
|
976
|
-
width: 100,
|
977
|
-
height: 60,
|
978
|
-
crop: true,
|
979
|
-
swf_url: mOxie.resolveUrl(self.options.flash_swf_url),
|
980
|
-
xap_url: mOxie.resolveUrl(self.options.silverlight_xap_url)
|
981
|
-
});
|
982
|
-
};
|
983
|
-
|
984
|
-
img.onembedded = function() {
|
985
|
-
$('#' + file.id + ' .plupload_file_thumb', self.filelist).addClass('plupload_file_thumb_loaded');
|
986
|
-
this.destroy();
|
987
|
-
setTimeout(cb, 1); // detach, otherwise ui might hang (in SilverLight for example)
|
988
|
-
};
|
989
|
-
|
990
|
-
img.onerror = function() {
|
991
|
-
var ext = file.name.match(/\.([^\.]{1,7})$/);
|
992
|
-
$('#' + file.id + ' .plupload_file_thumb', self.filelist)
|
993
|
-
.html('<div class="plupload_file_dummy ui-widget-content"><span class="ui-state-disabled">' + (ext ? ext[1] : 'none') + '</span></div>');
|
994
|
-
this.destroy();
|
995
|
-
setTimeout(cb, 1);
|
996
|
-
};
|
997
|
-
img.load(file.getSource());
|
998
|
-
});
|
999
|
-
}
|
1000
|
-
|
1001
1098
|
self._handleFileStatus(file);
|
1002
1099
|
});
|
1003
|
-
|
1004
|
-
if (queue.length) {
|
1005
|
-
o.inSeries(queue);
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
// re-enable sortable
|
1009
|
-
if (this.options.sortable && $.ui.sortable) {
|
1010
|
-
this._enableSortingList();
|
1011
|
-
}
|
1012
|
-
|
1013
|
-
this._trigger('updatelist', null, { filelist: this.filelist });
|
1014
1100
|
},
|
1015
1101
|
|
1016
1102
|
|
@@ -1023,25 +1109,21 @@ $.widget("ui.plupload", {
|
|
1023
1109
|
|
1024
1110
|
// destroy sortable if enabled
|
1025
1111
|
if ($.ui.sortable && this.options.sortable) {
|
1026
|
-
$('tbody', self.filelist).sortable('destroy');
|
1112
|
+
$('tbody', self.filelist).sortable('destroy');
|
1027
1113
|
}
|
1028
1114
|
|
1029
1115
|
$.each(files, function(i, file) {
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
});
|
1034
|
-
file.imgs = [];
|
1035
|
-
}
|
1036
|
-
$('#' + file.id).remove();
|
1116
|
+
$('#' + file.id).toggle("highlight", function() {
|
1117
|
+
this.remove();
|
1118
|
+
});
|
1037
1119
|
up.removeFile(file);
|
1038
1120
|
});
|
1039
1121
|
|
1040
|
-
|
1122
|
+
|
1041
1123
|
if (up.files.length) {
|
1042
1124
|
// re-initialize sortable
|
1043
1125
|
if (this.options.sortable && $.ui.sortable) {
|
1044
|
-
this._enableSortingList();
|
1126
|
+
this._enableSortingList();
|
1045
1127
|
}
|
1046
1128
|
}
|
1047
1129
|
|
@@ -1071,20 +1153,20 @@ $.widget("ui.plupload", {
|
|
1071
1153
|
|
1072
1154
|
this.counter.val(this.uploader.files.length);
|
1073
1155
|
},
|
1074
|
-
|
1156
|
+
|
1075
1157
|
|
1076
1158
|
_viewChanged: function(view) {
|
1077
1159
|
// update or write a new cookie
|
1078
1160
|
if (this.options.views.remember && $.cookie) {
|
1079
1161
|
$.cookie('plupload_ui_view', view, { expires: 7, path: '/' });
|
1080
|
-
}
|
1081
|
-
|
1162
|
+
}
|
1163
|
+
|
1082
1164
|
// ugly fix for IE6 - make content area stretchable
|
1083
|
-
if (
|
1165
|
+
if (o.Env.browser === 'IE' && o.Env.version < 7) {
|
1084
1166
|
this.content.attr('style', 'height:expression(document.getElementById("' + this.id + '_container' + '").clientHeight - ' + (view === 'list' ? 133 : 103) + ');');
|
1085
1167
|
}
|
1086
1168
|
|
1087
|
-
this.container.removeClass('plupload_view_list plupload_view_thumbs').addClass('plupload_view_' + view);
|
1169
|
+
this.container.removeClass('plupload_view_list plupload_view_thumbs').addClass('plupload_view_' + view);
|
1088
1170
|
this.view_mode = view;
|
1089
1171
|
this._trigger('viewchanged', null, { view: view });
|
1090
1172
|
},
|
@@ -1140,9 +1222,14 @@ $.widget("ui.plupload", {
|
|
1140
1222
|
switcher.show();
|
1141
1223
|
this._viewChanged(this.options.views.active);
|
1142
1224
|
}
|
1143
|
-
},
|
1144
|
-
|
1145
1225
|
|
1226
|
+
// initialize thumb viewer if requested
|
1227
|
+
if (this.options.views.thumbs) {
|
1228
|
+
this._displayThumbs();
|
1229
|
+
}
|
1230
|
+
},
|
1231
|
+
|
1232
|
+
|
1146
1233
|
_enableRenaming: function() {
|
1147
1234
|
var self = this;
|
1148
1235
|
|
@@ -1152,7 +1239,7 @@ $.widget("ui.plupload", {
|
|
1152
1239
|
if (!nameSpan.hasClass('plupload_file_namespan')) {
|
1153
1240
|
return;
|
1154
1241
|
}
|
1155
|
-
|
1242
|
+
|
1156
1243
|
// Get file name and split out name and extension
|
1157
1244
|
file = self.uploader.getFile(nameSpan.closest('.plupload_file')[0].id);
|
1158
1245
|
name = file.name;
|
@@ -1182,35 +1269,39 @@ $.widget("ui.plupload", {
|
|
1182
1269
|
})[0].focus();
|
1183
1270
|
});
|
1184
1271
|
},
|
1185
|
-
|
1186
|
-
|
1272
|
+
|
1273
|
+
|
1187
1274
|
_enableSortingList: function() {
|
1188
|
-
var self = this
|
1189
|
-
|
1190
|
-
if ($('.plupload_file', filelist).length < 2) {
|
1191
|
-
return;
|
1275
|
+
var self = this;
|
1276
|
+
|
1277
|
+
if ($('.plupload_file', this.filelist).length < 2) {
|
1278
|
+
return;
|
1192
1279
|
}
|
1193
1280
|
|
1194
|
-
|
1281
|
+
// destroy sortable if enabled
|
1282
|
+
$('tbody', this.filelist).sortable('destroy');
|
1283
|
+
|
1284
|
+
// enable
|
1285
|
+
this.filelist.sortable({
|
1195
1286
|
items: '.plupload_delete',
|
1196
|
-
|
1287
|
+
|
1197
1288
|
cancel: 'object, .plupload_clearer',
|
1198
1289
|
|
1199
1290
|
stop: function() {
|
1200
1291
|
var files = [];
|
1201
|
-
|
1292
|
+
|
1202
1293
|
$.each($(this).sortable('toArray'), function(i, id) {
|
1203
1294
|
files[files.length] = self.uploader.getFile(id);
|
1204
|
-
});
|
1205
|
-
|
1295
|
+
});
|
1296
|
+
|
1206
1297
|
files.unshift(files.length);
|
1207
1298
|
files.unshift(0);
|
1208
|
-
|
1209
|
-
// re-populate files array
|
1210
|
-
Array.prototype.splice.apply(self.uploader.files, files);
|
1299
|
+
|
1300
|
+
// re-populate files array
|
1301
|
+
Array.prototype.splice.apply(self.uploader.files, files);
|
1211
1302
|
}
|
1212
|
-
});
|
1303
|
+
});
|
1213
1304
|
}
|
1214
1305
|
});
|
1215
1306
|
|
1216
|
-
} (window, document, plupload, jQuery));
|
1307
|
+
} (window, document, plupload, mOxie, jQuery));
|