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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* This file registers the Overlay row action on the pages report.
*/
function DataTable_RowActions_Overlay(dataTable) {
this.dataTable = dataTable;
}
DataTable_RowActions_Overlay.prototype = new DataTable_RowAction;
DataTable_RowActions_Overlay.registeredReports = [];
DataTable_RowActions_Overlay.registerReport = function (handler) {
DataTable_RowActions_Overlay.registeredReports.push(handler);
};
DataTable_RowActions_Overlay.prototype.onClick = function (actionA, tr, e, originalRow) {
if (!actionA.data('overlay-manipulated')) {
actionA.data('overlay-manipulated', 1);
var segment, link;
var i = 0;
for (i; i < DataTable_RowActions_Overlay.registeredReports.length; i++) {
var report = DataTable_RowActions_Overlay.registeredReports[i];
if (report
&& report.onClick
&& report.isAvailableOnReport
&& report.isAvailableOnReport(this.dataTable.param)) {
var result = report.onClick.apply(this, arguments);
if (!result || !result.link) {
return;
}
link = result.link;
if (result.segment) {
segment = result.segment;
}
break;
}
}
var paramOverride = $(originalRow || tr).data('param-override');
if (typeof paramOverride === 'object' && paramOverride.segment) {
if (segment) {
segment += ';' + paramOverride.segment;
} else {
segment = paramOverride.segment;
}
}
if (link) {
var href = Overlay_Helper.getOverlayLink(this.dataTable.param.idSite, 'month', 'today', segment, link);
actionA.attr({
target: '_blank',
href: href
});
}
}
return true;
};
DataTable_RowActions_Registry.register({
name: 'Overlay',
dataTableIcon: 'icon-overlay',
order: 30,
dataTableIconTooltip: [
_pk_translate('General_OverlayRowActionTooltipTitle'),
_pk_translate('General_OverlayRowActionTooltip')
],
createInstance: function (dataTable) {
return new DataTable_RowActions_Overlay(dataTable);
},
isAvailableOnReport: function (dataTableParams) {
// Overlay plugin only works when Transitions plugin is enabled
if (!window.DataTable_RowActions_Transitions) {
return false;
}
var i = 0;
for (i; i < DataTable_RowActions_Overlay.registeredReports.length; i++) {
var report = DataTable_RowActions_Overlay.registeredReports[i];
if (report
&& report.isAvailableOnReport
&& report.isAvailableOnReport(dataTableParams)) {
return true;
}
}
return false;
},
isAvailableOnRow: function (dataTableParams, tr) {
var transitions = DataTable_RowActions_Registry.getActionByName('Transitions');
return transitions.isAvailableOnRow(dataTableParams, tr);
}
});
|