PluginProbe
TablePress – Tables in WordPress made easy / 1.14
TablePress – Tables in WordPress made easy v1.14
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 / list.js

list.js in TablePress – Tables in WordPress made easy 1.14, at admin/js/list.js

117 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * JavaScript code for the "List Tables" screen
3 *
4 * @package TablePress
5 * @subpackage Views JavaScript
6 * @author Tobias Bäthge
7 * @since 1.0.0
8 */
9
10 /* global prompt, confirm, tablepress_common, tablepress_list, tb_show, ajaxurl */
11
12 jQuery( function( $ ) {
13
14 'use strict';
15
16 /**
17 * Show a popup box with the table's Shortcode
18 *
19 * @since 1.0.0
20 */
21 $( '.tablepress-all-tables' ).on( 'click', '.shortcode a', function( /* event */ ) {
22 prompt( tablepress_list.shortcode_popup, $(this).attr( 'title' ) );
23 return false;
24 } );
25
26 /**
27 * Load a Thickbox with a table preview
28 *
29 * @since 1.0.0
30 */
31 $( '.tablepress-all-tables' ).on( 'click', '.table-preview a', function( /* event */ ) {
32 var width = $( window ).width() - 120,
33 height = $( window ).height() - 120,
34 $this = $(this);
35 if ( $( '#wpadminbar' ).length ) {
36 height -= parseInt( $( '#wpadminbar' ).css( 'height' ), 10 );
37 }
38 tb_show( $this.text(), $this.attr( 'href' ) + 'TB_iframe=true&height=' + height + '&width=' + width, false );
39 return false;
40 } );
41
42 /**
43 * Process links with a class "ajax-link" with AJAX
44 *
45 * @since 1.0.0
46 */
47 $( '#tablepress-page' ).on( 'click', '.ajax-link', function( /* event */ ) {
48 var $link = $(this),
49 action = $link.data( 'action' ),
50 item = $link.data( 'item' ),
51 target = $link.data( 'target' );
52 $.get(
53 ajaxurl,
54 this.href.split('?')['1'], /* query string of the link */
55 function( result ) {
56 if ( '1' !== result ) {
57 return;
58 }
59
60 switch ( action ) {
61 case 'hide_message':
62 /* Donation message links show new message */
63 if ( 'donation_nag' === item && '' !== target ) {
64 $link.closest( 'div' ).after( '<div class="donation-message-after-click-message notice notice-success"><p><strong>' + tablepress_list['donation-message-' + target] + '</strong></p></div>' );
65 $( '.donation-message-after-click-message' ).delay( 10000 ).fadeOut( 2000, function() { $(this).remove(); } );
66 }
67
68 /* Remove original message */
69 $link.closest( 'div' ).remove();
70 break;
71 }
72 }
73 );
74 return false;
75 } );
76
77 /**
78 * Submit Bulk Actions only if an action was selected an a table's checkbox was checked
79 *
80 * @since 1.0.0
81 */
82 $( '#doaction, #doaction2' ).on( 'click', function() {
83 var bulk_action,
84 confirm_message,
85 num_selected = $( '.tablepress-all-tables' ).find( 'tbody' ).find( 'input:checked' ).length;
86
87 // determine location of clicked bulk action controls
88 if ( 'doaction' === this.id ) {
89 bulk_action = 'top';
90 } else {
91 bulk_action = 'bottom';
92 }
93
94 // check whether an action was selected, and whether tables were selected
95 if ( '-1' === $( '#bulk-action-selector-' + bulk_action ).val() ) {
96 return false;
97 }
98 if ( 0 === num_selected ) {
99 return false;
100 }
101
102 // Show AYS prompt for deletion
103 if ( 'delete' === $( '#bulk-action-selector-' + bulk_action ).val() ) {
104 if ( 1 === num_selected ) {
105 confirm_message = tablepress_common.ays_delete_single_table;
106 } else {
107 confirm_message = tablepress_common.ays_delete_multiple_tables;
108 }
109
110 if ( ! confirm( confirm_message ) ) {
111 return false;
112 }
113 }
114 } );
115
116 } );
117