ux(): tooltip improvement

This commit is contained in:
Torkel Ödegaard
2016-04-15 19:56:39 -04:00
parent 49b2743a37
commit e307ada374
9 changed files with 116 additions and 75 deletions

View File

@@ -8,21 +8,30 @@ import Drop from 'tether-drop';
export function infoPopover() {
return {
restrict: 'E',
template: '<i class="fa fa-info-circle"></i>',
transclude: true,
link: function(scope, elem, attrs, ctrl, transclude) {
var inputElem = elem.prev();
if (inputElem.length === 0) {
console.log('Failed to find input element for popover');
return;
}
// var inputElem = elem.prev();
// if (inputElem.length === 0) {
// console.log('Failed to find input element for popover');
// return;
// }
var offset = attrs.offset || '0 -10px';
var position = attrs.position || 'right middle';
var classes = 'drop-help drop-hide-out-of-bounds';
var openOn = 'hover';
elem.addClass('gf-form-help-icon');
if (attrs.wide) {
classes += ' drop-wide';
}
if (attrs.mode) {
elem.addClass('gf-form-help-icon--' + attrs.mode);
}
transclude(function(clone, newScope) {
var content = document.createElement("div");
_.each(clone, (node) => {
@@ -30,11 +39,11 @@ export function infoPopover() {
});
var drop = new Drop({
target: inputElem[0],
target: elem[0],
content: content,
position: position,
classes: classes,
openOn: 'click',
openOn: openOn,
tetherOptions: {
offset: offset
}