Sha256: 309fc9408d9a2f96c60edc136decce9db39dc8d13c0497db985e172e4a0f7a12

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

//= require harpiya/frontend/coupon_manager

Harpiya.disableSaveOnClick = function () {
  $('form.edit_order').on('submit', function (event) {
    if ($(this).data('submitted') === true) {
      event.preventDefault()
    } else {
      $(this).data('submitted', true)
      $(this).find(':submit, :image').removeClass('primary').addClass('disabled')
    }
  })
}

Harpiya.enableSave = function () {
  $('#checkout form').data('submitted', false).find(':submit, :image').attr('disabled', false).addClass('primary').removeClass('disabled')
}

Harpiya.ready(function () {
  Harpiya.Checkout = {}

  var formCheckoutConfirm = $('form#checkout_form_confirm')
  if (formCheckoutConfirm.length) {
    $('form#checkout_form_confirm button#shopping-cart-coupon-code-button').off('click').on('click', function(event) {
      event.preventDefault()

      var input = {
        appliedCouponCodeField: $('#order_applied_coupon_code'),
        couponCodeField: $('#order_coupon_code'),
        couponStatus: $('#coupon_status'),
        couponButton: $('#shopping-cart-coupon-code-button'),
        removeCouponButton: $('#shopping-cart-remove-coupon-code-button')
      }

      if ($.trim(input.couponCodeField.val()).length && new CouponManager(input).applyCoupon()) {
        location.reload();
        return true
      } else {
        return false
      }
    })

    $('form#checkout_form_confirm button#shopping-cart-remove-coupon-code-button').off('click').on('click', function(event) {
      var input = {
        appliedCouponCodeField: $('#order_applied_coupon_code'),
        couponCodeField: $('#order_coupon_code'),
        couponStatus: $('#coupon_status'),
        couponButton: $('#shopping-cart-coupon-code-button'),
        removeCouponButton: $('#shopping-cart-remove-coupon-code-button')
      }

      if (new CouponManager(input).removeCoupon()) {
        return true
      } else {
        event.preventDefault()
        return false
      }
    })
  }

  return Harpiya.Checkout
})

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harpiya_frontend-4.3.0.alpha app/assets/javascripts/harpiya/frontend/checkout.js