PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.24
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.24
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 / js / spa-mixins.js

spa-mixins.js in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.6.24, at assets/js/spa-mixins.js

194 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2
3 /* ./assets/spa/mixins/bulk-action.js */
4
5 weForms.mixins.BulkAction = {
6 data: function data() {
7 return {
8 bulkAction: '-1',
9 checkedItems: []
10 };
11 },
12
13 computed: {
14 selectAll: {
15 get: function get() {
16 return this.items ? this.checkedItems.length == this.items.length : false;
17 },
18
19 set: function set(value) {
20 var selected = [],
21 self = this;
22
23 if (value) {
24 this.items.forEach(function (item) {
25 if (item[self.index] !== undefined) {
26 selected.push(item[self.index]);
27 } else {
28 selected.push(item.id);
29 }
30 });
31 }
32
33 this.checkedItems = selected;
34 }
35 }
36 },
37
38 methods: {
39 deleteBulk: function deleteBulk() {
40 var self = this;
41
42 self.loading = true;
43
44 wp.ajax.send(self.bulkDeleteAction, {
45 data: {
46 permanent: this.status == 'trash' ? 1 : 0,
47 ids: this.checkedItems,
48 _wpnonce: weForms.nonce
49 },
50 success: function success(response) {
51 self.checkedItems = [];
52 self.fetchData();
53 },
54 error: function error(_error) {
55 alert(_error);
56 },
57
58 complete: function complete(resp) {
59 self.loading = false;
60 }
61 });
62 },
63 restoreBulk: function restoreBulk() {
64 var self = this;
65
66 self.loading = true;
67
68 wp.ajax.send('weforms_form_entry_restore_bulk', {
69 data: {
70 ids: this.checkedItems,
71 _wpnonce: weForms.nonce
72 },
73 success: function success(response) {
74 self.checkedItems = [];
75 self.fetchData();
76 },
77 error: function error(_error2) {
78 alert(_error2);
79 },
80 complete: function complete(resp) {
81 self.loading = false;
82 }
83 });
84 }
85 }
86 };
87
88 /* ./assets/spa/mixins/cookie.js */
89 weForms.mixins.Cookie = {
90
91 methods: {
92
93 setCookie: function setCookie(cname, cvalue, exdays) {
94 var d = new Date();
95 d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
96 var expires = "expires=" + d.toUTCString();
97 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
98 },
99
100 getCookie: function getCookie(cname) {
101 var name = cname + "=";
102 var decodedCookie = decodeURIComponent(document.cookie);
103 var ca = decodedCookie.split(';');
104 for (var i = 0; i < ca.length; i++) {
105 var c = ca[i];
106 while (c.charAt(0) == ' ') {
107 c = c.substring(1);
108 }
109 if (c.indexOf(name) == 0) {
110 return c.substring(name.length, c.length);
111 }
112 }
113 return "";
114 }
115 }
116 };
117
118 /* ./assets/spa/mixins/loading.js */
119 weForms.mixins.Loading = {
120 watch: {
121 loading: function loading(value) {
122 if (value) {
123 NProgress.configure({ parent: '#wpadminbar' });
124 NProgress.start();
125 } else {
126 NProgress.done();
127 }
128 }
129
130 /* ./assets/spa/mixins/paginate.js */
131 } };weForms.mixins.Paginate = {
132 data: function data() {
133 return {
134 totalItems: 0,
135 totalPage: 1,
136 currentPage: 1,
137 pageNumberInput: 1
138 };
139 },
140
141 methods: {
142 isFirstPage: function isFirstPage() {
143 return this.currentPage == 1;
144 },
145
146 isLastPage: function isLastPage() {
147 return this.currentPage == this.totalPage;
148 },
149
150 goFirstPage: function goFirstPage() {
151 this.currentPage = 1;
152 this.pageNumberInput = this.currentPage;
153
154 this.goToPage();
155 },
156
157 goLastPage: function goLastPage() {
158 this.currentPage = this.totalPage;
159 this.pageNumberInput = this.currentPage;
160
161 this.goToPage();
162 },
163
164 goToPage: function goToPage(direction) {
165 if (direction == 'prev') {
166 this.currentPage--;
167 } else if (direction == 'next') {
168 this.currentPage++;
169 } else {
170 if (!isNaN(direction) && direction <= this.totalPage) {
171 this.currentPage = direction;
172 }
173 }
174
175 this.pageNumberInput = this.currentPage;
176 this.fetchData();
177 }
178 }
179 };
180
181 /* ./assets/spa/mixins/tabs.js */
182 weForms.mixins.Tabs = {
183
184 methods: {
185 makeActive: function makeActive(val) {
186 this.activeTab = val;
187 },
188
189 isActiveTab: function isActiveTab(val) {
190 return this.activeTab === val;
191 }
192 }
193 };
194