PluginProbe
Social Media Auto Poster – Schedule & Publish to Buffer / trunk
Social Media Auto Poster – Schedule & Publish to Buffer vtrunk
6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.2 6.1.1 6.1.0 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 All 125 releases
wp-to-buffer / lib / shared / js / tables.js

tables.js in Social Media Auto Poster – Schedule & Publish to Buffer trunk, at lib/shared/js/tables.js

92 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Add / delete table row functionality, for repeaters
3 * in tables.
4 *
5 * @package WPZincDashboardWidget
6 * @author WP Zinc
7 */
8
9 /**
10 * Adds a Table Row.
11 *
12 * @since 1.0.0
13 *
14 * @param string selector Selector.
15 * @param string table Table.
16 */
17 function wpzinc_table_row_add( selector, table ) {
18
19 ( function ( $ ) {
20
21 // Get row.
22 var row = $( 'tbody tr.' + selector, $( table ) );
23
24 // Clone row.
25 $( 'tbody tr:last-child', $( table ) ).after( '<tr class="' + selector + '">' + $( row ).html() + '</tr>' );
26
27 } )( jQuery );
28
29 }
30
31 /**
32 * Deletes the table row for the given button.
33 *
34 * @since 1.0.0
35 *
36 * @param object button Delete Table Row Button.
37 */
38 function wpzinc_table_row_delete( button ) {
39
40 ( function ( $ ) {
41
42 // Remove row.
43 $( button ).closest( 'tr' ).remove();
44
45 } )( jQuery );
46
47 }
48
49 /**
50 * Register event listeners
51 *
52 * @since 1.0.0
53 */
54 jQuery( document ).ready(
55 function ( $ ) {
56
57 /**
58 * Add Table Row.
59 */
60 $( 'body' ).on(
61 'click',
62 '.wpzinc-add-table-row',
63 function ( e ) {
64
65 e.preventDefault();
66
67 wpzinc_table_row_add(
68 $( this ).attr( 'data-table-row-selector' ),
69 $( this ).closest( 'table' )
70 );
71
72 }
73 );
74
75 /**
76 * Delete Table Row.
77 */
78 $( 'body' ).on(
79 'click',
80 '.wpzinc-delete-table-row',
81 function ( e ) {
82
83 e.preventDefault();
84
85 wpzinc_table_row_delete( this );
86
87 }
88 );
89
90 }
91 );
92