blob: 3e4840d5d772d487b007c91d1ae893c22f0ae747 [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
Matteo Scandoloc8178492017-04-11 17:55:13 -070010export interface IXosNavHandlerService {
11 minimalize: () => void;
12}
13
14export class XosNavHandlerService implements IXosNavHandlerService {
15
16 static $inject = ['XosKeyboardShortcut'];
17
18 constructor(
19 private XosKeyboardShortcut: IXosKeyboardShortcutService
20 ) {
21 this.XosKeyboardShortcut.registerKeyBinding({
22 key: 'n',
23 description: 'Toggle Navigation',
24 cb: this.minimalize,
25 }, 'global');
26 }
27
28 public minimalize() {
29 $("body").toggleClass("nav-toggle");
30 }
31
32}
33
Matteo Scandolo266907e2016-12-20 13:41:42 -080034/**
35 * minimalizaSidebar - Directive for minimalize sidebar
36 */
Matteo Scandoloc8178492017-04-11 17:55:13 -070037export function minimalizaMenu() {
Matteo Scandolo266907e2016-12-20 13:41:42 -080038 return {
39 restrict: 'EA',
40 template: '<div class="left-nav-toggle"><a href ng-click="minimalize()"><i class="stroke-hamburgermenu"></i> </a>',
Matteo Scandoloc8178492017-04-11 17:55:13 -070041 controller: function ($scope, XosNavHandler: IXosNavHandlerService) {
Matteo Scandolo266907e2016-12-20 13:41:42 -080042 $scope.minimalize = function () {
Matteo Scandoloc8178492017-04-11 17:55:13 -070043 XosNavHandler.minimalize();
Matteo Scandolo5053cbe2017-01-31 17:37:56 -080044 };
Matteo Scandolo266907e2016-12-20 13:41:42 -080045 }
46 };
47}
48
49
50/**
51 * sparkline - Directive for Sparkline chart
52 */
53// export function sparkline() {
54// return {
55// restrict: 'A',
56// scope: {
57// sparkData: '=',
58// sparkOptions: '=',
59// },
60// link: function (scope, element, attrs) {
61// scope.$watch(scope.sparkData, function () {
62// render();
63// });
64// scope.$watch(scope.sparkOptions, function(){
65// render();
66// });
67// var render = function () {
68// $(element).sparkline(scope.sparkData, scope.sparkOptions);
69// };
70// }
71// }
72// }
73
74/**
75 * panelTools - Directive for panel tools elements in right corner of panel
76 */
77export function panelTools($timeout) {
78 return {
79 restrict: 'A',
80 scope: true,
81 templateUrl: 'views/common/panel_tools.html',
82 controller: function ($scope, $element) {
83 // Function for collapse ibox
84 $scope.showhide = function () {
85 var hpanel = $element.closest('div.panel');
86 var icon = $element.find('i:first');
87 var body = hpanel.find('div.panel-body');
88 var footer = hpanel.find('div.panel-footer');
89 body.slideToggle(300);
90 footer.slideToggle(200);
91
92 // Toggle icon from up to down
93 icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
94 hpanel.toggleClass('').toggleClass('panel-collapse');
95 $timeout(function () {
96 hpanel.resize();
97 hpanel.find('[id^=map-]').resize();
98 }, 50);
99 };
100
101 // Function for close ibox
102 $scope.closebox = function () {
103 var hpanel = $element.closest('div.panel');
104 hpanel.remove();
105 }
106
107 }
108 };
109};