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
|
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Usage:
*
* <h2 piwik-enriched-headline>All Websites Dashboard</h2>
* -> uses "All Websites Dashboard" as featurename
*
* <h2 piwik-enriched-headline feature-name="All Websites Dashboard">All Websites Dashboard (Total: 309 Visits)</h2>
* -> custom featurename
*
* <h2 piwik-enriched-headline help-url="http://piwik.org/guide">All Websites Dashboard</h2>
* -> shows help icon and links to external url
*
* <h2 piwik-enriched-headline edit-url="index.php?module=Foo&action=bar&id=4">All Websites Dashboard</h2>
* -> makes the headline clickable linking to the specified url
*
* <h2 piwik-enriched-headline inline-help="inlineHelp">Pages report</h2>
* -> inlineHelp specified via a attribute shows help icon on headline hover
*
* <h2 piwik-enriched-headline>All Websites Dashboard
* <div class="inlineHelp">My <strong>inline help</strong></div>
* </h2>
* -> alternative definition for inline help
* -> shows help icon to display inline help on click. Note: You can combine inlinehelp and help-url
*/
(function () {
angular.module('piwikApp').directive('piwikEnrichedHeadline', piwikEnrichedHeadline);
piwikEnrichedHeadline.$inject = ['$document', 'piwik', '$filter'];
function piwikEnrichedHeadline($document, piwik, $filter){
var defaults = {
helpUrl: '',
editUrl: ''
};
return {
transclude: true,
restrict: 'A',
scope: {
helpUrl: '@',
editUrl: '@',
featureName: '@',
inlineHelp: '@?'
},
templateUrl: 'plugins/CoreHome/angularjs/enrichedheadline/enrichedheadline.directive.html?cb=' + piwik.cacheBuster,
compile: function (element, attrs) {
for (var index in defaults) {
if (!attrs[index]) { attrs[index] = defaults[index]; }
}
return function (scope, element, attrs) {
if (!scope.inlineHelp) {
var helpNode = $('[ng-transclude] .inlineHelp', element);
if ((!helpNode || !helpNode.length) && element.next()) {
// hack for reports :(
helpNode = element.next().find('.reportDocumentation');
}
if (helpNode && helpNode.length) {
if ($.trim(helpNode.text())) {
scope.inlineHelp = $.trim(helpNode.html());
}
helpNode.remove();
}
}
if (!attrs.featureName) {
attrs.featureName = $.trim(element.find('.title').first().text());
}
};
}
};
}
})();
|