Skip to content

Commit

Permalink
feat: move license key section
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Dec 27, 2024
1 parent c78e6fa commit 82602cc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
28 changes: 28 additions & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2466,3 +2466,31 @@ 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();
});

0 comments on commit 82602cc

Please sign in to comment.