Skip to content

Commit

Permalink
Merge pull request #120 from rashidkpc/master
Browse files Browse the repository at this point in the history
Add confirm-click directive
  • Loading branch information
Rashid Khan committed Jun 4, 2014
2 parents a7e4047 + fbfe94a commit 8c4a935
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/kibana/directives/confirm_click.js
Original file line number Diff line number Diff line change
@@ -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');
});
},
};
});
});

0 comments on commit 8c4a935

Please sign in to comment.