topnav.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. define([
  2. '../core_module',
  3. ],
  4. function (coreModule) {
  5. 'use strict';
  6. coreModule.directive('topnav', function($rootScope, contextSrv) {
  7. return {
  8. restrict: 'E',
  9. transclude: true,
  10. scope: {
  11. title: "@",
  12. section: "@",
  13. titleAction: "&",
  14. subnav: "=",
  15. },
  16. template:
  17. '<div class="navbar navbar-static-top"><div class="navbar-inner"><div class="container-fluid">' +
  18. '<div class="top-nav">' +
  19. '<a class="top-nav-menu-btn pointer" ng-if="!contextSrv.sidemenu" ng-click="toggle()">' +
  20. '<img class="logo-icon" src="img/fav32.png"></img> ' +
  21. '<i class="fa fa-bars"></i>' +
  22. '</a>' +
  23. '<span class="icon-circle top-nav-icon">' +
  24. '<i ng-class="icon"></i>' +
  25. '</span>' +
  26. '<span ng-show="section">' +
  27. '<span class="top-nav-title">{{section}}</span>' +
  28. '<i class="top-nav-breadcrumb-icon fa fa-angle-right"></i>' +
  29. '</span>' +
  30. '<a ng-click="titleAction()" class="top-nav-title">' +
  31. '{{title}}' +
  32. '</a>' +
  33. '<i ng-show="subnav" class="top-nav-breadcrumb-icon fa fa-angle-right"></i>' +
  34. '</div><div ng-transclude></div></div></div></div>',
  35. link: function(scope, elem, attrs) {
  36. scope.icon = attrs.icon;
  37. scope.contextSrv = contextSrv;
  38. scope.toggle = function() {
  39. $rootScope.appEvent('toggle-sidemenu');
  40. };
  41. }
  42. };
  43. });
  44. });