PluginProbe
Button Generator – Easily Create Custom Buttons with Icons and Analytics / 2.3.9
Button Generator – Easily Create Custom Buttons with Icons and Analytics v2.3.9
trunk 1.1.1 2.0 2.1 2.2 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.2 3.1.3 3.2 3.2.1 3.2.2 3.2.3 All 28 releases
button-generation / assets / js / admin-script.js

admin-script.js in Button Generator – Easily Create Custom Buttons with Icons and Analytics 2.3.9, at assets/js/admin-script.js

414 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* ========= INFORMATION ============================
2 - document: Button Generator!
3 - author: Wow-Company
4 - copyright: 2019 Wow-Company
5 - version: 1.0
6 - email: yoda@wow-company.com
7 ==================================================== */
8
9 'use strict';
10
11 (function ($) {
12 $("#wow-plugin").on('submit', function (event) {
13 event.preventDefault();
14 var dataform = $(this).serialize();
15 var dataform = 'action=wow_item_save&' + dataform;
16 $('.wow-plugin .saving').animate({opacity: "0.75"});
17
18 $.post(ajaxurl, dataform, function (response) {
19 if (response.status == 'OK') {
20 $('#wow-message').addClass('notice notice-success is-dismissible');
21 $('#wow-message').html('<p>' + response.message + '</p>');
22 $('#add_action').val(2);
23 }
24 $('.wow-plugin .saving').animate({opacity: "0"});
25 });
26
27 });
28
29 $('.wow-plugin .tab-nav li:first').addClass('select');
30 $('.wow-plugin .tab-panels>div').hide().filter(':first').show();
31 $('.wow-plugin .tab-nav a').on('click', function () {
32 $('.wow-plugin .tab-panels>div').hide().filter(this.hash).show();
33 $('.wow-plugin .tab-nav li').removeClass('select');
34 $(this).parent().addClass('select');
35 return false;
36 });
37
38 $('.wow-plugin input:checkbox:checked').each(function () {
39 $(this).siblings('input[type="hidden"]').val('1');
40 });
41
42 $('.wow-plugin input:checkbox').on('click', function () {
43 checkboxchecked(this);
44 }
45 );
46
47 //* Include colorpicker
48 $('.wp-color-picker-field').wpColorPicker();
49
50 $('#icon').fontIconPicker({
51 theme: 'fip-darkgrey',
52 emptyIcon: false,
53 allCategoryText: 'Show all'
54 });
55
56
57 $('input#depending_language:checkbox').each(function () {
58 languages(this);
59 });
60
61 $('select#show').each(function () {
62 showchange(this);
63 });
64
65 $('input.item_user:radio:checked').each(function () {
66 usersroles(this);
67 });
68
69 $('input#include_mobile:checkbox').each(function () {
70 screen_less(this);
71 });
72
73 $('input#include_more_screen:checkbox').each(function () {
74 screen_more(this);
75 });
76
77 $('select.item-type').each(function () {
78 itemtype(this);
79 });
80
81 $('body').on('hover', '.wow-help', function () {
82 if ( $(this).hasClass( "dashicons-lock" ) ) {
83 $(this).removeClass('dashicons-lock');
84 $(this).addClass('dashicons-unlock');
85 }
86 else if ( $(this).hasClass( "dashicons-unlock" ) ){
87 $(this).removeClass('dashicons-unlock');
88 $(this).addClass('dashicons-lock');
89 }
90 })
91
92 wow_attach_tooltips($(".wow-help"));
93
94 buttontype();
95 buttonlocation();
96 buttonappearance();
97 enablebadge();
98 border();
99 shadowblock();
100 borderbadge();
101 badgetype();
102
103 $('[data-share]').on('click', function(event) {
104 event.preventDefault();
105 let network = $(this).data('share');
106 let url = $('#wp-url').val();
107 let title = $('#wp-title').val();
108
109 let shareUrl;
110
111 switch (network) {
112 case 'facebook':
113 shareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + url;
114 break;
115 case 'vk':
116 shareUrl = 'http://vk.com/share.php?url=' + url;
117 break;
118 case 'twitter':
119 shareUrl = 'https://twitter.com/share?url=' + url + '&text=' + title;
120 break;
121 case 'linkedin':
122 shareUrl = 'https://www.linkedin.com/shareArticle?url=' + url + '&title=' + title;
123 break;
124 case 'pinterest':
125 shareUrl = 'https://pinterest.com/pin/create/button/?url=' + url;
126 break;
127 case 'xing':
128 shareUrl = 'https://www.xing.com/spi/shares/new?url=' + url;
129 break;
130 case 'reddit':
131 shareUrl = 'http://www.reddit.com/submit?url=' + url + '&title=' + title;
132 break;
133 case 'blogger':
134 shareUrl = 'https://www.blogger.com/blog-this.g?u=' + url + '&n=' + title;
135 break;
136 case 'telegram':
137 shareUrl = 'https://telegram.me/share/url?url=' + url + '&text=' + title;
138 break;
139
140
141 default:
142 shareUrl = '';
143 }
144
145 let popupWidth = 550;
146 let popupHeight = 450;
147 let topPosition = (screen.height - popupHeight) / 2;
148 let leftPosition = (screen.width - popupWidth) / 2;
149 let popup = 'width=' + popupWidth + ', height=' + popupHeight + ', top=' + topPosition + ', left=' + leftPosition +
150 ', scrollbars=0, resizable=1, menubar=0, toolbar=0, status=0';
151
152 window.open(shareUrl, null, popup);
153
154 });
155
156 $(document).on('click', '.wow-plugin-message .notice-dismiss', function() {
157 $.ajax({
158 url: ajaxurl, data: {
159 action: 'button_generation_message',
160 },
161 });
162 });
163
164 })(jQuery);
165
166 function buttontype() {
167 var type = jQuery('#type').val();
168 jQuery('.button-floating').css('display', 'none');
169 if (type == 'floating') {
170 jQuery('.button-floating').css('display', 'block');
171 }
172 }
173
174 function buttonlocation() {
175 var loc = jQuery('#location').val();
176 jQuery('.top-bottom').css('visibility', 'visible');
177 jQuery('.left-right').css('visibility', 'visible');
178 jQuery('#lg-top').css('display', 'none');
179 jQuery('#lg-bottom').css('display', 'none');
180 jQuery('#lg-left').css('display', 'none');
181 jQuery('#lg-right').css('display', 'none');
182 if (loc == 'topLeft') {
183 jQuery('#lg-top').css('display', 'block');
184 jQuery('#lg-left').css('display', 'block');
185 } else if (loc == 'topCenter') {
186 jQuery('#lg-top').css('display', 'block');
187 jQuery('.left-right').css('visibility', 'hidden');
188 } else if (loc == 'topRight') {
189 jQuery('#lg-top').css('display', 'block');
190 jQuery('#lg-right').css('display', 'block');
191 } else if (loc == 'bottomLeft') {
192 jQuery('#lg-bottom').css('display', 'block');
193 jQuery('#lg-left').css('display', 'block');
194 } else if (loc == 'bottomCenter') {
195 jQuery('#lg-bottom').css('display', 'block');
196 jQuery('.left-right').css('visibility', 'hidden');
197 } else if (loc == 'bottomRight') {
198 jQuery('#lg-bottom').css('display', 'block');
199 jQuery('#lg-right').css('display', 'block');
200 } else if (loc == 'left') {
201 jQuery('.top-bottom').css('visibility', 'hidden');
202 jQuery('#lg-left').css('display', 'block');
203 } else if (loc == 'right') {
204 jQuery('.top-bottom').css('visibility', 'hidden');
205 jQuery('#lg-right').css('display', 'block');
206 }
207 }
208
209 function buttonappearance() {
210 var type = jQuery('#appearance').val();
211 jQuery('.button-text').css('display', 'none');
212 jQuery('.button-icon').css('display', 'none');
213 jQuery('.text-location').css('visibility', 'hidden');
214 if (type == 'text') {
215 jQuery('.button-text').css('display', 'block');
216 } else if (type == 'text_icon') {
217 jQuery('.button-text').css('display', 'block');
218 jQuery('.button-icon').css('display', 'block');
219 jQuery('.text-location').css('visibility', 'visible');
220 } else if (type == 'icon') {
221 jQuery('.button-icon').css('display', 'block');
222 }
223 }
224
225 function badgetype() {
226 let type = jQuery('#badge_type').val();
227 if (type === 'actions') {
228 jQuery('.badge-content').css('visibility', 'hidden');
229 } else {
230 jQuery('.badge-content').css('visibility', 'visible');
231 }
232 }
233
234 function enablebadge() {
235 if (jQuery('#enable_badge').is(':checked')) {
236 jQuery('#notification-bage').css('visibility', 'visible');
237 jQuery('.notification-bage').css('display', 'block');
238 } else {
239 jQuery('#notification-bage').css('visibility', 'hidden');
240 jQuery('.notification-bage').css('display', 'none');
241 }
242 }
243
244
245 function border() {
246 var border = jQuery('#border_style').val();
247 if (border == 'none') {
248 jQuery('.border').css('display', 'none');
249 } else {
250 jQuery('.border').css('display', 'block');
251 }
252 }
253
254 function borderbadge() {
255 var border = jQuery('#badge_border_style').val();
256 if (border == 'none') {
257 jQuery('.border-badge').css('display', 'none');
258 } else {
259 jQuery('.border-badge').css('display', 'block');
260 }
261 }
262
263 function shadowblock() {
264 var shadow = jQuery('#shadow').val();
265 if (shadow == 'none') {
266 jQuery('.shadow').css('visibility', 'hidden');
267 jQuery('.shadow-block').css('display', 'none');
268
269 } else {
270 jQuery('.shadow').css('visibility', 'visible');
271 jQuery('.shadow-block').css('display', '');
272 }
273 }
274
275 //* Change item type
276 function itemtype(that) {
277 var type = jQuery(that).val();
278 var parent = jQuery(that).parents('.container');
279 jQuery(parent).find('.type-link-blank').css('visibility', 'hidden ');
280 jQuery(that).parents('.menu_block').find('.button_id').css('visibility', 'visible');
281 jQuery(that).parents('.menu_block').find('.button_class').css('visibility', 'visible');
282 if (type === 'link' || type === 'smoothscroll' || type === 'email' || type === 'telephone') {
283 jQuery(parent).find('.type-link').css('display', 'block');
284 jQuery(parent).find('.type-share').css('display', 'none');
285 jQuery(parent).find('.type-modal').css('display', 'none');
286 jQuery(parent).find('.type-link-text').text('Link');
287 if (type === 'link') {
288 jQuery(parent).find('.type-link-blank').css('visibility', 'visible');
289 } else if (type === 'email') {
290 jQuery(parent).find('.type-link-text').text('Email');
291 } else if (type === 'telephone') {
292 jQuery(parent).find('.type-link-text').text('Telephone');
293 }
294
295 } else if (type === 'share') {
296 jQuery(parent).find('.type-link').css('display', 'none');
297 jQuery(parent).find('.type-share').css('display', 'block');
298 jQuery(parent).find('.type-modal').css('display', 'none');
299 } else if (type === 'login' || type === 'logout' || type === 'lostpassword') {
300 jQuery(parent).find('.type-link').css('display', 'block');
301 jQuery(parent).find('.type-share').css('display', 'none');
302 jQuery(parent).find('.type-link-text').text('Redirect URL');
303 jQuery(parent).find('.type-modal').css('display', 'none');
304
305 } else {
306 jQuery(parent).find('.type-link').css('display', 'none');
307 jQuery(parent).find('.type-share').css('display', 'none');
308 jQuery(parent).find('.type-modal').css('display', 'none');
309 }
310 }
311
312 function wow_attach_tooltips(selector) {
313 selector.tooltip({
314 content: function () {
315 return jQuery(this).prop("title")
316 },
317 tooltipClass: "wow-ui-tooltip",
318 position: {
319 my: "center top",
320 at: "center bottom+10",
321 collision: "flipfit"
322 },
323 hide: {
324 duration: 200
325 },
326 show: {
327 duration: 200
328 }
329 })
330 }
331
332
333 function checkboxchecked(that) {
334 if (jQuery(that).prop('checked')) {
335 jQuery(that).siblings('input[type="hidden"]').val('1');
336 } else {
337 jQuery(that).siblings('input[type="hidden"]').val('0');
338 }
339 }
340
341
342 //* Show language
343 function languages(that) {
344 if (jQuery(that).is(':checked')) {
345 jQuery('#language').css('display', '');
346 } else {
347 jQuery('#language').css('display', 'none');
348 }
349 }
350
351 //* When show
352 function showchange(that) {
353 var show = jQuery(that).val();
354 if (show === 'posts' || show === 'pages' || show === 'expost' || show === 'expage' || show === 'taxonomy') {
355 jQuery('#id_post').css('display', '');
356 jQuery('#shortcode').css('display', 'none');
357 } else if (show === 'shortecode') {
358 jQuery('#shortcode').css('display', '');
359 jQuery('#id_post').css('display', 'none');
360 } else {
361 jQuery('#shortcode').css('display', 'none');
362 jQuery('#id_post').css('display', 'none');
363 }
364 if (show === 'taxonomy') {
365 jQuery('#taxonomy').css('display', '');
366 } else {
367 jQuery('#taxonomy').css('display', 'none');
368 }
369 }
370
371 //* Show screen
372 function screen_less(that) {
373 if (jQuery(that).is(':checked')) {
374 jQuery('#screen').css('display', '');
375 } else {
376 jQuery('#screen').css('display', 'none');
377 }
378 }
379
380 function screen_more(that) {
381 if (jQuery(that).is(':checked')) {
382 jQuery('#screenmore').css('display', '');
383 } else {
384 jQuery('#screenmore').css('display', 'none');
385 }
386 }
387
388 function usersroles(that) {
389 var users = jQuery(that).val();
390 if (users == 2) {
391 jQuery('#users_roles').css('display', '');
392 } else {
393 jQuery('#users_roles').css('display', 'none');
394 }
395 }
396
397 function resetcounts(tool_id) {
398
399 var data = {
400 security: btg_count.nonce,
401 action: 'btg_count',
402 count_type: 'reset',
403 tool_id: tool_id,
404 };
405 jQuery.post(btg_count.ajaxurl, data, function (msg) {
406 var result = msg.result;
407 if (result === 'OK') {
408 jQuery('#tool_view').html('0');
409 jQuery('#tool_action').html('0');
410 jQuery('#conversion').html('0%');
411 }
412 });
413
414 }