blob: 625c101501c058fa2812868e3e5b97ab7ce06dcd [file] [log] [blame]
Matteo Scandolo266907e2016-12-20 13:41:42 -08001/**
2 * LUNA - Responsive Admin Theme
3 *
4 */
5/* tslint:disable */
6
Matteo Scandolo266907e2016-12-20 13:41:42 -08007import * as $ from 'jquery';
Matteo Scandolo5053cbe2017-01-31 17:37:56 -08008import {IXosKeyboardShortcutService} from '../../core/services/keyboard-shortcut';
Matteo Scandolo266907e2016-12-20 13:41:42 -08009
10/**
11 * minimalizaSidebar - Directive for minimalize sidebar
12 */
Matteo Scandolo5053cbe2017-01-31 17:37:56 -080013export function minimalizaMenu($rootScope, XosKeyboardShortcut: IXosKeyboardShortcutService) {
Matteo Scandolo266907e2016-12-20 13:41:42 -080014 return {
15 restrict: 'EA',
16 template: '<div class="left-nav-toggle"><a href ng-click="minimalize()"><i class="stroke-hamburgermenu"></i> </a>',
17 controller: function ($scope, $element) {
Matteo Scandolo266907e2016-12-20 13:41:42 -080018 $scope.minimalize = function () {
19 $("body").toggleClass("nav-toggle");
Matteo Scandolo5053cbe2017-01-31 17:37:56 -080020 };
21
22 XosKeyboardShortcut.registerKeyBinding({
23 key: 'n',
24 description: 'Toggle Navigation',
25 cb: $scope.minimalize,
26 }, 'global');
Matteo Scandolo266907e2016-12-20 13:41:42 -080027 }
28 };
29}
30
31
32/**
33 * sparkline - Directive for Sparkline chart
34 */
35// export function sparkline() {
36// return {
37// restrict: 'A',
38// scope: {
39// sparkData: '=',
40// sparkOptions: '=',
41// },
42// link: function (scope, element, attrs) {
43// scope.$watch(scope.sparkData, function () {
44// render();
45// });
46// scope.$watch(scope.sparkOptions, function(){
47// render();
48// });
49// var render = function () {
50// $(element).sparkline(scope.sparkData, scope.sparkOptions);
51// };
52// }
53// }
54// }
55
56/**
57 * panelTools - Directive for panel tools elements in right corner of panel
58 */
59export function panelTools($timeout) {
60 return {
61 restrict: 'A',
62 scope: true,
63 templateUrl: 'views/common/panel_tools.html',
64 controller: function ($scope, $element) {
65 // Function for collapse ibox
66 $scope.showhide = function () {
67 var hpanel = $element.closest('div.panel');
68 var icon = $element.find('i:first');
69 var body = hpanel.find('div.panel-body');
70 var footer = hpanel.find('div.panel-footer');
71 body.slideToggle(300);
72 footer.slideToggle(200);
73
74 // Toggle icon from up to down
75 icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
76 hpanel.toggleClass('').toggleClass('panel-collapse');
77 $timeout(function () {
78 hpanel.resize();
79 hpanel.find('[id^=map-]').resize();
80 }, 50);
81 };
82
83 // Function for close ibox
84 $scope.closebox = function () {
85 var hpanel = $element.closest('div.panel');
86 hpanel.remove();
87 }
88
89 }
90 };
91};