1jQuery(document).ready(function() { 2 // Handle Form Fields on page load/refresh 3 handleFormFields(); 4}); 5 6/** 7 * Handles Form Fields 8 * 9 */ 10function handleFormFields () { 11 12 // mark disabled fields 13 jQuery('.wppb-form-field:not(.login-submit):not(.wppb-two-factor-authentication) input:disabled').parent().addClass('disabled-field'); 14 15 // set WYSIWYG to readonly if field is disabled 16 jQuery('.wppb-wysiwyg.disabled-field').each(function () { 17 let editorId = jQuery(this).find('textarea').attr('id'); 18 if (typeof tinymce !== 'undefined' && tinymce.get(editorId)) { 19 tinymce.get(editorId).setMode('readonly'); 20 } 21 }); 22 23 // mark Upload/Avatar Fields on Edit Form, if a file is present 24 if ( jQuery('.wppb-avatar').find('.upload-field-details').length > 0 ) 25 jQuery('.wppb-avatar').addClass('file-selected'); 26 if ( jQuery('.wppb-upload').find('.upload-field-details').length > 0 ) 27 jQuery('.wppb-upload').addClass('file-selected'); 28 29 // Disable HTML5 validation. It prevents form field error markers to be displayed for required fields. 30 jQuery('.wppb-register-user').attr('novalidate', 'novalidate'); 31 32 33 // handle changes for Upload and Avatar Fields 34 observeUploadFieldChanges(); 35 36 // handle PMS Billing Field Labels 37 handleBillingFieldLabels(); 38 39} 40 41 42/** 43 * Handles changes for Upload and Avatar Fields 44 * 45 */ 46function observeUploadFieldChanges() { 47 48 // mark Upload/Avatar Fields when a file is selected for upload 49 const uploadFieldObserver = new MutationObserver(handleUploadFieldChanges); 50 51 jQuery('.wppb-avatar, .wppb-upload').each(function() { 52 uploadFieldObserver.observe(this, { 53 childList: true, 54 subtree: true, 55 attributes: true 56 }); 57 }); 58 59 function handleUploadFieldChanges(mutationsList) { 60 mutationsList.forEach(mutation => { 61 if (mutation.type === 'childList' || mutation.type === 'attributes') { 62 let uploadField = jQuery(mutation.target); 63 64 if (uploadField.find('.upload-field-details').length > 0) { 65 uploadField.addClass('file-selected'); 66 } else { 67 uploadField.removeClass('file-selected'); 68 } 69 } 70 }); 71 } 72 73} 74 75 76/** 77 * Handles PMS Billing Fields 78 * 79 */ 80function handleBillingFieldLabels() { 81 82 let pmsSelectFields = jQuery('#pms_billing_country, #pms_billing_state'); 83 84 if (pmsSelectFields.length > 0) { 85 pmsSelectFields.each(function() { 86 jQuery(this).on('chosen:ready', function() { 87 jQuery('#' + jQuery(this).attr('id') + '_chosen .chosen-single.chosen-default span').html(jQuery('label[for="' + jQuery(this).attr('id') + '"]').html()); 88 }); 89 }); 90 } 91 92}
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.