globals.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. /* global setLocation */
  6. define([
  7. 'Magento_Ui/js/modal/confirm',
  8. 'mage/dataPost'
  9. ], function (confirm, dataPost) {
  10. 'use strict';
  11. /**
  12. * Set of a temporary methods used to provide
  13. * backward compatability with a legacy code.
  14. */
  15. window.setLocation = function (url) {
  16. window.location.href = url;
  17. };
  18. /**
  19. * Helper for onclick action.
  20. * @param {String} message
  21. * @param {String} url
  22. * @param {Object} postData
  23. * @returns {Boolean}
  24. */
  25. window.deleteConfirm = function (message, url, postData) {
  26. confirm({
  27. content: message,
  28. actions: {
  29. /**
  30. * Confirm action.
  31. */
  32. confirm: function () {
  33. if (postData !== undefined) {
  34. postData.action = url;
  35. dataPost().postData(postData);
  36. } else {
  37. setLocation(url);
  38. }
  39. }
  40. }
  41. });
  42. return false;
  43. };
  44. /**
  45. * Helper for onclick action.
  46. * @param {String} message
  47. * @param {String} url
  48. * @returns {Boolean}
  49. */
  50. window.confirmSetLocation = window.deleteConfirm;
  51. });