11/**
2- * Interactions used by the User Privacy tools in WordPress.
3- *
42 * @output wp-admin/js/privacy-tools.js
53 */
64
7- // Privacy request action handling.
5+ /**
6+ * Sets the interactions used by the User Privacy tools in WordPress.
7+ *
8+ * @param {jQueryStatic } $ The jQuery object.
9+ */
810jQuery ( function ( $ ) {
911 var __ = wp . i18n . __ ,
1012 copiedNoticeTimeout ;
1113
14+ /**
15+ * Sets the state of the action.
16+ *
17+ * @param {jQuery } $action The action to set the state for.
18+ * @param {string } state The state to set the action to.
19+ * @return {void }
20+ */
1221 function setActionState ( $action , state ) {
1322 $action . children ( ) . addClass ( 'hidden' ) ;
1423 $action . children ( '.' + state ) . removeClass ( 'hidden' ) ;
1524 }
1625
26+ /**
27+ * Clears any results row after the request row.
28+ *
29+ * @param {jQuery } $requestRow The request row to clear results for.
30+ * @return {void }
31+ */
1732 function clearResultsAfterRow ( $requestRow ) {
1833 $requestRow . removeClass ( 'has-request-results' ) ;
1934
@@ -22,6 +37,15 @@ jQuery( function( $ ) {
2237 }
2338 }
2439
40+ /**
41+ * Appends a results row after the request row.
42+ *
43+ * @param {jQuery } $requestRow The request row to append the results after.
44+ * @param {string } classes The classes to add to the results row.
45+ * @param {string } summaryMessage The summary message to display in the results row.
46+ * @param {string[] } additionalMessages Additional messages to display in the results row.
47+ * @return {void }
48+ */
2549 function appendResultsAfterRow ( $requestRow , classes , summaryMessage , additionalMessages ) {
2650 var itemList = '' ,
2751 resultRowClasses = 'request-results' ;
@@ -76,6 +100,12 @@ jQuery( function( $ ) {
76100 clearResultsAfterRow ( $requestRow ) ;
77101 setExportProgress ( 0 ) ;
78102
103+ /**
104+ * Handles a successful export.
105+ *
106+ * @param {string } zipUrl The URL of the generated ZIP file, if available.
107+ * @return {void }
108+ */
79109 function onExportDoneSuccess ( zipUrl ) {
80110 var summaryMessage = __ ( 'This user’s personal data export link was sent.' ) ;
81111
@@ -96,6 +126,12 @@ jQuery( function( $ ) {
96126 setTimeout ( function ( ) { $rowActions . removeClass ( 'processing' ) ; } , 500 ) ;
97127 }
98128
129+ /**
130+ * Handles an export failure.
131+ *
132+ * @param {string } errorMessage The error message to display.
133+ * @return {void }
134+ */
99135 function onExportFailure ( errorMessage ) {
100136 var summaryMessage = __ ( 'An error occurred while attempting to export personal data.' ) ;
101137
@@ -108,13 +144,26 @@ jQuery( function( $ ) {
108144 setTimeout ( function ( ) { $rowActions . removeClass ( 'processing' ) ; } , 500 ) ;
109145 }
110146
147+ /**
148+ * Updates the progress of the export process.
149+ *
150+ * @param {number } exporterIndex The index of the exporter to process.
151+ * @return {void }
152+ */
111153 function setExportProgress ( exporterIndex ) {
112154 var progress = ( exportersCount > 0 ? exporterIndex / exportersCount : 0 ) ,
113155 progressString = Math . round ( progress * 100 ) . toString ( ) + '%' ;
114156
115157 $progress . html ( progressString ) ;
116158 }
117159
160+ /**
161+ * Performs the next export request.
162+ *
163+ * @param {number } exporterIndex The index of the exporter to process.
164+ * @param {number } pageIndex The index of the page to process for the current exporter.
165+ * @return {void }
166+ */
118167 function doNextExport ( exporterIndex , pageIndex ) {
119168 $ . ajax (
120169 {
@@ -181,6 +230,11 @@ jQuery( function( $ ) {
181230 clearResultsAfterRow ( $requestRow ) ;
182231 setErasureProgress ( 0 ) ;
183232
233+ /**
234+ * Handles a successful erasure.
235+ *
236+ * @return {void }
237+ */
184238 function onErasureDoneSuccess ( ) {
185239 var summaryMessage = __ ( 'No personal data was found for this user.' ) ,
186240 classes = 'notice-success' ;
@@ -207,6 +261,9 @@ jQuery( function( $ ) {
207261 setTimeout ( function ( ) { $rowActions . removeClass ( 'processing' ) ; } , 500 ) ;
208262 }
209263
264+ /**
265+ * Handles an erasure failure.
266+ */
210267 function onErasureFailure ( ) {
211268 var summaryMessage = __ ( 'An error occurred while attempting to find and erase personal data.' ) ;
212269
@@ -217,13 +274,26 @@ jQuery( function( $ ) {
217274 setTimeout ( function ( ) { $rowActions . removeClass ( 'processing' ) ; } , 500 ) ;
218275 }
219276
277+ /**
278+ * Updates the progress of the erasure process.
279+ *
280+ * @param {number } eraserIndex The index of the eraser to process.
281+ * @return {void }
282+ */
220283 function setErasureProgress ( eraserIndex ) {
221284 var progress = ( erasersCount > 0 ? eraserIndex / erasersCount : 0 ) ,
222285 progressString = Math . round ( progress * 100 ) . toString ( ) + '%' ;
223286
224287 $progress . html ( progressString ) ;
225288 }
226289
290+ /**
291+ * Performs the next erasure request.
292+ *
293+ * @param {number } eraserIndex The index of the eraser to process.
294+ * @param {number } pageIndex The index of the page to process for the current eraser.
295+ * @return {void }
296+ */
227297 function doNextErasure ( eraserIndex , pageIndex ) {
228298 $ . ajax ( {
229299 url : window . ajaxurl ,
0 commit comments