salix/client/core/src/directives/dialog.js

24 lines
695 B
JavaScript
Raw Normal View History

import {module} from '../module';
2017-02-07 13:34:26 +00:00
import Dialog from '../dialog/index';
import {kebabToCamel} from '../lib/string';
/**
* Registers a click handler on the element that opens the dialog id
* specified as value.
*/
directive.$inject = ['$document'];
export function directive($document) {
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
$element.on('click', function(event) {
2017-02-07 13:34:26 +00:00
let dialog = $scope[kebabToCamel($attrs['vnDialog'])];
if(dialog instanceof Dialog)
dialog.show();
event.preventDefault();
});
}
}
}
module.directive('vnDialog', directive);