card-mod-script 0.13.3 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/components.js.coffee +3 -0
  3. data/assets/script/decko/decko.js.coffee +0 -15
  4. data/assets/script/decko/editor.js.coffee +3 -1
  5. data/assets/script/decko/filter.js.coffee +13 -6
  6. data/assets/script/decko/mod.js.coffee +2 -8
  7. data/assets/script/{script_pointer_config.js.coffee → decko/pointer_config.js.coffee} +1 -2
  8. data/assets/script/{script_pointer_list_editor.js.coffee → decko/pointer_list_editor.js.coffee} +0 -0
  9. data/assets/script/decko/slot.js.coffee +2 -2
  10. data/assets/script/decko/slot_ready.js.coffee +1 -0
  11. data/assets/script/decko/slotter.js.coffee +23 -31
  12. data/assets/script/decko/type_editor.js.coffee +21 -0
  13. data/assets/script/decko/upload.js.coffee +12 -5
  14. data/assets/script/manifest.yml +15 -2
  15. data/set/abstract/00_script.rb +30 -31
  16. data/set/abstract/01_asset_script.rb +0 -16
  17. data/set/abstract/{script_asset_list.rb → script_group.rb} +12 -13
  18. data/set/all/head_javascript.rb +4 -5
  19. data/set/right/script.rb +1 -14
  20. data/set/type/local_script_folder_group.rb +2 -2
  21. data/set/type/local_script_manifest_group.rb +1 -1
  22. data/set/type_plus_right/mod/script.rb +56 -0
  23. data/set/type_plus_right/set/script.rb +7 -0
  24. data/vendor/jquery_file_upload/LICENSE.txt +11 -12
  25. data/vendor/jquery_file_upload/README.md +189 -72
  26. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  27. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  28. data/vendor/jquery_file_upload/cors/postmessage.html +68 -58
  29. data/vendor/jquery_file_upload/cors/result.html +12 -10
  30. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +24 -13
  31. data/vendor/jquery_file_upload/css/jquery.fileupload.css +3 -4
  32. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  33. data/vendor/jquery_file_upload/index.html +332 -230
  34. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +109 -109
  35. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +81 -73
  36. data/vendor/jquery_file_upload/js/demo.js +75 -0
  37. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +82 -94
  38. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +321 -300
  39. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +138 -146
  40. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +737 -692
  41. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +91 -97
  42. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +82 -94
  43. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1569 -1451
  44. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +208 -205
  45. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +397 -340
  46. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  47. data/vendor/jquery_file_upload/package.json +71 -10
  48. data/vendor/jquery_file_upload/server/gae-python/app.yaml +11 -10
  49. data/vendor/jquery_file_upload/server/php/Dockerfile +23 -17
  50. data/vendor/jquery_file_upload/server/php/UploadHandler.php +206 -137
  51. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  52. data/vendor/jquery_file_upload/test/index.html +36 -159
  53. data/vendor/jquery_file_upload/test/unit.js +989 -0
  54. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  55. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  56. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  57. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  58. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  59. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  60. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  61. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  62. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  63. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  64. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  65. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  66. metadata +34 -52
  67. data/file/mod_script_script_decko_machine_output/file.js +0 -2685
  68. data/file/mod_script_script_jquery_machine_output/file.js +0 -12924
  69. data/lib/javascript/script_html5shiv_printshiv.js +0 -1
  70. data/set/self/script_html5shiv_printshiv.rb +0 -11
  71. data/set/self/script_mods.rb +0 -1
  72. data/set/type/mod_script_assets.rb +0 -21
  73. data/vendor/jquery_file_upload/CONTRIBUTING.md +0 -15
  74. data/vendor/jquery_file_upload/angularjs.html +0 -211
  75. data/vendor/jquery_file_upload/basic-plus.html +0 -226
  76. data/vendor/jquery_file_upload/basic.html +0 -136
  77. data/vendor/jquery_file_upload/bower-version-update.js +0 -16
  78. data/vendor/jquery_file_upload/bower.json +0 -64
  79. data/vendor/jquery_file_upload/css/jquery-ui-demo-ie8.css +0 -21
  80. data/vendor/jquery_file_upload/css/jquery-ui-demo.css +0 -67
  81. data/vendor/jquery_file_upload/css/style.css +0 -15
  82. data/vendor/jquery_file_upload/jquery-ui.html +0 -252
  83. data/vendor/jquery_file_upload/js/app.js +0 -101
  84. data/vendor/jquery_file_upload/js/jquery.fileupload-angular.js +0 -437
  85. data/vendor/jquery_file_upload/js/jquery.fileupload-jquery-ui.js +0 -161
  86. data/vendor/jquery_file_upload/js/main.js +0 -75
  87. data/vendor/jquery_file_upload/server/gae-go/app/main.go +0 -361
  88. data/vendor/jquery_file_upload/server/gae-go/app.yaml +0 -12
  89. data/vendor/jquery_file_upload/server/gae-go/static/favicon.ico +0 -0
  90. data/vendor/jquery_file_upload/server/gae-go/static/robots.txt +0 -2
  91. data/vendor/jquery_file_upload/server/php/docker-compose.yml +0 -9
  92. data/vendor/jquery_file_upload/test/test.js +0 -1292
@@ -1,1292 +0,0 @@
1
- /*
2
- * jQuery File Upload Plugin Test
3
- * https://github.com/blueimp/jQuery-File-Upload
4
- *
5
- * Copyright 2010, Sebastian Tschan
6
- * https://blueimp.net
7
- *
8
- * Licensed under the MIT license:
9
- * https://opensource.org/licenses/MIT
10
- */
11
-
12
- /* global $, QUnit, window, document, expect, module, test, asyncTest, start, ok, strictEqual, notStrictEqual */
13
-
14
- $(function () {
15
- // jshint nomen:false
16
- 'use strict';
17
-
18
- QUnit.done = function () {
19
- // Delete all uploaded files:
20
- var url = $('#fileupload').prop('action');
21
- $.getJSON(url, function (result) {
22
- $.each(result.files, function (index, file) {
23
- $.ajax({
24
- url: url + '?file=' + encodeURIComponent(file.name),
25
- type: 'DELETE'
26
- });
27
- });
28
- });
29
- };
30
-
31
- var lifecycle = {
32
- setup: function () {
33
- // Set the .fileupload method to the basic widget method:
34
- $.widget('blueimp.fileupload', window.testBasicWidget, {});
35
- },
36
- teardown: function () {
37
- // Remove all remaining event listeners:
38
- $(document).unbind();
39
- }
40
- },
41
- lifecycleUI = {
42
- setup: function () {
43
- // Set the .fileupload method to the UI widget method:
44
- $.widget('blueimp.fileupload', window.testUIWidget, {});
45
- },
46
- teardown: function () {
47
- // Remove all remaining event listeners:
48
- $(document).unbind();
49
- }
50
- };
51
-
52
- module('Initialization', lifecycle);
53
-
54
- test('Widget initialization', function () {
55
- var fu = $('#fileupload').fileupload();
56
- ok(fu.data('blueimp-fileupload') || fu.data('fileupload'));
57
- });
58
-
59
- test('Data attribute options', function () {
60
- $('#fileupload').attr('data-url', 'http://example.org');
61
- $('#fileupload').fileupload();
62
- strictEqual(
63
- $('#fileupload').fileupload('option', 'url'),
64
- 'http://example.org'
65
- );
66
- });
67
-
68
- test('File input initialization', function () {
69
- var fu = $('#fileupload').fileupload();
70
- ok(
71
- fu.fileupload('option', 'fileInput').length,
72
- 'File input field inside of the widget'
73
- );
74
- ok(
75
- fu.fileupload('option', 'fileInput').length,
76
- 'Widget element as file input field'
77
- );
78
- });
79
-
80
- test('Drop zone initialization', function () {
81
- ok($('#fileupload').fileupload()
82
- .fileupload('option', 'dropZone').length);
83
- });
84
-
85
- test('Paste zone initialization', function () {
86
- ok($('#fileupload').fileupload({pasteZone: document})
87
- .fileupload('option', 'pasteZone').length);
88
- });
89
-
90
- test('Event listeners initialization', function () {
91
- expect(
92
- $.support.xhrFormDataFileUpload ? 4 : 1
93
- );
94
- var eo = {
95
- originalEvent: {
96
- dataTransfer: {files: [{}], types: ['Files']},
97
- clipboardData: {items: [{}]}
98
- }
99
- },
100
- fu = $('#fileupload').fileupload({
101
- pasteZone: document,
102
- dragover: function () {
103
- ok(true, 'Triggers dragover callback');
104
- return false;
105
- },
106
- drop: function () {
107
- ok(true, 'Triggers drop callback');
108
- return false;
109
- },
110
- paste: function () {
111
- ok(true, 'Triggers paste callback');
112
- return false;
113
- },
114
- change: function () {
115
- ok(true, 'Triggers change callback');
116
- return false;
117
- }
118
- }),
119
- fileInput = fu.fileupload('option', 'fileInput'),
120
- dropZone = fu.fileupload('option', 'dropZone'),
121
- pasteZone = fu.fileupload('option', 'pasteZone');
122
- fileInput.trigger($.Event('change', eo));
123
- dropZone.trigger($.Event('dragover', eo));
124
- dropZone.trigger($.Event('drop', eo));
125
- pasteZone.trigger($.Event('paste', eo));
126
- });
127
-
128
- module('API', lifecycle);
129
-
130
- test('destroy', function () {
131
- expect(4);
132
- var eo = {
133
- originalEvent: {
134
- dataTransfer: {files: [{}], types: ['Files']},
135
- clipboardData: {items: [{}]}
136
- }
137
- },
138
- options = {
139
- pasteZone: document,
140
- dragover: function () {
141
- ok(true, 'Triggers dragover callback');
142
- return false;
143
- },
144
- drop: function () {
145
- ok(true, 'Triggers drop callback');
146
- return false;
147
- },
148
- paste: function () {
149
- ok(true, 'Triggers paste callback');
150
- return false;
151
- },
152
- change: function () {
153
- ok(true, 'Triggers change callback');
154
- return false;
155
- }
156
- },
157
- fu = $('#fileupload').fileupload(options),
158
- fileInput = fu.fileupload('option', 'fileInput'),
159
- dropZone = fu.fileupload('option', 'dropZone'),
160
- pasteZone = fu.fileupload('option', 'pasteZone');
161
- dropZone.bind('dragover', options.dragover);
162
- dropZone.bind('drop', options.drop);
163
- pasteZone.bind('paste', options.paste);
164
- fileInput.bind('change', options.change);
165
- fu.fileupload('destroy');
166
- fileInput.trigger($.Event('change', eo));
167
- dropZone.trigger($.Event('dragover', eo));
168
- dropZone.trigger($.Event('drop', eo));
169
- pasteZone.trigger($.Event('paste', eo));
170
- });
171
-
172
- test('disable/enable', function () {
173
- expect(
174
- $.support.xhrFormDataFileUpload ? 4 : 1
175
- );
176
- var eo = {
177
- originalEvent: {
178
- dataTransfer: {files: [{}], types: ['Files']},
179
- clipboardData: {items: [{}]}
180
- }
181
- },
182
- fu = $('#fileupload').fileupload({
183
- pasteZone: document,
184
- dragover: function () {
185
- ok(true, 'Triggers dragover callback');
186
- return false;
187
- },
188
- drop: function () {
189
- ok(true, 'Triggers drop callback');
190
- return false;
191
- },
192
- paste: function () {
193
- ok(true, 'Triggers paste callback');
194
- return false;
195
- },
196
- change: function () {
197
- ok(true, 'Triggers change callback');
198
- return false;
199
- }
200
- }),
201
- fileInput = fu.fileupload('option', 'fileInput'),
202
- dropZone = fu.fileupload('option', 'dropZone'),
203
- pasteZone = fu.fileupload('option', 'pasteZone');
204
- fu.fileupload('disable');
205
- fileInput.trigger($.Event('change', eo));
206
- dropZone.trigger($.Event('dragover', eo));
207
- dropZone.trigger($.Event('drop', eo));
208
- pasteZone.trigger($.Event('paste', eo));
209
- fu.fileupload('enable');
210
- fileInput.trigger($.Event('change', eo));
211
- dropZone.trigger($.Event('dragover', eo));
212
- dropZone.trigger($.Event('drop', eo));
213
- pasteZone.trigger($.Event('paste', eo));
214
- });
215
-
216
- test('option', function () {
217
- expect(
218
- $.support.xhrFormDataFileUpload ? 10 : 7
219
- );
220
- var eo = {
221
- originalEvent: {
222
- dataTransfer: {files: [{}], types: ['Files']},
223
- clipboardData: {items: [{}]}
224
- }
225
- },
226
- fu = $('#fileupload').fileupload({
227
- pasteZone: document,
228
- dragover: function () {
229
- ok(true, 'Triggers dragover callback');
230
- return false;
231
- },
232
- drop: function () {
233
- ok(true, 'Triggers drop callback');
234
- return false;
235
- },
236
- paste: function () {
237
- ok(true, 'Triggers paste callback');
238
- return false;
239
- },
240
- change: function () {
241
- ok(true, 'Triggers change callback');
242
- return false;
243
- }
244
- }),
245
- fileInput = fu.fileupload('option', 'fileInput'),
246
- dropZone = fu.fileupload('option', 'dropZone'),
247
- pasteZone = fu.fileupload('option', 'pasteZone');
248
- fu.fileupload('option', 'fileInput', null);
249
- fu.fileupload('option', 'dropZone', null);
250
- fu.fileupload('option', 'pasteZone', null);
251
- fileInput.trigger($.Event('change', eo));
252
- dropZone.trigger($.Event('dragover', eo));
253
- dropZone.trigger($.Event('drop', eo));
254
- pasteZone.trigger($.Event('paste', eo));
255
- fu.fileupload('option', 'dropZone', 'body');
256
- strictEqual(
257
- fu.fileupload('option', 'dropZone')[0],
258
- document.body,
259
- 'Allow a query string as parameter for the dropZone option'
260
- );
261
- fu.fileupload('option', 'dropZone', document);
262
- strictEqual(
263
- fu.fileupload('option', 'dropZone')[0],
264
- document,
265
- 'Allow a document element as parameter for the dropZone option'
266
- );
267
- fu.fileupload('option', 'pasteZone', 'body');
268
- strictEqual(
269
- fu.fileupload('option', 'pasteZone')[0],
270
- document.body,
271
- 'Allow a query string as parameter for the pasteZone option'
272
- );
273
- fu.fileupload('option', 'pasteZone', document);
274
- strictEqual(
275
- fu.fileupload('option', 'pasteZone')[0],
276
- document,
277
- 'Allow a document element as parameter for the pasteZone option'
278
- );
279
- fu.fileupload('option', 'fileInput', ':file');
280
- strictEqual(
281
- fu.fileupload('option', 'fileInput')[0],
282
- $(':file')[0],
283
- 'Allow a query string as parameter for the fileInput option'
284
- );
285
- fu.fileupload('option', 'fileInput', $(':file')[0]);
286
- strictEqual(
287
- fu.fileupload('option', 'fileInput')[0],
288
- $(':file')[0],
289
- 'Allow a document element as parameter for the fileInput option'
290
- );
291
- fu.fileupload('option', 'fileInput', fileInput);
292
- fu.fileupload('option', 'dropZone', dropZone);
293
- fu.fileupload('option', 'pasteZone', pasteZone);
294
- fileInput.trigger($.Event('change', eo));
295
- dropZone.trigger($.Event('dragover', eo));
296
- dropZone.trigger($.Event('drop', eo));
297
- pasteZone.trigger($.Event('paste', eo));
298
- });
299
-
300
- asyncTest('add', function () {
301
- expect(2);
302
- var param = {files: [{name: 'test'}]};
303
- $('#fileupload').fileupload({
304
- add: function (e, data) {
305
- strictEqual(
306
- data.files[0].name,
307
- param.files[0].name,
308
- 'Triggers add callback'
309
- );
310
- }
311
- }).fileupload('add', param).fileupload(
312
- 'option',
313
- 'add',
314
- function (e, data) {
315
- data.submit().complete(function () {
316
- ok(true, 'data.submit() Returns a jqXHR object');
317
- start();
318
- });
319
- }
320
- ).fileupload('add', param);
321
- });
322
-
323
- asyncTest('send', function () {
324
- expect(3);
325
- var param = {files: [{name: 'test'}]};
326
- $('#fileupload').fileupload({
327
- send: function (e, data) {
328
- strictEqual(
329
- data.files[0].name,
330
- 'test',
331
- 'Triggers send callback'
332
- );
333
- }
334
- }).fileupload('send', param).fail(function () {
335
- ok(true, 'Allows to abort the request');
336
- }).complete(function () {
337
- ok(true, 'Returns a jqXHR object');
338
- start();
339
- }).abort();
340
- });
341
-
342
- module('Callbacks', lifecycle);
343
-
344
- asyncTest('add', function () {
345
- expect(1);
346
- var param = {files: [{name: 'test'}]};
347
- $('#fileupload').fileupload({
348
- add: function () {
349
- ok(true, 'Triggers add callback');
350
- start();
351
- }
352
- }).fileupload('add', param);
353
- });
354
-
355
- asyncTest('submit', function () {
356
- expect(1);
357
- var param = {files: [{name: 'test'}]};
358
- $('#fileupload').fileupload({
359
- submit: function () {
360
- ok(true, 'Triggers submit callback');
361
- start();
362
- return false;
363
- }
364
- }).fileupload('add', param);
365
- });
366
-
367
- asyncTest('send', function () {
368
- expect(1);
369
- var param = {files: [{name: 'test'}]};
370
- $('#fileupload').fileupload({
371
- send: function () {
372
- ok(true, 'Triggers send callback');
373
- start();
374
- return false;
375
- }
376
- }).fileupload('send', param);
377
- });
378
-
379
- asyncTest('done', function () {
380
- expect(1);
381
- var param = {files: [{name: 'test'}]};
382
- $('#fileupload').fileupload({
383
- done: function () {
384
- ok(true, 'Triggers done callback');
385
- start();
386
- }
387
- }).fileupload('send', param);
388
- });
389
-
390
- asyncTest('fail', function () {
391
- expect(1);
392
- var param = {files: [{name: 'test'}]},
393
- fu = $('#fileupload').fileupload({
394
- url: '404',
395
- fail: function () {
396
- ok(true, 'Triggers fail callback');
397
- start();
398
- }
399
- });
400
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
401
- ._isXHRUpload = function () {
402
- return true;
403
- };
404
- fu.fileupload('send', param);
405
- });
406
-
407
- asyncTest('always', function () {
408
- expect(2);
409
- var param = {files: [{name: 'test'}]},
410
- counter = 0,
411
- fu = $('#fileupload').fileupload({
412
- always: function () {
413
- ok(true, 'Triggers always callback');
414
- if (counter === 1) {
415
- start();
416
- } else {
417
- counter += 1;
418
- }
419
- }
420
- });
421
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
422
- ._isXHRUpload = function () {
423
- return true;
424
- };
425
- fu.fileupload('add', param).fileupload(
426
- 'option',
427
- 'url',
428
- '404'
429
- ).fileupload('add', param);
430
- });
431
-
432
- asyncTest('progress', function () {
433
- expect(1);
434
- var param = {files: [{name: 'test'}]},
435
- counter = 0;
436
- $('#fileupload').fileupload({
437
- forceIframeTransport: true,
438
- progress: function () {
439
- ok(true, 'Triggers progress callback');
440
- if (counter === 0) {
441
- start();
442
- } else {
443
- counter += 1;
444
- }
445
- }
446
- }).fileupload('send', param);
447
- });
448
-
449
- asyncTest('progressall', function () {
450
- expect(1);
451
- var param = {files: [{name: 'test'}]},
452
- counter = 0;
453
- $('#fileupload').fileupload({
454
- forceIframeTransport: true,
455
- progressall: function () {
456
- ok(true, 'Triggers progressall callback');
457
- if (counter === 0) {
458
- start();
459
- } else {
460
- counter += 1;
461
- }
462
- }
463
- }).fileupload('send', param);
464
- });
465
-
466
- asyncTest('start', function () {
467
- expect(1);
468
- var param = {files: [{name: '1'}, {name: '2'}]},
469
- active = 0;
470
- $('#fileupload').fileupload({
471
- send: function () {
472
- active += 1;
473
- },
474
- start: function () {
475
- ok(!active, 'Triggers start callback before uploads');
476
- start();
477
- }
478
- }).fileupload('send', param);
479
- });
480
-
481
- asyncTest('stop', function () {
482
- expect(1);
483
- var param = {files: [{name: '1'}, {name: '2'}]},
484
- active = 0;
485
- $('#fileupload').fileupload({
486
- send: function () {
487
- active += 1;
488
- },
489
- always: function () {
490
- active -= 1;
491
- },
492
- stop: function () {
493
- ok(!active, 'Triggers stop callback after uploads');
494
- start();
495
- }
496
- }).fileupload('send', param);
497
- });
498
-
499
- test('change', function () {
500
- var fu = $('#fileupload').fileupload(),
501
- fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'),
502
- fileInput = fu.fileupload('option', 'fileInput');
503
- expect(2);
504
- fu.fileupload({
505
- change: function (e, data) {
506
- ok(true, 'Triggers change callback');
507
- strictEqual(
508
- data.files.length,
509
- 0,
510
- 'Returns empty files list'
511
- );
512
- },
513
- add: $.noop
514
- });
515
- fuo._onChange({
516
- data: {fileupload: fuo},
517
- target: fileInput[0]
518
- });
519
- });
520
-
521
- test('paste', function () {
522
- var fu = $('#fileupload').fileupload(),
523
- fuo = fu.data('blueimp-fileupload') || fu.data('fileupload');
524
- expect(1);
525
- fu.fileupload({
526
- paste: function () {
527
- ok(true, 'Triggers paste callback');
528
- },
529
- add: $.noop
530
- });
531
- fuo._onPaste({
532
- data: {fileupload: fuo},
533
- originalEvent: {
534
- dataTransfer: {files: [{}]},
535
- clipboardData: {items: [{}]}
536
- },
537
- preventDefault: $.noop
538
- });
539
- });
540
-
541
- test('drop', function () {
542
- var fu = $('#fileupload').fileupload(),
543
- fuo = fu.data('blueimp-fileupload') || fu.data('fileupload');
544
- expect(1);
545
- fu.fileupload({
546
- drop: function () {
547
- ok(true, 'Triggers drop callback');
548
- },
549
- add: $.noop
550
- });
551
- fuo._onDrop({
552
- data: {fileupload: fuo},
553
- originalEvent: {
554
- dataTransfer: {files: [{}]},
555
- clipboardData: {items: [{}]}
556
- },
557
- preventDefault: $.noop
558
- });
559
- });
560
-
561
- test('dragover', function () {
562
- var fu = $('#fileupload').fileupload(),
563
- fuo = fu.data('blueimp-fileupload') || fu.data('fileupload');
564
- expect(1);
565
- fu.fileupload({
566
- dragover: function () {
567
- ok(true, 'Triggers dragover callback');
568
- },
569
- add: $.noop
570
- });
571
- fuo._onDragOver({
572
- data: {fileupload: fuo},
573
- originalEvent: {dataTransfer: {types: ['Files']}},
574
- preventDefault: $.noop
575
- });
576
- });
577
-
578
- module('Options', lifecycle);
579
-
580
- test('paramName', function () {
581
- expect(1);
582
- var param = {files: [{name: 'test'}]};
583
- $('#fileupload').fileupload({
584
- paramName: null,
585
- send: function (e, data) {
586
- strictEqual(
587
- data.paramName[0],
588
- data.fileInput.prop('name'),
589
- 'Takes paramName from file input field if not set'
590
- );
591
- return false;
592
- }
593
- }).fileupload('send', param);
594
- });
595
-
596
- test('url', function () {
597
- expect(1);
598
- var param = {files: [{name: 'test'}]};
599
- $('#fileupload').fileupload({
600
- url: null,
601
- send: function (e, data) {
602
- strictEqual(
603
- data.url,
604
- $(data.fileInput.prop('form')).prop('action'),
605
- 'Takes url from form action if not set'
606
- );
607
- return false;
608
- }
609
- }).fileupload('send', param);
610
- });
611
-
612
- test('type', function () {
613
- expect(2);
614
- var param = {files: [{name: 'test'}]};
615
- $('#fileupload').fileupload({
616
- type: null,
617
- send: function (e, data) {
618
- strictEqual(
619
- data.type,
620
- 'POST',
621
- 'Request type is "POST" if not set to "PUT"'
622
- );
623
- return false;
624
- }
625
- }).fileupload('send', param);
626
- $('#fileupload').fileupload({
627
- type: 'PUT',
628
- send: function (e, data) {
629
- strictEqual(
630
- data.type,
631
- 'PUT',
632
- 'Request type is "PUT" if set to "PUT"'
633
- );
634
- return false;
635
- }
636
- }).fileupload('send', param);
637
- });
638
-
639
- test('replaceFileInput', function () {
640
- var fu = $('#fileupload').fileupload(),
641
- fuo = fu.data('blueimp-fileupload') || fu.data('fileupload'),
642
- fileInput = fu.fileupload('option', 'fileInput'),
643
- fileInputElement = fileInput[0];
644
- expect(2);
645
- fu.fileupload({
646
- replaceFileInput: false,
647
- change: function () {
648
- strictEqual(
649
- fu.fileupload('option', 'fileInput')[0],
650
- fileInputElement,
651
- 'Keeps file input with replaceFileInput: false'
652
- );
653
- },
654
- add: $.noop
655
- });
656
- fuo._onChange({
657
- data: {fileupload: fuo},
658
- target: fileInput[0]
659
- });
660
- fu.fileupload({
661
- replaceFileInput: true,
662
- change: function () {
663
- notStrictEqual(
664
- fu.fileupload('option', 'fileInput')[0],
665
- fileInputElement,
666
- 'Replaces file input with replaceFileInput: true'
667
- );
668
- },
669
- add: $.noop
670
- });
671
- fuo._onChange({
672
- data: {fileupload: fuo},
673
- target: fileInput[0]
674
- });
675
- });
676
-
677
- asyncTest('forceIframeTransport', function () {
678
- expect(1);
679
- var param = {files: [{name: 'test'}]};
680
- $('#fileupload').fileupload({
681
- forceIframeTransport: true,
682
- done: function (e, data) {
683
- strictEqual(
684
- data.dataType.substr(0, 6),
685
- 'iframe',
686
- 'Iframe Transport is used'
687
- );
688
- start();
689
- }
690
- }).fileupload('send', param);
691
- });
692
-
693
- test('singleFileUploads', function () {
694
- expect(3);
695
- var fu = $('#fileupload').fileupload(),
696
- param = {files: [{name: '1'}, {name: '2'}]},
697
- index = 1;
698
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
699
- ._isXHRUpload = function () {
700
- return true;
701
- };
702
- $('#fileupload').fileupload({
703
- singleFileUploads: true,
704
- add: function () {
705
- ok(true, 'Triggers callback number ' + index.toString());
706
- index += 1;
707
- }
708
- }).fileupload('add', param).fileupload(
709
- 'option',
710
- 'singleFileUploads',
711
- false
712
- ).fileupload('add', param);
713
- });
714
-
715
- test('limitMultiFileUploads', function () {
716
- expect(3);
717
- var fu = $('#fileupload').fileupload(),
718
- param = {files: [
719
- {name: '1'},
720
- {name: '2'},
721
- {name: '3'},
722
- {name: '4'},
723
- {name: '5'}
724
- ]},
725
- index = 1;
726
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
727
- ._isXHRUpload = function () {
728
- return true;
729
- };
730
- $('#fileupload').fileupload({
731
- singleFileUploads: false,
732
- limitMultiFileUploads: 2,
733
- add: function () {
734
- ok(true, 'Triggers callback number ' + index.toString());
735
- index += 1;
736
- }
737
- }).fileupload('add', param);
738
- });
739
-
740
- test('limitMultiFileUploadSize', function () {
741
- expect(7);
742
- var fu = $('#fileupload').fileupload(),
743
- param = {files: [
744
- {name: '1-1', size: 100000},
745
- {name: '1-2', size: 40000},
746
- {name: '2-1', size: 100000},
747
- {name: '3-1', size: 50000},
748
- {name: '3-2', size: 40000},
749
- {name: '4-1', size: 45000} // New request due to limitMultiFileUploads
750
- ]},
751
- param2 = {files: [
752
- {name: '5-1'},
753
- {name: '5-2'},
754
- {name: '6-1'},
755
- {name: '6-2'},
756
- {name: '7-1'}
757
- ]},
758
- index = 1;
759
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
760
- ._isXHRUpload = function () {
761
- return true;
762
- };
763
- $('#fileupload').fileupload({
764
- singleFileUploads: false,
765
- limitMultiFileUploads: 2,
766
- limitMultiFileUploadSize: 150000,
767
- limitMultiFileUploadSizeOverhead: 5000,
768
- add: function () {
769
- ok(true, 'Triggers callback number ' + index.toString());
770
- index += 1;
771
- }
772
- }).fileupload('add', param).fileupload('add', param2);
773
- });
774
-
775
- asyncTest('sequentialUploads', function () {
776
- expect(6);
777
- var param = {files: [
778
- {name: '1'},
779
- {name: '2'},
780
- {name: '3'},
781
- {name: '4'},
782
- {name: '5'},
783
- {name: '6'}
784
- ]},
785
- addIndex = 0,
786
- sendIndex = 0,
787
- loadIndex = 0,
788
- fu = $('#fileupload').fileupload({
789
- sequentialUploads: true,
790
- add: function (e, data) {
791
- addIndex += 1;
792
- if (addIndex === 4) {
793
- data.submit().abort();
794
- } else {
795
- data.submit();
796
- }
797
- },
798
- send: function () {
799
- sendIndex += 1;
800
- },
801
- done: function () {
802
- loadIndex += 1;
803
- strictEqual(sendIndex, loadIndex, 'upload in order');
804
- },
805
- fail: function (e, data) {
806
- strictEqual(data.errorThrown, 'abort', 'upload aborted');
807
- },
808
- stop: function () {
809
- start();
810
- }
811
- });
812
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
813
- ._isXHRUpload = function () {
814
- return true;
815
- };
816
- fu.fileupload('add', param);
817
- });
818
-
819
- asyncTest('limitConcurrentUploads', function () {
820
- expect(12);
821
- var param = {files: [
822
- {name: '1'},
823
- {name: '2'},
824
- {name: '3'},
825
- {name: '4'},
826
- {name: '5'},
827
- {name: '6'},
828
- {name: '7'},
829
- {name: '8'},
830
- {name: '9'},
831
- {name: '10'},
832
- {name: '11'},
833
- {name: '12'}
834
- ]},
835
- addIndex = 0,
836
- sendIndex = 0,
837
- loadIndex = 0,
838
- fu = $('#fileupload').fileupload({
839
- limitConcurrentUploads: 3,
840
- add: function (e, data) {
841
- addIndex += 1;
842
- if (addIndex === 4) {
843
- data.submit().abort();
844
- } else {
845
- data.submit();
846
- }
847
- },
848
- send: function () {
849
- sendIndex += 1;
850
- },
851
- done: function () {
852
- loadIndex += 1;
853
- ok(sendIndex - loadIndex < 3);
854
- },
855
- fail: function (e, data) {
856
- strictEqual(data.errorThrown, 'abort', 'upload aborted');
857
- },
858
- stop: function () {
859
- start();
860
- }
861
- });
862
- (fu.data('blueimp-fileupload') || fu.data('fileupload'))
863
- ._isXHRUpload = function () {
864
- return true;
865
- };
866
- fu.fileupload('add', param);
867
- });
868
-
869
- if ($.support.xhrFileUpload) {
870
- asyncTest('multipart', function () {
871
- expect(2);
872
- var param = {files: [{
873
- name: 'test.png',
874
- size: 123,
875
- type: 'image/png'
876
- }]},
877
- fu = $('#fileupload').fileupload({
878
- multipart: false,
879
- always: function (e, data) {
880
- strictEqual(
881
- data.contentType,
882
- param.files[0].type,
883
- 'non-multipart upload sets file type as contentType'
884
- );
885
- strictEqual(
886
- data.headers['Content-Disposition'],
887
- 'attachment; filename="' + param.files[0].name + '"',
888
- 'non-multipart upload sets Content-Disposition header'
889
- );
890
- start();
891
- }
892
- });
893
- fu.fileupload('send', param);
894
- });
895
- }
896
-
897
- module('UI Initialization', lifecycleUI);
898
-
899
- test('Widget initialization', function () {
900
- var fu = $('#fileupload').fileupload();
901
- ok(fu.data('blueimp-fileupload') || fu.data('fileupload'));
902
- ok(
903
- $('#fileupload').fileupload('option', 'uploadTemplate').length,
904
- 'Initialized upload template'
905
- );
906
- ok(
907
- $('#fileupload').fileupload('option', 'downloadTemplate').length,
908
- 'Initialized download template'
909
- );
910
- });
911
-
912
- test('Buttonbar event listeners', function () {
913
- var buttonbar = $('#fileupload .fileupload-buttonbar'),
914
- files = [{name: 'test'}];
915
- expect(4);
916
- $('#fileupload').fileupload({
917
- send: function () {
918
- ok(true, 'Started file upload via global start button');
919
- },
920
- fail: function (e, data) {
921
- ok(true, 'Canceled file upload via global cancel button');
922
- data.context.remove();
923
- },
924
- destroy: function () {
925
- ok(true, 'Delete action called via global delete button');
926
- }
927
- });
928
- $('#fileupload').fileupload('add', {files: files});
929
- buttonbar.find('.cancel').click();
930
- $('#fileupload').fileupload('add', {files: files});
931
- buttonbar.find('.start').click();
932
- buttonbar.find('.cancel').click();
933
- files[0].deleteUrl = 'http://example.org/banana.jpg';
934
- ($('#fileupload').data('blueimp-fileupload') ||
935
- $('#fileupload').data('fileupload'))
936
- ._renderDownload(files)
937
- .appendTo($('#fileupload .files')).show()
938
- .find('.toggle').click();
939
- buttonbar.find('.delete').click();
940
- });
941
-
942
- module('UI API', lifecycleUI);
943
-
944
- test('destroy', function () {
945
- var buttonbar = $('#fileupload .fileupload-buttonbar'),
946
- files = [{name: 'test'}];
947
- expect(1);
948
- $('#fileupload').fileupload({
949
- send: function () {
950
- ok(true, 'This test should not run');
951
- return false;
952
- }
953
- })
954
- .fileupload('add', {files: files})
955
- .fileupload('destroy');
956
- buttonbar.find('.start').click(function () {
957
- ok(true, 'Clicked global start button');
958
- return false;
959
- }).click();
960
- });
961
-
962
- test('disable/enable', function () {
963
- var buttonbar = $('#fileupload .fileupload-buttonbar');
964
- $('#fileupload').fileupload();
965
- $('#fileupload').fileupload('disable');
966
- strictEqual(
967
- buttonbar.find('input[type=file], button').not(':disabled').length,
968
- 0,
969
- 'Disables the buttonbar buttons'
970
- );
971
- $('#fileupload').fileupload('enable');
972
- strictEqual(
973
- buttonbar.find('input[type=file], button').not(':disabled').length,
974
- 4,
975
- 'Enables the buttonbar buttons'
976
- );
977
- });
978
-
979
- module('UI Callbacks', lifecycleUI);
980
-
981
- test('destroy', function () {
982
- expect(3);
983
- $('#fileupload').fileupload({
984
- destroy: function (e, data) {
985
- ok(true, 'Triggers destroy callback');
986
- strictEqual(
987
- data.url,
988
- 'test',
989
- 'Passes over deletion url parameter'
990
- );
991
- strictEqual(
992
- data.type,
993
- 'DELETE',
994
- 'Passes over deletion request type parameter'
995
- );
996
- }
997
- });
998
- ($('#fileupload').data('blueimp-fileupload') ||
999
- $('#fileupload').data('fileupload'))
1000
- ._renderDownload([{
1001
- name: 'test',
1002
- deleteUrl: 'test',
1003
- deleteType: 'DELETE'
1004
- }])
1005
- .appendTo($('#fileupload .files'))
1006
- .show()
1007
- .find('.toggle').click();
1008
- $('#fileupload .fileupload-buttonbar .delete').click();
1009
- });
1010
-
1011
- asyncTest('added', function () {
1012
- expect(1);
1013
- var param = {files: [{name: 'test'}]};
1014
- $('#fileupload').fileupload({
1015
- added: function (e, data) {
1016
- start();
1017
- strictEqual(
1018
- data.files[0].name,
1019
- param.files[0].name,
1020
- 'Triggers added callback'
1021
- );
1022
- },
1023
- send: function () {
1024
- return false;
1025
- }
1026
- }).fileupload('add', param);
1027
- });
1028
-
1029
- asyncTest('started', function () {
1030
- expect(1);
1031
- var param = {files: [{name: 'test'}]};
1032
- $('#fileupload').fileupload({
1033
- started: function () {
1034
- start();
1035
- ok('Triggers started callback');
1036
- return false;
1037
- },
1038
- sent: function () {
1039
- return false;
1040
- }
1041
- }).fileupload('send', param);
1042
- });
1043
-
1044
- asyncTest('sent', function () {
1045
- expect(1);
1046
- var param = {files: [{name: 'test'}]};
1047
- $('#fileupload').fileupload({
1048
- sent: function (e, data) {
1049
- start();
1050
- strictEqual(
1051
- data.files[0].name,
1052
- param.files[0].name,
1053
- 'Triggers sent callback'
1054
- );
1055
- return false;
1056
- }
1057
- }).fileupload('send', param);
1058
- });
1059
-
1060
- asyncTest('completed', function () {
1061
- expect(1);
1062
- var param = {files: [{name: 'test'}]};
1063
- $('#fileupload').fileupload({
1064
- completed: function () {
1065
- start();
1066
- ok('Triggers completed callback');
1067
- return false;
1068
- }
1069
- }).fileupload('send', param);
1070
- });
1071
-
1072
- asyncTest('failed', function () {
1073
- expect(1);
1074
- var param = {files: [{name: 'test'}]};
1075
- $('#fileupload').fileupload({
1076
- failed: function () {
1077
- start();
1078
- ok('Triggers failed callback');
1079
- return false;
1080
- }
1081
- }).fileupload('send', param).abort();
1082
- });
1083
-
1084
- asyncTest('stopped', function () {
1085
- expect(1);
1086
- var param = {files: [{name: 'test'}]};
1087
- $('#fileupload').fileupload({
1088
- stopped: function () {
1089
- start();
1090
- ok('Triggers stopped callback');
1091
- return false;
1092
- }
1093
- }).fileupload('send', param);
1094
- });
1095
-
1096
- asyncTest('destroyed', function () {
1097
- expect(1);
1098
- $('#fileupload').fileupload({
1099
- dataType: 'html',
1100
- destroyed: function () {
1101
- start();
1102
- ok(true, 'Triggers destroyed callback');
1103
- }
1104
- });
1105
- ($('#fileupload').data('blueimp-fileupload') ||
1106
- $('#fileupload').data('fileupload'))
1107
- ._renderDownload([{
1108
- name: 'test',
1109
- deleteUrl: '.',
1110
- deleteType: 'GET'
1111
- }])
1112
- .appendTo($('#fileupload .files'))
1113
- .show()
1114
- .find('.toggle').click();
1115
- $('#fileupload .fileupload-buttonbar .delete').click();
1116
- });
1117
-
1118
- module('UI Options', lifecycleUI);
1119
-
1120
- test('autoUpload', function () {
1121
- expect(1);
1122
- $('#fileupload')
1123
- .fileupload({
1124
- autoUpload: true,
1125
- send: function () {
1126
- ok(true, 'Started file upload automatically');
1127
- return false;
1128
- }
1129
- })
1130
- .fileupload('add', {files: [{name: 'test'}]})
1131
- .fileupload('option', 'autoUpload', false)
1132
- .fileupload('add', {files: [{name: 'test'}]});
1133
- });
1134
-
1135
- test('maxNumberOfFiles', function () {
1136
- expect(3);
1137
- var addIndex = 0,
1138
- sendIndex = 0;
1139
- $('#fileupload')
1140
- .fileupload({
1141
- autoUpload: true,
1142
- maxNumberOfFiles: 3,
1143
- singleFileUploads: false,
1144
- send: function () {
1145
- strictEqual(
1146
- sendIndex += 1,
1147
- addIndex
1148
- );
1149
- },
1150
- progress: $.noop,
1151
- progressall: $.noop,
1152
- done: $.noop,
1153
- stop: $.noop
1154
- })
1155
- .fileupload('add', {files: [{name: (addIndex += 1)}]})
1156
- .fileupload('add', {files: [{name: (addIndex += 1)}]})
1157
- .fileupload('add', {files: [{name: (addIndex += 1)}]})
1158
- .fileupload('add', {files: [{name: 'test'}]});
1159
- });
1160
-
1161
- test('maxFileSize', function () {
1162
- expect(2);
1163
- var addIndex = 0,
1164
- sendIndex = 0;
1165
- $('#fileupload')
1166
- .fileupload({
1167
- autoUpload: true,
1168
- maxFileSize: 1000,
1169
- send: function () {
1170
- strictEqual(
1171
- sendIndex += 1,
1172
- addIndex
1173
- );
1174
- return false;
1175
- }
1176
- })
1177
- .fileupload('add', {files: [{
1178
- name: (addIndex += 1)
1179
- }]})
1180
- .fileupload('add', {files: [{
1181
- name: (addIndex += 1),
1182
- size: 999
1183
- }]})
1184
- .fileupload('add', {files: [{
1185
- name: 'test',
1186
- size: 1001
1187
- }]})
1188
- .fileupload({
1189
- send: function (e, data) {
1190
- ok(
1191
- !$.blueimp.fileupload.prototype.options
1192
- .send.call(this, e, data)
1193
- );
1194
- return false;
1195
- }
1196
- });
1197
- });
1198
-
1199
- test('minFileSize', function () {
1200
- expect(2);
1201
- var addIndex = 0,
1202
- sendIndex = 0;
1203
- $('#fileupload')
1204
- .fileupload({
1205
- autoUpload: true,
1206
- minFileSize: 1000,
1207
- send: function () {
1208
- strictEqual(
1209
- sendIndex += 1,
1210
- addIndex
1211
- );
1212
- return false;
1213
- }
1214
- })
1215
- .fileupload('add', {files: [{
1216
- name: (addIndex += 1)
1217
- }]})
1218
- .fileupload('add', {files: [{
1219
- name: (addIndex += 1),
1220
- size: 1001
1221
- }]})
1222
- .fileupload('add', {files: [{
1223
- name: 'test',
1224
- size: 999
1225
- }]})
1226
- .fileupload({
1227
- send: function (e, data) {
1228
- ok(
1229
- !$.blueimp.fileupload.prototype.options
1230
- .send.call(this, e, data)
1231
- );
1232
- return false;
1233
- }
1234
- });
1235
- });
1236
-
1237
- test('acceptFileTypes', function () {
1238
- expect(2);
1239
- var addIndex = 0,
1240
- sendIndex = 0;
1241
- $('#fileupload')
1242
- .fileupload({
1243
- autoUpload: true,
1244
- acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
1245
- disableImageMetaDataLoad: true,
1246
- send: function () {
1247
- strictEqual(
1248
- sendIndex += 1,
1249
- addIndex
1250
- );
1251
- return false;
1252
- }
1253
- })
1254
- .fileupload('add', {files: [{
1255
- name: (addIndex += 1) + '.jpg'
1256
- }]})
1257
- .fileupload('add', {files: [{
1258
- name: (addIndex += 1),
1259
- type: 'image/jpeg'
1260
- }]})
1261
- .fileupload('add', {files: [{
1262
- name: 'test.txt',
1263
- type: 'text/plain'
1264
- }]})
1265
- .fileupload({
1266
- send: function (e, data) {
1267
- ok(
1268
- !$.blueimp.fileupload.prototype.options
1269
- .send.call(this, e, data)
1270
- );
1271
- return false;
1272
- }
1273
- });
1274
- });
1275
-
1276
- test('acceptFileTypes as HTML5 data attribute', function () {
1277
- expect(2);
1278
- var regExp = /(\.|\/)(gif|jpe?g|png)$/i;
1279
- $('#fileupload')
1280
- .attr('data-accept-file-types', regExp.toString())
1281
- .fileupload();
1282
- strictEqual(
1283
- $.type($('#fileupload').fileupload('option', 'acceptFileTypes')),
1284
- $.type(regExp)
1285
- );
1286
- strictEqual(
1287
- $('#fileupload').fileupload('option', 'acceptFileTypes').toString(),
1288
- regExp.toString()
1289
- );
1290
- });
1291
-
1292
- });