app/web/public/javascripts/jquery.form.js
function doSubmit() {
            // make sure form attrs are set
            var t = $form.attr('target'), a = $form.attr('action');

            // update form attrs in IE friendly way
            form.setAttribute('target',id);
            if (!method) {
                form.setAttribute('method', 'POST');
            }
            if (a != s.url) {
                form.setAttribute('action', s.url);
            }

            // ie borks in some cases when setting encoding
            if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
                $form.attr({
                    encoding: 'multipart/form-data',
                    enctype:  'multipart/form-data'
                });
            }

            // support timout
            if (s.timeout) {
                timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
            }
            
            // look for server aborts
            function checkState() {
                try {
                    var state = getDoc(io).readyState;
                    log('state = ' + state);
                    if (state && state.toLowerCase() == 'uninitialized')
                        setTimeout(checkState,50);
                }
                catch(e) {
                    log('Server abort: ' , e, ' (', e.name, ')');
                    cb(SERVER_ABORT);
                    if (timeoutHandle)
                        clearTimeout(timeoutHandle);
                    timeoutHandle = undefined;
                }
            }

            // add "extra" data to form if provided in options
            var extraInputs = [];
            try {
                if (s.extraData) {
                    for (var n in s.extraData) {
                        if (s.extraData.hasOwnProperty(n)) {
                            extraInputs.push(
                                $('<input type="hidden" name="'+n+'">').attr('value',s.extraData[n])
                                    .appendTo(form)[0]);
                        }
                    }
                }

                if (!s.iframeTarget) {
                    // add iframe to doc and submit the form
                    $io.appendTo('body');
                    if (io.attachEvent)
                        io.attachEvent('onload', cb);
                    else
                        io.addEventListener('load', cb, false);
                }
                setTimeout(checkState,15);
                form.submit();
            }
            finally {
                // reset attrs and remove "extra" input elements
                form.setAttribute('action',a);
                if(t) {
                    form.setAttribute('target', t);
                } else {
                    $form.removeAttr('target');
                }
                $(extraInputs).remove();
            }
        }
function doSubmit() {
            // make sure form attrs are set
            var t = $form.attr('target'), a = $form.attr('action');

            // update form attrs in IE friendly way
            form.setAttribute('target',id);
            if (!method) {
                form.setAttribute('method', 'POST');
            }
            if (a != s.url) {
                form.setAttribute('action', s.url);
            }

            // ie borks in some cases when setting encoding
            if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
                $form.attr({
                    encoding: 'multipart/form-data',
                    enctype:  'multipart/form-data'
                });
            }

            // support timout
            if (s.timeout) {
                timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
            }
            
            // look for server aborts
            function checkState() {
                try {
                    var state = getDoc(io).readyState;
                    log('state = ' + state);
                    if (state && state.toLowerCase() == 'uninitialized')
                        setTimeout(checkState,50);
                }
                catch(e) {
                    log('Server abort: ' , e, ' (', e.name, ')');
                    cb(SERVER_ABORT);
                    if (timeoutHandle)
                        clearTimeout(timeoutHandle);
                    timeoutHandle = undefined;
                }
            }

            // add "extra" data to form if provided in options
            var extraInputs = [];
            try {
                if (s.extraData) {
                    for (var n in s.extraData) {
                        if (s.extraData.hasOwnProperty(n)) {
                            extraInputs.push(
                                $('<input type="hidden" name="'+n+'">').attr('value',s.extraData[n])
                                    .appendTo(form)[0]);
                        }
                    }
                }

                if (!s.iframeTarget) {
                    // add iframe to doc and submit the form
                    $io.appendTo('body');
                    if (io.attachEvent)
                        io.attachEvent('onload', cb);
                    else
                        io.addEventListener('load', cb, false);
                }
                setTimeout(checkState,15);
                form.submit();
            }
            finally {
                // reset attrs and remove "extra" input elements
                form.setAttribute('action',a);
                if(t) {
                    form.setAttribute('target', t);
                } else {
                    $form.removeAttr('target');
                }
                $(extraInputs).remove();
            }
        }
function doSubmit ( ) { // make sure form attrs are set var t = $form . attr ( 'target' ) , a = $form . attr ( 'action' ) ; // update form attrs in IE friendly way form . setAttribute ( 'target' , id ) ; if ( ! method ) { form . setAttribute ( 'method' , 'POST' ) ; } if ( a != s . url ) { form . setAttribute ( 'action' , s . url ) ; } // ie borks in some cases when setting encoding if ( ! s . skipEncodingOverride && ( ! method || / post / i . test ( method ) ) ) { $form . attr ( { encoding : 'multipart/form-data' , enctype : 'multipart/form-data' } ) ; } // support timout if ( s . timeout ) { timeoutHandle = setTimeout ( function ( ) { timedOut = true ; cb ( CLIENT_TIMEOUT_ABORT ) ; } , s . timeout ) ; } // look for server aborts function checkState ( ) { try { var state = getDoc ( io ) . readyState ; log ( 'state = ' + state ) ; if ( state && state . toLowerCase ( ) == 'uninitialized' ) setTimeout ( checkState , 50 ) ; } catch ( e ) { log ( 'Server abort: ' , e , ' (' , e . name , ')' ) ; cb ( SERVER_ABORT ) ; if ( timeoutHandle ) clearTimeout ( timeoutHandle ) ; timeoutHandle = undefined ; } } // add "extra" data to form if provided in options var extraInputs = [ ] ; try { if ( s . extraData ) { for ( var n in s . extraData ) { if ( s . extraData . hasOwnProperty ( n ) ) { extraInputs . push ( $ ( '<input type="hidden" name="' + n + '">' ) . attr ( 'value' , s . extraData [ n ] ) . appendTo ( form ) [ 0 ] ) ; } } } if ( ! s . iframeTarget ) { // add iframe to doc and submit the form $io . appendTo ( 'body' ) ; if ( io . attachEvent ) io . attachEvent ( 'onload' , cb ) ; else io . addEventListener ( 'load' , cb , false ) ; } setTimeout ( checkState , 15 ) ; form . submit ( ) ; } finally { // reset attrs and remove "extra" input elements form . setAttribute ( 'action' , a ) ; if ( t ) { form . setAttribute ( 'target' , t ) ; } else { $form . removeAttr ( 'target' ) ; } $ ( extraInputs ) . remove ( ) ; } }
take a breath so that pending repaints get some cpu time before the upload starts
take a breath so that pending repaints get some cpu time before the upload starts