PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.2
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.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-legacy-core / assets / js / common.js

common.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.2, at admin-legacy-core/assets/js/common.js

84 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function ( $ ) {
2 const wcf_back_step_button = function () {
3 if ( 'cartflows_step' === typenow ) {
4 const step_back_button = $( '#wcf-gutenberg-back-step-button' );
5
6 if ( step_back_button.length > 0 ) {
7 $( '#editor' )
8 .find( '.edit-post-header__toolbar' )
9 .append( step_back_button.html() );
10 }
11 }
12 };
13
14 // Copy the log to clipboard.
15 const wcf_copy_the_log = function () {
16 $( '.wcf-log--copy' ).on( 'click', function ( e ) {
17 e.preventDefault();
18 const $this = $( this );
19
20 const copy_boundry = document.createRange();
21 copy_boundry.selectNode(
22 document.getElementById( 'wcf-log--text' )
23 );
24 ownerDocument.defaultView.getSelection().removeAllRanges();
25 ownerDocument.defaultView.getSelection().addRange( copy_boundry );
26 document.execCommand( 'copy' );
27 ownerDocument.defaultView.getSelection().removeAllRanges();
28
29 $this.text( $this.attr( 'data-success' ) );
30
31 setTimeout( function () {
32 $this.text( $this.attr( 'data-default' ) );
33 }, 500 );
34 } );
35 };
36
37 $( document ).on( 'ready', function () {
38 setTimeout( function () {
39 wcf_back_step_button();
40 }, 300 );
41
42 // Copy the log to clipboard.
43 wcf_copy_the_log();
44 } );
45
46 function installSuccess( event, args ) {
47 event.preventDefault();
48 const plugin_slug = args.slug;
49 activatePlugin( plugin_slug );
50 }
51
52 function activatePlugin( plugin_slug ) {
53 const plugin_init = plugin_slug + '/' + plugin_slug + '.php';
54 $.ajax( {
55 type: 'POST',
56 dataType: 'json',
57 url: cartflows_admin.ajax_url,
58 data: {
59 action: 'cartflows_activate_plugin',
60 security: cartflows_admin.activate_plugin_nonce,
61 init: plugin_init,
62 },
63 success( response ) {
64 if ( response.data && response.data.success ) {
65 if ( 'woocommerce-payments' === plugin_slug ) {
66 window.location.replace(
67 cartflows_admin.admin_base_url +
68 `admin.php?page=wc-admin&path=/payments/connect`
69 );
70 } else {
71 window.location.reload();
72 }
73 }
74 },
75 error() {
76 $( 'body' ).css( 'cursor', 'default' );
77 alert( 'Something went wrong!' );
78 },
79 } );
80 }
81
82 $( document ).on( 'wp-plugin-install-success', installSuccess );
83 } )( jQuery );
84