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: 8d10ca6e5cff691764b78c5a4755c090587dac99 (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
/*!
 * 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);

        var ajaxRequest = new ajaxHelper();
        ajaxRequest.setLoadingElement(loading);
        ajaxRequest.addParams({
            module: 'UserCountry',
            action: 'setCurrentLocationProvider',
            id:     $(this).val()
        }, 'get');
        ajaxRequest.setCallback(
            function () {
                ajaxSuccess.fadeIn(1000, function() {
                    setTimeout(function() {
                        ajaxSuccess.fadeOut(1000);
                    }, 2000);
                });
            }
        );
        ajaxRequest.send(false);
	});
	
	// 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');

        var ajaxRequest = new ajaxHelper();
        ajaxRequest.setLoadingElement(loading);
        ajaxRequest.addParams({
            module: 'UserCountry',
            action: 'getLocationUsingProvider',
            id:     $(this).attr('data-impl-id')
        }, 'get');
        ajaxRequest.setCallback(
            function (response) {
                location.html('<strong><em>' + response + '</em></strong>').css('visibility', 'visible');
            }
        );
        ajaxRequest.setFormat('html');
        ajaxRequest.send(false);

		return false;
	});
});