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