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
|
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
*
*/
(function () {
angular.module('piwikApp').directive('piwikExpandOnClick', piwikExpandOnClick);
piwikExpandOnClick.$inject = ['$document', 'piwik'];
function piwikExpandOnClick($document, piwik){
return {
restrict: 'A',
link: function(scope, element, attr) {
element.find('.title').on('click', function () {
element.toggleClass('expanded');
var $position = element.find('.dropdown.positionInViewport');
if ($position.size()) {
piwik.helper.setMarginLeftToBeInViewport($position);
}
});
function onClickOutsideElement (event) {
if (element.has(event.target).length === 0) {
element.removeClass('expanded');
}
}
function onEscapeHandler (event) {
if (event.which === 27) {
element.removeClass('expanded');
}
}
$document.on('keyup', onEscapeHandler);
$document.on('mouseup', onClickOutsideElement);
scope.$on('$destroy', function() {
$document.off('mouseup', onClickOutsideElement);
$document.off('keyup', onEscapeHandler);
});
}
};
}
angular.module('piwikApp').directive('piwikExpandOnHover', piwikExpandOnHover);
piwikExpandOnHover.$inject = ['$document', 'piwik'];
function piwikExpandOnHover($document, piwik){
return {
restrict: 'A',
link: function(scope, element, attr) {
element.on('mouseenter', '.title', function () {
element.addClass('expanded');
var $position = element.find('.dropdown.positionInViewport');
if ($position.size()) {
piwik.helper.setMarginLeftToBeInViewport($position);
}
});
element.on('mouseleave', function () {
element.removeClass('expanded');
});
function onClickOutsideElement (event) {
if (element.has(event.target).length === 0) {
element.removeClass('expanded');
}
}
function onEscapeHandler (event) {
if (event.which === 27) {
element.removeClass('expanded');
}
}
$document.on('keyup', onEscapeHandler);
$document.on('mouseup', onClickOutsideElement);
scope.$on('$destroy', function() {
$document.off('mouseup', onClickOutsideElement);
$document.off('keyup', onEscapeHandler);
});
}
};
}
})();
|