fe 2.0.8 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/fe/spinner.gif +0 -0
- data/app/assets/javascripts/fe/fe.admin.js +29 -29
- data/app/assets/javascripts/fe/fe.common.js.erb +7 -7
- data/app/assets/javascripts/fe/fe.public.nojquery.js.erb +48 -43
- data/app/assets/javascripts/fe/jquery.html5_upload.js +15 -15
- data/app/assets/javascripts/fe/jquery.metadata.js +6 -6
- data/app/assets/javascripts/fe/jquery.uploadify.v2.1.0.js +27 -26
- data/app/helpers/fe/application_helper.rb +1 -1
- data/app/views/fe/admin/question_sheets/show.html.erb +1 -1
- data/app/views/fe/questions/fe/_attachment_field.html.erb +2 -2
- data/app/views/layouts/fe/application.html.erb +1 -1
- data/lib/fe/version.rb +1 -1
- metadata +4 -6
- data/spec/dummy/log/test.log +0 -143467
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3679834a5251fd9a7412f9da4734020a7b1a72dc9882afd2994c8fa6fbd92fd
|
4
|
+
data.tar.gz: 4d0e2a3c4c2085bf1ff788912e85d0ca0ed012446acb137174ae42196a7546b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 796bbd4824ffe28319b5dfc7365a93dedcb06fed9e3b3bfe60bd8f5168b3328f9f9b6f4387d589202dd66281999e4217d934d490de12d4dec845733386f9d52d
|
7
|
+
data.tar.gz: 25addcd22738328428a59cdce369d221f8bd6131570d4923b71c4b18336c952553d51e32f8e08f8ae29b0d0cc25a6de21bf06f5b1473137fa976940a2e0a2810
|
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
$(function() {
|
1
|
+
$(document).on('ready turbo:load', function () {
|
2
2
|
setUpJsHelpers();
|
3
3
|
$(document).on('ajaxStart', function() {
|
4
4
|
$('#status').show();
|
@@ -8,7 +8,7 @@ $(function() {
|
|
8
8
|
});
|
9
9
|
|
10
10
|
$(document).on('click', '.link-show-xml', function() {
|
11
|
-
div = $(this).closest('.choices_section')
|
11
|
+
let div = $(this).closest('.choices_section')
|
12
12
|
$('.xmlChoices', div).show();
|
13
13
|
$('.link-show-csv', div).show();
|
14
14
|
$('.link-show-xml', div).hide();
|
@@ -16,7 +16,7 @@ $(function() {
|
|
16
16
|
});
|
17
17
|
|
18
18
|
$(document).on('click', '.link-show-csv', function() {
|
19
|
-
div = $(this).closest('.choices_section')
|
19
|
+
let div = $(this).closest('.choices_section')
|
20
20
|
$('.csvChoices', div).show();
|
21
21
|
$('.link-show-xml', div).show();
|
22
22
|
$('.link-show-csv', div).hide();
|
@@ -70,7 +70,7 @@ $(function() {
|
|
70
70
|
});
|
71
71
|
// used by form designer
|
72
72
|
|
73
|
-
|
73
|
+
let currentTab = 'pages_list';
|
74
74
|
|
75
75
|
function switchTab(toTab) {
|
76
76
|
if(currentTab != null) $('#tab-' + currentTab).removeClass('active');
|
@@ -82,50 +82,50 @@ function switchTab(toTab) {
|
|
82
82
|
}
|
83
83
|
|
84
84
|
function selectPage() {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
let el = $('#link-page-name');
|
86
|
+
clearCurrentElement();
|
87
|
+
el.addClass('active');
|
88
|
+
switchTab('properties');
|
89
89
|
|
90
|
-
|
90
|
+
if($('#page_label').length > 0) $('#page_label').focus();
|
91
91
|
}
|
92
92
|
|
93
93
|
function selectElement(id) {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
let el = $(id);
|
95
|
+
clearPageName();
|
96
|
+
clearCurrentElement();
|
97
|
+
el.addClass('active');
|
98
|
+
// snapElementProperties(el);
|
99
|
+
activeElement = id;
|
100
|
+
switchTab('properties');
|
101
|
+
|
102
|
+
// if( $('#element_label')) $('#element_label').focus();
|
103
103
|
}
|
104
104
|
|
105
105
|
function clearCurrentElement() {
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
if (activeElement != '' && $(activeElement)) {
|
107
|
+
$(activeElement).removeClass('active');
|
108
|
+
}
|
109
109
|
}
|
110
110
|
|
111
111
|
function clearPageName() {
|
112
|
-
|
112
|
+
$('#link-page-name').removeClass('active');
|
113
113
|
}
|
114
114
|
|
115
115
|
function snapElementProperties(el) {
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
let propsTop = Position.cumulativeOffset(el)[1] - 160;
|
117
|
+
if (propsTop < 0) propsTop = 0;
|
118
|
+
$('#panel-properties-element').css({'margin-top': propsTop});
|
119
119
|
}
|
120
120
|
|
121
121
|
function addError(id) {
|
122
|
-
|
122
|
+
$('#' + id).addClassName('fieldWithErrors');
|
123
123
|
}
|
124
124
|
|
125
125
|
// convert label to slug
|
126
126
|
function updateSlug(source, dest) {
|
127
|
-
label = $(source).val();
|
128
|
-
slug = $(dest).val();
|
127
|
+
let label = $(source).val();
|
128
|
+
let slug = $(dest).val();
|
129
129
|
if( label == null || slug == null) return; // oh oh
|
130
130
|
|
131
131
|
label = label.strip();
|
@@ -144,7 +144,7 @@ function updateSlug(source, dest) {
|
|
144
144
|
}
|
145
145
|
}
|
146
146
|
|
147
|
-
$(function() {
|
147
|
+
$(document).on('ready turbo:load', function () {
|
148
148
|
setUpSortables();
|
149
149
|
fixGridColumnWidths();
|
150
150
|
});
|
@@ -3,7 +3,7 @@ function setUpSortables() {
|
|
3
3
|
items: '> li.sortable',
|
4
4
|
dropOnEmpty:false,
|
5
5
|
update: function(event, ui) {
|
6
|
-
|
6
|
+
let sortable = this;
|
7
7
|
$.ajax({data:$(this).sortable('serialize',{key:sortable.id + '[]'}),
|
8
8
|
complete: function(request) {$(sortable).effect('highlight')},
|
9
9
|
success:function(request){$('#errors').html(request)},
|
@@ -12,12 +12,12 @@ function setUpSortables() {
|
|
12
12
|
})
|
13
13
|
},
|
14
14
|
stop: function(event, ui) {
|
15
|
-
before_dropper = $('li.before-container[data-element_id="'+ui.item.data('element_id'));
|
15
|
+
let before_dropper = $('li.before-container[data-element_id="'+ui.item.data('element_id'));
|
16
16
|
if (before_dropper.length > 0) {
|
17
17
|
before_dropper.detach();
|
18
18
|
before_dropper.insertBefore(ui.item);
|
19
19
|
}
|
20
|
-
after_dropper = $('li.after-container[data-element_id="'+ui.item.data('element_id'));
|
20
|
+
let after_dropper = $('li.after-container[data-element_id="'+ui.item.data('element_id'));
|
21
21
|
if (after_dropper.length > 0) {
|
22
22
|
after_dropper.detach();
|
23
23
|
after_dropper.insertAfter(ui.item);
|
@@ -57,8 +57,8 @@ function setUpSortables() {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
function setUpCalendars() {
|
60
|
-
now = new Date();
|
61
|
-
year = now.getFullYear() + 10;
|
60
|
+
let now = new Date();
|
61
|
+
let year = now.getFullYear() + 10;
|
62
62
|
$('[data-calendar]').datepicker({
|
63
63
|
changeYear:true,
|
64
64
|
yearRange: '1950:' + year,
|
@@ -81,9 +81,9 @@ function setUpJsHelpers() {
|
|
81
81
|
|
82
82
|
function fixGridColumnWidths() {
|
83
83
|
$("table.grid").each(function(i, grid) {
|
84
|
-
|
84
|
+
let num_columns = $(grid).find("th").length;
|
85
85
|
if (num_columns > 0) {
|
86
|
-
|
86
|
+
let width = (100 / num_columns) + "%";
|
87
87
|
$(grid).find("> tbody > tr > th").css("width", width);
|
88
88
|
$(grid).find("> tbody > tr > td").css("width", width);
|
89
89
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
// used by answer sheets
|
4
4
|
|
5
|
-
(function(
|
5
|
+
$(document).on('ready turbo:load', function () {
|
6
6
|
<% if Fe.bootstrap %>
|
7
7
|
// http://stackoverflow.com/questions/18754020/bootstrap-3-with-jquery-validation-plugin
|
8
8
|
$.validator.setDefaults({
|
@@ -29,9 +29,9 @@
|
|
29
29
|
});
|
30
30
|
|
31
31
|
$(document).on('click', '.reference_send_invite', function() {
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
let el = this;
|
33
|
+
let form_elements = $(el).closest('form').find('input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)');
|
34
|
+
let data = form_elements.serializeArray();
|
35
35
|
|
36
36
|
data.push({name: 'answer_sheet_type', value: answer_sheet_type});
|
37
37
|
$.ajax({url: $(el).attr('href'), data: data, dataType: 'script', type: 'POST',
|
@@ -48,10 +48,10 @@
|
|
48
48
|
return false;
|
49
49
|
});
|
50
50
|
$(document).on('focus', 'textarea[maxlength]', function() {
|
51
|
-
|
51
|
+
let max = parseInt($(this).attr('maxlength'));
|
52
52
|
$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
|
53
53
|
}).on('keyup', 'textarea[maxlength]', function(){
|
54
|
-
|
54
|
+
let max = parseInt($(this).attr('maxlength'));
|
55
55
|
if($(this).val().length > max){
|
56
56
|
$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
|
57
57
|
}
|
@@ -113,10 +113,10 @@
|
|
113
113
|
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
114
114
|
|
115
115
|
// var response = new String(transport.responseText);
|
116
|
-
|
116
|
+
let match = response.match(/<div id=\"(.*?)\"/i); // what did I just load? parse out the first div id
|
117
117
|
if( match != null )
|
118
118
|
{
|
119
|
-
|
119
|
+
let page = match[1];
|
120
120
|
if (response.match(/<html/)) {
|
121
121
|
alert("There was a problem loading that page. To work on other pages, please refresh the website.");
|
122
122
|
document.location = document.location;
|
@@ -142,6 +142,7 @@
|
|
142
142
|
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
143
143
|
validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : true;
|
144
144
|
|
145
|
+
let isValid;
|
145
146
|
if (validate_current_page) {
|
146
147
|
isValid = this.validatePage(this.current_page); // mark current page as valid (or not) as we're leaving
|
147
148
|
} else {
|
@@ -204,12 +205,13 @@
|
|
204
205
|
if (typeof blocking == "undefined") blocking = false;
|
205
206
|
|
206
207
|
// don't save more than once per second
|
207
|
-
timeNow = new Date();
|
208
|
-
|
208
|
+
let timeNow = new Date();
|
209
|
+
let lastSave;
|
210
|
+
if (typeof lastSave !== "undefined" && lastSave && !force && (timeNow - lastSave < 1000)) {
|
209
211
|
return true;
|
210
212
|
}
|
211
213
|
lastSave = timeNow;
|
212
|
-
form_data = this.captureForm(page);
|
214
|
+
let form_data = this.captureForm(page);
|
213
215
|
if( form_data ) {
|
214
216
|
if( page.data('form_data') == null || page.data('form_data').data !== form_data.data || force === true) { // if any changes
|
215
217
|
page.data('form_data', form_data);
|
@@ -225,7 +227,7 @@
|
|
225
227
|
},
|
226
228
|
async: !blocking,
|
227
229
|
error: function() {
|
228
|
-
save_fails = page.data('save_fails') == null ? 0 : page.data('save_fails');
|
230
|
+
let save_fails = page.data('save_fails') == null ? 0 : page.data('save_fails');
|
229
231
|
save_fails += 1;
|
230
232
|
page.data('save_fails', save_fails)
|
231
233
|
|
@@ -263,9 +265,9 @@
|
|
263
265
|
|
264
266
|
// serialize form data and extract url to post to
|
265
267
|
captureForm : function(page) {
|
266
|
-
form_el = $('#' + page.attr('id') + '-form');
|
268
|
+
let form_el = $('#' + page.attr('id') + '-form');
|
267
269
|
if( form_el[0] == null ) return null;
|
268
|
-
form_all_el = form_el.find("input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)");
|
270
|
+
let form_all_el = form_el.find("input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)");
|
269
271
|
return {url: form_el.attr('action'), data: form_all_el.serialize() + '&answer_sheet_type=' + answer_sheet_type};
|
270
272
|
},
|
271
273
|
|
@@ -296,10 +298,10 @@
|
|
296
298
|
if ($('#' + this.current_page + "-form").hasClass('no-validation')) { return; }
|
297
299
|
|
298
300
|
try {
|
299
|
-
|
300
|
-
|
301
|
+
let li = $('#' + page + '-li');
|
302
|
+
let form = $('#' + page + '-form');
|
301
303
|
|
302
|
-
valid = form.valid();
|
304
|
+
let valid = form.valid();
|
303
305
|
|
304
306
|
if (!page_classes_only) {
|
305
307
|
// Move radio button errors up
|
@@ -339,10 +341,10 @@
|
|
339
341
|
$('.page_link').each(function(index, page) {
|
340
342
|
fe.pageHandler.validatePage($(page).attr('data-page-id'));
|
341
343
|
});
|
342
|
-
|
344
|
+
let all_valid = ($('#list-pages li.incomplete').length == 0);
|
343
345
|
|
344
346
|
// Make sure any necessary payments are made
|
345
|
-
|
347
|
+
let payments_made = $('.payment_question.required').length <= $('.payment').length
|
346
348
|
|
347
349
|
|
348
350
|
if( payments_made)
|
@@ -353,10 +355,10 @@
|
|
353
355
|
// submit the application
|
354
356
|
if($('#submit_to')[0] != null)
|
355
357
|
{
|
356
|
-
url = $('#submit_to').val();
|
358
|
+
let url = $('#submit_to').val();
|
357
359
|
// clear out pages array to force reload. This enables "frozen" apps
|
358
360
|
// immediately after submission - :onSuccess (for USCM which stays in the application vs. redirecting to the dashboard)
|
359
|
-
|
361
|
+
let curr = fe.pageHandler.current_page;
|
360
362
|
$.ajax({url: url, dataType:'script',
|
361
363
|
data: {answer_sheet_type: answer_sheet_type, a: $('input[type=hidden][name=a]').val()},
|
362
364
|
type:'post',
|
@@ -370,7 +372,7 @@
|
|
370
372
|
},
|
371
373
|
complete: function(xhr) {
|
372
374
|
$('body').trigger('ajax:complete', xhr);
|
373
|
-
|
375
|
+
let btn = $('#submit_button');
|
374
376
|
if (btn) { btn.attr('disabled', false); }
|
375
377
|
}
|
376
378
|
});
|
@@ -382,7 +384,7 @@
|
|
382
384
|
$('#submit_message, .submit_message').html("Please make a payment");
|
383
385
|
$('#submit_message, .submit_message').show();
|
384
386
|
|
385
|
-
|
387
|
+
let btn = $('#submit_button'); if (btn) { btn.attr('disabled', false); }
|
386
388
|
}
|
387
389
|
},
|
388
390
|
|
@@ -393,7 +395,8 @@
|
|
393
395
|
},
|
394
396
|
|
395
397
|
checkConditional : function($element) {
|
396
|
-
|
398
|
+
let vals;
|
399
|
+
let matchable_answers = String($element.data('conditional_answer')).split(';').map(function(s) { return s.trim(); })
|
397
400
|
if ($element.hasClass('fe_choicefield') && ($element.hasClass('style_yes-no') || $element.hasClass('yes-no'))) {
|
398
401
|
if ($(matchable_answers).filter([1, '1', true, 'true', 'yes', 'Yes']).length > 0) {
|
399
402
|
matchable_answers = [1, '1', true, 'true', 'yes', 'Yes'];
|
@@ -409,7 +412,7 @@
|
|
409
412
|
} else {
|
410
413
|
vals = $([$element.find("input:visible, select:visible").val()]);
|
411
414
|
}
|
412
|
-
match = $(matchable_answers).filter(vals).length > 0 || (matchable_answers == "" && vals.length == 0);
|
415
|
+
let match = $(matchable_answers).filter(vals).length > 0 || (matchable_answers == "" && vals.length == 0);
|
413
416
|
|
414
417
|
switch ($element.data('conditional_type')) {
|
415
418
|
case 'Fe::Element':
|
@@ -420,9 +423,9 @@
|
|
420
423
|
}
|
421
424
|
break;
|
422
425
|
case 'Fe::Page':
|
423
|
-
prefix = $element.data('answer_sheet_id_prefix');
|
424
|
-
pg = prefix + '_' + $element.data('application_id') + '-fe_page_' + $element.data('conditional_id');
|
425
|
-
li_id = 'li#'+pg+'-li';
|
426
|
+
let prefix = $element.data('answer_sheet_id_prefix');
|
427
|
+
let pg = prefix + '_' + $element.data('application_id') + '-fe_page_' + $element.data('conditional_id');
|
428
|
+
let li_id = 'li#'+pg+'-li';
|
426
429
|
li_id += ', li#'+pg+'-no_cache-li';
|
427
430
|
|
428
431
|
if (match) {
|
@@ -439,9 +442,9 @@
|
|
439
442
|
next : function(validate_current_page) {
|
440
443
|
validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : false;
|
441
444
|
|
442
|
-
curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
445
|
+
let curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
443
446
|
//fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
444
|
-
page_link = curr_page_link
|
447
|
+
let page_link = curr_page_link
|
445
448
|
.parents('.application_section')
|
446
449
|
.nextAll()
|
447
450
|
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
@@ -452,9 +455,9 @@
|
|
452
455
|
},
|
453
456
|
|
454
457
|
prev : function() {
|
455
|
-
curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
458
|
+
let curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
456
459
|
//fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
457
|
-
page_link = curr_page_link
|
460
|
+
let page_link = curr_page_link
|
458
461
|
.parents('.application_section')
|
459
462
|
.prevAll()
|
460
463
|
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
@@ -474,15 +477,15 @@
|
|
474
477
|
$(document).on('change', ".conditional select", function() { $(this).click(); });
|
475
478
|
|
476
479
|
$(document).on('keyup', 'textarea[maxlength]', function() {
|
477
|
-
maxlength = parseInt($(this).attr('maxlength'));
|
478
|
-
remaining = maxlength - $(this).val().length;
|
480
|
+
let maxlength = parseInt($(this).attr('maxlength'));
|
481
|
+
let remaining = maxlength - $(this).val().length;
|
479
482
|
$('#'+$(this).attr('id')+'_count').val(remaining);
|
480
483
|
});
|
481
484
|
|
482
485
|
$(document).on('click', 'a[disabled]', function(event) {
|
483
486
|
event.preventDefault();
|
484
487
|
});
|
485
|
-
})
|
488
|
+
});
|
486
489
|
|
487
490
|
$(function() {
|
488
491
|
fixGridColumnWidths();
|
@@ -492,7 +495,7 @@ $(function() {
|
|
492
495
|
|
493
496
|
function updateTotal(id) {
|
494
497
|
try {
|
495
|
-
total = 0;
|
498
|
+
let total = 0;
|
496
499
|
$(".col_" + id).each(function(index, el) {
|
497
500
|
total += Number($(el).val().replace(',',''));
|
498
501
|
});
|
@@ -502,8 +505,8 @@ function updateTotal(id) {
|
|
502
505
|
}
|
503
506
|
|
504
507
|
function submitToFrame(id, url) {
|
505
|
-
form = $('<form method="post" action="'+url+'.js" endtype="multipart/form-data"></form>')
|
506
|
-
|
508
|
+
let form = $('<form method="post" action="'+url+'.js" endtype="multipart/form-data"></form>')
|
509
|
+
let csrf_token = $('meta[name=csrf-token]').attr('content'),
|
507
510
|
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
508
511
|
dom_id = '#attachment_field_' + id,
|
509
512
|
metadata_input = '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />',
|
@@ -518,9 +521,11 @@ function submitToFrame(id, url) {
|
|
518
521
|
return false
|
519
522
|
}
|
520
523
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
524
|
+
if (typeof scrollTo === 'undefined') {
|
525
|
+
function scrollTo(el) {
|
526
|
+
if ($(el).length == 0) { return; }
|
527
|
+
$('html, body').animate({
|
528
|
+
scrollTop: $(el).offset().top
|
529
|
+
}, 1000);
|
530
|
+
}
|
526
531
|
}
|
@@ -9,8 +9,8 @@
|
|
9
9
|
function get_file_size(file) {
|
10
10
|
return file.size || file.fileSize;
|
11
11
|
}
|
12
|
-
|
13
|
-
|
12
|
+
let available_events = ['onStart', 'onStartOne', 'onProgress', 'onFinishOne', 'onFinish', 'onError'];
|
13
|
+
let options = $.extend({
|
14
14
|
onStart: function(event, total) {
|
15
15
|
return true;
|
16
16
|
},
|
@@ -82,14 +82,14 @@
|
|
82
82
|
}, options);
|
83
83
|
|
84
84
|
function upload( files ) {
|
85
|
-
|
86
|
-
|
85
|
+
let total = files.length;
|
86
|
+
let $this = $(this);
|
87
87
|
if (!$this.triggerHandler('html5_upload.onStart', [total])) {
|
88
88
|
return false;
|
89
89
|
}
|
90
90
|
this.disabled = true;
|
91
|
-
|
92
|
-
|
91
|
+
let uploaded = 0;
|
92
|
+
let xhr = this.html5_upload['xhr'];
|
93
93
|
this.html5_upload['continue_after_abort'] = true;
|
94
94
|
function upload_file(number) {
|
95
95
|
if (number == total) {
|
@@ -101,7 +101,7 @@
|
|
101
101
|
}
|
102
102
|
return;
|
103
103
|
}
|
104
|
-
|
104
|
+
let file = files[number];
|
105
105
|
if (!$this.triggerHandler('html5_upload.onStartOne', [get_file_name(file), number, total])) {
|
106
106
|
return upload_file(number+1);
|
107
107
|
}
|
@@ -156,7 +156,7 @@
|
|
156
156
|
}
|
157
157
|
else {
|
158
158
|
if (window.FormData) {//Many thanks to scottt.tw
|
159
|
-
|
159
|
+
let f = new FormData();
|
160
160
|
f.append(typeof(options.fieldName) == "function" ? options.fieldName() : options.fieldName, file);
|
161
161
|
options.extraFields = typeof(options.extraFields) == "function" ? options.extraFields() : options.extraFields;
|
162
162
|
$.each(options.extraFields, function(key, val){
|
@@ -165,12 +165,12 @@
|
|
165
165
|
xhr.send(f);
|
166
166
|
}
|
167
167
|
else if (file.getAsBinary) {//Thanks to jm.schelcher
|
168
|
-
|
169
|
-
|
170
|
-
|
168
|
+
let boundary = '------multipartformboundary' + (new Date).getTime();
|
169
|
+
let dashdash = '--';
|
170
|
+
let crlf = '\r\n';
|
171
171
|
|
172
172
|
/* Build RFC2388 string. */
|
173
|
-
|
173
|
+
let builder = '';
|
174
174
|
|
175
175
|
builder += dashdash;
|
176
176
|
builder += boundary;
|
@@ -179,7 +179,7 @@
|
|
179
179
|
builder += 'Content-Disposition: form-data; name="'+(typeof(options.fieldName) == "function" ? options.fieldName() : options.fieldName)+'"';
|
180
180
|
|
181
181
|
//thanks to oyejo...@gmail.com for this fix
|
182
|
-
fileName = unescape(encodeURIComponent(get_file_name(file))); //encode_utf8
|
182
|
+
let fileName = unescape(encodeURIComponent(get_file_name(file))); //encode_utf8
|
183
183
|
|
184
184
|
builder += '; filename="' + fileName + '"';
|
185
185
|
builder += crlf;
|
@@ -212,7 +212,7 @@
|
|
212
212
|
|
213
213
|
try {
|
214
214
|
return this.each(function() {
|
215
|
-
|
215
|
+
let file_input = this;
|
216
216
|
this.html5_upload = {
|
217
217
|
xhr: new XMLHttpRequest(),
|
218
218
|
continue_after_abort: true
|
@@ -222,7 +222,7 @@
|
|
222
222
|
upload.call( e.target, this.files );
|
223
223
|
});
|
224
224
|
}
|
225
|
-
|
225
|
+
let self = this;
|
226
226
|
$.each(available_events, function(event) {
|
227
227
|
if (options[available_events[event]]) {
|
228
228
|
$(self).bind("html5_upload."+available_events[event], options[available_events[event]]);
|
@@ -69,28 +69,28 @@ $.extend({
|
|
69
69
|
this.defaults.name = name;
|
70
70
|
},
|
71
71
|
get: function( elem, opts ){
|
72
|
-
|
72
|
+
let settings = $.extend({},this.defaults,opts);
|
73
73
|
// check for empty string in single property
|
74
74
|
if ( !settings.single.length ) settings.single = 'metadata';
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
let data = $.data(elem, settings.single);
|
77
77
|
// returned cached data if it already exists
|
78
78
|
if ( data ) return data;
|
79
79
|
|
80
80
|
data = "{}";
|
81
81
|
|
82
82
|
if ( settings.type == "class" ) {
|
83
|
-
|
83
|
+
let m = settings.cre.exec( elem.className );
|
84
84
|
if ( m )
|
85
85
|
data = m[1];
|
86
86
|
} else if ( settings.type == "elem" ) {
|
87
87
|
if( !elem.getElementsByTagName )
|
88
88
|
return undefined;
|
89
|
-
|
89
|
+
let e = elem.getElementsByTagName(settings.name);
|
90
90
|
if ( e.length )
|
91
91
|
data = $.trim(e[0].innerHTML);
|
92
92
|
} else if ( elem.getAttribute != undefined ) {
|
93
|
-
|
93
|
+
let attr = elem.getAttribute( settings.name );
|
94
94
|
if ( attr )
|
95
95
|
data = attr;
|
96
96
|
}
|