diff --git a/src/kibana/directives/confirm_click.js b/src/kibana/directives/confirm_click.js new file mode 100644 index 0000000000000..cf3b4e30a070a --- /dev/null +++ b/src/kibana/directives/confirm_click.js @@ -0,0 +1,24 @@ +define(function (require) { + require('modules') + .get('kibana/directives') + .directive('confirmClick', function () { + return { + restrict: 'A', + link: function ($scope, $elem, attrs) { + $elem.bind('click', function () { + var message = attrs.confirmation || 'Are you sure?'; + if (window.confirm(message)) { + var action = attrs.confirmClick; + if (action) { + $scope.$apply($scope.$eval(action)); + } + } + }); + + $scope.$on('$destroy', function () { + $elem.unbind('click'); + }); + }, + }; + }); +}); \ No newline at end of file