PluginProbe
HT Builder – WordPress Theme Builder for Elementor / 1.2.4
HT Builder – WordPress Theme Builder for Elementor v1.2.4
1.3.5 1.3.4 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.8 1.0.9 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3
ht-builder / includes / admin / recommended-plugins / assets / js / plugins_install_manager.js

plugins_install_manager.js in HT Builder – WordPress Theme Builder for Elementor 1.2.4, at includes/admin/recommended-plugins/assets/js/plugins_install_manager.js

156 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Plugins Install manager JS
3 */
4 ;( function ( $ ) {
5 'use strict';
6
7 // Tab Menu
8 $(".htrp-admin-tabs").on('click', 'a', function(e){
9 e.preventDefault();
10 var $this = $(this),
11 $target = $this.attr('href');
12
13 $this.addClass('htrp-active').parent().siblings().children('a').removeClass('htrp-active');
14 $( '.htrp-admin-tab-pane'+ $target ).addClass('htrp-active').siblings().removeClass('htrp-active');
15 });
16
17 /*
18 * Plugin Installation Manager
19 */
20 var PluginInstallManager = {
21
22 init: function(){
23 $( document ).on('click','.install-now', PluginInstallManager.installNow );
24 $( document ).on('click','.activate-now', PluginInstallManager.activatePlugin);
25 $( document ).on('wp-plugin-install-success', PluginInstallManager.installingSuccess);
26 $( document ).on('wp-plugin-install-error', PluginInstallManager.installingError);
27 $( document ).on('wp-plugin-installing', PluginInstallManager.installingProcess);
28 },
29
30 /**
31 * Installation Error.
32 */
33 installingError: function( e, response ) {
34 e.preventDefault();
35 var $card = $( '.htrp-plugin-' + response.slug );
36 $button = $card.find( '.button' );
37 $button.removeClass( 'button-primary' ).addClass( 'disabled' ).html( wp.updates.l10n.installFailedShort );
38 },
39
40 /**
41 * Installing Process
42 */
43 installingProcess: function(e, args){
44 e.preventDefault();
45 var $card = $( '.htrp-plugin-' + args.slug ),
46 $button = $card.find( '.button' );
47 $button.text( htrp_params.buttontxt.installing ).addClass( 'updating-message' );
48 },
49
50 /**
51 * Plugin Install Now
52 */
53 installNow: function(e){
54 e.preventDefault();
55
56 var $button = $( e.target ),
57 $plugindata = $button.data('pluginopt');
58
59 if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
60 return;
61 }
62 if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
63 wp.updates.requestFilesystemCredentials( e );
64 $( document ).on( 'credential-modal-cancel', function() {
65 var $message = $( '.install-now.updating-message' );
66 $message.removeClass( 'updating-message' ).text( wp.updates.l10n.installNow );
67 wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
68 });
69 }
70 wp.updates.installPlugin( {
71 slug: $plugindata['slug']
72 });
73
74 },
75
76 /**
77 * After Plugin Install success
78 */
79 installingSuccess: function( e, response ) {
80 var $message = $( '.htrp-plugin-' + response.slug ).find( '.button' );
81
82 var $plugindata = $message.data('pluginopt');
83
84 $message.removeClass( 'install-now installed button-disabled updated-message' )
85 .addClass( 'updating-message' )
86 .html( htrp_params.buttontxt.activating );
87
88 setTimeout( function() {
89 $.ajax( {
90 url: htrp_params.ajaxurl,
91 type: 'POST',
92 data: {
93 action : htrp_params.text_domain+'_ajax_plugin_activation',
94 location : $plugindata['location'],
95 },
96 } ).done( function( result ) {
97 if ( result.success ) {
98 $message.removeClass( 'button-primary install-now activate-now updating-message' )
99 .attr( 'disabled', 'disabled' )
100 .addClass( 'disabled' )
101 .text( htrp_params.buttontxt.active );
102
103 } else {
104 $message.removeClass( 'updating-message' );
105 }
106
107 });
108
109 }, 1200 );
110
111 },
112
113 /**
114 * Plugin Activate
115 */
116 activatePlugin: function( e, response ) {
117 e.preventDefault();
118
119 var $button = $( e.target ),
120 $plugindata = $button.data('pluginopt');
121
122 if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
123 return;
124 }
125
126 $button.addClass( 'updating-message button-primary' ).html( htrp_params.buttontxt.activating );
127
128 $.ajax( {
129 url: htrp_params.ajaxurl,
130 type: 'POST',
131 data: {
132 action : htrp_params.text_domain+'_ajax_plugin_activation',
133 location : $plugindata['location'],
134 },
135 }).done( function( response ) {
136 if ( response.success ) {
137 $button.removeClass( 'button-primary install-now activate-now updating-message' )
138 .attr( 'disabled', 'disabled' )
139 .addClass( 'disabled' )
140 .text( htrp_params.buttontxt.active );
141 }
142 });
143
144 },
145
146
147 };
148
149 /**
150 * Initialize PluginInstallManager
151 */
152 $( document ).ready( function() {
153 PluginInstallManager.init();
154 });
155
156 } )( jQuery );