Subversion Repositories SmartDukaan

Rev

Rev 6930 | Rev 7791 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6930 Rev 6971
Line 5... Line 5...
5
	if(window.location.pathname === "/cart") {
5
	if(window.location.pathname === "/cart") {
6
		changeEstimate();
6
		changeEstimate();
7
	}
7
	}
8
	
8
	
9
	$('.wantInsurance').change( function() {
9
	$('.wantInsurance').change( function() {
10
		productId = $(this).parents('tr').prev().attr('id');
10
		productId = $(this).attr('productid');
11
		if(this.checked) {
11
		if(this.checked) {
12
			trackEventWithGA('Insurance', 'Want Insurance', productId);
12
			trackEventWithGA('Insurance', 'Want Insurance', productId);
13
		}
13
		}
14
		totalPrice = $('#totalAmountColumn').text();
14
		totalPrice = $('#totalAmountColumn').text();
15
		var initialPrice = parseFloat(totalPrice.replace(/,/g, ''));
15
		var initialPrice = parseFloat(totalPrice.replace(/,/g, ''));
Line 92... Line 92...
92
		finalString = finalString + '.' + afterDecimal;
92
		finalString = finalString + '.' + afterDecimal;
93
		return finalString;
93
		return finalString;
94
	} 
94
	} 
95
	
95
	
96
	$('.agreeInsuranceTnc').change(function() {
96
	$('.agreeInsuranceTnc').change(function() {
-
 
97
		
97
		$('.agreeInsuranceTnc').attr('disabled', 'disabled');
98
		$('.agreeInsuranceTnc').attr('disabled', 'disabled');
98
		$('.wantInsurance').attr('disabled', 'disabled');
99
		$('.wantInsurance').attr('disabled', 'disabled');
99
		productId = $(this).attr('productid');
100
		productId = $(this).attr('productid');
100
		if(this.checked){
101
		if(this.checked){
101
			trackEventWithGA('Insurance', 'Agreed to Terms', productId);
102
			trackEventWithGA('Insurance', 'Agreed to Terms', productId);
Line 138... Line 139...
138
		});
139
		});
139
	});
140
	});
140
	
141
	
141
	$('#checkout').click(function(){
142
	$('#checkout').click(function(){
142
		if($('input.agreeInsuranceTnc:checkbox:not(:hidden):not(:checked)').length != 0) {
143
		if($('input.agreeInsuranceTnc:checkbox:not(:hidden):not(:checked)').length != 0) {
-
 
144
			trackEventWithGA('Insurance', 'Alert for T&C', '');
143
			alert('Please agree to the terms and conditions to get insurance');
145
			alert('Please agree to the terms and conditions to get insurance');
144
			return false;
146
			return false;
145
		}
147
		}
146
		window.location.href = "/shipping";
148
		window.location.href = "/shipping";
147
	});
149
	});
Line 197... Line 199...
197
		temp = dateStrArray[0];
199
		temp = dateStrArray[0];
198
		dateStrArray[0] = dateStrArray[1];
200
		dateStrArray[0] = dateStrArray[1];
199
		dateStrArray[1] = temp;
201
		dateStrArray[1] = temp;
200
		var enteredDob = new Date(Date.parse(dateStrArray.join('/')));
202
		var enteredDob = new Date(Date.parse(dateStrArray.join('/')));
201
		if(isNaN(enteredDob.getFullYear())) {
203
		if(isNaN(enteredDob.getFullYear())) {
202
			alert('Please enter date of birth in given format');
204
			showInsuranceError('Please enter date of birth in given format');
203
			$('#dob').attr('style', 'color:#999;');
205
			$('#dob').attr('style', 'color:#999;');
204
			$('#dob').val('Example: 18/08/1986');
206
			$('#dob').val('Example: 18/08/1986');
205
			return false;
207
			return false;
206
		}
208
		}
207
		
209
		
208
		var today = new Date();
210
		var today = new Date();
209
		if(today.getFullYear() - enteredDob.getFullYear() < 14) {
211
		if(today.getFullYear() - enteredDob.getFullYear() < 14) {
210
			alert('You need to be at least 14 years old to get Insurance');
212
			showInsuranceError('You need to be at least 14 years old to get Insurance');
211
			$('#dob').attr('style', 'color:#999;');
213
			$('#dob').attr('style', 'color:#999;');
212
			$('#dob').val('Example: 18/08/1986');
214
			$('#dob').val('Example: 18/08/1986');
213
			return false;
215
			return false;
214
		}
216
		}
215
		if(today.getFullYear() - enteredDob.getFullYear() > 100) {
217
		if(today.getFullYear() - enteredDob.getFullYear() > 100) {
216
			alert('Sorry but this feature is only for people below 100 years of age');
218
			showInsuranceError('Sorry but this feature is only for people below 100 years of age');
217
			$('#dob').attr('style', 'color:#999;');
219
			$('#dob').attr('style', 'color:#999;');
218
			$('#dob').val('Example: 18/08/1986');
220
			$('#dob').val('Example: 18/08/1986');
219
			return false;
221
			return false;
220
		}
222
		}
221
		$('#dob').val(enteredDob.toDateString().substring(4));
223
		$('#dob').val(enteredDob.toDateString().substring(4));
222
		return true;
224
		return true;
223
	}
225
	}
224
	
226
	
-
 
227
	function showInsuranceError(msg) {
-
 
228
		$('#insDetErr').html(msg);
-
 
229
		$('#insDetErr').slideDown(300,function(){$('#shippingDetails').one('click', clickHandler);});
-
 
230
	}
-
 
231
	
-
 
232
	function clickHandler() {
-
 
233
		$('#insDetErr').slideUp(300);
-
 
234
		$('#insDetErr').html('');
-
 
235
	}
-
 
236
	
225
	function focusOutHandler() {
237
	function focusOutHandler() {
226
		if($(this).val() === '') {
238
		if($('#dob').val() === '') {
227
			$(this).attr('style', 'color:#999;');
239
			$('#dob').attr('style', 'color:#999;');
228
			$(this).val('Example: 18/08/1986');
240
			$('#dob').val('Example: 18/08/1986');
229
		} else {
241
		} else {
230
			if(validateDob()) {
242
			if(validateDob()) {
231
				$("#dob").animate({ "background-color": "orange"}, 200 );
243
				$("#dob").animate({ "background-color": "#2789C1"}, 200 );
232
				$("#dob").animate({ "background-color": "white"}, 200 );
244
				$("#dob").animate({ "background-color": "white"}, 200 );
233
				$('#dob').val((new Date(Date.parse(dateStrArray.join('/')))).toDateString().substring(4));
245
				$('#dob').val((new Date(Date.parse(dateStrArray.join('/')))).toDateString().substring(4));
234
			}
246
			}
235
		}
247
		}
236
	};
248
	};
Line 247... Line 259...
247
	);
259
	);
248
	
260
	
249
	
261
	
250
	$('#submitInsuranceDetails').click(function() {
262
	$('#submitInsuranceDetails').click(function() {
251
		if($('#guardianName').val() === '') {
263
		if($('#guardianName').val() === '') {
252
			alert('Please enter the name of your Father/Husband');
264
			showInsuranceError('Please enter the name of your Father/Husband');
253
			return false;
265
			return false;
254
		}
266
		}
255
		if($('#dob').val() === '' || $('#dob').val() === 'Example: 18/08/1986') {
267
		if($('#dob').val() === '' || $('#dob').val() === 'Example: 18/08/1986') {
256
			alert('Please enter your date of birth');
268
			showInsuranceError('Please enter your date of birth');
257
			return false;
269
			return false;
258
		}
270
		}
259
		
271
		
260
		if(!validateDob()) {
272
		if(!validateDob()) {
261
			return false;
273
			return false;
Line 291... Line 303...
291
    	});
303
    	});
292
	});
304
	});
293
	
305
	
294
	$('#proceedToPay').click(function(){
306
	$('#proceedToPay').click(function(){
295
		if($('#insuranceDetailsForm:visible').length == 1) {
307
		if($('#insuranceDetailsForm:visible').length == 1) {
296
			alert("Please submit the insurance details first");
308
			showInsuranceError("Please submit the insurance details first");
297
			return false;
309
			return false;
298
		}
310
		}
299
		
311
		
300
		if(($('#store-addresses').find('.default-address').attr('zone') !=  $('#zone-selector').val()) && ($("#tabSelector").val() == "HotSpot")) {
312
		if(($('#store-addresses').find('.default-address').attr('zone') !=  $('#zone-selector').val()) && ($("#tabSelector").val() == "HotSpot")) {
301
			alert("Please select one store address");
313
			alert("Please select one store address");
Line 366... Line 378...
366
		}
378
		}
367
	});
379
	});
368
	
380
	
369
	$('#submitAddress').click(function(){
381
	$('#submitAddress').click(function(){
370
		if($('#guardianName').length > 0 && $('#guardianName').val() === '') {
382
		if($('#guardianName').length > 0 && $('#guardianName').val() === '') {
371
			alert('Please enter the name of your Father/Husband');
383
			showInsuranceError('Please enter the name of your Father/Husband');
372
			return false;
384
			return false;
373
		}
385
		}
374
		if($('#dob').length > 0 && ($('#dob').val() === '' || $('#dob').val() === 'Example: 18/08/1986')) {
386
		if($('#dob').length > 0 && ($('#dob').val() === '' || $('#dob').val() === 'Example: 18/08/1986')) {
375
			alert('Please enter your date of birth');
387
			showInsuranceError('Please enter your date of birth');
376
			return false;
388
			return false;
377
		}
389
		}
378
		
390
		
379
		if($('#dob').length > 0) {
391
		if($('#dob').length > 0) {
380
			if(!validateDob()) {
392
			if(!validateDob()) {