navbar.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import _ from 'lodash';
  4. import $ from 'jquery';
  5. import coreModule from '../../core_module';
  6. export class NavbarCtrl {
  7. /** @ngInject */
  8. constructor(private $scope, private contextSrv) {
  9. }
  10. }
  11. export function navbarDirective() {
  12. return {
  13. restrict: 'E',
  14. templateUrl: 'public/app/core/components/navbar/navbar.html',
  15. controller: NavbarCtrl,
  16. bindToController: true,
  17. transclude: true,
  18. controllerAs: 'ctrl',
  19. scope: {
  20. title: "@",
  21. titleUrl: "@",
  22. },
  23. link: function(scope, elem, attrs, ctrl) {
  24. ctrl.icon = attrs.icon;
  25. }
  26. };
  27. }
  28. var navButtonTemplate = `
  29. <div class="top-nav-btn dashnav-dashboards-btn">
  30. <a href="{{::titleUrl}}">
  31. <i class="{{::icon}}"></i>
  32. <span class="dashboard-title">{{::title}}</span>
  33. </a>
  34. </div>
  35. `;
  36. function navButton() {
  37. return {
  38. restrict: 'E',
  39. template: navButtonTemplate,
  40. scope: {
  41. title: "@",
  42. titleUrl: "@",
  43. },
  44. link: function(scope, elem, attrs, ctrl) {
  45. scope.icon = attrs.icon;
  46. }
  47. };
  48. }
  49. coreModule.directive('navbar', navbarDirective);
  50. coreModule.directive('navButton', navButton);