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

visitorLog.js « javascripts « Live « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07cdd313f2ee20b30e9c0cd3d8050824eb1646fa (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
 * Piwik - free/libre analytics platform
 *
 * Visitor profile popup control.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

(function ($, require) {

    var exports = require('piwik/UI'),
        DataTable = exports.DataTable,
        dataTablePrototype = DataTable.prototype;

    /**
     * DataTable UI class for jqPlot graph datatable visualizations.
     *
     * @constructor
     */
    exports.VisitorLog = function (element) {
        DataTable.call(this, element);
    };

    $.extend(exports.VisitorLog.prototype, dataTablePrototype, {

        handleColumnHighlighting: function () {

        },

        setFixWidthToMakeEllipsisWork: function () {

        },

        /**
         * Initializes this class.
         */
        init: function () {
            dataTablePrototype.init.call(this);

            $('.visitorLogIconWithDetails>img').each(function () {
                $(this).tooltip({
                    items: 'img',
                    track: true,
                    show: false,
                    hide: false,
                    content: function () {
                        return $('<ul>').html($('ul', $(this).closest('.visitorLogIconWithDetails')).html());
                    },
                    tooltipClass: 'small',
                    open: function () {
                        tooltipIsOpened = true;
                    },
                    close: function () {
                        tooltipIsOpened = false;
                    }
                });
            });

            $('.visitorLogTooltip').each(function () {
                $(this).tooltip({
                    track: true,
                    show: false,
                    hide: false,
                    tooltipClass: 'small',
                    open: function () {
                        tooltipIsOpened = true;
                    },
                    close: function () {
                        tooltipIsOpened = false;
                    }
                });
            });

            // Replace duplicated page views by a NX count instead of using too much vertical space
            $("ol.visitorLog").each(function () {
                var prevelement;
                var prevhtml;
                var counter = 0;
                $(this).find("li").each(function () {
                    counter++;
                    $(this).val(counter);
                    var current = $(this).html();
                    if (current == prevhtml) {
                        var repeat = prevelement.find(".repeat");
                        if (repeat.length) {
                            repeat.html((parseInt(repeat.html()) + 1) + "x");
                        } else {
                            prevelement.find('>div').prepend($("<span>2x</span>").attr({'class': 'repeat', 'title': _pk_translate('Live_PageRefreshed')}));
                        }
                        $(this).hide();
                    } else {
                        prevhtml = current;
                        prevelement = $(this);
                    }

                    var $this = $(this);
                    var tooltipIsOpened = false;

                    $('a', $this).on('focus', function () {
                        // see https://github.com/piwik/piwik/issues/4099
                        if (tooltipIsOpened) {
                            $this.tooltip('close');
                        }
                    });

                    $this.tooltip({
                        track: true,
                        show: false,
                        hide: false,
                        content: function() {
                            var title = $(this).attr('title');
                            return $('<a>').text( title ).html().replace(/\n/g, '<br />');
                        },
                        tooltipClass: 'small',
                        open: function() { tooltipIsOpened = true; },
                        close: function() { tooltipIsOpened = false; }
                    });
                });
            });

            // launch visitor profile on visitor profile link click
            this.$element.on('click', '.visitor-log-visitor-profile-link', function (e) {
                e.preventDefault();
                broadcast.propagateNewPopoverParameter('visitorProfile', $(this).attr('data-visitor-id'));
                return false;
            });
        }
    });

})(jQuery, require);