Welcome to mirror list, hosted at ThFree Co, Russian Federation.

admin.js « templates « UserCountry « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88ebf559dfd4a5cc7e72411228f533126757189b (plain)
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
/*!
 * Piwik - Web Analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

$(document).ready(function() {
	// handle switch current location provider
	$('.current-location-provider').change(function() {
		if (!$(this).is(':checked')) return; // only handle radio buttons that get checked
		
		var parent = $(this).parent(),
			loading = $('.loadingPiwik', parent),
			ajaxSuccess = $('.ajaxSuccess', parent);
		loading.show();
		
		$.ajax({
			type: 'POST',
			url: 'index.php',
			data: {
				module: 'UserCountry',
				action: 'setCurrentLocationProvider',
				token_auth: piwik.token_auth,
				id: $(this).val()
			},
			async: true,
			error: piwikHelper.ajaxHandleError,		// Callback when the request fails
			success: function() {
				loading.hide();
				ajaxSuccess.fadeIn(1000, function() {
					setTimeout(function() {
						ajaxSuccess.fadeOut(1000);
					}, 2000);
				});
			}
		});
	});
	
	// handle 'refresh location' link click
	$('.refresh-loc').click(function(e) {
		e.preventDefault();
		
		var cell = $(this).parent().parent(),
			loading = $('.loadingPiwik', cell),
			location = $('.location', cell);
		
		location.css('visibility', 'hidden');
		loading.show();
		
		$.ajax({
			type: 'POST',
			url: 'index.php',
			data: {
				module: 'UserCountry',
				action: 'getLocationUsingProvider',
				id: $(this).attr('data-impl-id')
			},
			async: true,
			error: piwikHelper.ajaxHandleError,		// Callback when the request fails
			success: function(response) {
				loading.hide();
				location.html('<strong><em>' + response + '</em></strong>').css('visibility', 'visible');
			}
		});
		
		return false;
	});
});