blob: 36ac43a39a596df73366e6082377bd28d3a7e5e8 (
plain)
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
|
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Usage:
* <div piwik-zen-mode-switcher>...</div>
* Will toggle the zen mode on click on this element.
*/
(function () {
angular.module('piwikApp').directive('piwikZenModeSwitcher', piwikZenModeSwitcher);
piwikZenModeSwitcher.$inject = ['$rootElement', '$filter'];
function piwikZenModeSwitcher($rootElement, $filter) {
function showZenModeIsActivatedNotification() {
var howToSearch = $filter('translate')('ZenMode_HowToSearch');
var howToToggle = $filter('translate')('ZenMode_HowToToggleZenMode');
var activated = $filter('translate')('ZenMode_Activated');
var message = '<ul><li>' + howToSearch + '</li><li>' + howToToggle + '</li></ul>';
var UI = require('piwik/UI');
var notification = new UI.Notification();
notification.show(message, {
title: activated,
context: 'info',
id: 'ZenMode_EnabledInfo'
});
}
return {
restrict: 'A',
compile: function (element, attrs) {
element.on('click', function() {
$rootElement.trigger('zen-mode-toggle', {});
if ($rootElement.hasClass('zenMode')) {
showZenModeIsActivatedNotification();
}
});
return function () {
};
}
};
}
})();
|