1(function ($) { 2 $(function () { 3 $('button[type="submit"]').each(function () { 4 $(this).closest('form').submit(function (ev) { 5 if (!ev.isDefaultPrevented()) { 6 var button = $(this).find('button[type="submit"]'); 7 8 // If the submit button is not visible and there is a page break button next that is visible 9 // we asume that we are in case with multi step form, where the enter button is hit and the form is submited, 10 // so that we need to click next instead of submitting the form. 11 var isSubmitButtonVisible = $(button).is(":visible"); 12 var firstPageBreak = $(ev.target).find('[data-sf-btn-role="next"]:visible')[0]; 13 if (!isSubmitButtonVisible && firstPageBreak) { 14 firstPageBreak.click(); 15 ev.preventDefault(); 16 17 return; 18 } 19 20 button.prop('disabled', true); 21 22 //we need first to validate all inputs which require server side validation (cannot be validated client-side) 23 //before the form is submitted and submit the form only if all are valid - e.g. captcha is such control 24 var allInputs = ev.target.querySelectorAll('input, textarea', 'select'); 25 var widgetValidators = []; 26 27 for (var i = 0; i < allInputs.length; i++) { 28 if ($(allInputs[i]).data('widget-validator')) { 29 widgetValidators.push($(allInputs[i]).data('widget-validator')); 30 } 31 } 32 33 if (widgetValidators.length) { 34 ev.preventDefault(); 35 var deferreds = []; 36 for (i = 0; i < widgetValidators.length; i++) { 37 deferreds.push(widgetValidators[i]()); 38 } 39 40 $.when.apply($, deferreds).done(function () { 41 for (var i = 0; i < widgetValidators.length; i++) { 42 if (!arguments[i]) { 43 return false; 44 } 45 } 46 47 if (ev.target.checkValidity()) { 48 ev.target.submit(); 49 } 50 }).always(function () { 51 button.prop('disabled', false); 52 }); 53 } 54 } 55 }); 56 }); 57 }); 58}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.