panel_menu.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. define([
  2. 'angular',
  3. 'jquery',
  4. ],
  5. function (angular, $) {
  6. 'use strict';
  7. angular
  8. .module('grafana.directives')
  9. .directive('panelMenu', function($compile) {
  10. var linkTemplate =
  11. '<span class="panel-title drag-handle pointer">' +
  12. '<span class="icon-gf panel-alert-icon"></span>' +
  13. '<span class="panel-title-text drag-handle">{{ctrl.panel.title | interpolateTemplateVars:this}}</span>' +
  14. '<span class="panel-time-info" ng-show="ctrl.timeInfo"><i class="fa fa-clock-o"></i> {{ctrl.timeInfo}}</span>' +
  15. '</span>';
  16. return {
  17. restrict: 'A',
  18. link: function($scope, elem) {
  19. var $link = $(linkTemplate);
  20. //var menuScope = null;
  21. //var timeout = null;
  22. //var $menu = null;
  23. //var teather;
  24. elem.append($link);
  25. // function dismiss(time, force) {
  26. // clearTimeout(timeout);
  27. // timeout = null;
  28. //
  29. // if (time) {
  30. // timeout = setTimeout(dismiss, time);
  31. // return;
  32. // }
  33. //
  34. // // if hovering or draging pospone close
  35. // if (force !== true) {
  36. // if ($menu.is(':hover') || $scope.ctrl.dashboard.$$panelDragging) {
  37. // dismiss(2200);
  38. // return;
  39. // }
  40. // }
  41. //
  42. // if (menuScope) {
  43. // teather.destroy();
  44. // $menu.unbind();
  45. // $menu.remove();
  46. // menuScope.$destroy();
  47. // menuScope = null;
  48. // $menu = null;
  49. // $panelContainer.removeClass('panel-highlight');
  50. // }
  51. // }
  52. var showMenu = function() {
  53. // // if menu item is clicked and menu was just removed from dom ignore this event
  54. // if (!$.contains(document, e.target)) {
  55. // return;
  56. // }
  57. //
  58. // if ($menu) {
  59. // dismiss();
  60. // return;
  61. // }
  62. //
  63. // var menuTemplate;
  64. // menuTemplate = createMenuTemplate(ctrl);
  65. //
  66. // $menu = $(menuTemplate);
  67. // $menu.mouseleave(function() {
  68. // dismiss(1000);
  69. // });
  70. //
  71. // menuScope = $scope.$new();
  72. // menuScope.extendedMenu = getExtendedMenu(ctrl);
  73. // menuScope.dismiss = function() {
  74. // dismiss(null, true);
  75. // };
  76. //
  77. // $(".panel-container").removeClass('panel-highlight');
  78. // $panelContainer.toggleClass('panel-highlight');
  79. //
  80. // $('.panel-menu').remove();
  81. //
  82. // elem.append($menu);
  83. //
  84. // $scope.$apply(function() {
  85. // $compile($menu.contents())(menuScope);
  86. //
  87. // teather = new Tether({
  88. // element: $menu,
  89. // target: $panelContainer,
  90. // attachment: 'bottom center',
  91. // targetAttachment: 'top center',
  92. // constraints: [
  93. // {
  94. // to: 'window',
  95. // attachment: 'together',
  96. // pin: true
  97. // }
  98. // ]
  99. // });
  100. // });
  101. //
  102. // dismiss(2200);
  103. };
  104. elem.click(showMenu);
  105. $compile(elem.contents())($scope);
  106. }
  107. };
  108. });
  109. });