PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.1
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.6.1, at assets/spa/components/weforms-settings/index.js

142 lines 3.6 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 weForms.settings = response;
100 },
101
102 error: function(error) {
103 console.log(error);
104 },
105
106 complete: function() {
107 $(target).removeClass('updating-message');
108 }
109 });
110
111 },
112
113 post: function( action, data , success ){
114 data = data || {};
115 success = success || function(){ };
116 data._wpnonce = weForms.nonce;
117
118 wp.ajax.send(action, {
119 data: data,
120
121 success: function(response) {
122 success(response);
123 },
124
125 error: function(error) {
126 console.log(error);
127 },
128
129 complete: function() {
130
131 }
132 });
133 },
134 },
135
136 watch: {
137 activeTab: function(value){
138 this.setCookie('weforms_settings_active_tab', value, '365');
139 }
140 }
141 };
142