PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.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 All 45 releases
← All changes | admin/js/list.js +16 -50 2.3.2 → 3.4 View file →
@@ -6,62 +6,28 @@
6 6 * @author Tobias Bäthge
7 7 * @since 1.0.0
8 8 */
9 9
10 -/* globals confirm, prompt, tb_show, ajaxurl */
11 -
12 10 /**
13 11 * WordPress dependencies.
14 12 */
15 -import { __, _n } from '@wordpress/i18n';
13 +import { _n } from '@wordpress/i18n';
16 14
17 15 /**
18 16 * Internal dependencies.
19 17 */
20 18 import { $ } from './common/functions';
19 +import { initializeReactComponent } from './common/react-loader';
20 +import Screen from './list/screen';
21 21
22 -document.querySelector( '.tablepress-all-tables' ).addEventListener( 'click', ( event ) => {
23 - if ( ! event.target ) {
24 - return;
25 - }
26 -
27 - /**
28 - * Show a popup box with the table's Shortcode.
29 - *
30 - * @since 1.0.0
31 - */
32 - if ( event.target.matches( '.shortcode a' ) ) {
33 - prompt( __( 'To embed this table into a post or page, use this Shortcode:', 'tablepress' ), event.target.title );
34 - event.preventDefault();
35 - return;
36 - }
37 -
38 - /**
39 - * Load a Thickbox with a table preview.
40 - *
41 - * @since 1.0.0
42 - */
43 - if ( event.target.matches( '.table-preview a' ) ) {
44 - const width = window.innerWidth - 120;
45 - const height = window.innerHeight - 120;
46 - tb_show( event.target.title, `${ event.target.href }#TB_iframe=true&height=${ height }&width=${ width }`, false );
47 - event.preventDefault();
48 - return;
49 - }
50 -} );
51 -
52 22 /**
53 23 * Process links with an "ajax-link" class with AJAX.
54 24 *
55 25 * @since 1.0.0
56 26 */
57 -$( '#tablepress-page' ).addEventListener( 'click', ( event ) => {
58 - if ( ! event.target ) {
59 - return;
60 - }
61 -
62 - if ( event.target.matches( '.ajax-link' ) ) {
63 - fetch( `${ ajaxurl }?${ event.target.href.split('?')['1'] }` ) // Append original link's query string to AJAX endpoint.
27 +document.querySelectorAll( '#tablepress-page .ajax-link' ).forEach( ( link ) => {
28 + link.addEventListener( 'click', ( event ) => {
29 + fetch( `${ ajaxurl }?${ event.target.href.split( '?' )[1] }` ) // Append original link's query string to AJAX endpoint.
64 30 .then( ( response ) => response.text() )
65 31 .then( ( result ) => {
66 32 if ( '1' !== result ) {
67 33 return;
@@ -68,15 +34,13 @@
68 34 }
69 35
70 36 if ( 'hide_message' === event.target.dataset.action ) {
71 37 // Remove original message.
72 - event.target.closest( 'div' ).remove();
38 + event.target.closest( '.notice' ).remove();
73 39 }
74 40 } );
75 -
76 41 event.preventDefault();
77 - return;
78 - }
42 + } );
79 43 } );
80 44
81 45 /**
82 46 * Submit Bulk Actions only if an action was selected and at least one table was selected.
@@ -88,17 +52,14 @@
88 52 const bulk_action_dropdown = $( '#doaction' );
89 53 // The bulk action dropdown is only in the DOM if at least one table is shown in the list, thus an existence check is needed.
90 54 if ( bulk_action_dropdown ) {
91 55 bulk_action_dropdown.addEventListener( 'click', ( event ) => {
56 + // Set the ID of the bulk action dropdown in the global variable to the correct `name` attribute of the dropdown, as the default of `action` can not be used.
57 + window.bulkActionObserverIds.bulk_action = 'bulk-action-selector-top';
58 +
92 59 const action = $( '#bulk-action-selector-top' ).value;
93 60 const num_selected = $( '.tablepress-all-tables tbody input:checked' ).length;
94 61
95 - // Do nothing if no action or no tables were selected.
96 - if ( '-1' === action || 0 === num_selected ) {
97 - event.preventDefault();
98 - return;
99 - }
100 -
101 62 // Show AYS prompt when deleting tables.
102 63 if ( 'delete' === action ) {
103 64 if ( ! confirm( _n( 'Do you really want to delete this table?', 'Do you really want to delete these tables?', num_selected, 'tablepress' ) ) ) {
104 65 event.preventDefault();
@@ -106,4 +67,9 @@
106 67 }
107 68 }
108 69 } );
109 70 }
71 +
72 +initializeReactComponent(
73 + 'tablepress-list-screen',
74 + <Screen />,
75 +);