|
|
@ -2,40 +2,85 @@ |
|
|
|
( function ( $ ) { |
|
|
|
( function ( $ ) { |
|
|
|
$( document ).ready( function () { |
|
|
|
$( document ).ready( function () { |
|
|
|
$( '.wrap' ).on( 'click', '.notice-dismiss', function () { |
|
|
|
$( '.wrap' ).on( 'click', '.notice-dismiss', function () { |
|
|
|
$( this ).parent( '#message' ).fadeOut( 500, function () { |
|
|
|
$( this ) |
|
|
|
$( this ).remove(); |
|
|
|
.parent( '#message' ) |
|
|
|
} ); |
|
|
|
.fadeOut( 500, function () { |
|
|
|
|
|
|
|
$( this ).remove(); |
|
|
|
|
|
|
|
} ); |
|
|
|
} ); |
|
|
|
} ); |
|
|
|
$( 'input.in-catalog' ).on( 'change', function () { |
|
|
|
$( 'input.in-catalog' ).on( 'change', function () { |
|
|
|
let book_id = $( this ).parent( 'td' ).siblings( 'th' ).children( 'input' ).val(); |
|
|
|
let book_id = $( this ) |
|
|
|
|
|
|
|
.parent( 'td' ) |
|
|
|
|
|
|
|
.siblings( 'th' ) |
|
|
|
|
|
|
|
.children( 'input' ) |
|
|
|
|
|
|
|
.val(); |
|
|
|
let in_catalog = $( this ).prop( 'checked' ); |
|
|
|
let in_catalog = $( this ).prop( 'checked' ); |
|
|
|
$.ajax( { |
|
|
|
$.ajax( { |
|
|
|
url: ajaxurl, |
|
|
|
url: ajaxurl, |
|
|
|
type: 'POST', |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
action: 'pressbooks_aldine_update_catalog', |
|
|
|
action: 'pressbooks_aldine_update_catalog', |
|
|
|
book_id: book_id, |
|
|
|
book_id: book_id, |
|
|
|
in_catalog: in_catalog, |
|
|
|
in_catalog: in_catalog, |
|
|
|
_ajax_nonce: PB_Aldine_Admin.aldineAdminNonce, |
|
|
|
_ajax_nonce: PB_Aldine_Admin.aldineAdminNonce, |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function (){ |
|
|
|
success: function () { |
|
|
|
if ( $( '#message' ).length < 1 ) { |
|
|
|
if ( $( '#message' ).length < 1 ) { |
|
|
|
$( '<div id="message" class="updated notice is-dismissible">' ).html( '<p><strong>'+PB_Aldine_Admin.catalog_updated+'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">'+PB_Aldine_Admin.dismiss_notice+'</span></button>' ).hide().insertAfter( '.wrap h1' ).fadeIn( 500 ); |
|
|
|
$( '<div id="message" class="updated notice is-dismissible">' ) |
|
|
|
|
|
|
|
.html( |
|
|
|
|
|
|
|
'<p><strong>' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.catalog_updated + |
|
|
|
|
|
|
|
'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.dismiss_notice + |
|
|
|
|
|
|
|
'</span></button>' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.hide() |
|
|
|
|
|
|
|
.insertAfter( '.wrap h1' ) |
|
|
|
|
|
|
|
.fadeIn( 500 ); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$( '#message' ).fadeOut( 500, function () { |
|
|
|
$( '#message' ).fadeOut( 500, function () { |
|
|
|
$( this ).remove(); |
|
|
|
$( this ).remove(); |
|
|
|
$( '<div id="message" class="updated notice is-dismissible">' ).html( '<p><strong>'+PB_Aldine_Admin.catalog_updated+'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">'+PB_Aldine_Admin.dismiss_notice+'</span></button>' ).hide().insertAfter( '.wrap h1' ).fadeIn( 500 ); |
|
|
|
$( '<div id="message" class="updated notice is-dismissible">' ) |
|
|
|
|
|
|
|
.html( |
|
|
|
|
|
|
|
'<p><strong>' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.catalog_updated + |
|
|
|
|
|
|
|
'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.dismiss_notice + |
|
|
|
|
|
|
|
'</span></button>' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.hide() |
|
|
|
|
|
|
|
.insertAfter( '.wrap h1' ) |
|
|
|
|
|
|
|
.fadeIn( 500 ); |
|
|
|
} ); |
|
|
|
} ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
error: function ( jqXHR, textStatus, errorThrown ) { |
|
|
|
error: function ( jqXHR, textStatus, errorThrown ) { |
|
|
|
if ( $( '#message' ).length < 1 ) { |
|
|
|
if ( $( '#message' ).length < 1 ) { |
|
|
|
$( '<div id="message" class="error notice is-dismissible">' ).html( '<p><strong>'+PB_Aldine_Admin.catalog_not_updated+'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">'+PB_Aldine_Admin.dismiss_notice+'</span></button>' ).hide().insertAfter( '.wrap h1' ).fadeIn( 500 ); |
|
|
|
$( '<div id="message" class="error notice is-dismissible">' ) |
|
|
|
|
|
|
|
.html( |
|
|
|
|
|
|
|
'<p><strong>' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.catalog_not_updated + |
|
|
|
|
|
|
|
'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.dismiss_notice + |
|
|
|
|
|
|
|
'</span></button>' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.hide() |
|
|
|
|
|
|
|
.insertAfter( '.wrap h1' ) |
|
|
|
|
|
|
|
.fadeIn( 500 ); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$( '#message' ).fadeOut( 500, function () { |
|
|
|
$( '#message' ).fadeOut( 500, function () { |
|
|
|
$( this ).remove(); |
|
|
|
$( this ).remove(); |
|
|
|
$( '<div id="message" class="error notice is-dismissible">' ).html( '<p><strong>'+PB_Aldine_Admin.catalog_not_updated+'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">'+PB_Aldine_Admin.dismiss_notice+'</span></button>' ).hide().insertAfter( '.wrap h1' ).fadeIn( 500 ); |
|
|
|
$( '<div id="message" class="error notice is-dismissible">' ) |
|
|
|
|
|
|
|
.html( |
|
|
|
|
|
|
|
'<p><strong>' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.catalog_not_updated + |
|
|
|
|
|
|
|
'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' + |
|
|
|
|
|
|
|
PB_Aldine_Admin.dismiss_notice + |
|
|
|
|
|
|
|
'</span></button>' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.hide() |
|
|
|
|
|
|
|
.insertAfter( '.wrap h1' ) |
|
|
|
|
|
|
|
.fadeIn( 500 ); |
|
|
|
} ); |
|
|
|
} ); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|