update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -82,7 +82,7 @@
if (that.isStarted) {
window.clearTimeout(that.updateInterval);
if ($(that.element).closest('body').length) {
if (that.element.length && $.contains(document, that.element[0])) {
that.updateInterval = window.setTimeout(function() { that._update() }, that.currentInterval);
}
}
@ -188,6 +188,14 @@
window.clearTimeout(this.updateInterval);
},
/**
* Return true in case widget is started.
* @returns {boolean}
*/
started: function() {
return this.isStarted;
},
/**
* Set the interval for refresh
*
@ -200,11 +208,20 @@
});
})(jQuery);
$(function() {
var refreshWidget = function (element, refreshAfterXSecs) {
// if the widget has been removed from the DOM, abort
if ($(element).parent().length == 0) {
if (!element.length || !$.contains(document, element[0])) {
return;
}
function scheduleAnotherRequest()
{
setTimeout(function () { refreshWidget(element, refreshAfterXSecs); }, refreshAfterXSecs * 1000);
}
if (Visibility.hidden()) {
scheduleAnotherRequest();
return;
}
@ -249,8 +266,7 @@ $(function() {
? translations['one_minute'] : translations['minutes'].replace('%s', lastMinutes);
$(metrics[2]).text(lastMinutesText);
// schedule another request
setTimeout(function () { refreshWidget(element, refreshAfterXSecs); }, refreshAfterXSecs * 1000);
scheduleAnotherRequest();
});
ajaxRequest.send(true);
};
@ -271,18 +287,48 @@ $(function() {
};
});
var pauseImage = "plugins/Live/images/pause.gif";
var pauseDisabledImage = "plugins/Live/images/pause_disabled.gif";
var playImage = "plugins/Live/images/play.gif";
var playDisabledImage = "plugins/Live/images/play_disabled.gif";
function onClickPause() {
$('#pauseImage').attr('src', pauseImage);
$('#playImage').attr('src', playDisabledImage);
$('#pauseImage').hide();
$('#playImage').show();
return $('#visitsLive').liveWidget('stop');
}
function onClickPlay() {
$('#playImage').attr('src', playImage);
$('#pauseImage').attr('src', pauseDisabledImage);
$('#playImage').hide();
$('#pauseImage').show();
return $('#visitsLive').liveWidget('start');
}
(function () {
if (!Visibility.isSupported()) {
return;
}
var isStoppedByBlur = false;
function isStarted()
{
return $('#visitsLive').liveWidget('started');
}
function onTabBlur() {
if (isStarted()) {
isStoppedByBlur = true;
onClickPause();
}
}
function onTabFocus() {
if (isStoppedByBlur && !isStarted()) {
isStoppedByBlur = false;
onClickPlay();
}
}
Visibility.change(function (event, state) {
if (Visibility.hidden()) {
onTabBlur();
} else {
onTabFocus();
}
});
})();