ConfirmationDialog.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. /**
  3. * An extension of a MessageBox to provide a confirmation dialog
  4. *
  5. * Licensed Materials - Property of IBM IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule
  6. * Contract with IBM Corp.
  7. */
  8. define(['../../../lib/@waca/dashboard-common/dist/ui/dialogs/MessageBox'], function (MessageBox) {
  9. var Dialog = null;
  10. Dialog = MessageBox.extend({
  11. _buttons: ['ok', 'cancel'],
  12. _confirmCallback: null,
  13. _cancelCallback: null,
  14. /**
  15. * Opens the Confirmation dialog
  16. * @param {function} confirm - A callback to use when the user clicks OK
  17. * @param {function} cancel - A callback to use when the user clicks Cancel
  18. */
  19. confirm: function confirm(_confirm, cancel) {
  20. this._confirmCallback = _confirm;
  21. this._cancelCallback = cancel;
  22. Dialog.inherited('open', this);
  23. },
  24. ok: function ok() {
  25. Dialog.inherited('ok', this, arguments);
  26. if (this._confirmCallback) {
  27. this._confirmCallback();
  28. }
  29. },
  30. cancel: function cancel() {
  31. Dialog.inherited('cancel', this, arguments);
  32. if (this._cancelCallback) {
  33. this._cancelCallback();
  34. }
  35. }
  36. });
  37. return Dialog;
  38. });
  39. //# sourceMappingURL=ConfirmationDialog.js.map