PluginProbe
TablePress – Tables in WordPress made easy / 2.4
TablePress – Tables in WordPress made easy v2.4
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
tablepress / admin / js / options.js

options.js in TablePress – Tables in WordPress made easy 2.4, at admin/js/options.js

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * JavaScript code for the "Options" screen, without the CodeMirror handling.
3 *
4 * @package TablePress
5 * @subpackage Views JavaScript
6 * @author Tobias Bäthge
7 * @since 1.0.0
8 */
9
10 /* globals confirm */
11
12 /**
13 * WordPress dependencies.
14 */
15 import { __ } from '@wordpress/i18n';
16
17 /**
18 * Internal dependencies.
19 */
20 import { $ } from './common/functions';
21 import { register_save_changes_keyboard_shortcut } from './common/keyboard-shortcut';
22
23 /**
24 * Enable/disable the regular textarea according to state of "Load Custom CSS" checkbox.
25 *
26 * @since 1.0.0
27 */
28 const $cb_use_custom_css = $( '#option-use-custom-css' );
29 if ( $cb_use_custom_css ) { // The checkbox field only exists for admins!
30 $cb_use_custom_css.addEventListener( 'change', function () {
31 $( '#option-custom-css' ).disabled = ! this.checked;
32 } );
33 $cb_use_custom_css.dispatchEvent( new Event( 'change' ) );
34 }
35
36 /**
37 * On form submit: Enable disabled fields, so that they are sent in the HTTP POST request.
38 *
39 * @since 1.0.0
40 */
41 $( '#tablepress-page-form' ).addEventListener( 'submit', function () {
42 this.querySelectorAll( ':scope input, :scope select, :scope textarea' ).forEach( ( field ) => ( field.disabled = false ) );
43 } );
44
45 register_save_changes_keyboard_shortcut( $( '#tablepress-options-save-changes' ) );
46
47 /**
48 * Require double confirmation when wanting to uninstall TablePress.
49 *
50 * @since 1.0.0
51 */
52 $( '#uninstall-tablepress' ).addEventListener( 'click', ( event ) => {
53 if (
54 ! confirm( __( 'Do you really want to uninstall TablePress and delete ALL data?', 'tablepress' ) ) ||
55 ! confirm( __( 'Are you really sure?', 'tablepress' ) )
56 ) {
57 event.preventDefault();
58 }
59 } );
60