2016-03-01 14:01:41 -06:00
|
|
|
///<reference path="../../headers/common.d.ts" />
|
2016-02-21 11:08:44 -06:00
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
import _ from "lodash";
|
|
|
|
import coreModule from "app/core/core_module";
|
|
|
|
import Drop from "tether-drop";
|
2016-02-21 11:08:44 -06:00
|
|
|
|
2016-03-01 14:01:41 -06:00
|
|
|
export function infoPopover() {
|
2016-02-21 11:08:44 -06:00
|
|
|
return {
|
2017-12-19 09:06:54 -06:00
|
|
|
restrict: "E",
|
2016-04-15 18:56:39 -05:00
|
|
|
template: '<i class="fa fa-info-circle"></i>',
|
2016-02-22 03:17:35 -06:00
|
|
|
transclude: true,
|
|
|
|
link: function(scope, elem, attrs, ctrl, transclude) {
|
2017-12-19 09:06:54 -06:00
|
|
|
var offset = attrs.offset || "0 -10px";
|
|
|
|
var position = attrs.position || "right middle";
|
|
|
|
var classes = "drop-help drop-hide-out-of-bounds";
|
|
|
|
var openOn = "hover";
|
2016-04-15 18:56:39 -05:00
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
elem.addClass("gf-form-help-icon");
|
2016-04-15 18:56:39 -05:00
|
|
|
|
2016-03-01 14:01:41 -06:00
|
|
|
if (attrs.wide) {
|
2017-12-19 09:06:54 -06:00
|
|
|
classes += " drop-wide";
|
2016-03-01 14:01:41 -06:00
|
|
|
}
|
2016-02-22 03:17:35 -06:00
|
|
|
|
2016-04-15 18:56:39 -05:00
|
|
|
if (attrs.mode) {
|
2017-12-19 09:06:54 -06:00
|
|
|
elem.addClass("gf-form-help-icon--" + attrs.mode);
|
2016-04-15 18:56:39 -05:00
|
|
|
}
|
|
|
|
|
2016-02-22 03:17:35 -06:00
|
|
|
transclude(function(clone, newScope) {
|
|
|
|
var content = document.createElement("div");
|
2017-12-19 09:06:54 -06:00
|
|
|
content.className = "markdown-html";
|
2017-10-07 03:31:39 -05:00
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
_.each(clone, node => {
|
2016-02-22 03:17:35 -06:00
|
|
|
content.appendChild(node);
|
|
|
|
});
|
|
|
|
|
|
|
|
var drop = new Drop({
|
2016-04-15 18:56:39 -05:00
|
|
|
target: elem[0],
|
2016-02-22 03:17:35 -06:00
|
|
|
content: content,
|
2016-03-01 14:01:41 -06:00
|
|
|
position: position,
|
|
|
|
classes: classes,
|
2016-04-15 18:56:39 -05:00
|
|
|
openOn: openOn,
|
2016-04-16 11:03:29 -05:00
|
|
|
hoverOpenDelay: 400,
|
2016-02-22 03:17:35 -06:00
|
|
|
tetherOptions: {
|
2017-04-12 14:20:47 -05:00
|
|
|
offset: offset,
|
|
|
|
constraints: [
|
2017-12-19 09:06:54 -06:00
|
|
|
{
|
|
|
|
to: "window",
|
|
|
|
attachment: "together",
|
|
|
|
pin: true
|
|
|
|
}
|
|
|
|
]
|
2016-02-22 03:17:35 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
var unbind = scope.$on("$destroy", function() {
|
2016-02-22 03:17:35 -06:00
|
|
|
drop.destroy();
|
2016-10-30 09:14:18 -05:00
|
|
|
unbind();
|
2016-02-22 03:17:35 -06:00
|
|
|
});
|
2016-02-21 11:08:44 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
coreModule.directive("infoPopover", infoPopover);
|