Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move license key section #1042

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2375,4 +2375,32 @@ li.draggable-item .components-panel__body-toggle.components-button{
}
.fz-prompt-button button.components-button {
height: 28px;
}
.fz-license-section button#check_ti_license:disabled {
opacity: 0.5;
pointer-events: none;
}
.fz-license-section button#check_ti_license .dashicons-update {
display: none;
}
.fz-license-section button#check_ti_license.fz-checking .dashicons-update {
-webkit-animation:spin 2s linear infinite;
-moz-animation:spin 2s linear infinite;
animation:spin 2s linear infinite;
display: inline-block;
}
.fz-license-section .help-text:has(.dashicons-dismiss) {
color: #F00;
}
.fz-license-section .help-text:has(.dashicons-yes) {
color: #6eb77a;
}
@-webkit-keyframes spin {
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
100% {
-webkit-transform: rotate(360deg);
transform:rotate(360deg);
}
}
1 change: 1 addition & 0 deletions includes/layouts/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e
case 'general':
?>
<div class="fz-form-wrap">
<?php do_action( 'feedzy_general_setting_before' ); ?>
<div class="form-block">
<div class="fz-form-group">
<label for="feed-post-default-thumbnail" class="form-label"><?php echo esc_html_e( 'Fallback image for imported posts', 'feedzy-rss-feeds' ); ?></label>
Expand Down
45 changes: 44 additions & 1 deletion js/feedzy-setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jQuery( function( $ ) {
$( ':input' ).change(function () {
unsaved = true;
});
$( '#feedzy-settings-submit, #check_wordai_api, #check_spinnerchief_api, #check_aws_api, #check_openai_api, #check_openrouter_api' ).on( 'click', function() {
$( '#feedzy-settings-submit, #check_wordai_api, #check_spinnerchief_api, #check_aws_api, #check_openai_api, #check_openrouter_api, #check_ti_license' ).on( 'click', function() {
unsaved = false;
} );
window.addEventListener( 'beforeunload', function( e ) {
Expand All @@ -78,5 +78,48 @@ jQuery( function( $ ) {
$( document ).on( 'change', '#fz-event-execution', function() {
$( '#fz-execution-offset' ).val( new Date().getTimezoneOffset() / 60 );
} );

// License key.
jQuery('.fz-license-section #license_key').on( 'input', function() {
var licenseKey = jQuery(this).val();
if ( licenseKey !== '' ) {
jQuery( '#check_ti_license' ).removeAttr( 'disabled' );
} else {
jQuery( '#check_ti_license' ).attr( 'disabled', true );
}
jQuery('.fz-license-section input[name="license_key"]').val( licenseKey );
} );

jQuery('.fz-license-section #check_ti_license').on('click', function (e) {
e.preventDefault();
var _this = jQuery(this);
_this
.attr('disabled', true)
.addClass( 'fz-checking' );

_this
.parents( '.fz-license-section' )
.find( '.feedzy-api-error' )
.remove();

const LicenseData = _this
.parent( '.fz-input-group-btn' )
.find( 'input' )
.serialize();

jQuery.post( ajaxurl, LicenseData,
function (response) {
if ( ! response.success ) {
jQuery( '<p class="feedzy-api-error">' + response.message + '</p>' ).insertAfter( jQuery( '.fz-license-section' ).find( '.help-text' ) );
_this
.removeAttr('disabled')
.removeClass( 'fz-checking' );
} else {
window.location.reload();
}
},
'json'
);
});
snackbarNotice();
});
Loading