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 / common.js

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

56 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * JavaScript code for all TablePress admin screens.
3 *
4 * @package TablePress
5 * @subpackage Views JavaScript
6 * @author Tobias Bäthge
7 * @since 1.0.0
8 */
9
10 /* globals confirm, postboxes, pagenow, jQuery */
11
12 /**
13 * WordPress dependencies.
14 */
15 import { _n } from '@wordpress/i18n';
16
17 /**
18 * Enable toggle/order functionality for post meta boxes.
19 * For TablePress, pagenow has the form "tablepress_{$action}".
20 *
21 * @since 1.0.0
22 */
23 postboxes.add_postbox_toggles( pagenow );
24
25 /**
26 * Turn off the collapsing feature of postboxes when directly clicking on the postbox header bar.
27 * This causes confusion to many users that accidentally click this.
28 * After this, the postboxes can only be collapsed/expanded via the arrow icon in their header bar.
29 *
30 * @since 2.1.0
31 */
32 jQuery( '.postbox .hndle' ).off( 'click.postboxes', postboxes.handle_click );
33
34 document.getElementById( 'tablepress-page' ).addEventListener( 'click', ( event ) => {
35 if ( ! event.target ) {
36 return;
37 }
38
39 /**
40 * Show an AYS warning when a "Delete" link is clicked.
41 *
42 * @since 1.0.0
43 */
44 if ( event.target.matches( '.delete-link' ) ) {
45 if ( ! confirm( _n( 'Do you really want to delete this table?', 'Do you really want to delete these tables?', 1, 'tablepress' ) ) ) {
46 event.preventDefault();
47 return;
48 }
49
50 // Prevent onunload warning, by calling unset method from edit.js (if defined).
51 window?.tp?.helpers?.unsaved_changes?.unset?.();
52
53 return;
54 }
55 } );
56