mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tooltips for function definitions
This commit is contained in:
parent
80a6e0d8d1
commit
4d3bac0284
@ -2,8 +2,10 @@ define([
|
||||
'angular',
|
||||
'lodash',
|
||||
'jquery',
|
||||
'rst2html',
|
||||
'tether-drop',
|
||||
],
|
||||
function (angular, _, $) {
|
||||
function (angular, _, $, rst2html, Drop) {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
@ -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 = '<h4>' + funcDef.name + '</h4>' + rst2html(shortDesc);
|
||||
|
||||
var drop = new Drop({
|
||||
target: this,
|
||||
content: contentElement,
|
||||
classes: 'drop-popover',
|
||||
openOn: 'always',
|
||||
tetherOptions: {
|
||||
attachment: 'bottom left',
|
||||
targetAttachment: 'bottom right',
|
||||
},
|
||||
});
|
||||
|
||||
drops.push(drop);
|
||||
|
||||
drop.open();
|
||||
}
|
||||
})
|
||||
.on('mouseout', 'ul.dropdown-menu li', function() {
|
||||
while (drops.length > 0) {
|
||||
drops.pop().remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ function (angular, _, $, rst2html) {
|
||||
|
||||
angular
|
||||
.module('grafana.directives')
|
||||
.directive('graphiteFuncEditor', function($compile, templateSrv) {
|
||||
.directive('graphiteFuncEditor', function($compile, templateSrv, popoverSrv) {
|
||||
|
||||
var funcSpanTemplate = '<a ng-click="">{{func.def.name}}</a><span>(</span>';
|
||||
var paramTemplate = '<input type="text" style="display:none"' +
|
||||
@ -259,8 +259,14 @@ function (angular, _, $, rst2html) {
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-question-circle')) {
|
||||
if (func.def.description) {
|
||||
alert(rst2html(func.def.description));
|
||||
var funcDef = ctrl.datasource.getFuncDef(func.def.name);
|
||||
if (funcDef && funcDef.description) {
|
||||
popoverSrv.show({
|
||||
element: e.target,
|
||||
position: 'bottom left',
|
||||
template: '<div><h4>' + funcDef.name + '</h4>' + rst2html(funcDef.description) + '</div>',
|
||||
openOn: 'click',
|
||||
});
|
||||
} else {
|
||||
window.open(
|
||||
"http://graphite.readthedocs.org/en/latest/functions.html#graphite.render.functions." + func.def.name,'_blank');
|
||||
|
Loading…
Reference in New Issue
Block a user