@@ -39,6 +39,7 @@ define([
39
39
this . isOnlyVirtualProduct = false ;
40
40
this . excludedPaymentMethods = [ ] ;
41
41
this . summarizePrice = true ;
42
+ this . timerId = null ;
42
43
jQuery . async ( '#order-items' , ( function ( ) {
43
44
this . dataArea = new OrderFormArea ( 'data' , $ ( this . getAreaId ( 'data' ) ) , this ) ;
44
45
this . itemsArea = Object . extend ( new OrderFormArea ( 'items' , $ ( this . getAreaId ( 'items' ) ) , this ) , {
@@ -189,14 +190,27 @@ define([
189
190
bindAddressFields : function ( container ) {
190
191
var fields = $ ( container ) . select ( 'input' , 'select' , 'textarea' ) ;
191
192
for ( var i = 0 ; i < fields . length ; i ++ ) {
192
- Event . observe ( fields [ i ] , 'change' , this . changeAddressField . bind ( this ) ) ;
193
+ Event . observe ( fields [ i ] , 'change' , this . triggerChangeEvent . bind ( this ) ) ;
193
194
}
194
195
} ,
195
196
197
+ /**
198
+ * Calls changing address field handler after timeout to prevent multiple simultaneous calls.
199
+ *
200
+ * @param {Event } event
201
+ */
202
+ triggerChangeEvent : function ( event ) {
203
+ if ( this . timerId ) {
204
+ window . clearTimeout ( this . timerId ) ;
205
+ }
206
+
207
+ this . timerId = window . setTimeout ( this . changeAddressField . bind ( this ) , 500 , event ) ;
208
+ } ,
209
+
196
210
/**
197
211
* Triggers on each form's element changes.
198
212
*
199
- * @param {Object } event
213
+ * @param {Event } event
200
214
*/
201
215
changeAddressField : function ( event ) {
202
216
var field = Event . element ( event ) ,
@@ -619,7 +633,7 @@ define([
619
633
}
620
634
else if ( ( ( elms [ i ] . type == 'checkbox' || elms [ i ] . type == 'radio' ) && elms [ i ] . checked )
621
635
|| ( ( elms [ i ] . type == 'file' || elms [ i ] . type == 'text' || elms [ i ] . type == 'textarea' || elms [ i ] . type == 'hidden' )
622
- && Form . Element . getValue ( elms [ i ] ) )
636
+ && Form . Element . getValue ( elms [ i ] ) )
623
637
) {
624
638
if ( this . _isSummarizePrice ( elms [ i ] ) ) {
625
639
productPrice += getPrice ( elms [ i ] ) ;
@@ -1131,7 +1145,7 @@ define([
1131
1145
*/
1132
1146
isPaymentValidationAvailable : function ( ) {
1133
1147
return ( ( typeof this . paymentMethod ) == 'undefined'
1134
- || this . excludedPaymentMethods . indexOf ( this . paymentMethod ) == - 1 ) ;
1148
+ || this . excludedPaymentMethods . indexOf ( this . paymentMethod ) == - 1 ) ;
1135
1149
} ,
1136
1150
1137
1151
serializeData : function ( container ) {
0 commit comments