PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.2
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.2
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / admin / assets / js / setup-wizard.js

setup-wizard.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.2, at admin/assets/js/setup-wizard.js

141 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( $ ) {
2
3 CartFlowsWizard = {
4
5 init: function() {
6 this._bind();
7 },
8
9 /**
10 * Bind
11 */
12 _bind: function() {
13 $( document ).on('click', '.wcf-install-plugins', CartFlowsWizard._installNow);
14 $( document ).on('wp-plugin-installing' , CartFlowsWizard._pluginInstalling);
15 $( document ).on('wp-plugin-install-error' , CartFlowsWizard._installError);
16 $( document ).on('wp-plugin-install-success' , CartFlowsWizard._installSuccess);
17 },
18
19 /**
20 * Installing Plugin
21 */
22 _pluginInstalling: function(event, args) {
23 event.preventDefault();
24 console.log( 'Installing..' );
25 },
26
27 /**
28 * Install Error
29 */
30 _installError: function(event, args) {
31 event.preventDefault();
32 console.log( 'Install Error!' );
33
34 var redirect_link = $( '.page-builder-list' ).data('redirect-link') || '';
35 console.log( redirect_link );
36 if( '' !== redirect_link ) {
37 window.location = redirect_link;
38 console.log( 'redirecting..' );
39 }
40 },
41
42 /**
43 * Install Success
44 */
45 _installSuccess: function(event, args) {
46 event.preventDefault();
47
48 CartFlowsWizard._activatePlugin();
49 },
50
51 _activatePlugin: function() {
52 var plugin_slug = $( '.page-builder-list option:selected' ).data( 'slug' ) || '',
53 plugin_init = $( '.page-builder-list option:selected' ).data( 'init' ) || '',
54 redirect_link = $( '.page-builder-list' ).data('redirect-link') || '';
55
56 console.log( plugin_slug );
57 console.log( plugin_init );
58 console.log( redirect_link );
59
60 $.ajax({
61 url : ajaxurl,
62 method : 'POST',
63 data : {
64 action : 'page_builder_step_save',
65 page_builder : plugin_slug,
66 plugin_init : plugin_init,
67 security : cartflows_admin.wcf_page_builder_step_save_nonce
68 },
69 })
70 .done(function( data ) {
71 console.log( data );
72 console.log( redirect_link );
73 if( data.success ) {
74 if( '' !== redirect_link ) {
75 window.location = redirect_link;
76 }
77 }
78 })
79 .fail(function() {
80 console.log("error");
81 })
82 .always(function() {
83 console.log("complete");
84 });
85 },
86
87 /**
88 * Install Now
89 */
90 _installNow: function(event)
91 {
92 event.preventDefault();
93
94 var $button = $( this ),
95 $document = $(document),
96 plugin_slug = $( '.page-builder-list option:selected' ).data( 'slug' ) || '',
97 install = $( '.page-builder-list option:selected' ).data( 'install' ) || 'no',
98 plugin_init = $( '.page-builder-list option:selected' ).data( 'init' ) || '';
99
100 if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
101 return;
102 }
103
104 $button.addClass( 'updating-message' );
105
106 if( 'yes' === install ) {
107 CartFlowsWizard._activatePlugin();
108 } else {
109
110 console.log( 'plugin_slug' );
111
112
113 if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
114 wp.updates.requestFilesystemCredentials( event );
115
116 $document.on( 'credential-modal-cancel', function() {
117 var $message = $( '.install-now.updating-message' );
118
119 $message
120 .removeClass( 'updating-message' )
121 .text( wp.updates.l10n.installNow );
122
123 wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
124 } );
125 }
126
127 wp.updates.installPlugin( {
128 slug: plugin_slug
129 } );
130 }
131
132
133 },
134 }
135
136 $( document ).ready(function() {
137 CartFlowsWizard.init();
138 });
139
140
141 } )( jQuery );