Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

70 строки
1.8 KiB

  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery',
  7. 'jquery-ui-modules/widget'
  8. ], function ($) {
  9. 'use strict';
  10. /**
  11. * @api
  12. */
  13. $.widget('mage.captcha', {
  14. options: {
  15. refreshClass: 'refreshing',
  16. reloadSelector: '.captcha-reload',
  17. imageSelector: '.captcha-img',
  18. imageLoader: ''
  19. },
  20. /**
  21. * Method binds click event to reload image
  22. * @private
  23. */
  24. _create: function () {
  25. this.element.on('click', this.options.reloadSelector, $.proxy(this.refresh, this));
  26. },
  27. /**
  28. * Method triggers an AJAX request to refresh the CAPTCHA image
  29. */
  30. refresh: function () {
  31. var imageLoader = this.options.imageLoader;
  32. if (imageLoader) {
  33. this.element.find(this.options.imageSelector).attr('src', imageLoader);
  34. }
  35. this.element.addClass(this.options.refreshClass);
  36. $.ajax({
  37. url: this.options.url,
  38. type: 'post',
  39. dataType: 'json',
  40. context: this,
  41. data: {
  42. 'formId': this.options.type
  43. },
  44. /**
  45. * @param {Object} response
  46. */
  47. success: function (response) {
  48. if (response.imgSrc) {
  49. this.element.find(this.options.imageSelector).attr('src', response.imgSrc);
  50. }
  51. },
  52. /** Complete callback. */
  53. complete: function () {
  54. this.element.removeClass(this.options.refreshClass);
  55. }
  56. });
  57. }
  58. });
  59. return $.mage.captcha;
  60. });