Subversion Repositories SmartDukaan

Rev

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

Rev 7893 Rev 9301
Line 102... Line 102...
102
			trackEventWithGA('Insurance', 'Agreed to Terms', productId);
102
			trackEventWithGA('Insurance', 'Agreed to Terms', productId);
103
		}
103
		}
104
		jQuery.ajax({
104
		jQuery.ajax({
105
			type: "POST",
105
			type: "POST",
106
			url: "/cart!insureItem",
106
			url: "/cart!insureItem",
107
			data: "toInsure=" + this.checked + "&productId=" + productId + "&quantity=" + $(this).attr('quantity'),
107
			data: "toInsure=" + this.checked + "&productId=" + productId + "&quantity=" + $(this).attr('quantity')+"&insurerType=1",
108
			success: function(response){
108
			success: function(response){
109
				if(response === "SUCCESS") {
109
				if(response === "SUCCESS") {
110
					if ($('#agreeInsuranceTnc_' + productId)[0].checked == true) {
110
					if ($('#agreeInsuranceTnc_' + productId)[0].checked == true) {
111
						$("#insuranceMessage").html("Your product is now insured!");
111
						$("#insuranceMessage").html("Your product is now insured!");
112
					} else {
112
					} else {
Line 121... Line 121...
121
								$("#insuranceMessage").removeAttr('style');
121
								$("#insuranceMessage").removeAttr('style');
122
							});
122
							});
123
						}, 1500);
123
						}, 1500);
124
					});
124
					});
125
				} else {
125
				} else {
-
 
126
					//If we were not able to update user's insurance preference then let's reload.
-
 
127
					location.reload();
-
 
128
					
-
 
129
					//OR ????
-
 
130
					//window.location.href = "/exception";
-
 
131
					
-
 
132
				}
-
 
133
			},
-
 
134
			error : function(){
-
 
135
				//There was an error with AJAX call and we can't be sure what happened; 
-
 
136
				//Let us reload this page and see what was persisted in cart.
-
 
137
				location.reload();
-
 
138
			}
-
 
139
		});
-
 
140
	});
-
 
141
	
-
 
142
$('.dataProtection').change(function() {
-
 
143
	$('.dataProtection').attr('disabled', 'disabled');
-
 
144
		productId = $(this).attr('productid');
-
 
145
		jQuery.ajax({
-
 
146
			type: "POST",
-
 
147
			url: "/cart!insureItem",
-
 
148
			data: "toInsure=" + this.checked + "&productId=" + productId + "&quantity=" + $(this).attr('quantity') +"&insurerType=2",
-
 
149
			success: function(response){
-
 
150
				if(response === "SUCCESS") {
-
 
151
					if ($('#dataProtection_' + productId)[0].checked == true) {
-
 
152
						$("#insuranceMessage").html("Free data protection enabled!");
-
 
153
					} else {
-
 
154
						$("#insuranceMessage").attr('style', 'color:red;border:1px solid red;box-shadow: red 0 0 30px 1px;');
-
 
155
						$("#insuranceMessage").html("Free data protection disabled!");
-
 
156
					}
-
 
157
					$("#insuranceMessage").fadeIn(600, function() {
-
 
158
						window.setTimeout(function() {
-
 
159
							$("#insuranceMessage").fadeOut(800, function() {
-
 
160
								$('.dataProtection').removeAttr('disabled');
-
 
161
								$("#insuranceMessage").removeAttr('style');
-
 
162
							});
-
 
163
						}, 1500);
-
 
164
					});
-
 
165
				} else {
126
					//If we were not able to update user's insurance preference then let's reload.
166
					//If we were not able to update user's insurance preference then let's reload.
127
					location.reload();
167
					location.reload();
128
					
168
					
129
					//OR ????
169
					//OR ????
130
					//window.location.href = "/exception";
170
					//window.location.href = "/exception";