update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -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
|
||||
|
|
@ -54,9 +54,9 @@ var broadcast = {
|
|||
}
|
||||
broadcast._isInit = true;
|
||||
|
||||
// Initialize history plugin.
|
||||
// The callback is called at once by present location.hash
|
||||
$.history.init(broadcast.pageload, {unescape: true});
|
||||
angular.element(document).injector().invoke(function (historyService) {
|
||||
historyService.init();
|
||||
});
|
||||
|
||||
if(noLoadingMessage != true) {
|
||||
piwikHelper.showAjaxLoading();
|
||||
|
|
@ -151,7 +151,7 @@ var broadcast = {
|
|||
var handlerName = popoverParamParts[0];
|
||||
popoverParamParts.shift();
|
||||
var param = popoverParamParts.join(':');
|
||||
if (typeof broadcast.popoverHandlers[handlerName] != 'undefined') {
|
||||
if (typeof broadcast.popoverHandlers[handlerName] != 'undefined' && !broadcast.isLoginPage()) {
|
||||
broadcast.popoverHandlers[handlerName](param);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,6 +164,14 @@ var broadcast = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns if the current page is the login page
|
||||
* @return {boolean}
|
||||
*/
|
||||
isLoginPage: function() {
|
||||
return !!$('body#loginPage').length;
|
||||
},
|
||||
|
||||
/**
|
||||
* propagateAjax -- update hash values then make ajax calls.
|
||||
* example :
|
||||
|
|
@ -197,7 +205,7 @@ var broadcast = {
|
|||
// if the module is not 'Goals', we specifically unset the 'idGoal' parameter
|
||||
// this is to ensure that the URLs are clean (and that clicks on graphs work as expected - they are broken with the extra parameter)
|
||||
var action = broadcast.getParamValue('action', currentHashStr);
|
||||
if (action != 'goalReport' && action != 'ecommerceReport') {
|
||||
if (action != 'goalReport' && action != 'ecommerceReport' && action != 'products' && action != 'sales') {
|
||||
currentHashStr = broadcast.updateParamValue('idGoal=', currentHashStr);
|
||||
}
|
||||
// unset idDashboard if use doesn't display a dashboard
|
||||
|
|
@ -206,15 +214,21 @@ var broadcast = {
|
|||
currentHashStr = broadcast.updateParamValue('idDashboard=', currentHashStr);
|
||||
}
|
||||
|
||||
if (module != 'CustomDimensions') {
|
||||
currentHashStr = broadcast.updateParamValue('idDimension=', currentHashStr);
|
||||
}
|
||||
|
||||
if (disableHistory) {
|
||||
var newLocation = window.location.href.split('#')[0] + '#' + currentHashStr;
|
||||
var newLocation = window.location.href.split('#')[0] + '#?' + currentHashStr;
|
||||
// window.location.replace changes the current url without pushing it on the browser's history stack
|
||||
window.location.replace(newLocation);
|
||||
}
|
||||
else {
|
||||
// Let history know about this new Hash and load it.
|
||||
broadcast.forceReload = true;
|
||||
$.history.load(currentHashStr);
|
||||
angular.element(document).injector().invoke(function (historyService) {
|
||||
historyService.load(currentHashStr);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -324,17 +338,17 @@ var broadcast = {
|
|||
/**
|
||||
* Loads a popover by adding a 'popover' query parameter to the current URL and
|
||||
* indirectly executing the popover handler.
|
||||
*
|
||||
*
|
||||
* This function should be called to open popovers that can be opened by URL alone.
|
||||
* That is, if you want users to be able to copy-paste the URL displayed when a popover
|
||||
* is open into a new browser window/tab and have the same popover open, you should
|
||||
* call this function.
|
||||
*
|
||||
*
|
||||
* In order for this function to open a popover, there must be a popover handler
|
||||
* associated with handlerName. To associate one, call broadcast.addPopoverHandler.
|
||||
*
|
||||
*
|
||||
* @param {String} handlerName The name of the popover handler.
|
||||
* @param {String} value The String value that should be passed to the popover
|
||||
* @param {String} value The String value that should be passed to the popover
|
||||
* handler.
|
||||
*/
|
||||
propagateNewPopoverParameter: function (handlerName, value) {
|
||||
|
|
@ -370,14 +384,16 @@ var broadcast = {
|
|||
}
|
||||
|
||||
broadcast.forceReload = false;
|
||||
$.history.load(newHash);
|
||||
angular.element(document).injector().invoke(function (historyService) {
|
||||
historyService.load(newHash);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a handler for the 'popover' query parameter.
|
||||
*
|
||||
*
|
||||
* @see broadcast#propagateNewPopoverParameter
|
||||
*
|
||||
*
|
||||
* @param {String} handlerName The handler name, eg, 'visitorProfile'. Should identify
|
||||
* the popover that the callback will open up.
|
||||
* @param {Function} callback This function should open the popover. It should take
|
||||
|
|
@ -397,11 +413,31 @@ var broadcast = {
|
|||
*/
|
||||
loadAjaxContent: function (urlAjax) {
|
||||
if (typeof piwikMenu !== 'undefined') {
|
||||
piwikMenu.activateMenu(
|
||||
broadcast.getParamValue('module', urlAjax),
|
||||
broadcast.getParamValue('action', urlAjax),
|
||||
broadcast.getParamValue('idGoal', urlAjax) || broadcast.getParamValue('idDashboard', urlAjax)
|
||||
);
|
||||
// we have to use a $timeout since menu groups are displayed using an angular directive, and on initial
|
||||
// page load, the dropdown will not be completely rendered at this point. using 2 $timeouts (to push
|
||||
// the menu activation logic to the end of the event queue twice), seems to work.
|
||||
angular.element(document).injector().invoke(function ($timeout) {
|
||||
$timeout(function () {
|
||||
$timeout(function () {
|
||||
piwikMenu.activateMenu(
|
||||
broadcast.getParamValue('module', urlAjax),
|
||||
broadcast.getParamValue('action', urlAjax),
|
||||
{
|
||||
idGoal: broadcast.getParamValue('idGoal', urlAjax),
|
||||
idDashboard: broadcast.getParamValue('idDashboard', urlAjax),
|
||||
idDimension: broadcast.getParamValue('idDimension', urlAjax)
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if(broadcast.getParamValue('module', urlAjax) == 'API') {
|
||||
broadcast.lastUrlRequested = null;
|
||||
$('#content').html("Loading content from the API and displaying it within Piwik is not allowed.");
|
||||
piwikHelper.hideAjaxLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
piwikHelper.hideAjaxError('loadingError');
|
||||
|
|
@ -411,7 +447,24 @@ var broadcast = {
|
|||
|
||||
urlAjax = urlAjax.match(/^\?/) ? urlAjax : "?" + urlAjax;
|
||||
broadcast.lastUrlRequested = urlAjax;
|
||||
function sectionLoaded(content) {
|
||||
|
||||
function sectionLoaded(content, status, request) {
|
||||
if (request) {
|
||||
var responseHeader = request.getResponseHeader('Content-Type');
|
||||
if (responseHeader && 0 <= responseHeader.toLowerCase().indexOf('json')) {
|
||||
var message = 'JSON cannot be displayed for';
|
||||
if (this.getParams && this.getParams['module']) {
|
||||
message += ' module=' + this.getParams['module'];
|
||||
}
|
||||
if (this.getParams && this.getParams['action']) {
|
||||
message += ' action=' + this.getParams['action'];
|
||||
}
|
||||
$('#content').text(message);
|
||||
piwikHelper.hideAjaxLoading();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if content is whole HTML document, do not show it, otherwise recursive page load could occur
|
||||
var htmlDocType = '<!DOCTYPE';
|
||||
if (content.substring(0, htmlDocType.length) == htmlDocType) {
|
||||
|
|
@ -437,6 +490,9 @@ var broadcast = {
|
|||
|
||||
var ajax = new ajaxHelper();
|
||||
ajax.setUrl(urlAjax);
|
||||
ajax._getDefaultPostParams = function () {
|
||||
return {};
|
||||
};
|
||||
ajax.setErrorCallback(broadcast.customAjaxHandleError);
|
||||
ajax.setCallback(sectionLoaded);
|
||||
ajax.setFormat('html');
|
||||
|
|
@ -454,14 +510,14 @@ var broadcast = {
|
|||
customAjaxHandleError: function (deferred, status) {
|
||||
broadcast.lastUrlRequested = null;
|
||||
|
||||
piwikHelper.hideAjaxLoading();
|
||||
|
||||
// do not display error message if request was aborted
|
||||
if(status == 'abort') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingError').show();
|
||||
setTimeout( function(){
|
||||
$('#loadingError').fadeOut('slow');
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -551,7 +607,6 @@ var broadcast = {
|
|||
return this.extractKeyValuePairsFromQueryString(searchString);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* help to get param value for any given url string with provided param name
|
||||
* if no url is provided, it will get param from current address.
|
||||
|
|
@ -584,7 +639,6 @@ var broadcast = {
|
|||
return broadcast.getParamValue(param, hashStr);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* return value for the requested param, will return the first match.
|
||||
* out side of this class should use getValueFromHash() or getValueFromUrl() instead.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue