blob: c96ecdcfbf5b0e3c7439469f5a654f80b9ddd730 [file] [log] [blame]
Matteo Scandolofb46ae62017-08-08 09:10:50 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Matteo Scandolo266907e2016-12-20 13:41:42 -080019/**
20 * LUNA - Responsive Admin Theme
21 *
22 */
23/* tslint:disable */
24
Matteo Scandolo266907e2016-12-20 13:41:42 -080025import * as $ from 'jquery';
Matteo Scandolo5053cbe2017-01-31 17:37:56 -080026import {IXosKeyboardShortcutService} from '../../core/services/keyboard-shortcut';
Matteo Scandolo266907e2016-12-20 13:41:42 -080027
Matteo Scandoloc8178492017-04-11 17:55:13 -070028export interface IXosNavHandlerService {
29 minimalize: () => void;
30}
31
32export class XosNavHandlerService implements IXosNavHandlerService {
33
34 static $inject = ['XosKeyboardShortcut'];
35
36 constructor(
37 private XosKeyboardShortcut: IXosKeyboardShortcutService
38 ) {
39 this.XosKeyboardShortcut.registerKeyBinding({
40 key: 'n',
41 description: 'Toggle Navigation',
42 cb: this.minimalize,
43 }, 'global');
44 }
45
46 public minimalize() {
47 $("body").toggleClass("nav-toggle");
48 }
49
50}
51
Matteo Scandolo266907e2016-12-20 13:41:42 -080052/**
53 * minimalizaSidebar - Directive for minimalize sidebar
54 */
Matteo Scandoloc8178492017-04-11 17:55:13 -070055export function minimalizaMenu() {
Matteo Scandolo266907e2016-12-20 13:41:42 -080056 return {
57 restrict: 'EA',
58 template: '<div class="left-nav-toggle"><a href ng-click="minimalize()"><i class="stroke-hamburgermenu"></i> </a>',
Matteo Scandoloc8178492017-04-11 17:55:13 -070059 controller: function ($scope, XosNavHandler: IXosNavHandlerService) {
Matteo Scandolo266907e2016-12-20 13:41:42 -080060 $scope.minimalize = function () {
Matteo Scandoloc8178492017-04-11 17:55:13 -070061 XosNavHandler.minimalize();
Matteo Scandolo5053cbe2017-01-31 17:37:56 -080062 };
Matteo Scandolo266907e2016-12-20 13:41:42 -080063 }
64 };
65}
66
67
68/**
69 * sparkline - Directive for Sparkline chart
70 */
71// export function sparkline() {
72// return {
73// restrict: 'A',
74// scope: {
75// sparkData: '=',
76// sparkOptions: '=',
77// },
78// link: function (scope, element, attrs) {
79// scope.$watch(scope.sparkData, function () {
80// render();
81// });
82// scope.$watch(scope.sparkOptions, function(){
83// render();
84// });
85// var render = function () {
86// $(element).sparkline(scope.sparkData, scope.sparkOptions);
87// };
88// }
89// }
90// }
91
92/**
93 * panelTools - Directive for panel tools elements in right corner of panel
94 */
95export function panelTools($timeout) {
96 return {
97 restrict: 'A',
98 scope: true,
99 templateUrl: 'views/common/panel_tools.html',
100 controller: function ($scope, $element) {
101 // Function for collapse ibox
102 $scope.showhide = function () {
103 var hpanel = $element.closest('div.panel');
104 var icon = $element.find('i:first');
105 var body = hpanel.find('div.panel-body');
106 var footer = hpanel.find('div.panel-footer');
107 body.slideToggle(300);
108 footer.slideToggle(200);
109
110 // Toggle icon from up to down
111 icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
112 hpanel.toggleClass('').toggleClass('panel-collapse');
113 $timeout(function () {
114 hpanel.resize();
115 hpanel.find('[id^=map-]').resize();
116 }, 50);
117 };
118
119 // Function for close ibox
120 $scope.closebox = function () {
121 var hpanel = $element.closest('div.panel');
122 hpanel.remove();
123 }
124
125 }
126 };
127};