confirmClick.js 597 B

1234567891011121314151617181920212223242526
  1. define([
  2. 'angular',
  3. 'kbn'
  4. ],
  5. function (angular) {
  6. 'use strict';
  7. var module = angular.module('grafana.directives');
  8. module.directive('confirmClick', function() {
  9. return {
  10. restrict: 'A',
  11. link: function(scope, elem, attrs) {
  12. elem.bind('click', function() {
  13. var message = attrs.confirmation || "Are you sure you want to do that?";
  14. if (window.confirm(message)) {
  15. var action = attrs.confirmClick;
  16. if (action) {
  17. scope.$apply(scope.$eval(action));
  18. }
  19. }
  20. });
  21. },
  22. };
  23. });
  24. });