PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.3
JetFormBuilder — Dynamic Blocks Form Builder v1.2.3
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
action-localize-helper.js 5 years ago admin.js 5 years ago editor.js 5 years ago file-upload.js 5 years ago form-block.js 5 years ago frontend-forms.js 5 years ago package.js 5 years ago
action-localize-helper.js
79 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 getLocalizedWithFunc = ( { actionType = false, source = false },
12 objectKey,
13 ifEmptyReturn = '' ) => {
14
15 let action = false;
16
17 if ( source && source[ objectKey ] ) {
18 action = source[ objectKey ];
19 } else if ( actionType ) {
20 action = ( getLocalized( actionType )[ objectKey ] );
21 }
22
23 if ( ! action ) {
24 return () => ifEmptyReturn;
25 }
26
27 return attr => {
28 if ( attr ) {
29 return ( action[ attr ] ? action[ attr ] : ifEmptyReturn );
30 } else {
31 return action;
32 }
33 };
34 };
35
36 const getActionLabel = ( type ) => {
37 const action = window.jetFormActionTypes.find( el => el.id === type );
38 return action ? action.name : '';
39 };
40
41 const localizedLabel = settings => {
42 return getLocalizedWithFunc( settings, '__labels', '[Empty Label]' );
43 };
44
45 const localizedHelp = settings => {
46 return getLocalizedWithFunc( settings, '__help_messages' );
47 };
48
49 const localizedGatewayAttrs = settings => {
50 return getLocalizedWithFunc( settings, '__gateway_attrs', [] );
51 };
52
53 const localizedMessages = settings => {
54 return getLocalizedWithFunc( settings, '__messages', {} );
55 };
56
57 const getLocalizedFullPack = ( actionType, source = false ) => {
58 if ( ! source ) {
59 source = getLocalized( actionType );
60 }
61
62 const label = localizedLabel( { source } );
63 const help = localizedHelp( { source } );
64 const messages = localizedMessages( { source } );
65 const gatewayAttrs = localizedGatewayAttrs( { source } );
66
67 return { source, label, help, messages, gatewayAttrs };
68 };
69
70 window.JetFBLocalizeHelper = {
71 getActionLabel,
72 getLocalizedWithFunc,
73 localizedLabel,
74 localizedHelp,
75 localizedGatewayAttrs,
76 localizedMessages,
77 getLocalizedFullPack
78 };
79