55jQuery ( document ) . ready ( function ( $ ) {
66 'use strict' ;
77
8- const SCG_Admin = {
8+ var SCG_Admin = {
99
1010 init : function ( ) {
1111 this . bindEvents ( ) ;
@@ -20,18 +20,18 @@ jQuery(document).ready(function($) {
2020 $ ( '#coupon_prefix' ) . on ( 'input' , this . formatPrefix ) ;
2121
2222 // Number input validation
23- $ ( '#number_of_coupons' ) . on ( 'input' , this . validateCouponCount ) ;
23+ $ ( '#number_of_coupons' ) . on ( 'input' , this . validateNumberInput ) ;
2424
2525 // Product selection change
2626 $ ( '#product_id' ) . on ( 'change' , this . handleProductChange ) ;
2727 } ,
2828
2929 handleFormSubmission : function ( e ) {
30- const $form = $ ( this ) ;
31- const $submitBtn = $form . find ( '.button-primary' ) ;
30+ var $form = $ ( this ) ;
31+ var $submitBtn = $form . find ( '.button-primary' ) ;
3232
3333 // Validate form before submission
34- if ( ! SCG_Admin . validateForm ( $form ) ) {
34+ if ( ! SCG_Admin . validateForm ( ) ) {
3535 e . preventDefault ( ) ;
3636 return false ;
3737 }
@@ -41,9 +41,9 @@ jQuery(document).ready(function($) {
4141 $submitBtn . prop ( 'disabled' , true ) ;
4242
4343 // Show confirmation for large batches
44- const couponCount = parseInt ( $ ( '#number_of_coupons' ) . val ( ) , 10 ) ;
44+ var couponCount = parseInt ( $ ( '#number_of_coupons' ) . val ( ) , 10 ) ;
4545 if ( couponCount > 25 ) {
46- const confirmed = confirm (
46+ var confirmed = confirm (
4747 'You are about to generate ' + couponCount + ' coupons. ' +
4848 'This may take a while and could potentially timeout depending on your server settings. Do you want to continue?'
4949 ) ;
@@ -55,6 +55,17 @@ jQuery(document).ready(function($) {
5555 return false ;
5656 }
5757 }
58+
59+ return true ;
60+ } ,
61+
62+ if ( ! confirmed ) {
63+ $form . removeClass ( 'loading' ) ;
64+ $submitBtn . prop ( 'disabled' , false ) ;
65+ e . preventDefault ( ) ;
66+ return false ;
67+ }
68+ }
5869 } ,
5970
6071 formatPrefix : function ( ) {
0 commit comments