cl01/wp-content/themes/hester/inc/admin/assets/js/hester-admin.min.js
2025-02-24 12:39:24 +08:00

29 lines
2.7 KiB
JavaScript
Executable File

! ( function( $ ) {
'use strict';var HesterAdmin = {init: function() {
$( document ).ready( HesterAdmin.ready ), $( window ).on( 'load', HesterAdmin.load ), HesterAdmin.bindUIActions(), $( document ).trigger( 'hesterReady' );
}, ready: function() {}, load: function() {
window.dispatchEvent( new Event( 'resize' ) );
}, resize: function() {}, bindUIActions: function() {
var $this,
$wrap = $( '#wpwrap' );$( 'body' );$wrap.on( 'click', '.plugins .hester-btn:not(.active)', ( function( e ) {
e.preventDefault(), $wrap.find( '.plugins .hester-btn.in-progress' ).length || ( $this = $( this ), HesterAdmin.pluginAction( $this ) );
}) ), $( document ).on( 'wp-plugin-install-success', HesterAdmin.pluginInstallSuccess ), $( document ).on( 'wp-plugin-install-error', HesterAdmin.pluginInstallError );
}, pluginAction: function( $button ) {
if ( $button.addClass( 'in-progress' ).attr( 'disabled', 'disabled' ).html( hester_strings.texts[$button.data( 'action' ) + '-inprogress']), 'install' === $button.data( 'action' ) ) {
wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked && ( wp.updates.requestFilesystemCredentials( event ), $( document ).on( 'credential-modal-cancel', ( function() {
$button.removeAttr( 'disabled' ).removeClass( 'in-progress' ).html( hester_strings.texts.install ), wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
}) ) ), wp.updates.installPlugin({slug: $button.data( 'plugin' )});
} else {
var data = {_ajax_nonce: hester_strings.wpnonce, plugin: $button.data( 'plugin' ), action: 'hester-plugin-' + $button.data( 'action' )};$.post( hester_strings.ajaxurl, data, ( function( response ) {
response.success ? $button.data( 'redirect' ) ? window.location.href = $button.data( 'redirect' ) : location.reload() : $( '.plugins .hester-btn.in-progress' ).removeAttr( 'disabled' ).removeClass( 'in-progress primary' ).addClass( 'secondary' ).html( hester_strings.texts.retry );
}) );
}
}, pluginInstallSuccess: function( event, response ) {
event.preventDefault();var activatedSlug,
$init = jQuery( event.target ).data( 'init' );activatedSlug = void 0 === $init ? response.slug : $init;var $button = $( '.plugins a[data-plugin="' + activatedSlug + '"]' );$button.data( 'action', 'activate' ), HesterAdmin.pluginAction( $button );
}, pluginInstallError: function( event, response ) {
event.preventDefault();var activatedSlug,
$init = jQuery( event.target ).data( 'init' );activatedSlug = void 0 === $init ? response.slug : $init, $( '.plugins a[data-plugin="' + activatedSlug + '"]' ).attr( 'disabled', 'disabled' ).removeClass( 'in-progress primary' ).addClass( 'secondary' ).html( wp.updates.l10n.installFailedShort );
}};HesterAdmin.init(), window.hesteradmin = HesterAdmin;
}( jQuery ) );