| @@ -17,9 +17,9 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * Internal dependencies. |
| 19 | 19 | */ |
| 20 | 20 | import { $ } from './common/functions'; |
| 21 | -import { register_save_changes_keyboard_shortcut } from './common/keyboard-shortcut'; | |
| 21 | +import { registerSaveChangesKeyboardShortcut } from './common/keyboard-shortcut'; | |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Enable/disable the regular textarea according to state of "Load Custom CSS" checkbox. |
| 25 | 25 | * |
| @@ -37,13 +37,13 @@ | ||
| 37 | 37 | * On form submit: Enable disabled fields, so that they are sent in the HTTP POST request. |
| 38 | 38 | * |
| 39 | 39 | * @since 1.0.0 |
| 40 | 40 | */ |
| 41 | -document.querySelector( '#tablepress-page form' ).addEventListener( 'submit', function () { | |
| 41 | +$( '#tablepress-page-form' ).addEventListener( 'submit', function () { | |
| 42 | 42 | this.querySelectorAll( ':scope input, :scope select, :scope textarea' ).forEach( ( field ) => ( field.disabled = false ) ); |
| 43 | 43 | } ); |
| 44 | 44 | |
| 45 | -register_save_changes_keyboard_shortcut( $( '#tablepress-options-save-changes' ) ); | |
| 45 | +registerSaveChangesKeyboardShortcut( $( '#tablepress-options-save-changes' ) ); | |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Require double confirmation when wanting to uninstall TablePress. |
| 49 | 49 | * |
| @@ -48,12 +48,15 @@ | ||
| 48 | 48 | * Require double confirmation when wanting to uninstall TablePress. |
| 49 | 49 | * |
| 50 | 50 | * @since 1.0.0 |
| 51 | 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 | -} ); | |
| 52 | +const $button_uninstall = $( '#uninstall-tablepress' ); | |
| 53 | +if ( $button_uninstall ) { // The button only exists for admins! | |
| 54 | + $button_uninstall.addEventListener( 'click', ( event ) => { | |
| 55 | + if ( | |
| 56 | + ! confirm( __( 'Do you really want to uninstall TablePress and delete ALL data?', 'tablepress' ) ) || | |
| 57 | + ! confirm( __( 'Are you really sure?', 'tablepress' ) ) | |
| 58 | + ) { | |
| 59 | + event.preventDefault(); | |
| 60 | + } | |
| 61 | + } ); | |
| 62 | +} | |