extra-options.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. /**
  6. * @deprecated since version 2.2.0
  7. */
  8. define([
  9. 'jquery',
  10. 'jquery/ui'
  11. ], function ($) {
  12. 'use strict';
  13. $.widget('mage.extraOptions', {
  14. options: {
  15. events: 'billingSave shippingSave',
  16. additionalContainer: '#onepage-checkout-shipping-method-additional-load'
  17. },
  18. /**
  19. * Set up event handler for requesting any additional extra options from the backend.
  20. * @private
  21. */
  22. _create: function () {
  23. this.element.on(this.options.events, $.proxy(this._addExtraOptions, this));
  24. },
  25. /**
  26. * Fetch the extra options using an Ajax call. Extra options include Gift Receipt and
  27. * Printed Card.
  28. * @private
  29. */
  30. _addExtraOptions: function () {
  31. $.ajax({
  32. url: this.options.additionalUrl,
  33. context: this,
  34. type: 'post',
  35. async: false,
  36. /** @inheritdoc */
  37. success: function (response) {
  38. $(this.options.additionalContainer).html(response).trigger('contentUpdated');
  39. }
  40. });
  41. }
  42. });
  43. return $.mage.extraOptions;
  44. });