1jQuery(function(){ 2 3 // handle Edit Profile form admin approval 4 handleAdminApproval(); 5 6}); 7 8 9/** 10 * Handle the admin approval on Edit Profile form 11 * 12 */ 13function handleAdminApproval() { 14 if( jQuery( '#wppb-epaa-finish-review' ).length != 0 ) { 15 16 jQuery('.wppb-user-forms.wppb-edit-user #wppb-epaa-finish-review').click(function (e) { 17 e.preventDefault(); 18 19 $field_ids = jQuery(this).attr('data-wppb-epaa-approve-fields'); 20 $user_id = jQuery(this).attr('data-wppb-epaa-user-id'); 21 22 $unapproved_field_is = []; 23 jQuery('.wppb-epaa-switch input').each(function(){ 24 if ( ! jQuery(this).is(":checked") ) { 25 $unapproved_field_is.push( jQuery(this).attr('data-wppb-epaa-field-id') ); 26 } 27 }); 28 29 30 jQuery('.wppb-user-forms.wppb-edit-user').css('opacity', '0.6'); 31 32 jQuery.post(wppb_epaa.ajaxurl, { 33 action: "wppb_epaa_approve_values", 34 fieldIDS: $field_ids, 35 unapprovedIDS: $unapproved_field_is, 36 userID: $user_id, 37 nonce: wppb_epaa.nonce 38 }, function (response) { 39 if( response == 'success' ){ 40 approvedFieldIds = $field_ids.split(','); 41 for (var i = 0; i < approvedFieldIds.length; i++) { 42 //remove on each field the approve actions and the attribute 43 jQuery( '#wppb-form-element-' + approvedFieldIds[i] + ' *[data-wppb-epaa-approval-action="true"]' ).removeAttr('data-wppb-epaa-approval-action'); 44 jQuery( '#wppb-form-element-' + approvedFieldIds[i] + ' .wppb-epaa-actions' ).remove(); 45 } 46 47 // remove the approved fields from the list of field to be approved 48 jQuery('#wppb-epaa-finish-review').attr('data-wppb-epaa-approve-fields', ''); 49 50 /* remove the buttons if there are no more fields to approve */ 51 if( jQuery('.wppb-user-forms.wppb-edit-user *[data-wppb-epaa-approval-action="true"]').length === 0 ){ 52 jQuery('.wppb-user-forms.wppb-edit-user .wppb-epaa-admin-actions').remove(); 53 } 54 55 } 56 jQuery('.wppb-user-forms.wppb-edit-user').css('opacity', '1.0'); 57 }); 58 59 }); 60 61 62 jQuery("#wppb-epaa-approve-all").click(function (e) { 63 e.preventDefault(); 64 65 fieldIDS = []; 66 67 jQuery('.wppb-epaa-switch input').prop('checked', true); 68 69 jQuery('.wppb-user-forms.wppb-edit-user *[data-wppb-epaa-approval-action="true"]').each(function () { 70 $field_id = jQuery(this).attr('data-wppb-epaa-field-id'); 71 fieldIDS.push($field_id); 72 }); 73 74 fieldIDS = fieldIDS.join(','); 75 76 jQuery('#wppb-epaa-finish-review').attr('data-wppb-epaa-approve-fields', fieldIDS); 77 78 jQuery(this).prop('disabled', true); 79 80 }); 81 82 83 jQuery('.wppb-epaa-switch input').click(function (e) { 84 85 $field_id = jQuery(this).attr('data-wppb-epaa-field-id'); 86 $all_field_ids_to_be_approved = jQuery('#wppb-epaa-finish-review').attr('data-wppb-epaa-approve-fields'); 87 if ($all_field_ids_to_be_approved != '') { 88 $all_field_ids_to_be_approved = $all_field_ids_to_be_approved.split(','); 89 } 90 else { 91 $all_field_ids_to_be_approved = new Array(); 92 } 93 94 95 if (jQuery(this).is(":checked")) { 96 $all_field_ids_to_be_approved.push($field_id); 97 if( jQuery('.wppb-epaa-switch input:checked').length ==jQuery('.wppb-epaa-switch input').length ){ 98 jQuery("#wppb-epaa-approve-all").prop('disabled', true); 99 } 100 } 101 else { 102 var index = $all_field_ids_to_be_approved.indexOf($field_id); 103 if (index > -1) { 104 $all_field_ids_to_be_approved.splice(index, 1); 105 } 106 107 jQuery("#wppb-epaa-approve-all").prop('disabled', false); 108 109 } 110 111 $all_field_ids_to_be_approved = $all_field_ids_to_be_approved.join(','); 112 jQuery('#wppb-epaa-finish-review').attr('data-wppb-epaa-approve-fields', $all_field_ids_to_be_approved); 113 114 }); 115 } 116}
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.