salix/front/core/directives/popover.js

25 lines
715 B
JavaScript
Raw Permalink Normal View History

import ngModule from '../module';
import Popover from '../components/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;
let popoverKey = kebabToCamel($attrs.vnPopover);
let popover = $scope[popoverKey];
if (popover instanceof Popover)
popover.show($element[0]);
});
}
};
}
ngModule.directive('vnPopover', directive);