Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 1 | /** |
| 2 | * LUNA - Responsive Admin Theme |
| 3 | * |
| 4 | */ |
| 5 | /* tslint:disable */ |
| 6 | |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 7 | import * as $ from 'jquery'; |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 8 | import {IXosKeyboardShortcutService} from '../../core/services/keyboard-shortcut'; |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 9 | |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 10 | export interface IXosNavHandlerService { |
| 11 | minimalize: () => void; |
| 12 | } |
| 13 | |
| 14 | export 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 Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 34 | /** |
| 35 | * minimalizaSidebar - Directive for minimalize sidebar |
| 36 | */ |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 37 | export function minimalizaMenu() { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 38 | return { |
| 39 | restrict: 'EA', |
| 40 | 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] | 41 | controller: function ($scope, XosNavHandler: IXosNavHandlerService) { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 42 | $scope.minimalize = function () { |
Matteo Scandolo | c817849 | 2017-04-11 17:55:13 -0700 | [diff] [blame] | 43 | XosNavHandler.minimalize(); |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 44 | }; |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 45 | } |
| 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 | */ |
| 77 | export 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 | }; |