overview.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery',
  7. 'jquery/ui',
  8. 'mage/translate'
  9. ], function ($) {
  10. 'use strict';
  11. $.widget('mage.orderOverview', {
  12. options: {
  13. opacity: 0.5, // CSS opacity for the 'Place Order' button when it's clicked and then disabled.
  14. pleaseWaitLoader: 'span.please-wait', // 'Submitting order information...' Ajax loader.
  15. placeOrderSubmit: 'button[type="submit"]', // The 'Place Order' button.
  16. agreements: '#checkout-agreements' // Container for all of the checkout agreements and terms/conditions
  17. },
  18. /**
  19. * Bind a submit handler to the form.
  20. * @private
  21. */
  22. _create: function () {
  23. this.element.on('submit', $.proxy(this._showLoader, this));
  24. },
  25. /**
  26. * Verify that all agreements and terms/conditions are checked. Show the Ajax loader. Disable
  27. * the submit button (i.e. Place Order).
  28. * @return {Boolean}
  29. * @private
  30. */
  31. _showLoader: function () {
  32. if ($(this.options.agreements).find('input[type="checkbox"]:not(:checked)').length > 0) {
  33. return false;
  34. }
  35. this.element.find(this.options.pleaseWaitLoader).show().end()
  36. .find(this.options.placeOrderSubmit).prop('disabled', true).css('opacity', this.options.opacity);
  37. return true;
  38. }
  39. });
  40. return $.mage.orderOverview;
  41. });