From fbfe94af5c5642e460a9961b1b7f777671463c81 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Wed, 4 Jun 2014 13:01:16 -0700 Subject: [PATCH] Add confirm-click directive --- src/kibana/directives/confirm_click.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/kibana/directives/confirm_click.js 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