PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.1
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 / flow-admin-edit.js

flow-admin-edit.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.1, at admin/assets/js/flow-admin-edit.js

148 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 /* Create default steps */
4 var wcf_setup_default_steps = function() {
5
6 $('.wcf-setup-default-steps').on('click', function(e) {
7
8 e.preventDefault();
9
10 if( $( 'body' ).hasClass( 'post-type-cartflows_flow' ) && $( 'body' ).hasClass( 'post-new-php' ) ) {
11
12 var $wpTitle = $( '#title' );
13
14 if ( ! $wpTitle.val() ) {
15 $wpTitle.val( 'Flow #' + $( '#post_ID' ).val() );
16 }
17
18 if ( wp.autosave ) {
19 wp.autosave.server.triggerSave();
20 }
21
22 $(window).off( 'beforeunload.edit-post' );
23 }
24
25 var $this = $(this);
26 post_id = $( 'form#post #post_ID').val();
27
28 $.ajax({
29 url: ajaxurl,
30 data: {
31 action: "cartflows_setup_default_steps",
32 post_id : post_id,
33 security: cartflows_admin.wcf_setup_default_steps_nonce
34 },
35 dataType: 'json',
36 type: 'POST',
37 success: function ( data ) {
38
39 if ( data.status ) {
40
41
42
43 location.href = data.redirect.replace( '&', '&' );
44 }
45 console.log( data );
46 }
47 });
48 });
49 }
50
51 var wcf_steps_hide_show_delete = function() {
52
53 $('.wcf-flow-settings .wcf-step-delete').on('click', function(e) {
54
55 e.preventDefault();
56 var current_target = $( e.target );
57
58 var $this = $(this),
59 step_id = $this.data('id'),
60 icon_span = $this.find('.dashicons-trash'),
61 text_span = $this.find('.wcf-step-act-btn-text'),
62 parent = $this.parents('.wcf-step-wrap');
63
64 var delete_status = confirm( "This action will delete this flow step. Are you sure?" );
65 if (true == delete_status) {
66
67 console.log( 'Step Deleting' );
68 icon_span.addClass('wp-ui-text-notification');
69 text_span.addClass('wp-ui-text-notification').text('Deleting..');
70 //$this.text('Deleting..');
71
72 var post_id = $( 'form#post #post_ID').val();
73
74 $.ajax({
75 url: ajaxurl,
76 data: {
77 action: "cartflows_delete_flow_step",
78 post_id : post_id,
79 step_id : step_id,
80 security: cartflows_admin.wcf_delete_flow_step_nonce
81 },
82 dataType: 'json',
83 type: 'POST',
84 success: function ( data ) {
85 parent.slideUp(400, 'swing', function() {
86 parent.remove();
87 });
88 console.log( data );
89 }
90 });
91 }
92 });
93 }
94
95 var wcf_flow_steps_sortbale = function() {
96
97 $('.wcf-flow-settings .wcf-flow-steps-container').sortable({
98
99 connectWith: '.wcf-flow-steps-container',
100
101 update: function(event, ui) {
102
103 var $this = $(this),
104 step_fields = $this.find('.wcf-steps-hidden'),
105 step_ids = [],
106 post_id = $( 'form#post #post_ID').val();
107
108 step_fields.each(function(i, obj) {
109 step_ids.push( $(this).val() ) //test
110 });
111
112 $this.sortable('disable');
113
114 $.ajax({
115 url: ajaxurl,
116 data: {
117 action: "cartflows_reorder_flow_steps",
118 post_id : post_id,
119 step_ids : step_ids,
120 security: cartflows_admin.wcf_reorder_flow_steps_nonce
121 },
122 dataType: 'json',
123 type: 'POST',
124 success: function ( data ) {
125
126 $this.sortable('enable');
127
128 if ( data.status ) {
129 console.log( 'Sorted' );
130 }
131
132 console.log( data );
133 }
134 });
135 }
136 });
137
138 }
139 $(document).ready(function($) {
140
141 wcf_setup_default_steps();
142
143 wcf_steps_hide_show_delete();
144
145 wcf_flow_steps_sortbale();
146 });
147 })(jQuery);
148