stats.js
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* stats javascript behavior
*
* To allow users to accept & configure stats sending
*
* @package Joomla
* @since 3.5.0
* @version 1.0
*/
(function ($) {
$(document).ready(function () {
var ajaxData = {
'option' : 'com_ajax',
'group' : 'system',
'plugin' : 'renderStatsMessage',
'format' : 'raw'
},
messageContainer = $('#system-message-container');
/**
* Initialise events for the message container
*
* @return void
*/
function initStatsEvents()
{
var globalContainer = messageContainer.find('.js-pstats-alert'),
detailsContainer = messageContainer.find('.js-pstats-data-details');
// Show details about the information being sent
messageContainer.on('click', '.js-pstats-btn-details', function(e){
detailsContainer.toggle(200);
e.preventDefault();
});
// Always allow
messageContainer.on('click', '.js-pstats-btn-allow-always', function(e){
// Remove message
globalContainer.hide(200);
detailsContainer.remove();
ajaxData.plugin = 'sendAlways';
$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});
// Allow once
messageContainer.on('click', '.js-pstats-btn-allow-once', function(e){
// Remove message
globalContainer.hide(200);
detailsContainer.remove();
ajaxData.plugin = 'sendOnce';
$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});
// Never allow
messageContainer.on('click', '.js-pstats-btn-allow-never', function(e){
// Remove message
globalContainer.hide(200);
detailsContainer.remove();
ajaxData.plugin = 'sendNever';
$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});
}
ajaxData.plugin = 'sendStats';
$.getJSON('index.php', ajaxData, function(response){
if (response && response.html) {
messageContainer
.append(response.html)
.find('.js-pstats-alert').show(200);
initStatsEvents();
}
});
});
})(jQuery);