2018-03-12 11:31:50 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Popover from '../components/popover/popover';
|
|
|
|
import {kebabToCamel} from '../lib/string';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Directive used to open a popover.
|
|
|
|
*
|
|
|
|
* @return {Object} The directive
|
|
|
|
*/
|
|
|
|
export function directive() {
|
|
|
|
return {
|
|
|
|
restrict: 'A',
|
|
|
|
link: function($scope, $element, $attrs) {
|
|
|
|
$element.on('click', function(event) {
|
2019-10-24 08:17:32 +00:00
|
|
|
if (event.defaultPrevented) return;
|
2018-03-12 11:31:50 +00:00
|
|
|
let popoverKey = kebabToCamel($attrs.vnPopover);
|
|
|
|
let popover = $scope[popoverKey];
|
|
|
|
if (popover instanceof Popover) {
|
|
|
|
popover.parent = $element[0];
|
|
|
|
popover.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
ngModule.directive('vnPopover', directive);
|