| 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());
|
|
|
11 |
|
|
|
12 |
updateEstimate();
|
|
|
13 |
|
| 1761 |
vikas |
14 |
var prodid = $("#product_id").val();
|
|
|
15 |
|
|
|
16 |
add_to_storage_set("histitems", prodid);
|
|
|
17 |
|
| 1623 |
rajveer |
18 |
load_history_widget();
|
| 1761 |
vikas |
19 |
|
| 2652 |
rajveer |
20 |
load_accessories_widget();
|
| 2754 |
rajveer |
21 |
|
| 2731 |
varun.gupt |
22 |
myNotes.getNotes();
|
|
|
23 |
|
| 1922 |
varun.gupt |
24 |
/**
|
|
|
25 |
* Code to track user clicks on Product slides and 'Proceed to Payment' option
|
|
|
26 |
*/
|
|
|
27 |
$('a.vt').click(function(){
|
|
|
28 |
trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
|
|
|
29 |
});
|
|
|
30 |
|
| 1761 |
vikas |
31 |
$("#addcart").click(function(){
|
| 1456 |
varun.gupt |
32 |
jQuery.ajax({
|
|
|
33 |
type: "POST",
|
| 1614 |
rajveer |
34 |
url: "/addtocart",
|
| 1456 |
varun.gupt |
35 |
data: "productid=" + $("#item_id").val(),
|
|
|
36 |
success: function(msg) {
|
| 2036 |
rajveer |
37 |
if(msg==""){
|
|
|
38 |
window.location = "/cart";
|
|
|
39 |
}else{
|
| 2754 |
rajveer |
40 |
displayRelatedProducts(msg);
|
|
|
41 |
}
|
|
|
42 |
}
|
| 1456 |
varun.gupt |
43 |
});
|
|
|
44 |
});
|
|
|
45 |
|
|
|
46 |
$("#colorselector").change(function(){
|
|
|
47 |
var itemid = $("#colorselector option:selected").val();
|
|
|
48 |
$('#sp').html(PARAMETERS[itemid].SP);
|
|
|
49 |
$('#mrp').html(PARAMETERS[itemid].MRP);
|
|
|
50 |
$('#saving').html(PARAMETERS[itemid].SAVING);
|
|
|
51 |
$("#item_id").val(itemid);
|
|
|
52 |
updateEstimate(itemid);
|
|
|
53 |
return false;
|
|
|
54 |
});
|
|
|
55 |
|
|
|
56 |
$("a.colorselector").click(function() {
|
|
|
57 |
$('.a.colorselector').addClass('deselect');
|
|
|
58 |
$(this).addClass('deselect');
|
| 1567 |
vikas |
59 |
var itemid = $(this).attr('itemid');
|
| 1456 |
varun.gupt |
60 |
$('#sp').html(" "+PARAMETERS[itemid].SP);
|
|
|
61 |
$('#mrp').html(" "+PARAMETERS[itemid].MRP);
|
|
|
62 |
$('#saving').html(PARAMETERS[itemid].SAVING);
|
|
|
63 |
$("#item_id").val(itemid);
|
|
|
64 |
return false;
|
|
|
65 |
});
|
| 2228 |
rajveer |
66 |
|
|
|
67 |
$("#util_compare").click(function() {
|
| 2754 |
rajveer |
68 |
$.fn.colorbox({inline:true, href:"#compareLightBox", open:true, onComplete:function(){
|
| 2228 |
rajveer |
69 |
var posLeft = (document.documentElement.clientWidth / 2) - (parseInt($('#colorbox').css('width')) / 2);
|
|
|
70 |
var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
|
|
|
71 |
|
|
|
72 |
$('#colorbox').css('top', posTop);
|
|
|
73 |
$('#colorbox').css('left', posLeft);
|
|
|
74 |
}});
|
|
|
75 |
});
|
|
|
76 |
|
|
|
77 |
/* This code is for compare with button */
|
|
|
78 |
var availableNames = [];
|
|
|
79 |
for (var k in productIdNames)availableNames.push(k);
|
| 2235 |
rajveer |
80 |
$("#mobilename").autocomplete({ autoFocus: true, minLength: 3,
|
| 2228 |
rajveer |
81 |
source: availableNames
|
|
|
82 |
});
|
|
|
83 |
|
|
|
84 |
|
| 2236 |
rajveer |
85 |
$('#mobilename').keypress(function(e) {
|
|
|
86 |
if(e.keyCode == 13) {
|
|
|
87 |
return compareProducts();
|
|
|
88 |
}
|
|
|
89 |
});
|
|
|
90 |
|
|
|
91 |
|
| 2228 |
rajveer |
92 |
$("#compare_continue").click(function() {
|
| 2236 |
rajveer |
93 |
return compareProducts();
|
| 2228 |
rajveer |
94 |
});
|
| 2236 |
rajveer |
95 |
|
| 2320 |
rajveer |
96 |
$('.tooltip').each(function(index) {
|
|
|
97 |
$(this).qtip({
|
|
|
98 |
style: { width: 300, overflow: 'auto',
|
|
|
99 |
tip: { corner: 'topLeft' },
|
|
|
100 |
border: { width: 2, radius: 2, color: '#DDDDDD' } },
|
|
|
101 |
show: { when: { event: 'click' } },
|
|
|
102 |
content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
|
|
|
103 |
hide: { when: { event: 'unfocus' } },
|
|
|
104 |
position: { adjust: {screen: true} }
|
|
|
105 |
});
|
|
|
106 |
});
|
|
|
107 |
|
|
|
108 |
|
| 2236 |
rajveer |
109 |
function compareProducts(){
|
|
|
110 |
var productName = $("#mobilename").val();
|
|
|
111 |
var productTwo = productIdNames[productName];
|
|
|
112 |
if(typeof productTwo == 'undefined'){
|
|
|
113 |
alert("Please select a valid product");
|
|
|
114 |
return false;
|
|
|
115 |
}
|
|
|
116 |
var productOne = $("#catelog_id").val();
|
|
|
117 |
window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;
|
|
|
118 |
}
|
| 2228 |
rajveer |
119 |
|
| 2754 |
rajveer |
120 |
function displayRelatedProducts(message){
|
|
|
121 |
var radBtn = "";
|
|
|
122 |
jQuery.ajax({
|
|
|
123 |
type: "GET",
|
|
|
124 |
url: "/related-products/" + $("#product_id").val(),
|
|
|
125 |
data: "productid=" + $("#product_id").val(),
|
|
|
126 |
success: function(msg) {
|
|
|
127 |
radBtn += "<h3 style='margin-top:5px; margin-bottom:5px;'>" + message + "</h3>";
|
|
|
128 |
if($.trim(msg)!=""){
|
|
|
129 |
radBtn += "<span style='font-size:14px; color:#003300; background-color:#ffffdd; margin-bottom:8px;'>You can check out following similar products</span><hr size=1/>";
|
|
|
130 |
}
|
|
|
131 |
radBtn += msg;
|
|
|
132 |
radBtn += '<div class="clearBoth"></div>';
|
|
|
133 |
$("#colorSelLightBoxColor").html(radBtn);
|
|
|
134 |
|
|
|
135 |
$.colorbox({
|
|
|
136 |
inline:true,
|
|
|
137 |
width:"400px",
|
|
|
138 |
height:"410px",
|
|
|
139 |
href:"#colorSelLightBoxColor",
|
|
|
140 |
|
|
|
141 |
onComplete: function(){
|
|
|
142 |
$('#colorSelLightBoxColor').show().find('.widgetChkBox').hide();
|
|
|
143 |
},
|
|
|
144 |
onCleanup: function(){
|
|
|
145 |
$('#colorSelLightBoxColor').hide();
|
|
|
146 |
}
|
|
|
147 |
});
|
|
|
148 |
}
|
|
|
149 |
});
|
|
|
150 |
}
|
|
|
151 |
|
| 1456 |
varun.gupt |
152 |
});
|
|
|
153 |
|
|
|
154 |
function changeSignInClass(){
|
|
|
155 |
if(document.getElementById("signinClass").className.indexOf("signin1") > -1) {
|
|
|
156 |
document.getElementById("signinClass").className = 'signin';
|
|
|
157 |
} else {
|
|
|
158 |
document.getElementById("signinClass").className = 'signin1';
|
|
|
159 |
}
|
|
|
160 |
}
|
|
|
161 |
|
| 2228 |
rajveer |
162 |
|
| 1456 |
varun.gupt |
163 |
function updateEstimate(itemId) {
|
|
|
164 |
itemId = itemId || $("#item_id").val();
|
|
|
165 |
|
|
|
166 |
jQuery.ajax({
|
|
|
167 |
type: "GET",
|
| 1919 |
rajveer |
168 |
url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
|
| 1456 |
varun.gupt |
169 |
beforeSend: function() {
|
| 2652 |
rajveer |
170 |
$("#days").html("<img src='/images/loader_l.gif'>");
|
| 1456 |
varun.gupt |
171 |
},
|
|
|
172 |
success: function(msg) {
|
|
|
173 |
$("#shipping_time").html(msg);
|
|
|
174 |
}
|
|
|
175 |
});
|
| 2228 |
rajveer |
176 |
}
|
|
|
177 |
|
| 2652 |
rajveer |
178 |
function load_accessories_widget(){
|
|
|
179 |
jQuery.ajax({
|
|
|
180 |
type : "GET",
|
|
|
181 |
url : "/related-accessories/" + $("#product_id").val(),
|
|
|
182 |
cache: false,
|
|
|
183 |
success : function(html) {
|
|
|
184 |
$("#accessories").html(html);
|
|
|
185 |
|
|
|
186 |
// Product Title
|
|
|
187 |
$("#accessories table td div a").each(function() {
|
|
|
188 |
$(this).truncate({addtitle : true});
|
|
|
189 |
});
|
|
|
190 |
|
|
|
191 |
// Product Price
|
|
|
192 |
$("#accessories table td div div.price").each(function() {
|
|
|
193 |
$(this).truncate({addtitle : true});
|
|
|
194 |
});
|
|
|
195 |
|
|
|
196 |
// Product Details
|
|
|
197 |
$("#accessories table td div div.text").each(function() {
|
|
|
198 |
$(this).truncate( {addtitle : true});
|
|
|
199 |
});
|
|
|
200 |
}
|
|
|
201 |
});
|
|
|
202 |
}
|