Matteo Scandolo | fb46ae6 | 2017-08-08 09:10:50 -0700 | [diff] [blame] | 1 | |
| 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 Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 19 | /** |
| 20 | * LUNA - Responsive Admin Theme |
| 21 | * |
| 22 | */ |
| 23 | /* tslint:disable */ |
| 24 | |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 25 | import * as $ from 'jquery'; |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 26 | import {IXosKeyboardShortcutService} from '../../core/services/keyboard-shortcut'; |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 27 | |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 28 | export interface IXosNavHandlerService { |
| 29 | minimalize: () => void; |
| 30 | } |
| 31 | |
| 32 | export 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 Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 52 | /** |
| 53 | * minimalizaSidebar - Directive for minimalize sidebar |
| 54 | */ |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 55 | export function minimalizaMenu() { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 56 | return { |
| 57 | restrict: 'EA', |
| 58 | template: '<div class="left-nav-toggle"><a href ng-click="minimalize()"><i class="stroke-hamburgermenu"></i> </a>', |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 59 | controller: function ($scope, XosNavHandler: IXosNavHandlerService) { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 60 | $scope.minimalize = function () { |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 61 | XosNavHandler.minimalize(); |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 62 | }; |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 63 | } |
| 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 | */ |
| 95 | export 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 | }; |