23 lines
662 B
JavaScript
23 lines
662 B
JavaScript
|
import {module} from '../module';
|
||
|
import Dialog from './index';
|
||
|
|
||
|
/**
|
||
|
* 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) {
|
||
|
let dialog = $document[0].getElementById($attrs['vnDialog']);
|
||
|
if(dialog.$ctrl instanceof Dialog)
|
||
|
dialog.$ctrl.show();
|
||
|
event.preventDefault();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
module.directive('vnDialog', directive);
|