confirm_click.js 558 B

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