settings.js
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
( function( $ ) {
FLBuilder.registerModuleHelper( 'subscribe-form', {
rules: {
btn_text: {
required: true
},
btn_font_size: {
required: true,
number: true
},
btn_padding: {
required: true,
number: true
},
btn_border_radius: {
required: true,
number: true
},
service: {
required: true
}
},
init: function()
{
var form = $( '.fl-builder-settings' ),
action = form.find( 'select[name=success_action]' );
this._actionChanged();
action.on( 'change', this._actionChanged );
// Button background color change
$( 'input[name=btn_bg_color]' ).on( 'change', this._bgColorChange );
this._bgColorChange();
},
submit: function()
{
var form = $( '.fl-builder-settings' ),
service = form.find( '.fl-builder-service-select' ),
serviceVal = service.val(),
account = form.find( '.fl-builder-service-account-select' ),
list = form.find( '.fl-builder-service-list-select' );
if ( 0 === account.length ) {
FLBuilder.alert( FLBuilderStrings.subscriptionModuleConnectError );
return false;
}
else if ( '' == account.val() || 'add_new_account' == account.val() ) {
FLBuilder.alert( FLBuilderStrings.subscriptionModuleAccountError );
return false;
}
else if ( ( 0 === list.length || '' == list.val() ) && 'email-address' != serviceVal && 'sendy' != serviceVal ) {
if ( 'drip' == serviceVal || 'hatchbuck' == serviceVal ) {
FLBuilder.alert( FLBuilderStrings.subscriptionModuleTagsError );
}
else {
FLBuilder.alert( FLBuilderStrings.subscriptionModuleListError );
}
return false;
}
return true;
},
_actionChanged: function()
{
var form = $( '.fl-builder-settings' ),
action = form.find( 'select[name=success_action]' ).val(),
url = form.find( 'input[name=success_url]' );
url.rules('remove');
if ( 'redirect' == action ) {
url.rules( 'add', { required: true } );
}
},
_bgColorChange: function()
{
var bgColor = $( 'input[name=btn_bg_color]' ),
style = $( '#fl-builder-settings-section-btn_style' );
if ( '' == bgColor.val() ) {
style.hide();
}
else {
style.show();
}
}
});
})(jQuery);