PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.0
JetFormBuilder — Dynamic Blocks Form Builder v3.1.0
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / js / action-localize-helper.js
jetformbuilder / assets / js Last commit date
admin 3 years ago chunks 3 years ago editor 3 years ago frontend 3 years ago action-localize-helper.js 3 years ago file-upload.js 3 years ago import-form.js 3 years ago map-field.js 3 years ago
action-localize-helper.js
106 lines
1 const getLocalized = ( actionType, objectKey = '' ) => {
2 const preparedAction = window.jetFormActionTypes.find( action => actionType === action.id );
3 if ( ! preparedAction ) {
4 return false;
5 }
6 const actionSelfLocalized = window[ preparedAction.self ];
7
8 return ( objectKey && actionSelfLocalized[ objectKey ] ) ? actionSelfLocalized[ objectKey ] : actionSelfLocalized;
9 };
10
11 const getSourceObjectName = actionType => {
12 const preparedAction = window.jetFormActionTypes.find( action => actionType === action.id );
13
14 return preparedAction ? preparedAction.self : false;
15 };
16
17 const getLocalizedWithFunc = ( { actionType = false, source = false },
18 objectKey,
19 ifEmptyReturn = '' ) => {
20
21 let action = false;
22
23 if ( source && source[ objectKey ] ) {
24 action = source[ objectKey ];
25 } else if ( actionType ) {
26 action = ( getLocalized( actionType )[ objectKey ] );
27 }
28
29 if ( ! action ) {
30 return () => ifEmptyReturn;
31 }
32
33 return attr => {
34 if ( attr ) {
35 return ( action[ attr ] ? action[ attr ] : ifEmptyReturn );
36 } else {
37 return action;
38 }
39 };
40 };
41
42 const getActionLabel = ( type ) => {
43 const action = window.jetFormActionTypes.find( el => el.id === type );
44 return action ? action.name : '';
45 };
46
47 const localizedLabel = settings => {
48 return getLocalizedWithFunc( settings, '__labels', '[Empty Label]' );
49 };
50
51 const localizedHelp = settings => {
52 return getLocalizedWithFunc( settings, '__help_messages' );
53 };
54
55 const localizedGatewayAttrs = settings => {
56 return getLocalizedWithFunc( settings, '__gateway_attrs', [] );
57 };
58
59 const localizedMessages = settings => {
60 return getLocalizedWithFunc( settings, '__messages', {} );
61 };
62
63 const getLocalizedFullPack = ( actionType, source = false ) => {
64 if ( ! source ) {
65 source = getLocalized( actionType );
66 }
67
68 function setSource( props = {} ) {
69 const name = getSourceObjectName( actionType );
70
71 if ( ! name || ! window[ name ] ) {
72 return false;
73 }
74 window[ name ] = {
75 ...window[ name ],
76 ...props,
77 };
78
79 return true;
80 }
81
82 const label = localizedLabel( { source } );
83 const help = localizedHelp( { source } );
84 const messages = localizedMessages( { source } );
85 const gatewayAttrs = localizedGatewayAttrs( { source } );
86
87 return { source, label, help, messages, gatewayAttrs, setSource };
88 };
89
90 const isInDefaultFlow = actionType => {
91 const flow = 'Jet_Form_Builder\\Actions\\Executors\\Action_Default_Executor';
92
93 return flow === getLocalized( actionType, '__flow' );
94 };
95
96 window.JetFBLocalizeHelper = {
97 getActionLabel,
98 getLocalizedWithFunc,
99 localizedLabel,
100 localizedHelp,
101 localizedGatewayAttrs,
102 localizedMessages,
103 getLocalizedFullPack,
104 isInDefaultFlow
105 };
106