2016-03-01 14:01:41 -06:00
|
|
|
///<reference path="../../headers/common.d.ts" />
|
2016-02-21 11:08:44 -06:00
|
|
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
import $ from 'jquery';
|
2016-03-01 14:01:41 -06:00
|
|
|
import coreModule from 'app/core/core_module';
|
2016-02-21 11:08:44 -06:00
|
|
|
import Drop from 'tether-drop';
|
|
|
|
|
2016-03-01 14:01:41 -06:00
|
|
|
export function infoPopover() {
|
2016-02-21 11:08:44 -06:00
|
|
|
return {
|
|
|
|
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) {
|
2016-02-22 04:41:50 -06:00
|
|
|
var offset = attrs.offset || '0 -10px';
|
2016-03-01 14:01:41 -06:00
|
|
|
var position = attrs.position || 'right middle';
|
2016-03-29 04:01:00 -05:00
|
|
|
var classes = 'drop-help drop-hide-out-of-bounds';
|
2016-04-15 18:56:39 -05:00
|
|
|
var openOn = 'hover';
|
|
|
|
|
|
|
|
elem.addClass('gf-form-help-icon');
|
|
|
|
|
2016-03-01 14:01:41 -06:00
|
|
|
if (attrs.wide) {
|
|
|
|
classes += ' drop-wide';
|
|
|
|
}
|
2016-02-22 03:17:35 -06:00
|
|
|
|
2016-04-15 18:56:39 -05:00
|
|
|
if (attrs.mode) {
|
|
|
|
elem.addClass('gf-form-help-icon--' + attrs.mode);
|
|
|
|
}
|
|
|
|
|
2016-02-22 03:17:35 -06:00
|
|
|
transclude(function(clone, newScope) {
|
|
|
|
var content = document.createElement("div");
|
|
|
|
_.each(clone, (node) => {
|
|
|
|
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: {
|
2016-02-22 04:41:50 -06:00
|
|
|
offset: offset
|
2016-02-22 03:17:35 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-30 09:14:18 -05: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
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-03-01 14:01:41 -06:00
|
|
|
coreModule.directive('infoPopover', infoPopover);
|