PageSourceSearch

https://www.kaosalonpartner.no/_ui/responsive/common/js/acc.silentorderpost.js

js kaosalonpartner.no collected 2026-10-08 23:29:53 UTC 8,092 bytes, 272 lines download raw bytes

1ACC.silentorderpost = {
2
3	spinner: $("<img src='" + ACC.config.commonResourcePath + "/images/spinner.gif' />"),
4
5	bindUseDeliveryAddress: function ()
6	{
7		$('#useDeliveryAddress').on('change', function ()
8		{
9			if ($('#useDeliveryAddress').is(":checked"))
10			{
11				$("#billingCountrySelector").find('.validation').hide();
12				var options = {'countryIsoCode': $('#useDeliveryAddressData').data('countryisocode'), 'useDeliveryAddress': true};
13				ACC.silentorderpost.enableAddressForm();
14				ACC.silentorderpost.displayCreditCardAddressForm(options, ACC.silentorderpost.useDeliveryAddressSelected);
15				ACC.silentorderpost.disableAddressForm();
16			}
17			else
18			{
19				ACC.silentorderpost.clearAddressForm();
20				ACC.silentorderpost.enableAddressForm();
21			}
22		});
23
24		if ($('#useDeliveryAddress').is(":checked"))
25		{
26			$("#billingCountrySelector").find('.validation').hide();
27			var options = {'countryIsoCode': $('#useDeliveryAddressData').data('countryisocode'), 'useDeliveryAddress': true};
28			ACC.silentorderpost.enableAddressForm();
29			ACC.silentorderpost.displayCreditCardAddressForm(options, ACC.silentorderpost.useDeliveryAddressSelected);
30			ACC.silentorderpost.disableAddressForm();
31		}
32		
33		//Validation on keyPress for billing address start
34		$("#address\\.firstName").on("keypress",function(e) {
35			$('#address\\.firstName').parent().next().find('.validation').hide();
36				
37	    });
38
39		$("#address\\.lastName").on("keypress",function(e) {
40			$('#address\\.lastName').parent().next().find('.validation').hide();
41				
42	    });
43
44		$("#address\\.line1").on("keypress",function(e) {
45			$('#address\\.line1').parent().next().find('.validation').hide();
46				
47	    });
48
49		$("#address\\.postcode").on("keypress",function(e) {
50			$('#address\\.postcode').parent().next().find('.validation').hide();
51				
52	    });
53		$("#address\\.townCity").on("keypress",function(e) {
54			$('#address\\.townCity').parent().next().find('.validation').hide();
55				
56	    });
57
58		//Validation on keyPress for billing address end
59		
60		$("#address\\.country").on("change",function(e) {
61			$("#billingCountrySelector").find('.validation').hide();
62				
63	    });
64	},
65
66	bindSubmitSilentOrderPostForm: function ()
67	{
68		$('.submit_silentOrderPostForm').click(function ()
69		{
70		
71			var ValidAddress = false;
72			
73			//Validation for Card payment info  Start
74			var cardType= $('#card_cardType').val();
75			 var accountNumber= $('#card_accountNumber').val();
76			 var expiryMonth= $('#ExpiryMonth').val();
77			 var expiryYear= $('#ExpiryYear').val();
78			 var cvNumber= $('#card_cvNumber').val();
79			
80			if (cardType == '' || cardType == null) {
81				$('#card_cardType').closest('.form-input-section').find('.validation').show();
82				ValidAddress = true;
83			} else {
84			
85				$('#card_cardType').closest('.form-input-section').find('.validation').hide();
86			}	
87			if (accountNumber == '' || accountNumber == null) {
88				$('#card_accountNumber').closest('.form-input-section').find('.validation').show();
89				ValidAddress = true;
90			} else {
91			
92				$('#card_accountNumber').closest('.form-input-section').find('.validation').hide();
93			}
94			if (expiryMonth == '' || expiryMonth == null) {
95				$('#ExpiryMonth').closest('.form-input-section').find('.validation').show();
96				ValidAddress = true;
97			} else {
98			
99				$('#ExpiryMonth').closest('.form-input-section').find('.validation').hide();
100			}
101			if (expiryYear == '' || expiryYear == null) {
102				$('#ExpiryYear').closest('.form-input-section').find('.validation').show();
103				ValidAddress = true;
104			} else {
105			
106				$('#ExpiryYear').closest('.form-input-section').find('.validation').hide();
107			}
108			if (cvNumber == '' || cvNumber == null) {
109				$('#card_cvNumber').closest('.form-input-section').find('.validation').show();
110				ValidAddress = true;
111			} else {
112			
113				$('#card_cvNumber').closest('.form-input-section').find('.validation').hide();
114			}
115			//Validation for Card payment info  End
116		
117			//Validation for billing address
118			var country=$('#address\\.country').val();
119			var firstName = $('#address\\.firstName').val();
120			var lastName=  $('#address\\.surname').val();
121			var line1= $('#address\\.line1').val();
122			var city=  $('#address\\.townCity').val();
123			var postCode=$('#address\\.postcode').val();
124			
125			console.log(country);
126			if (country == '' || country == null) {
127				$('#address\\.country').parent().parent().next().find('.validation').show();
128				ValidAddress = true;
129			} else {
130			
131				$('#address\\.country').parent().next().parent().find('.validation').hide();
132			}
133			
134			if (firstName == '' || firstName == null) {
135				$('#address\\.firstName').parent().next().find('.validation').show();
136				ValidAddress = true;
137			} else {
138			
139				$('#address\\.firstName').parent().next().find('.validation').hide();
140			}
141			if (lastName == '' || lastName == null) {
142				$('#address\\.surname').parent().next().find('.validation').show();
143				ValidAddress = true;
144			} else {
145				$('#address\\.surname').parent().next().find('.validation').hide();
146			}
147			if (line1 == '' || line1 == null) {
148				$('#address\\.line1').parent().next().find('.validation').show();
149				ValidAddress = true;
150			} else {
151				$('#address\\.line1').parent().next().find('.validation').hide();
152			}
153			if (city == '' || city == null) {
154				$('#address\\.townCity').parent().next().find('.validation').show();
155				ValidAddress = true;
156			} else {
157				$('#address\\.townCity').parent().next().find('.validation').hide();
158			}
159			if (postCode == '' || postCode == null) {
160				$('#address\\.postcode').parent().next().find('.validation').show();
161				ValidAddress = true;
162			} else {
163				$('#address\\.postcode').parent().next().find('.validation').hide();
164			}
165			if(!ValidAddress){
166				ACC.common.blockFormAndShowProcessingMessage($(this));
167				$('.billingAddressForm').filter(":hidden").remove();
168				ACC.silentorderpost.enableAddressForm();
169				$('#silentOrderPostForm').submit();		
170			}
171			//Validation for billing address
172			return !ValidAddress;
173		
174		});
175	},
176
177	bindCycleFocusEvent: function ()
178	{
179		$('#lastInTheForm').blur(function ()
180		{
181			$('#silentOrderPostForm [tabindex$="10"]').focus();
182		})
183	},
184
185	isEmpty: function (obj)
186	{
187		if (typeof obj == 'undefined' || obj === null || obj === '') return true;
188		return false;
189	},
190
191	disableAddressForm: function ()
192	{
193		$('input[id^="address\\."]').prop('disabled', true);
194		$('select[id^="address\\."]').prop('disabled', true);
195	},
196
197	enableAddressForm: function ()
198	{
199		$('input[id^="address\\."]').prop('disabled', false);
200		$('select[id^="address\\."]').prop('disabled', false);
201	},
202
203	clearAddressForm: function ()
204	{
205		$('input[id^="address\\."]').val("");
206		$('select[id^="address\\."]').val("");
207	},
208
209	useDeliveryAddressSelected: function ()
210	{
211		if ($('#useDeliveryAddress').is(":checked"))
212		{
213			$("#billingCountrySelector").find('.error').remove();
214			$('#address\\.country').val($('#useDeliveryAddressData').data('countryisocode'));
215			ACC.silentorderpost.disableAddressForm();
216		}
217		else
218		{
219			ACC.silentorderpost.clearAddressForm();
220			ACC.silentorderpost.enableAddressForm();
221		}
222	},
223	
224	
225
226	bindCreditCardAddressForm: function ()
227	{
228		$('#billingCountrySelector :input').on("change", function ()
229		{
230			var countrySelection = $(this).val();
231			var options = {
232				'countryIsoCode': countrySelection,
233				'useDeliveryAddress': false
234			};
235			ACC.silentorderpost.displayCreditCardAddressForm(options);
236		})
237	},
238
239	displayCreditCardAddressForm: function (options, callback)
240	{
241		$.ajax({ 
242			url: ACC.config.encodedContextPath + '/checkout/multi/sop/billingaddressform',
243			async: true,
244			data: options,
245			dataType: "html",
246			beforeSend: function ()
247			{
248				$('#billingAddressForm').html(ACC.silentorderpost.spinner);
249			}
250		}).done(function (data)
251				{
252					$("#billingAddressForm").html(data);
253					if (typeof callback == 'function')
254					{
255						callback.call();
256					}
257				});
258	}
259}
260
261$(document).ready(function ()
262{
263	with (ACC.silentorderpost)
264	{
265		bindUseDeliveryAddress()
266		bindSubmitSilentOrderPostForm();
267		bindCreditCardAddressForm();
268	}
269
270	// check the checkbox
271	/*$("#useDeliveryAddress").click();*/
272});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.