1(function($){ 2 $(document).ready(function(){ 3 var $obj = $('input[data=submit-once]'); 4 5 // solve last submitted qfkey 6 var last_qfkey = getUrlParams('qfKey'); 7 if(!last_qfkey){ 8 if ($('[name=qfKey]').length >= 1) { 9 last_qfkey = $('[name=qfKey]').val(); 10 } 11 else if($('input[name=submit_once_check]').length >= 1){ 12 last_qfkey = $('input[name=submit_once_check]').val(); 13 } 14 } 15 16 if(last_qfkey){ 17 last_submitted = getCookie(last_qfkey); 18 if(last_submitted == 1){ 19 if($obj.parents("form").has('.error:visible').length > 0 || $obj.parents("form").has('.crm-error').length > 0) { 20 last_submitted = 0; // submit validate error from backend 21 } 22 else{ 23 last_submitted = 2; // don't change btn stat anymore. 24 } 25 setCookie(last_qfkey, last_submitted, 3600); 26 } 27 } 28 29 var qfkey = getUrlParams('qfKey'); 30 if(!qfkey){ 31 qfkey = $('[name=qfKey]').val(); 32 if(!qfkey){ 33 qfkey = $('[name=submit_once_check]').val(); 34 } 35 } 36 var submitted = getCookie(qfkey); 37 if($obj.length && qfkey){ 38 if(submitted == "1" || submitted >= 1){ 39 $obj.each(function(){ 40 $(this)[0].onclick = null; 41 }); 42 $obj.css({"color":"#aaa","cursor":"not-allowed"}); 43 $obj.attr("readonly", true); 44 $('.disable-submit-message').show(); 45 $obj.parents("form").on('submit', function(e){ 46 e.preventDefault(); 47 }); 48 } 49 else{ 50 // set cookie 51 $obj.bind('click', function(e){ 52 // If attribute is readonly, don't enable. 53 54 // Not trigger when jvalidate is not enabled. 55 if( $obj.parents("form").has('.error:visible').length > 0 || $obj.parents("form").has('.crm-error').length > 0){ 56 var is_block_by_error = true; 57 } 58 if(submitted < 1 && !is_block_by_error && !$obj.attr("readonly")){ 59 setCookie(qfkey, 1, 3600); 60 submitted = 1; 61 $(this).val($(this).val() + ' ...'); 62 } 63 }); 64 } 65 66 // prevent double submit 67 $obj.parents("form").on('submit', function(e){ 68 var $form = $(this); 69 window.setTimeout(function(){ 70 if( $form.has('.error:visible').length > 0 || $form.has('.crm-error').length > 0){ 71 var is_block_by_error = true; 72 } 73 if ($form.data('submitted') === true || is_block_by_error || $obj.attr("readonly")) { 74 // Previously submitted - don't submit again 75 e.preventDefault(); 76 } 77 else { 78 // Mark it so that the next submit can be ignored 79 $form.data('submitted', true); 80 // Don't use disabled cause profile edit will have problem. refs #20289 - 9F 81 $obj.attr("readonly", true); 82 $obj.first().before('<i class="zmdi zmdi-rotate-right zmdi-hc-spin"></i>'); 83 if ($obj.data('once-msg')) { 84 let msg = $obj.data('once-msg'); 85 $obj.first().parent().prepend('<div class="once-message"><i class="zmdi zmdi-rotate-right zmdi-hc-spin"></i>'+msg+'<div>'); 86 } 87 } 88 }, 250); 89 }); 90 } 91 92 var $obj_click_once = $('input[data=click-once]'); 93 if($obj_click_once.length){ 94 // prevent double submit 95 $obj_click_once.parents("form").on('submit', function(e){ 96 var $form = $(this); 97 if ($form.data('submitted') === true || $obj_click_once.attr("readonly")) { 98 // Previously submitted - don't submit again 99 e.preventDefault(); 100 } 101 else { 102 // Mark it so that the next submit can be ignored 103 $form.data('submitted', true); 104 // Don't use disabled cause profile edit will have problem. refs #20289 - 9F 105 $obj_click_once.attr("readonly", true); 106 $obj_click_once.first().before('<i class="zmdi zmdi-rotate-right zmdi-hc-spin"></i>'); 107 if ($obj_click_once.data('once-msg')) { 108 let msg = $obj_click_once.data('once-msg'); 109 $obj_click_once.first().parent().prepend('<div class="once-message">'+msg+'<div>'); 110 } 111 } 112 }); 113 } 114 }); 115})(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.