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
@ -16,50 +16,78 @@ menu.prototype =
{
resetTimer: null,
adaptSubMenuHeight: function() {
var subNavHeight = $('.sfHover > ul').outerHeight();
$('.nav_sep').height(subNavHeight);
onItemClick: function (e) {
if (e.which === 2) {
return;
}
$('#secondNavBar').removeClass('open fadeInLeft');
var $link = $(this);
var href = $link.attr('href');
if (!$('#content.admin').size()) {
if (!href && $link.parent().is('.menuTab')) {
var $li = $link.parents('li').first();
if ($li.hasClass('sfActive')) {
$li.removeClass('sfActive');
} else {
$li.siblings().removeClass('sfActive');
$li.addClass('sfActive');
}
var $children = $li.find('ul li > .item');
if ($children.length === 1) {
$children.first().click();
}
} else if (href) {
$('#secondNavBar').trigger('piwikSwitchPage', this);
broadcast.propagateAjax(href.substr(1));
}
return false;
}
return !!href;
},
overMainLI: function () {
var $this = $(this);
$this.siblings().removeClass('sfHover');
$this.addClass('sfHover');
menu.prototype.adaptSubMenuHeight();
clearTimeout(menu.prototype.resetTimer);
},
outMainLI: function () {
clearTimeout(menu.prototype.resetTimer);
menu.prototype.resetTimer = setTimeout(function() {
$('.Menu-tabList > .sfHover', this.menuNode).removeClass('sfHover');
$('.Menu-tabList > .sfActive', this.menuNode).addClass('sfHover');
menu.prototype.adaptSubMenuHeight();
}, 2000);
},
onItemClick: function (item) {
$('.Menu--dashboard').trigger('piwikSwitchPage', item);
broadcast.propagateAjax( $(item).attr('href').substr(1) );
return false;
isAdmin: function () {
return !!$('#content.admin').size();
},
init: function () {
this.menuNode = $('.Menu--dashboard');
this.menuNode.find("li:has(ul)").hover(this.overMainLI, this.outMainLI);
this.menuNode = $('#secondNavBar');
// add id to all li menu to support menu identification.
// for all sub menu we want to have a unique id based on their module and action
// for main menu we want to add just the module as its id.
this.menuNode.find('li').each(function () {
var url = $(this).find('a').attr('href').substr(1);
var module = broadcast.getValueFromUrl("module", url);
var action = broadcast.getValueFromUrl("action", url);
var $this = $(this);
var link = $this.find('a');
var main_menu = $this.parent().hasClass('navbar') ? true : false;
if (!link) {
return;
}
var href = link.attr('href');
if (!href) {
return;
}
var url = href.substr(1);
var module = broadcast.getValueFromUrl('module', url);
var action = broadcast.getValueFromUrl('action', url);
var moduleId = broadcast.getValueFromUrl("idGoal", url) || broadcast.getValueFromUrl("idDashboard", url);
var main_menu = $(this).parent().hasClass('Menu-tabList') ? true : false;
if (main_menu) {
$(this).attr({id: module});
$this.attr({id: module});
}
// if there's a idGoal or idDashboard, use this in the ID
else if (moduleId != '') {
@ -70,27 +98,65 @@ menu.prototype =
}
});
menu.prototype.adaptSubMenuHeight();
this.menuNode.find('a.item').click(this.onItemClick);
var self = this;
$('#header .toggle-second-menu').click(function () {
self.menuNode.toggleClass('open fadeInLeft');
});
},
activateMenu: function (module, action, id) {
this.menuNode.find('li').removeClass('sfHover').removeClass('sfActive');
var $li = this.getSubmenuID(module, id, action);
var mainLi = $("#" + module);
if (!mainLi.length) {
mainLi = $li.parents('li');
}
activateMenu: function (module, action, params) {
params = params || {};
params.module = module;
params.action = action;
mainLi.addClass('sfActive').addClass('sfHover');
this.menuNode.find('li').removeClass('sfActive');
$li.addClass('sfHover');
var isAdmin = this.isAdmin();
var $activeLink = this.menuNode.find('a').filter(function () {
var url = $(this).attr('href');
if (!url) {
return false;
}
var found = false;
for (var key in params) {
if (!params.hasOwnProperty(key)
|| !params[key]
) {
continue;
}
var actual;
if (isAdmin) {
actual = broadcast.getValueFromUrl(key, url);
} else {
actual = broadcast.getValueFromHash(key, url);
}
if (actual != params[key]) {
return false;
}
found = true;
// at least one param must match. Otherwise all menu items might be highlighted if params[key] = null;
}
return found;
});
$activeLink.closest('li').addClass('sfActive');
$activeLink.closest('li.menuTab').addClass('sfActive');
},
// getting the right li is a little tricky since goals uses idGoal, and overview is index.
getSubmenuID: function (module, id, action) {
var $li = '';
// So, if module is Goals, id is present, and action is not Index, must be one of the goals
if (module == 'Goals' && id != '' && (action != 'index')) {
if ((module == 'Goals' || module == 'Ecommerce') && id != '' && (action != 'index')) {
$li = $("#" + module + "_" + action + "_" + id);
// if module is Dashboard and id is present, must be one of the dashboards
} else if (module == 'Dashboard') {
@ -104,7 +170,7 @@ menu.prototype =
loadFirstSection: function () {
if (broadcast.isHashExists() == false) {
$('li:first a:first', this.menuNode).click().addClass('sfHover').addClass('sfActive');
$('.navbar li:first ul a:first', this.menuNode).click().addClass('sfActive');
}
}
};
};