Skip to content

Commit

Permalink
Merge pull request #36 from tdgroot/get-form-method
Browse files Browse the repository at this point in the history
 Move form selector to individual method
  • Loading branch information
boldsidney authored Apr 3, 2019
2 parents 5f40cd9 + d8ca052 commit 14fdce2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions view/frontend/web/js/model/checkout/order-comment-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ define(
*/
validate: function () {
var isCustomer = customer.isLoggedIn();
var form = $('.payment-method input[name="payment[method]"]:checked').parents('.payment-method').find('form.order-comment-form');

// Compatibility for Rubic_CleanCheckout
if (!form.length) {
form = $('form.order-comment-form');
}
var form = this.getForm();

var comment = form.find('.input-text.order-comment').val();
if (this.hasMaxLength() && comment.length > this.getMaxLength()) {
Expand Down Expand Up @@ -76,7 +71,19 @@ define(

return result;
},
hasMaxLength: function() {
getForm: function () {
var form = $('.payment-method input[name="payment[method]"]:checked')
.parents('.payment-method')
.find('form.order-comment-form');

// Compatibility for Rubic_CleanCheckout
if (!form.length) {
form = $('form.order-comment-form');
}

return form;
},
hasMaxLength: function () {
return window.checkoutConfig.max_length > 0;
},
getMaxLength: function () {
Expand Down

0 comments on commit 14fdce2

Please sign in to comment.