v0.1.0
This commit is contained in:
commit
bc1cb5e00a
32 changed files with 4254 additions and 0 deletions
89
admin/js/robotstxt-manager-settings.js
Normal file
89
admin/js/robotstxt-manager-settings.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Settings page JS — "Test connection" and "Delete API key" handlers.
|
||||
*
|
||||
* @global RobotstxtManagerSettings
|
||||
* @global jQuery
|
||||
* @package Robotstxt_Manager
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
// Test connection.
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#robotstxt-manager-test-connection',
|
||||
function () {
|
||||
var $btn = $( this );
|
||||
var $result = $( '#robotstxt-manager-test-result' );
|
||||
|
||||
$btn.prop( 'disabled', true ).text( RobotstxtManagerSettings.i18n.testing );
|
||||
$result.text( '' ).css( 'color', '' );
|
||||
|
||||
$.post(
|
||||
RobotstxtManagerSettings.ajaxUrl,
|
||||
{
|
||||
action: 'robotstxt_manager_test_connection',
|
||||
nonce: RobotstxtManagerSettings.nonce,
|
||||
},
|
||||
function ( response ) {
|
||||
if ( response.success ) {
|
||||
$result.text( response.data.message ).css( 'color', '#00a32a' );
|
||||
} else {
|
||||
$result.text( response.data.message ).css( 'color', '#d63638' );
|
||||
}
|
||||
}
|
||||
).fail(
|
||||
function () {
|
||||
$result.text( RobotstxtManagerSettings.i18n.ajaxError ).css( 'color', '#d63638' );
|
||||
}
|
||||
).always(
|
||||
function () {
|
||||
$btn.prop( 'disabled', false ).text( RobotstxtManagerSettings.i18n.testLabel );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Delete API key.
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#robotstxt-manager-delete-key',
|
||||
function () {
|
||||
var $btn = $( this );
|
||||
var $result = $( '#robotstxt-manager-test-result' );
|
||||
|
||||
if ( ! window.confirm( RobotstxtManagerSettings.i18n.deleteConfirm ) ) { /* eslint-disable-line no-alert */
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.prop( 'disabled', true ).text( RobotstxtManagerSettings.i18n.deleting );
|
||||
$result.text( '' ).css( 'color', '' );
|
||||
|
||||
$.post(
|
||||
RobotstxtManagerSettings.ajaxUrl,
|
||||
{
|
||||
action: 'robotstxt_manager_delete_key',
|
||||
nonce: RobotstxtManagerSettings.deleteNonce,
|
||||
},
|
||||
function ( response ) {
|
||||
if ( response.success ) {
|
||||
$result.text( RobotstxtManagerSettings.i18n.deleted ).css( 'color', '#00a32a' );
|
||||
// Hide the delete button + test button; update description.
|
||||
$btn.hide();
|
||||
$( '#robotstxt-manager-test-connection' ).prop( 'disabled', true );
|
||||
$( '#robotstxt_manager_api_key' ).next( '.description' ).html( RobotstxtManagerSettings.i18n.deleted );
|
||||
} else {
|
||||
$result.text( response.data.message ).css( 'color', '#d63638' );
|
||||
$btn.prop( 'disabled', false ).text( RobotstxtManagerSettings.i18n.deleteLabel );
|
||||
}
|
||||
}
|
||||
).fail(
|
||||
function () {
|
||||
$result.text( RobotstxtManagerSettings.i18n.ajaxError ).css( 'color', '#d63638' );
|
||||
$btn.prop( 'disabled', false ).text( RobotstxtManagerSettings.i18n.deleteLabel );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}( jQuery ) );
|
||||
Loading…
Reference in a new issue