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,11 +1,10 @@
|
|||
/*!
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// TRANSITIONS ROW ACTION FOR DATA TABLES
|
||||
//
|
||||
|
|
@ -18,8 +17,12 @@ function DataTable_RowActions_Transitions(dataTable) {
|
|||
DataTable_RowActions_Transitions.prototype = new DataTable_RowAction;
|
||||
|
||||
/** Static helper method to launch transitions from anywhere */
|
||||
DataTable_RowActions_Transitions.launchForUrl = function (url) {
|
||||
broadcast.propagateNewPopoverParameter('RowAction', 'Transitions:url:' + url);
|
||||
DataTable_RowActions_Transitions.launchForUrl = function (url, segment) {
|
||||
var value = 'Transitions:url:' + url;
|
||||
if (segment) {
|
||||
value += ':segment:' + segment;
|
||||
}
|
||||
broadcast.propagateNewPopoverParameter('RowAction', value);
|
||||
};
|
||||
|
||||
DataTable_RowActions_Transitions.isPageUrlReport = function (module, action) {
|
||||
|
|
@ -31,32 +34,48 @@ DataTable_RowActions_Transitions.isPageTitleReport = function (module, action) {
|
|||
return module == 'Actions' && (action == 'getPageTitles' || action == 'getPageTitlesFollowingSiteSearch');
|
||||
};
|
||||
|
||||
DataTable_RowActions_Transitions.prototype.trigger = function (tr, e, subTableLabel) {
|
||||
var link = tr.find('> td:first > a').attr('href');
|
||||
link = $('<textarea>').html(link).val(); // remove html entities
|
||||
DataTable_RowActions_Transitions.registeredReports = [];
|
||||
DataTable_RowActions_Transitions.registerReport = function (handler) {
|
||||
DataTable_RowActions_Transitions.registeredReports.push(handler);
|
||||
}
|
||||
|
||||
var module = this.dataTable.param.module;
|
||||
var action = this.dataTable.param.action;
|
||||
if (DataTable_RowActions_Transitions.isPageUrlReport(module, action)) {
|
||||
this.openPopover('url:' + link);
|
||||
} else if (DataTable_RowActions_Transitions.isPageTitleReport(module, action)) {
|
||||
DataTable_RowAction.prototype.trigger.apply(this, [tr, e, subTableLabel]);
|
||||
} else {
|
||||
alert('Transitions can\'t be used on this report.');
|
||||
DataTable_RowActions_Transitions.prototype.trigger = function (tr, e, subTableLabel) {
|
||||
var i = 0;
|
||||
for (i; i < DataTable_RowActions_Transitions.registeredReports.length; i++) {
|
||||
var report = DataTable_RowActions_Transitions.registeredReports[i];
|
||||
if (report
|
||||
&& report.trigger
|
||||
&& report.isAvailableOnReport
|
||||
&& report.isAvailableOnReport(this.dataTable.param)) {
|
||||
report.trigger.apply(this, arguments);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
alert('Transitions can\'t be used on this report.');
|
||||
};
|
||||
|
||||
DataTable_RowAction.prototype.performAction = function (label, tr, e) {
|
||||
DataTable_RowActions_Transitions.prototype.performAction = function (label, tr, e) {
|
||||
var separator = ' > '; // LabelFilter::SEPARATOR_RECURSIVE_LABEL
|
||||
var labelParts = label.split(separator);
|
||||
for (var i = 0; i < labelParts.length; i++) {
|
||||
labelParts[i] = $.trim(decodeURIComponent(labelParts[i]));
|
||||
var labelPart = labelParts[i].replace('@', '');
|
||||
labelParts[i] = $.trim(decodeURIComponent(labelPart));
|
||||
}
|
||||
label = labelParts.join(piwik.config.action_url_category_delimiter);
|
||||
this.openPopover('title:' + label);
|
||||
};
|
||||
|
||||
DataTable_RowActions_Transitions.prototype.doOpenPopover = function (link) {
|
||||
var posSegment = (link+'').indexOf(':segment:');
|
||||
var segment = null;
|
||||
|
||||
// handle and remove ':segment:$SEGMENT' from link
|
||||
if (posSegment && posSegment > 0) {
|
||||
segment = link.substring(posSegment + (':segment:'.length));
|
||||
link = link.substring(0, posSegment);
|
||||
}
|
||||
|
||||
var parts = link.split(':');
|
||||
if (parts.length < 2) {
|
||||
return;
|
||||
|
|
@ -67,9 +86,9 @@ DataTable_RowActions_Transitions.prototype.doOpenPopover = function (link) {
|
|||
var actionName = parts.join(':');
|
||||
|
||||
if (this.transitions === null) {
|
||||
this.transitions = new Piwik_Transitions(actionType, actionName, this);
|
||||
this.transitions = new Piwik_Transitions(actionType, actionName, this, segment);
|
||||
} else {
|
||||
this.transitions.reset(actionType, actionName);
|
||||
this.transitions.reset(actionType, actionName, segment);
|
||||
}
|
||||
this.transitions.showPopover();
|
||||
};
|
||||
|
|
@ -93,34 +112,47 @@ DataTable_RowActions_Registry.register({
|
|||
},
|
||||
|
||||
isAvailableOnReport: function (dataTableParams) {
|
||||
return (
|
||||
DataTable_RowActions_Transitions.isPageUrlReport(dataTableParams.module, dataTableParams.action) ||
|
||||
DataTable_RowActions_Transitions.isPageTitleReport(dataTableParams.module, dataTableParams.action)
|
||||
);
|
||||
var i = 0;
|
||||
for (i; i < DataTable_RowActions_Transitions.registeredReports.length; i++) {
|
||||
var report = DataTable_RowActions_Transitions.registeredReports[i];
|
||||
if (report
|
||||
&& report.isAvailableOnReport
|
||||
&& report.isAvailableOnReport(dataTableParams)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isAvailableOnRow: function (dataTableParams, tr) {
|
||||
if (tr.attr('id')) {
|
||||
if (tr.hasClass('subDataTable')) {
|
||||
// not available on groups (i.e. folders)
|
||||
return false;
|
||||
}
|
||||
if (DataTable_RowActions_Transitions.isPageUrlReport(dataTableParams.module, dataTableParams.action)
|
||||
&& !tr.find('> td:first span.label').parent().is('a')) {
|
||||
// not on page url without link (i.e. "Page URL not defined")
|
||||
return false;
|
||||
|
||||
var i = 0;
|
||||
for (i; i < DataTable_RowActions_Transitions.registeredReports.length; i++) {
|
||||
var report = DataTable_RowActions_Transitions.registeredReports[i];
|
||||
if (report
|
||||
&& report.isAvailableOnRow
|
||||
&& report.isAvailableOnReport
|
||||
&& report.isAvailableOnReport(dataTableParams)) {
|
||||
return report.isAvailableOnRow(dataTableParams, tr);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// TRANSITIONS IMPLEMENTATION
|
||||
//
|
||||
|
||||
function Piwik_Transitions(actionType, actionName, rowAction) {
|
||||
this.reset(actionType, actionName);
|
||||
function Piwik_Transitions(actionType, actionName, rowAction, segment) {
|
||||
this.reset(actionType, actionName, segment);
|
||||
this.rowAction = rowAction;
|
||||
|
||||
this.ajax = new Piwik_Transitions_Ajax();
|
||||
|
|
@ -130,9 +162,10 @@ function Piwik_Transitions(actionType, actionName, rowAction) {
|
|||
this.rightGroups = ['followingPages', 'followingSiteSearches', 'downloads', 'outlinks'];
|
||||
}
|
||||
|
||||
Piwik_Transitions.prototype.reset = function (actionType, actionName) {
|
||||
Piwik_Transitions.prototype.reset = function (actionType, actionName, segment) {
|
||||
this.actionType = actionType;
|
||||
this.actionName = actionName;
|
||||
this.segment = segment;
|
||||
|
||||
this.popover = null;
|
||||
this.canvas = null;
|
||||
|
|
@ -180,7 +213,7 @@ Piwik_Transitions.prototype.showPopover = function () {
|
|||
}
|
||||
|
||||
// load the data
|
||||
self.model.loadData(self.actionType, self.actionName, function () {
|
||||
self.model.loadData(self.actionType, self.actionName, self.segment, function () {
|
||||
if (typeof Piwik_Transitions.popoverHtml == 'undefined') {
|
||||
// html not there yet
|
||||
callbackForHtml = bothLoaded;
|
||||
|
|
@ -232,10 +265,10 @@ Piwik_Transitions.prototype.preparePopover = function () {
|
|||
var totalNbPageviews = self.model.getTotalNbPageviews();
|
||||
if (totalNbPageviews > 0) {
|
||||
|
||||
var share = Math.round(self.model.pageviews / totalNbPageviews * 1000) / 10;
|
||||
var share = NumberFormatter.formatPercent(Math.round(self.model.pageviews / totalNbPageviews * 1000) / 10);
|
||||
|
||||
var text = Piwik_Transitions_Translations.ShareOfAllPageviews;
|
||||
text = text.replace(/%s/, self.model.pageviews).replace(/%s/, share + '%');
|
||||
text = text.replace(/%s/, NumberFormatter.formatNumber(self.model.pageviews)).replace(/%s/, share);
|
||||
text += '<br /><em>' + Piwik_Transitions_Translations.DateRange + ' ' + self.model.date + '</em>';
|
||||
|
||||
var title = '<h3>' + piwikHelper.addBreakpointsToUrl(self.actionName) + '</h3>';
|
||||
|
|
@ -342,12 +375,12 @@ Piwik_Transitions.prototype.renderCenterBox = function () {
|
|||
var box = this.centerBox;
|
||||
|
||||
Piwik_Transitions_Util.replacePlaceholderInHtml(
|
||||
box.find('.Transitions_Pageviews'), this.model.pageviews);
|
||||
box.find('.Transitions_Pageviews'), NumberFormatter.formatNumber(this.model.pageviews));
|
||||
|
||||
var self = this;
|
||||
var showMetric = function (cssClass, modelProperty, highlightCurveOnSide, groupCanBeExpanded) {
|
||||
var el = box.find('.Transitions_' + cssClass);
|
||||
Piwik_Transitions_Util.replacePlaceholderInHtml(el, self.model[modelProperty]);
|
||||
Piwik_Transitions_Util.replacePlaceholderInHtml(el, NumberFormatter.formatNumber(self.model[modelProperty]));
|
||||
|
||||
if (self.model[modelProperty] == 0) {
|
||||
el.addClass('Transitions_Value0');
|
||||
|
|
@ -405,7 +438,7 @@ Piwik_Transitions.prototype.renderLoops = function () {
|
|||
}
|
||||
|
||||
var loops = this.popover.find('#Transitions_Loops').show();
|
||||
Piwik_Transitions_Util.replacePlaceholderInHtml(loops, this.model.loops);
|
||||
Piwik_Transitions_Util.replacePlaceholderInHtml(loops, NumberFormatter.formatNumber(this.model.loops));
|
||||
|
||||
this.addTooltipShowingPercentageOfAllPageviews(loops, 'loops');
|
||||
|
||||
|
|
@ -563,7 +596,7 @@ Piwik_Transitions.prototype.renderOpenGroup = function (groupName, side, onlyBg)
|
|||
boxText: label,
|
||||
boxTextTooltip: isOthers || !shortened ? false : fullLabel,
|
||||
boxTextNumLines: 3,
|
||||
curveText: data.percentage + '%',
|
||||
curveText: NumberFormatter.formatPercent(data.percentage),
|
||||
curveTextTooltip: tooltip,
|
||||
onClick: onClick
|
||||
});
|
||||
|
|
@ -616,7 +649,7 @@ Piwik_Transitions.prototype.renderClosedGroup = function (groupName, side, onlyB
|
|||
boxText: self.model.getGroupTitle(groupName),
|
||||
boxTextNumLines: 1,
|
||||
boxTextCssClass: 'SingleLine',
|
||||
boxIcon: 'plugins/Zeitgeist/images/plus_blue.png',
|
||||
boxIcon: 'plugins/Morpheus/images/plus_blue.png',
|
||||
smallBox: true,
|
||||
onClick: function () {
|
||||
self.unHighlightGroup(groupName, side);
|
||||
|
|
@ -716,7 +749,6 @@ Piwik_Transitions.prototype.openExternalUrl = function (url) {
|
|||
window.open(url, '_newtab');
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// CANVAS
|
||||
// --------------------------------------
|
||||
|
|
@ -1220,7 +1252,6 @@ Piwik_Transitions_Canvas.prototype.clearSide = function (side, onlyBg) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// MODEL
|
||||
// --------------------------------------
|
||||
|
|
@ -1252,7 +1283,7 @@ Piwik_Transitions_Model.prototype.htmlLoaded = function () {
|
|||
};
|
||||
};
|
||||
|
||||
Piwik_Transitions_Model.prototype.loadData = function (actionType, actionName, callback) {
|
||||
Piwik_Transitions_Model.prototype.loadData = function (actionType, actionName, segment, callback) {
|
||||
var self = this;
|
||||
|
||||
this.pageviews = 0;
|
||||
|
|
@ -1290,11 +1321,16 @@ Piwik_Transitions_Model.prototype.loadData = function (actionType, actionName, c
|
|||
|
||||
this.date = '';
|
||||
|
||||
this.ajax.callApi('Transitions.getTransitionsForAction', {
|
||||
actionType: actionType,
|
||||
actionName: actionName,
|
||||
expanded: 1
|
||||
},
|
||||
var params = {
|
||||
actionType: actionType,
|
||||
actionName: actionName,
|
||||
expanded: 1
|
||||
};
|
||||
if (segment) {
|
||||
params.segment = segment;
|
||||
}
|
||||
|
||||
this.ajax.callApi('Transitions.getTransitionsForAction', params,
|
||||
function (report) {
|
||||
self.date = report.date;
|
||||
|
||||
|
|
@ -1378,8 +1414,9 @@ Piwik_Transitions_Model.prototype.getPercentage = function (metric, formatted) {
|
|||
var percentage = (this.pageviews == 0 ? 0 : this[metric] / this.pageviews);
|
||||
|
||||
if (formatted) {
|
||||
|
||||
percentage = this.roundPercentage(percentage);
|
||||
percentage += '%';
|
||||
return NumberFormatter.formatPercent(percentage);
|
||||
}
|
||||
|
||||
return percentage;
|
||||
|
|
@ -1407,7 +1444,6 @@ Piwik_Transitions_Model.prototype.roundPercentage = function (value) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// AJAX
|
||||
// --------------------------------------
|
||||
|
|
@ -1492,7 +1528,6 @@ Piwik_Transitions_Ajax.prototype.callApi = function (method, params, callback) {
|
|||
ajaxRequest.send(false);
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// STATIC UTIL FUNCTIONS
|
||||
// --------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue