PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.17
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.17
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 / assets / js / import.js

import.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.17, at assets/js/import.js

1,472 lines 44.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * AJAX Request Queue
3 *
4 * - add()
5 * - remove()
6 * - run()
7 * - stop()
8 *
9 * @since 1.0.0
10 */
11
12 var CartFlowsAjaxQueue = (function() {
13
14 var requests = [];
15
16 return {
17
18 /**
19 * Add AJAX request
20 *
21 * @since 1.0.0
22 */
23 add: function(opt) {
24 requests.push(opt);
25 },
26
27 /**
28 * Remove AJAX request
29 *
30 * @since 1.0.0
31 */
32 remove: function(opt) {
33 if( jQuery.inArray(opt, requests) > -1 )
34 requests.splice($.inArray(opt, requests), 1);
35 },
36
37 /**
38 * Run / Process AJAX request
39 *
40 * @since 1.0.0
41 */
42 run: function() {
43 var self = this,
44 oriSuc;
45
46 if( requests.length ) {
47 oriSuc = requests[0].complete;
48
49 requests[0].complete = function() {
50 if( typeof(oriSuc) === 'function' ) oriSuc();
51 requests.shift();
52 self.run.apply(self, []);
53 };
54
55 jQuery.ajax(requests[0]);
56
57 } else {
58
59 self.tid = setTimeout(function() {
60 self.run.apply(self, []);
61 }, 1000);
62 }
63 },
64
65 /**
66 * Stop AJAX request
67 *
68 * @since 1.0.0
69 */
70 stop: function() {
71
72 requests = [];
73 clearTimeout(this.tid);
74 }
75 };
76
77 }());
78
79
80 (function($){
81
82 CartFlowsImport = {
83
84 doc : $( document ),
85 wrap : $( '.wcf-flow-steps-data-wrap' ),
86 inner : $( '.wcf-flow-steps-data-wrap-importer' ),
87 post_id : $( '#post_ID' ).val(),
88
89 _ref : null,
90
91 _api_step_type : {},
92 _api_params : {},
93
94 all_steps : 0,
95 remaining_steps : 0,
96 remaining_install_plugins : 0,
97 remaining_active_plugins : 0,
98
99 /**
100 * Init
101 */
102 init: function()
103 {
104 this._bind();
105
106 if( 'other' !== CartFlowsImportVars.default_page_builder ) {
107 if( $('.post-type-cartflows_flow').hasClass('edit-php') ) {
108 this._process_cache_remote_flows();
109 }
110 if( $('.post-type-cartflows_flow').hasClass('post-php') ) {
111 this._process_cache_remote_steps();
112 }
113 }
114
115 if( $('.post-type-cartflows_flow').hasClass('edit-php') && null !== this._getParamFromURL('add-new-flow') ) {
116 this._render_remote_flows();
117 }
118 if( $('.post-type-cartflows_flow').hasClass('post-php') && null !== this._getParamFromURL('add-new-step') ) {
119 this._render_remote_steps();
120 }
121
122 if( this._getParamFromURL('highlight-step-id') ) {
123 var selector = $('.wcf-step-wrap[data-id="'+this._getParamFromURL('highlight-step-id')+'"]');
124 if( selector.length ) {
125 $('html, body').animate({
126 scrollTop: selector.offset().top
127 }, 1500);
128 }
129 }
130
131 if( $('.post-type-cartflows_flow').hasClass('edit-php') ) {
132 var $product_screen = $( '.edit-php.post-type-cartflows_flow' ),
133 $title_action = $product_screen.find( '.page-title-action:first' );
134
135 $title_action.after('<a href="'+CartFlowsImportVars.export_url+'" class="page-title-action">Export</a>' );
136 $title_action.after('<a href="'+CartFlowsImportVars.import_url+'" class="page-title-action">Import</a>');
137 }
138
139 },
140
141 /**
142 * Get URL param.
143 */
144 _getParamFromURL: function(name, url)
145 {
146 if (!url) url = window.location.href;
147 name = name.replace(/[\[\]]/g, "\\$&");
148 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
149 results = regex.exec(url);
150 if (!results) return null;
151 if (!results[2]) return '';
152 return decodeURIComponent(results[2].replace(/\+/g, " "));
153 },
154
155 /**
156 * Binds events
157 */
158 _bind: function()
159 {
160 var self = CartFlowsImport;
161
162 self.doc.on('click', '.wcf-install-plugin', self._install_plugin);
163
164 self.doc.on( 'cartflows-api-request-fail', self._api_request_failed );
165 self.doc.on('click', '#wcf-get-started-steps a, .wcf-create-from-scratch-link', self._toggle_ready_templates);
166 self.doc.on('click', '.cartflows-flow-import-blank', self._create_default_flow);
167 self.doc.on('click', '#wcf-remote-flow-importer .wcf-page-builder-links a', self._filterFlowPageBuilderClick);
168 self.doc.on('click', '#wcf-remote-step-importer #wcf-categories .step-type-filter-links a', self._filterBlankStepCategoryClick );
169 self.doc.on('change', '#wcf-remote-step-importer #wcf-scratch-steps-categories .step-type-filter-links', self._filterBlankStepCategoryChange );
170 self.doc.on('click', '#wcf-remote-step-importer .wcf-page-builder-links a', self._filterStepPageBuilderClick );
171
172 self.doc.on('click' , '.cartflows-step-import-blank:not(.get-pro)', self._create_blank_step);
173 self.doc.on('click' , '#wcf-remote-step-importer .cartflows-step-import', self._process_import_step);
174 self.doc.on('click' , '#wcf-remote-flow-importer .cartflows-step-import', self._process_import_flow);
175
176 self.doc.on('click' , '.cartflows-preview-flow-step', self._preview_individual);
177
178 self.doc.on( 'add_template_to_page-fail', self._add_template_to_page_fail);
179
180 $( 'body' ).on('thickbox:iframe:loaded', self._previewLoaded );
181
182 // Event's for API request.
183 $( document ).on('keyup input', '#wcf-remote-step-importer .wcf-flow-search-input', self._remote_step_search );
184
185 $( document ).on('click', '.actions a', self._previewResponsive );
186
187 $( document ).on( 'click', '.page-title-action:first', self._render_remote_flows );
188 $( document ).on( 'click', '.wcf-trigger-popup', self._render_remote_steps );
189
190 $( document ).on( 'click', '.wcf-templates-popup-overlay', self._close_template_popup );
191 $( document ).on( 'click', '.wcf-popup-close-wrap .close-icon', self._close_template_popup );
192
193 $( document ).on('wp-plugin-install-success' , self._installSuccess);
194 },
195
196 _install_plugin: function( event ) {
197 event.preventDefault();
198
199 var btn = $( this );
200
201 if( btn.hasClass('updating-message') ) {
202 return;
203 }
204
205 $('#wcf-remote-flow-importer').addClass('request-process');
206 $('#wcf-remote-step-importer').addClass('request-process');
207
208 btn.addClass('updating-message button');
209
210 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
211
212 $.each( page_builder_plugins, function( index, plugin ) {
213 if( 'install' === plugin.status ) {
214 CartFlowsImport.remaining_install_plugins++;
215 }
216 if( 'activate' === plugin.status ) {
217 CartFlowsImport.remaining_active_plugins++;
218 }
219 });
220
221 // Have any plugin for install?
222 if( CartFlowsImport.remaining_install_plugins ) {
223 CartFlowsImport._install_all_plugins();
224 } else if( CartFlowsImport.remaining_active_plugins ) {
225 CartFlowsImport._activate_all_plugins();
226 } else {
227 if( $('#wcf-remote-flow-importer').length ) {
228 CartFlowsImport._cache_remote_flows();
229 } else if( $('#wcf-remote-step-importer').length ) {
230 CartFlowsImport._cache_remote_steps();
231 }
232 }
233 },
234
235 _install_all_plugins: function() {
236
237 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
238
239 $.each( page_builder_plugins, function( index, plugin ) {
240 if( 'install' === plugin.status ) {
241 // Add each plugin activate request in Ajax queue.
242 // @see wp-admin/js/updates.js
243 wp.updates.queue.push( {
244 action: 'install-plugin', // Required action.
245 data: {
246 slug: plugin.slug
247 }
248 } );
249 }
250 });
251
252 // Required to set queue.
253 wp.updates.queueChecker();
254 },
255
256 _activate_all_plugins: function() {
257
258 if( ! CartFlowsImport.remaining_active_plugins && ! CartFlowsImport.remaining_install_plugins ) {
259 if( $('#wcf-remote-flow-importer').length ) {
260 CartFlowsImport._cache_remote_flows();
261 } else if( $('#wcf-remote-step-importer').length ) {
262 CartFlowsImport._cache_remote_steps();
263 }
264 } else {
265 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
266
267 // Activate ALl Plugins.
268 CartFlowsAjaxQueue.stop();
269 CartFlowsAjaxQueue.run();
270
271 $.each( page_builder_plugins, function( index, plugin ) {
272 if( 'activate' === plugin.status ) {
273
274 CartFlowsAjaxQueue.add({
275 url: CartFlowsImportVars.ajaxurl,
276 type: 'POST',
277 data: {
278 action : 'cartflows_activate_plugin',
279 plugin_init : plugin.init
280 },
281 success: function( result ) {
282
283 CartFlowsImport.remaining_active_plugins--;
284
285 if( ! CartFlowsImport.remaining_active_plugins && ! CartFlowsImport.remaining_install_plugins ) {
286 if( $('#wcf-remote-flow-importer').length ) {
287 CartFlowsImport._cache_remote_flows();
288 } else if( $('#wcf-remote-step-importer').length ) {
289 CartFlowsImport._cache_remote_steps();
290 }
291 }
292
293 }
294 });
295 }
296 });
297 }
298
299 },
300
301 _installSuccess: function( event, response ) {
302
303 event.preventDefault();
304
305 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
306
307 $.each( page_builder_plugins, function( index, plugin ) {
308 if( 'install' === plugin.status && response.slug === plugin.slug ) {
309
310 $.ajax({
311 url : ajaxurl,
312 type : 'POST',
313 data : {
314 action : 'cartflows_activate_plugin',
315 plugin_init : plugin.init
316 },
317 })
318 .done(function( request, status, XHR )
319 {
320 CartFlowsImport.remaining_install_plugins--;
321
322 if( ! CartFlowsImport.remaining_install_plugins ) {
323 CartFlowsImport._activate_all_plugins();
324 }
325 });
326 }
327 });
328
329 },
330
331 _api_request_failed: function( event, data, jqXHR, textStatus ) {
332 if( 'error' == textStatus ) {
333 if( ! $('#wcf-remote-content-failed').length ) {
334 $('#wcf-ready-templates').html( wp.template('cartflows-website-unreachable') );
335 }
336 }
337 },
338
339 _toggle_ready_templates: function( event ) {
340 event.preventDefault();
341
342 var slug = $(this).data('slug') || '';
343
344 $('#wcf-get-started-steps').find('a').removeClass('current');
345 $('#wcf-get-started-steps').find('a[data-slug="'+slug+'"]').addClass('current');
346
347 if( 'canvas' == slug ) {
348 $('#wcf-ready-templates').hide();
349 $('#wcf-start-from-scratch').show();
350 } else {
351 $('#wcf-ready-templates').show();
352 $('#wcf-start-from-scratch').hide();
353 }
354
355 if( ! $('.wcf-page-builder-notice').length && $('#wcf-remote-step-importer').length ) {
356 CartFlowsImport._showSteps();
357 }
358 },
359
360 _switch_step_tab: function( event ) {
361
362 event.preventDefault();//stop browser to take action for clicked anchor
363
364 //get displaying tab content jQuery selector
365 var active_tab_selector = $('.wcf-tab > li.active > a').attr('href');
366
367 //find actived navigation and remove 'active' css
368 var actived_nav = $('.wcf-tab > li.active');
369 actived_nav.removeClass('active');
370
371 //add 'active' css into clicked navigation
372 $(this).parents('li').addClass('active');
373
374 //hide displaying tab content
375 $(active_tab_selector).removeClass('active');
376 $(active_tab_selector).addClass('hide');
377
378 //show target tab content
379 var target_tab_selector = $(this).attr('href');
380 $(target_tab_selector).removeClass('hide');
381 $(target_tab_selector).addClass('active');
382 },
383
384 /**
385 * Search Site.
386 *
387 * Prepare Before API Request:
388 * - Remove Inline Height
389 * - Added 'hide-me' class to hide the 'No more sites!' string.
390 * - Added 'loading-content' for body.
391 * - Show spinner.
392 */
393 _remote_step_search: function( event ) {
394
395 event.preventDefault();//stop browser to take action for clicked anchor
396
397 // Remove all filter classes.
398 $('.step-type-filter-links').find('option').removeClass('current');
399 $('.step-type-filter-links').find('option:first-child').addClass('current');
400
401 window.clearTimeout(CartFlowsImport._ref);
402 CartFlowsImport._ref = window.setTimeout(function () {
403 CartFlowsImport._ref = null;
404 CartFlowsImport._showSteps();
405 }, 500);
406
407 },
408
409 /**
410 * Responsive On Click.
411 */
412 _previewResponsive: function( event ) {
413
414 event.preventDefault();
415
416 var icon = $(this).find('.dashicons');
417
418 var viewClass = icon.attr('data-view') || '';
419
420 $('#TB_window').removeClass( 'desktop tablet mobile' );
421 $('#TB_window').addClass( viewClass );
422
423 $('.actions .dashicons').removeClass('active');
424 icon.addClass('active');
425
426 $('#TB_iframeContent').removeClass();
427 $('#TB_iframeContent').addClass( viewClass );
428
429 },
430
431 /**
432 * On Filter Clicked
433 */
434 _filterStepPageBuilderClick: function( event ) {
435 event.preventDefault();
436
437 $(this).parents('ul').find('a').removeClass('current');
438 $(this).addClass('current');
439
440 var step_type = $('.step-type-filter-links .current').data('slug') || '';
441
442 if ( 'upsell' === step_type || 'downsell' === step_type ) {
443 $( '.wcf-template-notice' ).show();
444
445 }else{
446 $( '.wcf-template-notice' ).hide();
447 }
448
449 $('.wcf-page-builder-notice').html( '' );
450
451 $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
452
453 CartFlowsImport._showSteps();
454 },
455
456 _filterBlankStepCategoryClick: function( event ) {
457 event.preventDefault();
458
459 $('.wcf-page-builder-notice').html( '' );
460
461 var val = $(this).data('group') || '';
462 if( val ) {
463 $('#wcf-scratch-steps-categories .step-type-filter-links').val( val );
464 $('#wcf-scratch-steps-categories .step-type-filter-links option').removeClass('current');
465 $('#wcf-scratch-steps-categories .step-type-filter-links option[data-group="'+val+'"]').addClass('current');
466 }
467
468 $('.step-type-filter-links').find('a').removeClass('current');
469 $(this).addClass('current');
470
471 $step_type = $(this).data('slug');
472
473 if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
474 $( '.wcf-template-notice' ).show();
475
476 }else{
477 $( '.wcf-template-notice' ).hide();
478 }
479
480 if( '' == CartFlowsImportVars._is_pro_active && ( 'upsell' == $step_type || 'downsell' == $step_type ) ) {
481 $('.cartflows-step-import-blank').text( 'Get Pro' );
482 $('.cartflows-step-import-blank').attr( 'href', CartFlowsImportVars.domain_url );
483 $('.cartflows-step-import-blank').attr( 'target', '_blank' );
484 $('.cartflows-step-import-blank').addClass('get-pro');
485 // // $('#wcf-remote-step-list').find('.cartflows-step-import-blank').attr( 'class', 'button button-primary' );
486 } else {
487 $('.cartflows-step-import-blank').text( 'Create Step' );
488 $('.cartflows-step-import-blank').removeClass( 'get-pro' );
489 $('.cartflows-step-import-blank').removeAttr( 'target' );
490 }
491
492 $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
493 CartFlowsImport._showSteps();
494 },
495
496 _filterBlankStepCategoryChange: function( event ) {
497 event.preventDefault();
498
499 var val = $(this).find('option:selected').val() || '';
500 if( val ) {
501 $('.step-type-filter-links').val( val );
502 $('.step-type-filter-links').find('a').removeClass('current');
503 $('.step-type-filter-links').find('a[data-group="'+val+'"]').addClass('current');
504 }
505
506 $('.step-type-filter-links').find('option').removeClass('current');
507 $('.step-type-filter-links').find('option:selected').addClass('current');
508
509 $step_type = $(this).find('option:selected').data('slug');
510
511 if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
512 $( '.wcf-template-notice' ).show();
513 }else{
514 $( '.wcf-template-notice' ).hide();
515 }
516
517 if( '' == CartFlowsImportVars._is_pro_active && ( 'upsell' == $step_type || 'downsell' == $step_type ) ) {
518 $('.cartflows-step-import-blank').text( 'Get Pro' );
519 $('.cartflows-step-import-blank').attr( 'href', CartFlowsImportVars.domain_url );
520 $('.cartflows-step-import-blank').attr( 'target', '_blank' );
521 $('.cartflows-step-import-blank').addClass('get-pro');
522 // // $('#wcf-remote-step-list').find('.cartflows-step-import-blank').attr( 'class', 'button button-primary' );
523 } else {
524 $('.cartflows-step-import-blank').text( 'Create Step' );
525 $('.cartflows-step-import-blank').removeClass( 'get-pro' );
526 $('.cartflows-step-import-blank').removeAttr( 'target' );
527 }
528
529 if( ! $('.wcf-page-builder-notice').length && $('#wcf-remote-step-importer').length ) {
530 $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
531 CartFlowsImport._showSteps();
532 }
533 },
534
535 _showSteps: function() {
536
537 // Add Params for API request.
538 var api_params = {
539 licence_args : CartFlowsImportVars.licence_args,
540 per_page : 15,
541 _fields : CartFlowsImportVars.step_fields.toString(),
542 };
543
544 var type = $('#wcf-categories .step-type-filter-links').find('.current').data('group') || '';
545 var step_type = $('#wcf-categories .step-type-filter-links').find('.current').data('slug') || '';
546
547 if( '' !== type && 'all' !== type ) {
548 api_params[ CartFlowsImportVars.step_type ] = type;
549 }
550
551 // Page Builder.
552 var type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('group') || '';
553 var step_type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('slug') || '';
554 var title = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('title') || 'Page Builder';
555 if( '' !== type && 'all' !== type ) {
556 api_params[ CartFlowsImportVars.step_page_builder ] = type;
557 }
558
559 // API Request.
560 var api_post = {
561 remote_slug : CartFlowsImportVars.step,
562 slug : CartFlowsImportVars.step + '?' + decodeURIComponent( $.param( api_params ) ),
563 };
564
565 CartFlowsAPI._api_request( api_post, function( data ) {
566
567 data.current_step_type = step_type;
568
569 var template = wp.template('cartflows-steps-list');
570 if( parseInt( data.items_count ) ) {
571 $('#wcf-remote-step-list').html( template( data ) );
572 } else {
573 $('#wcf-remote-step-list').html( wp.template('cartflows-no-steps') );
574 $('.cartflows-no-steps').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
575 }
576
577 $('.wcf-page-builder-notice').remove();
578 $('#wcf-remote-step-importer').removeClass('request-process');
579 } );
580 },
581
582 _apiAddParam_per_page: function() {
583 CartFlowsImport._api_params['per_page'] = 15;
584 },
585
586 // Add Params for API request.
587 _apiAddParam_licence_args: function() {
588 CartFlowsImport._api_params['licence_args'] = CartFlowsImportVars.licence_args;
589 },
590
591 // Add 'search'
592 _apiAddParam_search: function() {
593 var search_val = $('.wcf-flow-search-input').val() || '';
594 if( '' !== search_val ) {
595 CartFlowsImport._api_params['search'] = search_val;
596 }
597 },
598
599 _close_popup: function() {
600 $('#cartflows-steps').fadeOut();
601 $('body').removeClass('cartflows-popup-is-open');
602 },
603
604 _post_auto_save: function() {
605 var post_title = $( '#title' );
606 var post_prompt_text = $( '#title-prompt-text' );
607 var self = CartFlowsImport;
608
609 if ( ! post_title.val() ) {
610 post_title.val( 'CartFlows #' + self.post_id );
611 if( post_prompt_text.length ) {
612 post_prompt_text.remove();
613 }
614 }
615
616 if ( wp.autosave ) {
617 wp.autosave.server.triggerSave();
618 }
619 },
620
621 _process_cache_remote_flows: function() {
622
623
624 if( 'gutenberg' == CartFlowsImportVars.default_page_builder ) {
625 CartFlowsImport._cache_remote_flows();
626 } else {
627 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
628
629 var anyInactive = true;
630
631 $.each( page_builder_plugins, function( index, plugin ) {
632
633 if( anyInactive ) {
634 if( 'install' === plugin.status || 'activate' === plugin.status ) {
635 anyInactive = false;
636 }
637 }
638 });
639
640 if( false === anyInactive ) {
641 $('.wcf-page-builder-notice').html( wp.template('cartflows-page-builder-notice') );
642 $('#wcf-remote-flow-list').find( '.spinner' ).remove();
643 } else {
644 CartFlowsImport._cache_remote_flows();
645 }
646 }
647
648
649 },
650
651 _cache_remote_flows: function() {
652
653 var self = CartFlowsImport;
654
655 // Add Params for API request.
656 var api_params = {
657 search : CartFlowsImportVars.default_page_builder,
658 licence_args : CartFlowsImportVars.licence_args,
659 hide_empty : false,
660 _fields : CartFlowsImportVars.flow_page_builder_fields.toString(),
661 };
662
663 // API Request.
664 var api_post = {
665 remote_slug : CartFlowsImportVars.flow_page_builder,
666 slug : CartFlowsImportVars.flow_page_builder + '?'+decodeURIComponent( $.param( api_params ) ),
667 wrapper_class : 'wcf-page-builder-links filter-links',
668 show_all : false,
669 };
670
671 CartFlowsAPI._api_request( api_post, function( data ) {
672
673 var template = wp.template('cartflows-term-filters');
674 $('#wcf-page-builders').html(template( data ));
675 $('#wcf-page-builders').find('li:first a').addClass('current');
676
677 // Step 2: Categories.
678 // Add Params for API request.
679 var api_params = {
680 licence_args : CartFlowsImportVars.licence_args,
681 hide_empty : true,
682 _fields : CartFlowsImportVars.flow_type_fields.toString(),
683 };
684
685 // API Request.
686 var api_post = {
687 remote_slug : CartFlowsImportVars.flow_type,
688 slug : CartFlowsImportVars.flow_type + '?'+decodeURIComponent( $.param( api_params ) ),
689 wrapper_class : 'flow-type-filter-links filter-links',
690 show_all : false,
691 };
692
693 CartFlowsAPI._api_request( api_post, function( data ) {
694 var template = wp.template('cartflows-term-filters');
695 $('#wcf-categories').html(template( data ));
696 $('#wcf-categories').find('li:first a').addClass('current');
697
698 // Step 3: Flows.
699 CartFlowsImport._showFlows();
700 } );
701 } );
702 },
703
704 _render_remote_flows: function( event ) {
705
706 if( event ) {
707 event.preventDefault();
708 }
709
710 $("#wcf-remote-flow-importer").addClass('open');
711
712 $("html").addClass('wcf-popup-open');
713
714 },
715
716 _process_cache_remote_steps: function() {
717
718 if( 'gutenberg' == CartFlowsImportVars.default_page_builder ) {
719 CartFlowsImport._cache_remote_steps();
720 } else {
721
722 var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
723
724
725 var anyInactive = true;
726
727 $.each( page_builder_plugins, function( index, plugin ) {
728
729 if( anyInactive ) {
730 if( 'install' === plugin.status || 'activate' === plugin.status ) {
731 anyInactive = false;
732 }
733 }
734 });
735
736 if( false === anyInactive ) {
737 $('.wcf-page-builder-notice').html( wp.template('cartflows-page-builder-notice') );
738 $('#wcf-remote-step-list').find( '.spinner' ).remove();
739 } else {
740 CartFlowsImport._cache_remote_steps();
741 }
742 }
743
744 },
745
746 _cache_remote_steps: function() {
747
748 var self = CartFlowsImport;
749
750 // Disable the button until caching the data.
751 $( 'html' ).addClass('wcf-steps-loading');
752
753 // Add Params for API request.
754 var api_params = {
755 search : CartFlowsImportVars.default_page_builder,
756 licence_args : CartFlowsImportVars.licence_args,
757 hide_empty : false,
758 _fields : CartFlowsImportVars.step_page_builder_fields.toString(),
759 };
760
761 // API Request.
762 var api_post = {
763 remote_slug : CartFlowsImportVars.step_page_builder,
764 slug : CartFlowsImportVars.step_page_builder + '?'+decodeURIComponent( $.param( api_params ) ),
765 wrapper_class : 'wcf-page-builder-links filter-links',
766 show_all : false,
767 };
768
769 CartFlowsAPI._api_request( api_post, function( data ) {
770 var template = wp.template('cartflows-term-filters');
771 $('#wcf-page-builders').html(template( data ));
772 $('#wcf-page-builders').find('li:first a').addClass('current');
773 } );
774
775 // Add Params for API request.
776 var api_params = {
777 licence_args : CartFlowsImportVars.licence_args,
778 _fields : CartFlowsImportVars.step_type_fields.toString(),
779 };
780
781 // API Request.
782 var api_post = {
783 remote_slug : CartFlowsImportVars.step_type,
784 slug : CartFlowsImportVars.step_type + '?'+decodeURIComponent( $.param( api_params ) ),
785 wrapper_class : 'step-type-filter-links filter-links',
786 show_all : false,
787 };
788
789 CartFlowsAPI._api_request( api_post, function( data ) {
790
791 var step_type_response_data = data;
792 var step_types_count = data.items_count;
793
794 // Send other request for JS caching.
795 if( data.items ) {
796 for ( key in data.items ) {
797
798 // Add Params for API request.
799 var api_params = {
800 licence_args : CartFlowsImportVars.licence_args,
801 per_page : 15,
802 _fields : CartFlowsImportVars.step_fields.toString(),
803 };
804
805 api_params[ CartFlowsImportVars.step_type ] = data.items[ key ].id;
806
807 // API Request.
808 var api_post = {
809 remote_slug : CartFlowsImportVars.step,
810 slug : CartFlowsImportVars.step + '?' + decodeURIComponent( $.param( api_params ) ),
811 };
812
813 CartFlowsAPI._api_request( api_post, function( data ) {
814 var template = wp.template('cartflows-steps-list');
815 if( parseInt( data.items_count ) ) {
816 $('#wcf-remote-step-list').html( template( data ) );
817 } else {
818 $('#wcf-remote-step-list').html( wp.template('cartflows-no-steps') );
819 }
820
821 step_types_count--;
822
823 if( 0 == step_types_count ) {
824
825 var template_dropdown = wp.template('cartflows-term-filters-dropdown');
826 var template = wp.template('cartflows-term-filters');
827 $('#wcf-categories').html(template( step_type_response_data ));
828 $('#wcf-scratch-steps-categories').html(template_dropdown( step_type_response_data ));
829 $('#wcf-categories, #wcf-scratch-steps-categories').find('option:first').addClass('current');
830 $('#wcf-categories').find('li:first a').addClass('current');
831
832 $('.wcf-page-builder-notice').remove();
833 $('#wcf-remote-content').find( '.spinner' ).remove();
834
835 CartFlowsImport._showSteps();
836
837 $( 'html' ).removeClass('wcf-steps-loading');
838 }
839 });
840 }
841 }
842 } );
843 },
844
845 _render_remote_steps: function( event ) {
846 if( event ) {
847 event.preventDefault();
848 }
849
850 $("#wcf-remote-step-importer").addClass('open');
851
852 $("html").addClass('wcf-popup-open');
853 },
854
855 _categorize_data: function( items ) {
856
857 var categorised_data = [];
858
859 $.each( items, function( index, value ) {
860
861 var step_type = value.step_type.slug;
862
863 if( 'undefined' == typeof categorised_data[step_type] ) {
864 categorised_data[step_type] = [];
865 }
866
867 categorised_data[step_type].push( value );
868
869 });
870
871 return categorised_data;
872
873 },
874
875 _close_template_popup: function( event ) {
876 if ( $( event.target ).hasClass('wcf-templates-popup-overlay')
877 || $( event.target ).hasClass('close-icon') ) {
878
879 // New step creation/importing is in process..
880 if( ! $( '.wcf-templates-popup-overlay' ).hasClass('request-process') ) {
881 $("html").removeClass('wcf-popup-open');
882 $(".wcf-templates-popup-overlay").removeClass( 'open' );
883 }
884 }
885 },
886
887 _ajax: function( data, callback, trigger ) {
888
889 var self = CartFlowsImport;
890
891 $.ajax({
892 url : ajaxurl,
893 type : 'POST',
894 data : data,
895 })
896 .done(function( request, status, XHR )
897 {
898 var data = {
899 request : request,
900 status : status,
901 XHR : XHR,
902 };
903
904 if( callback && typeof callback == "function"){
905 callback( data );
906 }
907
908 self.doc.trigger( trigger + '-done', [request, status, XHR] );
909 })
910 .fail(function( jqXHR, textStatus )
911 {
912 self.doc.trigger( trigger + '-fail', [jqXHR, textStatus] );
913 })
914 .always(function()
915 {
916 self.doc.trigger( trigger + '-always' );
917 });
918
919 },
920
921 _load_templates: function( args, trigger_name ) {
922 var self = CartFlowsImport;
923
924 if( $('body').hasClass('processing') ) {
925 return;
926 }
927
928 $('body').addClass('processing');
929
930 $.ajax({
931 url : ajaxurl,
932 type : 'POST',
933 data : {
934 action : 'cartflows_load_steps',
935 security: cartflows_admin.cf_load_steps_nonce,
936 args : args,
937 },
938 })
939 .done(function( items, status, XHR )
940 {
941 self.doc.trigger( trigger_name, [items] );
942 $('body').removeClass('processing');
943 })
944 .fail(function( jqXHR, textStatus )
945 {
946 })
947 .always(function()
948 {
949 });
950 },
951
952 _empty: function(data)
953 {
954 if(typeof(data) == 'number' || typeof(data) == 'boolean')
955 {
956 return false;
957 }
958 if(typeof(data) == 'undefined' || data === null)
959 {
960 return true;
961 }
962 if(typeof(data.length) != 'undefined')
963 {
964 return data.length == 0;
965 }
966 var count = 0;
967 for(var i in data)
968 {
969 if(data.hasOwnProperty(i))
970 {
971 count ++;
972 }
973 }
974 return count == 0;
975 },
976
977 _preview_individual: function()
978 {
979 var id = $(this).data('id') || '';
980 var href = $(this).data('href') || '';
981
982 // Active.
983 $('.cartflows-preview-flow-step').removeClass('active');
984 $('.cartflows-preview-flow-step[data-id="'+id+'"]').addClass('active');
985
986 $('#TB_window').addClass('cartflows-thickbox-loading');
987
988 $('#TB_iframeContent').removeAttr('onload');
989 $('#TB_iframeContent').removeAttr('src');
990 $('#TB_iframeContent').attr('src', href );
991 $('#TB_iframeContent').attr('onload', 'CartFlowsImport.showIframe()' )
992 },
993 showIframe: function() {
994 $("#TB_load").remove();
995 $("#TB_window").css({'visibility':'visible'});
996 // $("#TB_window").css({'visibility':'visible'}).trigger( 'thickbox:iframe:loaded' );
997 $('#TB_window').removeClass('cartflows-thickbox-loading');
998 },
999
1000 /**
1001 * Remove thickbox loading class
1002 *
1003 * @param object event Event object.
1004 * @return void.
1005 */
1006 _previewLoaded: function( event ) {
1007 event.preventDefault();
1008 $('#TB_window').removeClass('cartflows-thickbox-loading');
1009 },
1010
1011 _filterFlowPageBuilderClick: function( event ) {
1012 event.preventDefault();
1013
1014 $(this).parents('ul').find('a').removeClass('current');
1015 $(this).addClass('current');
1016
1017 $('.wcf-page-builder-notice').html( '' );
1018
1019 $('#wcf-remote-flow-list').html( '<span class="spinner is-active"></span>' );
1020
1021 CartFlowsImport._showFlows();
1022 },
1023
1024 _showFlows: function() {
1025 // Add Params for API request.
1026 var api_params = {
1027 licence_args : CartFlowsImportVars.licence_args,
1028 _fields : CartFlowsImportVars.flow_fields.toString(),
1029 };
1030
1031 // Page Builder.
1032 var type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('group') || '';
1033 var step_type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('slug') || '';
1034 var title = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('title') || 'Page Builder';
1035 if( '' !== type && 'all' !== type ) {
1036 api_params[ CartFlowsImportVars.flow_page_builder ] = type;
1037 }
1038
1039 // API Request.
1040 var api_post = {
1041 remote_slug : CartFlowsImportVars.flow,
1042 slug : CartFlowsImportVars.flow + '?' + decodeURIComponent( $.param( api_params ) ),
1043 };
1044
1045 CartFlowsAPI._api_request( api_post, function( data ) {
1046
1047 var template = wp.template('cartflows-flows-list');
1048 if( parseInt( data.items_count ) ) {
1049 $('#wcf-remote-flow-list').html( template( data ) );
1050 } else {
1051 $('#wcf-remote-flow-list').html( wp.template('cartflows-no-flows') );
1052 // $('.cartflows-no-flows').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
1053 }
1054
1055 $('.wcf-page-builder-notice').remove();
1056 $('#wcf-remote-flow-importer').removeClass('request-process');
1057 } );
1058 },
1059
1060 _create_default_flow: function( event )
1061 {
1062 event.preventDefault();
1063 var self = CartFlowsImport;
1064 var btn = $( this );
1065
1066 if( btn.hasClass('updating-message') ) {
1067 return;
1068 }
1069
1070 $('#wcf-remote-flow-importer').addClass('request-process');
1071
1072 btn.addClass('updating-message').text( 'Creating Flow..' );
1073 btn.parents('.template').addClass('importing');
1074
1075 var data = {
1076 action : 'cartflows_default_flow',
1077 security: cartflows_admin.cf_default_flow_nonce
1078 };
1079
1080 // Import Template AJAX.
1081 self._ajax( data, function( data ) {
1082
1083 if( data.request.success ) {
1084
1085 var flow_id = data.request.data;
1086
1087 // Created.
1088 setTimeout(function() {
1089 btn.removeClass('updating-message').text('Flow Created! Redirecting..');
1090 window.location = CartFlowsImportVars.admin_url + 'post.php?post='+flow_id+'&action=edit';
1091 }, 3000);
1092
1093 }
1094 });
1095
1096 },
1097
1098 _activate_plugin: function( plugin_init ) {
1099
1100 var self = CartFlowsImport;
1101
1102 var data = {
1103 action : 'cartflows_activate_plugin',
1104 plugin_init : plugin_init
1105 };
1106
1107 self._ajax( data, function( data ) {
1108 });
1109 },
1110
1111 _process_import_flow: function( event )
1112 {
1113 event.preventDefault();
1114
1115 var btn = $( this );
1116
1117 if( btn.hasClass('updating-message') ) {
1118 return;
1119 }
1120
1121 $('#wcf-remote-flow-importer').addClass('request-process');
1122
1123 var self = CartFlowsImport;
1124
1125 btn.text( 'Creating Flow..' );
1126
1127 btn.addClass('updating-message');
1128 btn.parents('.template').addClass('importing');
1129
1130 var flow_steps_string = btn.data('flow-steps') || '';
1131 var flow_steps = ( '' !== flow_steps_string ) ? JSON.parse("[" + flow_steps_string + "]") : [];
1132
1133 var data = {
1134 action : 'cartflows_create_flow',
1135 security: cartflows_admin.cf_create_flow_nonce
1136 };
1137
1138 // Import Template AJAX.
1139 self._ajax( data, function( data ) {
1140
1141 if( data.request.success ) {
1142
1143 var flow_id = data.request.data;
1144
1145 if( flow_steps ) {
1146
1147 // Activate ALl Plugins.
1148 CartFlowsAjaxQueue.stop();
1149 CartFlowsAjaxQueue.run();
1150
1151 CartFlowsImport.all_steps = flow_steps.length;
1152
1153 // Importing.
1154 btn.addClass('updating-message').text('Importing Step 1 of ' + CartFlowsImport.all_steps );
1155
1156 $.each(flow_steps, function(index, template_id) {
1157
1158 CartFlowsAjaxQueue.add({
1159 url: CartFlowsImportVars.ajaxurl,
1160 type: 'POST',
1161 data: {
1162 action : 'cartflows_import_flow_step',
1163 flow_id : flow_id,
1164 template_id : template_id,
1165 security : cartflows_admin.cf_import_flow_step_nonce
1166 },
1167 success: function( result ) {
1168 CartFlowsImport.remaining_steps = CartFlowsImport.remaining_steps + 1;
1169
1170 if( CartFlowsImport.remaining_steps === CartFlowsImport.all_steps ) {
1171
1172 // Imported.
1173 btn.addClass('updating-message').text('Imported Step ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1174
1175 setTimeout(function() {
1176 btn.removeClass('updating-message').text('All Imported! Redirecting..');
1177 window.location = CartFlowsImportVars.admin_url + 'post.php?post='+flow_id+'&action=edit';
1178 }, 3000);
1179
1180 } else {
1181 // Importing.
1182 btn.addClass('updating-message').text('Importing Step ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1183 }
1184 },
1185 error: function( result ) {
1186 CartFlowsImport.remaining_steps = CartFlowsImport.remaining_steps + 1;
1187
1188 template = btn.parents('.template.importing');
1189 template.find('.preview')
1190 .addClass('notice notice-warning')
1191 .removeClass('preview')
1192 .text( result.statusText );
1193
1194 if( CartFlowsImport.remaining_steps === CartFlowsImport.all_steps ) {
1195
1196 // Imported.
1197 btn.addClass('updating-message').text('Failed ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1198
1199 setTimeout(function() {
1200 btn.removeClass('updating-message button-primary').addClass('disabled');
1201 // location.reload();
1202 }, 3000);
1203
1204 } else {
1205 // Importing.
1206 btn.addClass('updating-message').text('Failed ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1207 }
1208 },
1209 fail: function( result ) {
1210
1211 CartFlowsImport.remaining_steps = CartFlowsImport.remaining_steps + 1;
1212
1213 if( CartFlowsImport.remaining_steps === CartFlowsImport.all_steps ) {
1214
1215 // Imported.
1216 btn.addClass('updating-message').text('Imported ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1217
1218 setTimeout(function() {
1219 btn.removeClass('updating-message').text('All Step Imported! Reloading..');
1220 location.reload();
1221 }, 3000);
1222
1223 } else {
1224 // Importing.
1225 btn.addClass('updating-message').text('Importing ' + CartFlowsImport.remaining_steps + ' of ' + CartFlowsImport.all_steps );
1226 }
1227 }
1228 });
1229 });
1230 }
1231 }
1232 });
1233 },
1234
1235 _handle_error: function( response )
1236 {
1237 var btn = $( '.cartflows-step-import.updating-message' );
1238
1239 btn.addClass('updating-message').text( response.errorMessage );
1240 },
1241
1242 _create_blank_step: function( event )
1243 {
1244 event.preventDefault();
1245
1246 var btn = $(this),
1247 self = CartFlowsImport,
1248 flow_id = $("#post_ID").val(),
1249 step_slug = $('#wcf-scratch-steps-categories .step-type-filter-links .current').data('slug') || '',
1250 step_title = $('#wcf-scratch-steps-categories .step-type-filter-links .current').data('title') || '',
1251 step_type = step_slug,
1252 step_count = $('.wcf-step-wrap[data-term-slug="'+step_slug+'"]').length || 1,
1253 step_custom_title = step_title + ' ' + ( parseInt( step_count ) + 1 );
1254
1255 $('#wcf-start-from-scratch .wcf-notice-wrap').remove();
1256
1257 if( '' === step_type ) {
1258 $('#wcf-start-from-scratch .inner').append( '<div class="wcf-notice-wrap"><div class="notice notice-info"><p>Please select the step type.</p></div></div>' );
1259 return;
1260 }
1261
1262 if ( ! CartFlowsImportVars._is_pro_active && ( 'upsell' === step_type || 'downsell' === step_type )) {
1263 return;
1264 }
1265
1266 btn.parents('.template').addClass('importing');
1267
1268 if ( ! CartFlowsImportVars._is_pro_active ) {
1269
1270 if ( 'checkout' === step_type ) {
1271 var checkout_steps = $( '.wcf-step-wrap[data-term-slug="checkout"]');
1272
1273 if ( 0 < checkout_steps.length ) {
1274
1275 var parent_template = btn.parents('.template.importing');
1276
1277 btn.removeClass('importing updating-message')
1278 .text('Import Failed!');
1279
1280 $('#wcf-start-from-scratch .inner').append( '<div class="wcf-notice-wrap"><div class="notice notice-warning"><p>Upgrade to Pro for adding more than one Checkout step.</p></div></div>' );
1281
1282 return;
1283 }
1284 }
1285 }
1286
1287 $('#wcf-remote-step-importer').addClass('request-process');
1288
1289 $('.cartflows-step-import').addClass('disabled');
1290 btn.addClass('importing updating-message').text('Creating..');
1291
1292 // Process Import Page.
1293 if( $( 'body' ).hasClass( 'post-type-cartflows_flow' ) ) {
1294 var data = {
1295 action : 'cartflows_step_create_blank',
1296 flow_id : flow_id,
1297 step_type : step_type,
1298 step_title : step_custom_title,
1299 security : cartflows_admin.cf_step_create_blank_nonce
1300 };
1301
1302 // Import Template AJAX.
1303 self._ajax( data, function( data ) {
1304
1305 var self = CartFlowsImport;
1306 var template = btn.parents('.template.importing');
1307
1308 if( data.request.success ) {
1309 btn.text('Created. Reloading..');
1310 setTimeout(function() {
1311 window.location.href = window.location.href + '&highlight-step-id=' + data.request.data;
1312 }, 3000);
1313
1314 } else {
1315
1316 btn.removeClass('importing updating-message')
1317 .text('Creating Failed!');
1318
1319 $('#wcf-remote-step-importer').removeClass('request-process');
1320
1321 template.find('.cartflows-step-preview').append( "<div class='preview'></div>" );
1322
1323 template.find('.preview')
1324 .addClass('notice notice-warning')
1325 .removeClass('preview')
1326 .text( data.request.data );
1327 }
1328 } );
1329 }
1330 },
1331
1332 _process_import_step: function( event ) {
1333
1334 event.preventDefault();
1335
1336 var btn = $( this ),
1337 step_slug = btn.data('slug') || '',
1338 step_count = $('.wcf-step-wrap[data-term-slug="'+step_slug+'"]').length || 1;
1339 step_title = btn.data('title') || '',
1340 step_custom_title = step_title + ' ' + ( parseInt( step_count ) + 1 ),
1341 self = CartFlowsImport;
1342
1343 if ( ! CartFlowsImportVars._is_pro_active ) {
1344
1345 if ( 'checkout' === step_slug ) {
1346
1347 var checkout_steps = $( '.wcf-step-wrap[data-term-slug="checkout"]');
1348
1349 if ( 0 < checkout_steps.length ) {
1350
1351 var parent_template = btn.parents('.template');
1352
1353 btn.removeClass('importing updating-message')
1354 .text('Import Failed!');
1355
1356 parent_template.find('.preview').hide();
1357 var notice_wrap = parent_template.find('#wcf_create_notice')
1358 .show();
1359
1360 notice_wrap.find('a')
1361 .addClass('notice notice-warning ')
1362 .text ( 'Upgrade to Pro for adding more than one Checkout step' );
1363
1364 $('#wcf-remote-step-importer').removeClass('request-process');
1365 return;
1366 }
1367 }
1368 }
1369
1370 if( btn.hasClass('updating-message') ) {
1371 return;
1372 }
1373
1374 $('#wcf-remote-step-importer').addClass('request-process');
1375
1376 var self = CartFlowsImport;
1377
1378 btn.addClass('updating-message');
1379 btn.parents('.template').addClass('importing');
1380
1381 // var plugin_slug = '';
1382 // plugin = response.slug;
1383
1384 // switch ( plugin ) {
1385 // case 'elementor':
1386 // plugin_slug = 'elementor/elementor.php';
1387 // break;
1388 // case 'beaver-builder-lite-version':
1389 // plugin_slug = 'beaver-builder-lite-version/fl-builder.php';
1390 // break;
1391 // }
1392
1393 // self._activate_plugin( plugin_slug );
1394
1395 var template_id = btn.data('template-id') || '';
1396 var flow_id = $("#post_ID").val();
1397 var step_type = step_slug;
1398 var self = CartFlowsImport;
1399
1400 $('.cartflows-step-import-blank').addClass('disabled');
1401 $('.cartflows-step-import').addClass('disabled');
1402 btn.addClass('importing updating-message').text('Importing..');
1403
1404 // Process Import Page.
1405 if( $( 'body' ).hasClass( 'post-type-cartflows_flow' ) )
1406 {
1407 var data = {
1408 action : 'cartflows_step_import',
1409 flow_id : flow_id,
1410 template_id : template_id,
1411 step_title : step_custom_title,
1412 step_type : step_type,
1413 security : cartflows_admin.cf_step_import_nonce
1414 };
1415
1416 // Import Template AJAX.
1417 self._ajax( data, function( data ) {
1418
1419
1420 var self = CartFlowsImport;
1421 var template = btn.parents('.template.importing');
1422
1423 if( data.request.success ) {
1424 btn.text('Imported. Reloading..');
1425 setTimeout(function() {
1426 window.location.href = window.location.href + '&highlight-step-id=' + data.request.data;
1427
1428 }, 3000);
1429
1430 } else {
1431
1432 $( '.wcf-templates-popup-overlay' ).removeClass('request-process');
1433
1434 btn.removeClass('importing updating-message')
1435 .text('Import Failed!');
1436
1437 template.find('.preview')
1438 .addClass('notice notice-warning')
1439 .removeClass('preview')
1440 .text( data.request.data );
1441 }
1442
1443 }, 'add_template_to_page' );
1444 }
1445 },
1446
1447 _add_template_to_page_fail: function( event, jqXHR, textStatus ) {
1448 event.preventDefault();
1449 var self = CartFlowsImport,
1450 template = $('.wcf-flow-steps-data-wrap-importer .template.importing');
1451
1452 template.find('.cartflows-step-import')
1453 .removeClass('importing updating-message')
1454 .text('Import Failed!');
1455
1456
1457 template.find('.preview')
1458 .addClass('notice notice-warning')
1459 .removeClass('preview')
1460 .text( jqXHR.responseText );
1461 }
1462
1463 };
1464
1465 /**
1466 * Initialization
1467 */
1468 $(function(){
1469 CartFlowsImport.init();
1470 });
1471
1472 })(jQuery);