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