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

refresh-button.js « javascripts « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96f7176d93e59547eb360d709ec57d0537930cc2 (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
/*!
 * Matomo - free/libre analytics platform
 *
 * @link http://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
$(function () {
  var iconRefresh = $('.top_controls .icon-reload');

  function refresh() {
    var Matomo = window.CoreHome.Matomo;
    var hashParsed = window.CoreHome.MatomoUrl.hashParsed.value;

    Matomo.postEvent('loadPage', hashParsed.category, hashParsed.subcategory);
  }

  function isCoreHomeModuleActive() {
    var search = window.CoreHome.MatomoUrl.parse(window.location.search.slice(1));
    return search.module === 'CoreHome';
  }

  if (isCoreHomeModuleActive()) {
    iconRefresh.show();

    iconRefresh.on('click', function (e) {
      e.preventDefault();
      refresh();
    });

    piwikHelper.registerShortcut('r', _pk_translate('CoreHome_ShortcutRefresh'), function (event) {
      if (event.altKey) {
        return;
      }
      if (event.preventDefault) {
        event.preventDefault();
      } else {
        event.returnValue = false; // IE
      }

      refresh();
    });
  }
});