MCPcopy Index your code
hub / github.com/TruthHun/BookStack / doSubmit

Function doSubmit

static/js/jquery.form.js:502–601  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

500
501 // take a breath so that pending repaints get some cpu time before the upload starts
502 function doSubmit() {
503 // make sure form attrs are set
504 var t = $form.attr2('target'),
505 a = $form.attr2('action'),
506 mp = 'multipart/form-data',
507 et = $form.attr('enctype') || $form.attr('encoding') || mp;
508
509 // update form attrs in IE friendly way
510 form.setAttribute('target',id);
511 if (!method || /post/i.test(method) ) {
512 form.setAttribute('method', 'POST');
513 }
514 if (a != s.url) {
515 form.setAttribute('action', s.url);
516 }
517
518 // ie borks in some cases when setting encoding
519 if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
520 $form.attr({
521 encoding: 'multipart/form-data',
522 enctype: 'multipart/form-data'
523 });
524 }
525
526 // support timout
527 if (s.timeout) {
528 timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
529 }
530
531 // look for server aborts
532 function checkState() {
533 try {
534 var state = getDoc(io).readyState;
535 log('state = ' + state);
536 if (state && state.toLowerCase() == 'uninitialized') {
537 setTimeout(checkState,50);
538 }
539 }
540 catch(e) {
541 log('Server abort: ' , e, ' (', e.name, ')');
542 cb(SERVER_ABORT);
543 if (timeoutHandle) {
544 clearTimeout(timeoutHandle);
545 }
546 timeoutHandle = undefined;
547 }
548 }
549
550 // add "extra" data to form if provided in options
551 var extraInputs = [];
552 try {
553 if (s.extraData) {
554 for (var n in s.extraData) {
555 if (s.extraData.hasOwnProperty(n)) {
556 // if using the $.param format that allows for multiple values with the same name
557 if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
558 extraInputs.push(
559 $('<input type="hidden" name="'+s.extraData[n].name+'">').val(s.extraData[n].value)

Callers 1

fileUploadIframeFunction · 0.85

Calls 3

cbFunction · 0.70
$Function · 0.50
setAttributeMethod · 0.45

Tested by

no test coverage detected