diff --git a/public/app/plugins/datasource/graphite/add_graphite_func.js b/public/app/plugins/datasource/graphite/add_graphite_func.js index 97c34664ed7..c66176aeb8f 100644 --- a/public/app/plugins/datasource/graphite/add_graphite_func.js +++ b/public/app/plugins/datasource/graphite/add_graphite_func.js @@ -2,13 +2,15 @@ define([ 'angular', 'lodash', 'jquery', + 'rst2html', + 'tether-drop', ], -function (angular, _, $) { +function (angular, _, $, rst2html, Drop) { 'use strict'; angular .module('grafana.directives') - .directive('graphiteAddFunc', function($compile) { + .directive('graphiteAddFunc', function($compile) { var inputTemplate = ''; @@ -81,6 +83,52 @@ function (angular, _, $) { $compile(elem.contents())($scope); }); + + var drops = []; + + $(elem) + .on('mouseenter', 'ul.dropdown-menu li', function () { + while (drops.length > 0) { + drops.pop().remove(); + } + + var funcDef; + try { + funcDef = ctrl.datasource.getFuncDef($('a', this).text()); + } catch (e) { + // ignore + } + + if (funcDef && funcDef.description) { + var shortDesc = funcDef.description; + if (shortDesc.length > 500) { + shortDesc = shortDesc.substring(0, 497) + '...'; + } + + var contentElement = document.createElement('div'); + contentElement.innerHTML = '