PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.3
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / assets / spa / components / weforms-settings / index.js

index.js in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.4.3, at assets/spa/components/weforms-settings/index.js

139 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 weForms.routeComponents.Settings = {
2 template: '#tmpl-wpuf-weforms-settings',
3 mixins: [weForms.mixins.Loading, weForms.mixins.Cookie],
4 data: function() {
5 return {
6 loading: false,
7 settings: {
8 email_gateway: 'wordpress',
9 credit: false,
10 permission: 'manage_options',
11 gateways: {
12 sendgrid: '',
13 mailgun: '',
14 sparkpost: ''
15 },
16 recaptcha: {
17 type: 'v2',
18 key: '',
19 secret: ''
20 }
21 },
22
23 activeTab: 'general',
24 };
25 },
26
27 computed: {
28
29 is_pro: function() {
30 return 'true' === weForms.is_pro;
31 }
32 },
33
34 created: function() {
35 this.fetchSettings();
36
37 if ( this.getCookie('weforms_settings_active_tab') ) {
38 this.activeTab = this.getCookie('weforms_settings_active_tab');
39 }
40 },
41
42 methods: {
43
44 makeActive: function(val) {
45 this.activeTab = val;
46 },
47
48 isActiveTab: function(val) {
49 return this.activeTab === val;
50 },
51
52 fetchSettings: function() {
53 var self = this;
54
55 self.loading = true;
56
57 wp.ajax.send('weforms_get_settings', {
58 data: {
59 _wpnonce: weForms.nonce
60 },
61
62 success: function(response) {
63
64 if ( response === undefined ){
65 return;
66 }
67
68 // set defaults if undefined
69 $.each( self.settings, function( key, value ) {
70 if( response[key] === undefined ) {
71 response[key] = value;
72 }
73 });
74
75 self.settings = response;
76 },
77
78 complete: function() {
79 self.loading = false;
80 }
81 });
82 },
83
84 saveSettings: function(target) {
85 var self = this;
86
87 $(target).addClass('updating-message');
88
89 wp.ajax.send('weforms_save_settings', {
90 data: {
91 settings: JSON.stringify(self.settings),
92 _wpnonce: weForms.nonce
93 },
94
95 success: function(response) {
96 toastr.options.timeOut = 1000;
97 toastr.success( 'Settings has been updated' );
98 },
99
100 error: function(error) {
101 console.log(error);
102 },
103
104 complete: function() {
105 $(target).removeClass('updating-message');
106 }
107 });
108
109 },
110
111 post: function( action, data , success ){
112 data = data || {};
113 success = success || function(){ };
114 data._wpnonce = weForms.nonce;
115
116 wp.ajax.send(action, {
117 data: data,
118
119 success: function(response) {
120 success(response);
121 },
122
123 error: function(error) {
124 console.log(error);
125 },
126
127 complete: function() {
128
129 }
130 });
131 },
132 },
133
134 watch: {
135 activeTab: function(value){
136 this.setCookie('weforms_settings_active_tab', value, '365');
137 }
138 }
139 };