alert.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. /**
  6. * @api
  7. */
  8. define([
  9. 'jquery',
  10. 'underscore',
  11. 'jquery/ui',
  12. 'Magento_Ui/js/modal/confirm',
  13. 'mage/translate'
  14. ], function ($, _) {
  15. 'use strict';
  16. $.widget('mage.alert', $.mage.confirm, {
  17. options: {
  18. modalClass: 'confirm',
  19. title: $.mage.__('Attention'),
  20. actions: {
  21. /**
  22. * Callback always - called on all actions.
  23. */
  24. always: function () {}
  25. },
  26. buttons: [{
  27. text: $.mage.__('OK'),
  28. class: 'action-primary action-accept',
  29. /**
  30. * Click handler.
  31. */
  32. click: function () {
  33. this.closeModal(true);
  34. }
  35. }]
  36. },
  37. /**
  38. * Close modal window.
  39. */
  40. closeModal: function () {
  41. this.options.actions.always();
  42. this.element.bind('alertclosed', _.bind(this._remove, this));
  43. return this._super();
  44. }
  45. });
  46. return function (config) {
  47. return $('<div></div>').html(config.content).alert(config);
  48. };
  49. });