2017-02-06 17:01:04 +00:00
|
|
|
import {module} from '../module';
|
2017-02-07 13:34:26 +00:00
|
|
|
import Dialog from '../dialog/index';
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
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();
|
2017-02-06 17:01:04 +00:00
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.directive('vnDialog', directive);
|