Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

71 wiersze
1.6 KiB

  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. 'Magento_Ui/js/modal/alert',
  11. 'jquery-ui-modules/widget',
  12. 'mage/mage',
  13. 'mage/translate'
  14. ], function ($, alert) {
  15. 'use strict';
  16. $.widget('mage.requireCookie', {
  17. options: {
  18. event: 'click',
  19. noCookieUrl: 'enable-cookies',
  20. triggers: ['.action.login', '.action.submit'],
  21. isRedirectCmsPage: true
  22. },
  23. /**
  24. * Constructor
  25. * @private
  26. */
  27. _create: function () {
  28. this._bind();
  29. },
  30. /**
  31. * This method binds elements found in this widget.
  32. * @private
  33. */
  34. _bind: function () {
  35. var events = {};
  36. $.each(this.options.triggers, function (index, value) {
  37. events['click ' + value] = '_checkCookie';
  38. });
  39. this._on(events);
  40. },
  41. /**
  42. * This method set the url for the redirect.
  43. * @param {jQuery.Event} event
  44. * @private
  45. */
  46. _checkCookie: function (event) {
  47. if (navigator.cookieEnabled) {
  48. return;
  49. }
  50. event.preventDefault();
  51. if (this.options.isRedirectCmsPage) {
  52. window.location = this.options.noCookieUrl;
  53. } else {
  54. alert({
  55. content: $.mage.__('Cookies are disabled in your browser.')
  56. });
  57. }
  58. }
  59. });
  60. return $.mage.requireCookie;
  61. });