PluginProbe
MaxButtons – Create buttons / 6.9
MaxButtons – Create buttons v6.9
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / js / front.js

front.js in MaxButtons – Create buttons 6.9, at js/front.js

114 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*function mbAddListener(element, type, callback) {
2 if (element.addEventListener) element.addEventListener(type, callback);
3 else if (element.attachEvent) element.attachEvent('on' + type, callback);
4 }*/
5
6 jQuery(document).ready(function($){
7
8 function mbSocialShare(e)
9 {
10 e.preventDefault();
11 var data = $(this).data('popup');
12
13 var url = $(this).find('a').attr("href");
14 var width = data.width;
15 var height = data.height;
16 var left = ($(window).width() - width) / 2;
17 var top = ($(window).height() - height) / 2;
18
19 var params = "toolbar=0,scrollbars=1, location=0, width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
20 var popup = window.open(url, 'mb-social-share-window', params);
21 popup.focus();
22 mbSocialTrack();
23 }
24
25 // track a click ( not a share! )
26 mbSocialTrack = function (data)
27 {
28
29
30 }
31
32
33 function mbGetShareCount(el, data)
34 {
35 var ajax_url = mb_ajax.ajaxurl;
36 var share_url = data.share_url;
37 var network = data.network;
38 var collection_id = data.collection_id;
39 var nonce = data.nonce;
40
41 var block_data = {
42 share_url: share_url,
43 network: network,
44 };
45
46 var data = {
47 block_name : 'social',
48 block_action : 'ajax_get_count',
49 action : 'mbpro_collection_block_front',
50 collection_id: collection_id,
51 collection_type: 'social',
52 block_data: block_data,
53 };
54
55 $.ajax({
56 type: "POST",
57 url: ajax_url,
58 data: data,
59 success: function (result) {
60 mbPutShareCount(result, el);
61
62 },
63 });
64 }
65
66 function mbPutShareCount(result, el)
67 {
68
69 var resJSON = $.parseJSON(result);
70
71 var data = $(el).data('onload');
72 var threshold = parseInt(data.count_threshold);
73 var count = parseInt(resJSON.data.count);
74
75
76 if (count >= threshold)
77 {
78 var text = data.text;
79 var text2 = data.text2;
80
81 text = text.replace('{count}', count);
82 text = text.replace('{c}', count);
83 text2 = text2.replace('{count}', count);
84 text2 = text2.replace('{c}', count);
85
86 $(el).find('.mb-text').html(text);
87 $(el).find('.mb-text2').html(text2);
88
89 }
90
91 }
92
93 function mb_init()
94 {
95 if (typeof($) !== 'function')
96 {
97 console.log('Maxbuttons : Jquery load conflict.');
98 return;
99 }
100
101 $('.maxcollection .mb-collection-item[data-popup]').on('click', mbSocialShare );
102
103 $('.maxcollection .mb-collection-item[data-onload]').each( function () {
104 var collection_id = $(this).parents('.maxcollection').data('collection');
105
106 var data = $(this).data('onload');
107 data.collection_id = collection_id;
108 mbGetShareCount(this, data);
109
110 });
111 }
112 mb_init(); // init JS instructions
113 });
114