PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | js/admin/legacy-views.js +41 -39 6.26 → trunk View file →
@@ -2,9 +2,9 @@
2 2 let thisFormId = 0;
3 3
4 4 jQuery( document ).ready( function() {
5 5 const thisForm = document.getElementById( 'form_id' );
6 - if ( thisForm !== null ) {
6 + if ( thisForm ) {
7 7 thisFormId = thisForm.value;
8 8 }
9 9
10 10 // Only load on views settings page.
@@ -59,16 +59,16 @@
59 59 /**
60 60 * Checks the Detail Page slug to see if it's a reserved word and displays a message if it is.
61 61 */
62 62 function checkDetailPageSlug() {
63 - let slug = jQuery( '#param' ).val(),
64 - msg;
63 + let slug = jQuery( '#param' ).val();
64 + let msg;
65 65 slug = slug.trim().toLowerCase();
66 66 if ( Array.isArray( frmAdminJs.unsafe_params ) && frmAdminJs.unsafe_params.includes( slug ) ) {
67 67 msg = frmAdminJs.slug_is_reserved;
68 68 msg = msg.replace( '****', addHtmlTags( slug, 'strong' ) );
69 69 msg += '<br /><br />';
70 - msg += addHtmlTags( '<a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank" class="frm-standard-link">' + frmAdminJs.reserved_words + '</a>', 'div' );
70 + msg += addHtmlTags( `<a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank" class="frm-standard-link">${ frmAdminJs.reserved_words }</a>`, 'div' );
71 71 infoModal( msg );
72 72 }
73 73 }
74 74
@@ -83,9 +83,9 @@
83 83
84 84 while ( match !== null ) {
85 85 if ( Array.isArray( frmAdminJs.unsafe_params ) && frmAdminJs.unsafe_params.includes( match[ 1 ] ) ) {
86 86 if ( unsafeParams !== '' ) {
87 - unsafeParams += '", "' + match[ 1 ];
87 + unsafeParams += `", "${ match[ 1 ] }`;
88 88 } else {
89 89 unsafeParams = match[ 1 ];
90 90 }
91 91 }
@@ -95,9 +95,9 @@
95 95 if ( unsafeParams !== '' ) {
96 96 let msg = frmAdminJs.param_is_reserved;
97 97 msg = msg.replace( '****', addHtmlTags( unsafeParams, 'strong' ) );
98 98 msg += '<br /><br />';
99 - msg += ' <a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank" class="frm-standard-link">' + frmAdminJs.reserved_words + '</a>';
99 + msg += ` <a href="https://codex.wordpress.org/WordPress_Query_Vars" target="_blank" class="frm-standard-link">${ frmAdminJs.reserved_words }</a>`;
100 100
101 101 infoModal( msg );
102 102 }
103 103 }
@@ -103,9 +103,9 @@
103 103 }
104 104
105 105 function addHtmlTags( text, tag ) {
106 106 tag = tag ? tag : 'p';
107 - return '<' + tag + '>' + text + '</' + tag + '>';
107 + return `<${ tag }>${ text }</${ tag }>`;
108 108 }
109 109
110 110 function initToggleShortcodes() {
111 111 if ( typeof tinymce !== 'object' ) {
@@ -112,9 +112,9 @@
112 112 return;
113 113 }
114 114
115 115 DOM = tinymce.DOM;
116 - if ( typeof DOM.events !== 'undefined' && typeof DOM.events.add !== 'undefined' ) {
116 + if ( DOM.events !== undefined && DOM.events.add !== undefined ) {
117 117 DOM.events.add( DOM.select( '.wp-editor-wrap' ), 'mouseover', function() {
118 118 if ( jQuery( '*:focus' ).length > 0 ) {
119 119 return;
120 120 }
@@ -143,9 +143,9 @@
143 143 }
144 144
145 145 function setDefaultPostStatus() {
146 146 const urlQuery = window.location.search.substring( 1 );
147 - if ( urlQuery.indexOf( 'action=edit' ) === -1 ) {
147 + if ( ! urlQuery.includes( 'action=edit' ) ) {
148 148 document.getElementById( 'post-visibility-display' ).textContent = frmAdminJs.private_label;
149 149 document.getElementById( 'hidden-post-visibility' ).value = 'private';
150 150 document.getElementById( 'visibility-radio-private' ).checked = true;
151 151 }
@@ -157,9 +157,9 @@
157 157 }
158 158
159 159 function setMenuOffset() {
160 160 const fields = document.getElementById( 'frm_adv_info' );
161 - if ( fields === null ) {
161 + if ( ! fields ) {
162 162 return;
163 163 }
164 164
165 165 const currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
@@ -168,9 +168,9 @@
168 168 return;
169 169 }
170 170
171 171 const posEle = document.getElementById( 'frm_position_ele' );
172 - if ( posEle === null ) {
172 + if ( ! posEle ) {
173 173 return;
174 174 }
175 175
176 176 const eleOffset = jQuery( posEle ).offset();
@@ -178,9 +178,9 @@
178 178 let desiredOffset = offset - currentOffset;
179 179 let menuHeight = 0;
180 180
181 181 const menu = document.getElementById( 'wpadminbar' );
182 - if ( menu !== null ) {
182 + if ( menu ) {
183 183 menuHeight = menu.offsetHeight;
184 184 }
185 185
186 186 if ( desiredOffset < menuHeight ) {
@@ -191,9 +191,9 @@
191 191 fields.classList.remove( 'frm_fixed' );
192 192 } else {
193 193 fields.classList.add( 'frm_fixed' );
194 194 if ( desiredOffset !== 32 ) {
195 - fields.style.top = desiredOffset + 'px';
195 + fields.style.top = `${ desiredOffset }px`;
196 196 }
197 197 }
198 198 }
199 199
@@ -239,9 +239,9 @@
239 239 action: 'frm_get_cd_tags_box',
240 240 form_id: formId,
241 241 nonce: frmGlobal.nonce
242 242 },
243 - success: function( html ) {
243 + success( html ) {
244 244 jQuery( '#frm_adv_info .categorydiv' ).html( html );
245 245 }
246 246 } );
247 247
@@ -252,9 +252,9 @@
252 252 action: 'frm_get_date_field_select',
253 253 form_id: formId,
254 254 nonce: frmGlobal.nonce
255 255 },
256 - success: function( html ) {
256 + success( html ) {
257 257 jQuery( document.getElementById( 'date_select_container' ) ).html( html );
258 258 }
259 259 } );
260 260 }
@@ -270,9 +270,9 @@
270 270 function clickContentTab() {
271 271 /*jshint validthis:true */
272 272 const link = jQuery( this );
273 273 const t = link.attr( 'href' );
274 - if ( typeof t === 'undefined' ) {
274 + if ( t === undefined ) {
275 275 return false;
276 276 }
277 277
278 278 const c = t.replace( '#', '.' );
@@ -278,9 +278,9 @@
278 278 const c = t.replace( '#', '.' );
279 279 link.closest( '.nav-tab-wrapper' ).find( 'a' ).removeClass( 'nav-tab-active' );
280 280 link.addClass( 'nav-tab-active' );
281 281 jQuery( '.nav-menu-content' ).not( t ).not( c ).hide();
282 - jQuery( t + ',' + c ).show();
282 + jQuery( `${ t },${ c }` ).show();
283 283
284 284 return false;
285 285 }
286 286
@@ -294,9 +294,9 @@
294 294 form_id: thisFormId,
295 295 order_key: getNewRowId( logicRows, 'frm_order_field_', 1 ),
296 296 nonce: frmGlobal.nonce
297 297 },
298 - success: function( html ) {
298 + success( html ) {
299 299 jQuery( '#frm_order_options .frm_logic_rows' ).append( html ).show().prev( '.frm_add_order_row' ).hide();
300 300 }
301 301 } );
302 302 }
@@ -311,9 +311,9 @@
311 311 form_id: thisFormId,
312 312 where_key: getNewRowId( rowDivs, 'frm_where_field_', 1 ),
313 313 nonce: frmGlobal.nonce
314 314 },
315 - success: function( html ) {
315 + success( html ) {
316 316 jQuery( '#frm_where_options .frm_logic_rows' ).append( html ).show().prev( '.frm_add_where_row' ).hide();
317 317 }
318 318 } );
319 319 }
@@ -319,10 +319,10 @@
319 319 }
320 320
321 321 function insertWhereOptions() {
322 322 /*jshint validthis:true */
323 - const value = this.value,
324 - whereKey = jQuery( this ).closest( '.frm_where_row' ).attr( 'id' ).replace( 'frm_where_field_', '' );
323 + const { value } = this;
324 + const whereKey = jQuery( this ).closest( '.frm_where_row' ).attr( 'id' ).replace( 'frm_where_field_', '' );
325 325
326 326 jQuery.ajax( {
327 327 type: 'POST',
328 328 url: ajaxurl,
@@ -331,10 +331,10 @@
331 331 where_key: whereKey,
332 332 field_id: value,
333 333 nonce: frmGlobal.nonce
334 334 },
335 - success: function( html ) {
336 - jQuery( document.getElementById( 'where_field_options_' + whereKey ) ).html( html );
335 + success( html ) {
336 + jQuery( document.getElementById( `where_field_options_${ whereKey }` ) ).html( html );
337 337 }
338 338 } );
339 339 }
340 340
@@ -339,33 +339,35 @@
339 339 }
340 340
341 341 function hideWhereOptions() {
342 342 /*jshint validthis:true */
343 - const value = this.value,
344 - whereKey = jQuery( this ).closest( '.frm_where_row' ).attr( 'id' ).replace( 'frm_where_field_', '' );
343 + const { value } = this;
344 + const whereKey = jQuery( this ).closest( '.frm_where_row' ).attr( 'id' ).replace( 'frm_where_field_', '' );
345 345
346 346 if ( value === 'group_by' || value === 'group_by_newest' ) {
347 - document.getElementById( 'where_field_options_' + whereKey ).style.display = 'none';
347 + document.getElementById( `where_field_options_${ whereKey }` ).style.display = 'none';
348 348 } else {
349 - document.getElementById( 'where_field_options_' + whereKey ).style.display = 'inline-block';
349 + document.getElementById( `where_field_options_${ whereKey }` ).style.display = 'inline-block';
350 350 }
351 351 }
352 352
353 353 function getNewRowId( rows, replace, defaultValue ) {
354 354 if ( ! rows.length ) {
355 - return 'undefined' !== typeof defaultValue ? defaultValue : 0;
355 + return defaultValue !== undefined ? defaultValue : 0;
356 356 }
357 357 return parseInt( rows[ rows.length - 1 ].id.replace( replace, '' ), 10 ) + 1;
358 358 }
359 359
360 360 function toggleAllowedShortcodes( id ) {
361 - let c, clickedID;
362 - if ( typeof id === 'undefined' ) {
361 + let c;
362 + let clickedID;
363 +
364 + if ( id === undefined ) {
363 365 id = '';
364 366 }
365 367 c = id;
366 368
367 - if ( id.indexOf( '-search-input' ) !== -1 ) {
369 + if ( id.includes( '-search-input' ) ) {
368 370 return;
369 371 }
370 372
371 373 if ( id !== '' ) {
@@ -371,14 +373,14 @@
371 373 if ( id !== '' ) {
372 374 const $ele = jQuery( document.getElementById( id ) );
373 375 if ( $ele.attr( 'class' ) && id !== 'wpbody-content' && id !== 'content' && id !== 'dyncontent' && id !== 'success_msg' ) {
374 376 let d = $ele.attr( 'class' ).split( ' ' )[ 0 ];
375 - if ( d === 'frm_long_input' || d === 'frm_98_width' || typeof d === 'undefined' ) {
377 + if ( d === 'frm_long_input' || d === 'frm_98_width' || d === undefined ) {
376 378 d = '';
377 379 } else {
378 380 id = d.trim();
379 381 }
380 - c = c + ' ' + d;
382 + c = `${ c } ${ d }`;
381 383 c = c.replace( 'widefat', '' ).replace( 'frm_with_left_label', '' );
382 384 }
383 385 }
384 386
@@ -394,12 +396,12 @@
394 396 ];
395 397
396 398 if ( jQuery.inArray( id, a ) >= 0 ) {
397 399 jQuery( '.frm_code_list a' ).removeClass( 'frm_noallow' ).addClass( 'frm_allow' );
398 - jQuery( '.frm_code_list a.hide_' + id ).addClass( 'frm_noallow' ).removeClass( 'frm_allow' );
400 + jQuery( `.frm_code_list a.hide_${ id }` ).addClass( 'frm_noallow' ).removeClass( 'frm_allow' );
399 401 } else if ( jQuery.inArray( id, b ) >= 0 ) {
400 - jQuery( '.frm_code_list:not(.frm-dropdown-menu) a:not(.show_' + id + ')' ).addClass( 'frm_noallow' ).removeClass( 'frm_allow' );
401 - jQuery( '.frm_code_list a.show_' + id ).removeClass( 'frm_noallow' ).addClass( 'frm_allow' );
402 + jQuery( `.frm_code_list:not(.frm-dropdown-menu) a:not(.show_${ id })` ).addClass( 'frm_noallow' ).removeClass( 'frm_allow' );
403 + jQuery( `.frm_code_list a.show_${ id }` ).removeClass( 'frm_noallow' ).addClass( 'frm_allow' );
402 404 } else {
403 405 jQuery( '.frm_code_list:not(.frm-dropdown-menu) a' ).addClass( 'frm_noallow' ).removeClass( 'frm_allow' );
404 406 }
405 407
@@ -405,10 +407,10 @@
405 407
406 408 // Automatically select a tab.
407 409 if ( id === 'dyn_default_value' ) {
408 410 clickedID = 'frm_dynamic_values';
409 - document.getElementById( clickedID + '_tab' ).click();
410 - jQuery( '#' + clickedID.replace( /_/g, '-' ) + ' .frm_show_inactive' ).addClass( 'frm_hidden' );
411 - jQuery( '#' + clickedID.replace( /_/g, '-' ) + ' .frm_show_active' ).removeClass( 'frm_hidden' );
411 + document.getElementById( `${ clickedID }_tab` ).click();
412 + jQuery( `#${ clickedID.replace( /_/g, '-' ) } .frm_show_inactive` ).addClass( 'frm_hidden' );
413 + jQuery( `#${ clickedID.replace( /_/g, '-' ) } .frm_show_active` ).removeClass( 'frm_hidden' );
412 414 }
413 415 }
414 416 }() );