@@ -6,32 +6,30 @@ jQuery( '.bulk-action' ).append( jQuery( '<option>', {
6
6
const gd_checked_rows = [ ] ;
7
7
8
8
jQuery ( 'tbody th.checkbox input' ) . on ( 'change' , function ( ) {
9
+ const row = jQuery ( this ) . parent ( ) . parent ( ) . attr ( 'row' ) ;
9
10
if ( jQuery ( this ) . is ( ':checked' ) ) {
10
- gd_checked_rows . push ( jQuery ( this ) ) ;
11
+ gd_checked_rows . push ( row ) ;
11
12
} else {
12
- gd_checked_rows . splice ( gd_checked_rows . indexOf ( jQuery ( this ) ) , 1 ) ;
13
+ gd_checked_rows . splice ( gd_checked_rows . indexOf ( row ) , 1 ) ;
13
14
}
14
15
} ) ;
15
16
16
- jQuery ( 'tbody th.checkbox input, .gp-column-checkbox input' ) . on ( 'change' , function ( ) {
17
- if ( jQuery ( this ) . is ( ':checked' ) ) {
18
- jQuery ( '.preview .checkbox input' ) . each ( function ( ) {
19
- gd_checked_rows . push ( jQuery ( this ) ) ;
20
- } ) ;
21
- } else {
22
- gd_checked_rows . slice ( 0 ) ;
23
- }
17
+ jQuery ( 'thead th.checkbox input' ) . on ( 'change' , function ( ) {
18
+ gd_checked_rows . splice ( 0 , gd_checked_rows . length ) ;
19
+ if ( jQuery ( this ) . is ( ':checked' ) ) {
20
+ jQuery ( 'tbody th.checkbox input' ) . each ( function ( ) {
21
+ gd_checked_rows . push ( jQuery ( this ) . parent ( ) . parent ( ) . attr ( 'row' ) ) ;
22
+ } ) ;
23
+ }
24
24
} ) ;
25
25
26
26
jQuery ( '.bulk-actions' ) . on ( 'click' , '.button' , ( e ) => {
27
27
if ( 'copy-from-original' === jQuery ( '.bulk-action option:selected' ) . val ( ) ) {
28
28
let copied_count = 0 ;
29
29
let timeout = 0 ;
30
30
$gp . editor . hide ( ) ; // Avoid validation on open editors that are empty.
31
- gd_checked_rows . forEach ( el => {
32
- const checkbox = jQuery ( el ) ;
33
- const parent = checkbox . closest ( 'tr' ) ;
34
- const row = parent . attr ( 'row' ) ;
31
+ gd_checked_rows . forEach ( row => {
32
+ const checkbox = jQuery ( `#preview-${ row } th.checkbox input` ) ;
35
33
if ( gd_get_setting ( 'autosubmit_bulk_copy_from_original' ) ) {
36
34
setTimeout ( ( ) => {
37
35
$gp . editor . show ( checkbox ) ;
@@ -55,6 +53,7 @@ jQuery( '.bulk-actions' ).on( 'click', '.button', ( e ) => {
55
53
gd_copied_count_notice ( copied_count ) ;
56
54
}
57
55
} ) ;
56
+ gd_checked_rows . splice ( 0 , gd_checked_rows . length ) ;
58
57
e . preventDefault ( ) ;
59
58
return false ;
60
59
}
0 commit comments