PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.3
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.3
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 / product-page.js

product-page.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.3, at admin/assets/js/product-page.js

133 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function ( $ ) {
2 const wcf_flows_search_init = function () {
3 const product_search = $( '.wcf-flows-search' );
4
5 if ( product_search.length > 0 ) {
6 $( 'select.wcf-flows-search' ).select2();
7 const nonce = $(
8 'input[name="wcf_json_search_flows_nonce"]'
9 ).val();
10
11 $( 'select.wcf-flows-search' )
12 .filter( ':not(.enhanced)' )
13 .each( function () {
14 let select2_args = {
15 allowClear: $( this ).data( 'allow_clear' )
16 ? true
17 : false,
18 placeholder: $( this ).data( 'placeholder' ),
19 minimumInputLength: $( this ).data(
20 'minimum_input_length'
21 )
22 ? $( this ).data( 'minimum_input_length' )
23 : '3',
24 escapeMarkup( m ) {
25 return m;
26 },
27
28 ajax: {
29 url: ajaxurl,
30 dataType: 'json',
31 quietMillis: 250,
32 method: 'post',
33 data( params ) {
34 return {
35 term: params.term,
36 action:
37 $( this ).data( 'action' ) ||
38 'wcf_json_search_flows',
39
40 security: nonce,
41 };
42 },
43 processResults( data ) {
44 const terms = [];
45 if ( data ) {
46 $.each( data, function ( id, text ) {
47 terms.push( {
48 id,
49 text,
50 } );
51 } );
52 }
53 return { results: terms };
54 },
55 cache: true,
56 },
57 };
58
59 select2_args = $.extend(
60 select2_args,
61 getEnhancedSelectFormatString()
62 );
63
64 $( this ).select2( select2_args ).addClass( 'enhanced' );
65 } );
66 }
67 };
68
69 if ( typeof getEnhancedSelectFormatString === 'undefined' ) {
70 // This is the optional function. Not used every time.
71 /* eslint-disable */
72 function getEnhancedSelectFormatString() {
73 const formatString = {
74 noResults() {
75 return wc_enhanced_select_params.i18n_no_matches;
76 },
77 errorLoading() {
78 return wc_enhanced_select_params.i18n_searching;
79 },
80 inputTooShort( args ) {
81 const remainingChars = args.minimum - args.input.length;
82
83 if ( 1 === remainingChars ) {
84 return wc_enhanced_select_params.i18n_input_too_short_1;
85 }
86
87 return wc_enhanced_select_params.i18n_input_too_short_n.replace(
88 '%qty%',
89 remainingChars
90 );
91 },
92 inputTooLong( args ) {
93 const overChars = args.input.length - args.maximum;
94
95 if ( 1 === overChars ) {
96 return wc_enhanced_select_params.i18n_input_too_long_1;
97 }
98
99 return wc_enhanced_select_params.i18n_input_too_long_n.replace(
100 '%qty%',
101 overChars
102 );
103 },
104 maximumSelected( args ) {
105 if ( args.maximum === 1 ) {
106 return wc_enhanced_select_params.i18n_selection_too_long_1;
107 }
108
109 return wc_enhanced_select_params.i18n_selection_too_long_n.replace(
110 '%qty%',
111 args.maximum
112 );
113 },
114 loadingMore() {
115 return wc_enhanced_select_params.i18n_load_more;
116 },
117 searching() {
118 return wc_enhanced_select_params.i18n_searching;
119 },
120 };
121
122 const language = { language: formatString };
123
124 return language;
125 }
126 /* eslint-enable */
127 }
128
129 $( function () {
130 wcf_flows_search_init();
131 } );
132 } )( jQuery );
133