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 | |
| 10 | /** |
| 11 | * minimalizaSidebar - Directive for minimalize sidebar |
| 12 | */ |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 13 | export function minimalizaMenu($rootScope, XosKeyboardShortcut: IXosKeyboardShortcutService) { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 14 | 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 Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 18 | $scope.minimalize = function () { |
| 19 | $("body").toggleClass("nav-toggle"); |
Matteo Scandolo | 5053cbe | 2017-01-31 17:37:56 -0800 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | XosKeyboardShortcut.registerKeyBinding({ |
| 23 | key: 'n', |
| 24 | description: 'Toggle Navigation', |
| 25 | cb: $scope.minimalize, |
| 26 | }, 'global'); |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 27 | } |
| 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 | */ |
| 59 | export 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 | }; |