| 1456 |
varun.gupt |
1 |
$(function(){
|
|
|
2 |
$('#loopedSlider').loopedSlider();
|
|
|
3 |
|
|
|
4 |
runEffect();
|
|
|
5 |
|
|
|
6 |
$(".controls").tabs();
|
|
|
7 |
|
|
|
8 |
$('#forgot_username_link').tipsy({gravity: 'w'});
|
|
|
9 |
|
|
|
10 |
$("#zipcode").val($("#defaultpincode").val());
|
| 4934 |
amit.gupta |
11 |
|
|
|
12 |
if(typeof Entity != 'undefined'){
|
|
|
13 |
var select = $("#colorSelector");
|
| 5373 |
rajveer |
14 |
if(Entity.orderedItems){
|
| 5347 |
amit.gupta |
15 |
$.each(Entity.orderedItems, function(index, sort) {
|
|
|
16 |
select.find('option[value="' + sort + '"]').appendTo(select);
|
|
|
17 |
});
|
|
|
18 |
$("#item_id").val(Entity.orderedItems[0]);
|
| 5889 |
amit.gupta |
19 |
onColorSelectorChange(Entity.orderedItems[0]);
|
| 5347 |
amit.gupta |
20 |
}
|
| 4934 |
amit.gupta |
21 |
select.find("option:eq(0)").remove();
|
|
|
22 |
}
|
| 1456 |
varun.gupt |
23 |
|
| 1761 |
vikas |
24 |
var prodid = $("#product_id").val();
|
|
|
25 |
|
|
|
26 |
add_to_storage_set("histitems", prodid);
|
|
|
27 |
|
| 2652 |
rajveer |
28 |
load_accessories_widget();
|
| 3406 |
rajveer |
29 |
|
|
|
30 |
load_most_compared_widget();
|
| 2754 |
rajveer |
31 |
|
| 2731 |
varun.gupt |
32 |
|
| 4489 |
varun.gupt |
33 |
// Fix to always show first image's title on page load
|
| 4530 |
mandeep.dh |
34 |
if ("undefined" != typeof(title_1)){
|
|
|
35 |
$('.slides .modelName').html(title_1[0]);
|
|
|
36 |
}
|
| 4489 |
varun.gupt |
37 |
|
| 4530 |
mandeep.dh |
38 |
|
| 3830 |
chandransh |
39 |
function getSeletectedItemId(){
|
|
|
40 |
return $("#item_id").val();
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
|
| 1922 |
varun.gupt |
44 |
/**
|
|
|
45 |
* Code to track user clicks on Product slides and 'Proceed to Payment' option
|
|
|
46 |
*/
|
|
|
47 |
$('a.vt').click(function(){
|
|
|
48 |
trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
|
|
|
49 |
});
|
|
|
50 |
|
| 3830 |
chandransh |
51 |
$('#computeShippingEstimate').click(function(){
|
|
|
52 |
updateEstimate(getSeletectedItemId());
|
|
|
53 |
});
|
|
|
54 |
|
|
|
55 |
$("#addToCart").click(function(){
|
| 2811 |
rajveer |
56 |
jQuery.ajax({
|
| 1456 |
varun.gupt |
57 |
type: "POST",
|
| 1614 |
rajveer |
58 |
url: "/addtocart",
|
| 3830 |
chandransh |
59 |
data: "productid=" + getSeletectedItemId(),
|
| 1456 |
varun.gupt |
60 |
success: function(msg) {
|
| 4530 |
mandeep.dh |
61 |
if(msg == "") {
|
| 3830 |
chandransh |
62 |
trackEventWithGA('Order', 'Add to Cart', getSeletectedItemId() + '');
|
| 2036 |
rajveer |
63 |
window.location = "/cart";
|
| 4530 |
mandeep.dh |
64 |
} else {
|
| 4934 |
amit.gupta |
65 |
var productDetail = $("#productDetail");
|
|
|
66 |
var prodInfo = $(productDetail).find("span.brand").html() + $(productDetail).find("span.product-name").html();
|
| 2810 |
rajveer |
67 |
displayRelatedProducts(msg);
|
| 4934 |
amit.gupta |
68 |
trackEventWithGA('Order', 'OOS Lightbox', prodInfo);
|
| 4530 |
mandeep.dh |
69 |
}
|
| 2754 |
rajveer |
70 |
}
|
| 1456 |
varun.gupt |
71 |
});
|
|
|
72 |
});
|
|
|
73 |
|
| 3830 |
chandransh |
74 |
$("#colorSelector").change(function(){
|
|
|
75 |
var itemid = $("#colorSelector option:selected").val();
|
| 5889 |
amit.gupta |
76 |
onColorSelectorChange(itemid);
|
| 1456 |
varun.gupt |
77 |
return false;
|
|
|
78 |
});
|
|
|
79 |
|
| 3830 |
chandransh |
80 |
$(".util_compare").click(function() {
|
| 2755 |
rajveer |
81 |
$.colorbox({
|
|
|
82 |
inline:true,
|
|
|
83 |
href:"#compareLightBox",
|
|
|
84 |
width:"350px",
|
|
|
85 |
height:"230px",
|
|
|
86 |
|
|
|
87 |
onComplete: function(){
|
|
|
88 |
$('#compareLightBox').show();
|
|
|
89 |
},
|
|
|
90 |
onCleanup: function(){
|
|
|
91 |
$('#compareLightBox').hide();
|
|
|
92 |
}
|
|
|
93 |
});
|
| 2228 |
rajveer |
94 |
});
|
| 3830 |
chandransh |
95 |
|
|
|
96 |
$('.util_addnewresearch').click(function(){
|
|
|
97 |
addResearch('', 'single');
|
|
|
98 |
});
|
|
|
99 |
|
| 2236 |
rajveer |
100 |
$('#mobilename').keypress(function(e) {
|
|
|
101 |
if(e.keyCode == 13) {
|
| 5347 |
amit.gupta |
102 |
return compareProducts($("#compare_continue").attr("producttype"));
|
| 2236 |
rajveer |
103 |
}
|
|
|
104 |
});
|
|
|
105 |
|
|
|
106 |
|
| 2228 |
rajveer |
107 |
$("#compare_continue").click(function() {
|
| 5347 |
amit.gupta |
108 |
return compareProducts($(this).attr("producttype"));
|
| 2228 |
rajveer |
109 |
});
|
| 2236 |
rajveer |
110 |
|
| 3305 |
rajveer |
111 |
$('.tooltip').click(function() {
|
|
|
112 |
trackEventWithGA('Product', 'Helpdoc Click', $(this).attr('name'));
|
|
|
113 |
});
|
|
|
114 |
|
| 2320 |
rajveer |
115 |
$('.tooltip').each(function(index) {
|
|
|
116 |
$(this).qtip({
|
|
|
117 |
style: { width: 300, overflow: 'auto',
|
|
|
118 |
tip: { corner: 'topLeft' },
|
|
|
119 |
border: { width: 2, radius: 2, color: '#DDDDDD' } },
|
|
|
120 |
show: { when: { event: 'click' } },
|
|
|
121 |
content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
|
|
|
122 |
hide: { when: { event: 'unfocus' } },
|
|
|
123 |
position: { adjust: {screen: true} }
|
|
|
124 |
});
|
|
|
125 |
});
|
|
|
126 |
|
|
|
127 |
|
| 5347 |
amit.gupta |
128 |
function compareProducts(productType){
|
|
|
129 |
var hyphenatedProductType = productType.replace(/ +/g, '-').toLowerCase();
|
|
|
130 |
|
|
|
131 |
var productName = $("#mobilename").val();
|
| 5358 |
amit.gupta |
132 |
var hypenatedNameTwo = productName.replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
|
| 4143 |
varun.gupt |
133 |
|
| 5347 |
amit.gupta |
134 |
var productTwo = productIdNames[productType][productName];
|
| 2236 |
rajveer |
135 |
if(typeof productTwo == 'undefined'){
|
|
|
136 |
alert("Please select a valid product");
|
|
|
137 |
return false;
|
|
|
138 |
}
|
| 2827 |
rajveer |
139 |
var productOne = $("#catalog_id").val();
|
| 5347 |
amit.gupta |
140 |
var prodDetail = $("#productDetail");
|
|
|
141 |
var productNameOne = $(prodDetail).find("span.brand").html() + " " + $(prodDetail).find("span.product-name").html();
|
| 5358 |
amit.gupta |
142 |
var hyphenateNameOne = productNameOne.replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
|
| 5347 |
amit.gupta |
143 |
window.location = "/compare-" + hyphenatedProductType + "/"
|
| 5552 |
phani.kuma |
144 |
+ hyphenateNameOne + "-vs-" + hypenatedNameTwo + "?p1="+productOne+"&p2="+productTwo+"&fromsrc=product_page";
|
| 2236 |
rajveer |
145 |
}
|
| 2228 |
rajveer |
146 |
|
| 2802 |
rajveer |
147 |
$("#accessories table td div a").live('click', function() {
|
|
|
148 |
var productId = $(this).parent().parent().parent().children().find('input[type=checkbox]').val();
|
|
|
149 |
trackEventWithGA('Widget', 'Accessory Click', productId);
|
|
|
150 |
});
|
|
|
151 |
|
| 5862 |
amit.gupta |
152 |
|
|
|
153 |
$('.nextSlide-anchorLink').live('click', function() {
|
|
|
154 |
var nextSlideLink = $(this).attr('nextSlideId');
|
|
|
155 |
$('a[href="' + nextSlideLink +'"]').click();
|
|
|
156 |
return false;
|
|
|
157 |
});
|
|
|
158 |
|
| 5552 |
phani.kuma |
159 |
$('a.compare-now').live('click', function(){
|
|
|
160 |
var productType = $(this).attr('producttype');
|
|
|
161 |
productType = productType.replace(/ +/g, '-').toLowerCase();
|
|
|
162 |
|
|
|
163 |
var productOne = $("#catalog_id").val();
|
|
|
164 |
var prodDetail = $("#productDetail");
|
|
|
165 |
var productNameOne = $(prodDetail).find("span.brand").html() + " " + $(prodDetail).find("span.product-name").html();
|
|
|
166 |
var hyphenateNameOne = productNameOne.replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
|
|
|
167 |
|
|
|
168 |
var productTwo = $(this).attr("value");
|
|
|
169 |
var hypenatedNameTwo = $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
|
|
|
170 |
|
|
|
171 |
window.location = "/compare-" + productType + "/" + hyphenateNameOne + "-vs-" + hypenatedNameTwo + "?p1="+productOne+"&p2="+productTwo+"&fromsrc=most_compared_widget";
|
|
|
172 |
});
|
|
|
173 |
|
| 1456 |
varun.gupt |
174 |
});
|
|
|
175 |
|
|
|
176 |
function changeSignInClass(){
|
|
|
177 |
if(document.getElementById("signinClass").className.indexOf("signin1") > -1) {
|
|
|
178 |
document.getElementById("signinClass").className = 'signin';
|
|
|
179 |
} else {
|
|
|
180 |
document.getElementById("signinClass").className = 'signin1';
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
|
| 2228 |
rajveer |
184 |
|
| 1456 |
varun.gupt |
185 |
function updateEstimate(itemId) {
|
| 3830 |
chandransh |
186 |
itemId = itemId || $("#colorSelector option:selected").val();
|
| 1456 |
varun.gupt |
187 |
|
|
|
188 |
jQuery.ajax({
|
|
|
189 |
type: "GET",
|
| 1919 |
rajveer |
190 |
url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
|
| 1456 |
varun.gupt |
191 |
beforeSend: function() {
|
| 5234 |
amit.gupta |
192 |
$("#shipping_time").show();
|
|
|
193 |
$("#shipping_time_1").hide();
|
|
|
194 |
$("#shipping_time .red").html("<img src='/images/loader_l.gif'> business days");
|
| 1456 |
varun.gupt |
195 |
},
|
|
|
196 |
success: function(msg) {
|
| 3830 |
chandransh |
197 |
var response = eval('(' + msg + ')');
|
|
|
198 |
var deliveryEstimate = parseInt(response['delivery_estimate']);
|
|
|
199 |
var isCODAvailableForLocation = (response['is_cod_available_for_location'] === 'true');
|
| 6561 |
amit.gupta |
200 |
var isOTG = (response['on_time_guarantee'] === 'true');
|
| 3830 |
chandransh |
201 |
|
|
|
202 |
if(deliveryEstimate == -1) {
|
| 5234 |
amit.gupta |
203 |
$("#shipping_time").hide();
|
|
|
204 |
$("#shipping_time_1").show();
|
| 3830 |
chandransh |
205 |
} else {
|
| 5234 |
amit.gupta |
206 |
$("#shipping_time .red").html(deliveryEstimate + ' Business Days');
|
| 3830 |
chandransh |
207 |
}
|
|
|
208 |
|
| 4869 |
rajveer |
209 |
if (isCODAvailableForLocation) {
|
| 3830 |
chandransh |
210 |
$('#cod').show();
|
|
|
211 |
} else {
|
|
|
212 |
$('#cod').hide();
|
|
|
213 |
}
|
| 6561 |
amit.gupta |
214 |
|
|
|
215 |
if (isOTG) {
|
|
|
216 |
$('#otg').show();
|
|
|
217 |
} else {
|
|
|
218 |
$('#otg').hide();
|
|
|
219 |
}
|
| 1456 |
varun.gupt |
220 |
}
|
|
|
221 |
});
|
| 2228 |
rajveer |
222 |
}
|
|
|
223 |
|
| 3406 |
rajveer |
224 |
function load_most_compared_widget(){
|
|
|
225 |
jQuery.ajax({
|
|
|
226 |
type : "GET",
|
|
|
227 |
url : "/most-compared-products/" + $("#product_id").val(),
|
|
|
228 |
cache: false,
|
|
|
229 |
success : function(html) {
|
|
|
230 |
$("#mostcompared").html(html);
|
|
|
231 |
|
|
|
232 |
// Product Title
|
|
|
233 |
$("#mostcompared table td div a").each(function() {
|
| 5552 |
phani.kuma |
234 |
if($(this).attr('class') != "compare-now"){
|
|
|
235 |
$(this).truncate({addtitle : true});
|
|
|
236 |
}
|
| 3406 |
rajveer |
237 |
});
|
|
|
238 |
|
|
|
239 |
// Product Price
|
|
|
240 |
$("#mostcompared table td div div.price").each(function() {
|
|
|
241 |
$(this).truncate({addtitle : true});
|
|
|
242 |
});
|
|
|
243 |
|
|
|
244 |
// Product Details
|
|
|
245 |
$("#mostcompared table td div div.text").each(function() {
|
|
|
246 |
$(this).truncate( {addtitle : true});
|
|
|
247 |
});
|
|
|
248 |
}
|
|
|
249 |
});
|
| 5889 |
amit.gupta |
250 |
}
|
|
|
251 |
function onColorSelectorChange(itemid){
|
| 6021 |
amit.gupta |
252 |
if($('#sp').length>0){
|
|
|
253 |
$('#sp').html(PARAMETERS[itemid].SP);
|
|
|
254 |
$('#mrp').html(PARAMETERS[itemid].MRP);
|
|
|
255 |
$('#saving').html(PARAMETERS[itemid].SAVING);
|
|
|
256 |
$("#item_id").val(itemid);
|
|
|
257 |
}
|
| 5889 |
amit.gupta |
258 |
updateEstimate(itemid);
|
| 3406 |
rajveer |
259 |
}
|