27 lines
770 B
JavaScript
27 lines
770 B
JavaScript
|
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) {
|
||
|
let popoverKey = kebabToCamel($attrs.vnPopover);
|
||
|
let popover = $scope[popoverKey];
|
||
|
if (popover instanceof Popover) {
|
||
|
popover.parent = $element[0];
|
||
|
popover.show();
|
||
|
}
|
||
|
event.preventDefault();
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
ngModule.directive('vnPopover', directive);
|