| 4126 |
varun.gupt |
1 |
$(function(){
|
| 4984 |
varun.gupt |
2 |
function CollapsibleWidget(container) {
|
|
|
3 |
|
|
|
4 |
this.widgetContainer = container;
|
|
|
5 |
this.collapsbiles = $(container).children('.common-widget-control-bar, .common-widget-content-area');
|
|
|
6 |
this.isCollapsed = null;
|
|
|
7 |
|
|
|
8 |
this.collapse = function() {
|
|
|
9 |
$(this.collapsbiles).each(function() {
|
|
|
10 |
$(this).slideUp();
|
|
|
11 |
});
|
|
|
12 |
this.isCollapsed = true;
|
|
|
13 |
};
|
|
|
14 |
|
|
|
15 |
this.open = function() {
|
|
|
16 |
$(this.collapsbiles).each(function() {
|
|
|
17 |
$(this).slideDown();
|
|
|
18 |
});
|
|
|
19 |
this.isCollapsed = false;
|
|
|
20 |
};
|
|
|
21 |
|
|
|
22 |
this.test = function() {
|
|
|
23 |
};
|
|
|
24 |
}
|
| 4798 |
varun.gupt |
25 |
|
| 4984 |
varun.gupt |
26 |
ResearchWidget.prototype = new CollapsibleWidget();
|
|
|
27 |
ResearchWidget.prototype.constructor = CollapsibleWidget;
|
|
|
28 |
|
|
|
29 |
function ResearchWidget(container) {
|
|
|
30 |
CollapsibleWidget.call(this, container);
|
|
|
31 |
}
|
|
|
32 |
|
| 4798 |
varun.gupt |
33 |
function updateCompareCount() {
|
|
|
34 |
$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length);
|
|
|
35 |
}
|
|
|
36 |
|
| 4126 |
varun.gupt |
37 |
/** Sidebar Widgets **/
|
| 4237 |
varun.gupt |
38 |
|
|
|
39 |
$('#shoppingExpInfo').click(function(){
|
|
|
40 |
$.colorbox({
|
| 4284 |
varun.gupt |
41 |
width: "550px",
|
|
|
42 |
height: "320px",
|
| 4237 |
varun.gupt |
43 |
inline: true,
|
|
|
44 |
href: "<h3>Shopping with Saholic.com is completely safe</h3><br />" +
|
| 4284 |
varun.gupt |
45 |
"<b>1.</b> We are part of Spice Group - India's # 1 Mobile retailer.<br /><br />" +
|
|
|
46 |
"<b>2.</b> We procure directly from the Manufacturers - Hence we only sell genuine products with full Manufacturer Warranty.<br /><br />" +
|
|
|
47 |
"<b>3.</b> We provide free Next Day Delivery to most locations - You can check the delivery time to your location by entering your pin code on the product page.<br /><br />" +
|
| 4372 |
varun.gupt |
48 |
"<b>4.</b> We use the best Internet Security technlology - Your payment is 100% secure.<br />",
|
|
|
49 |
onComplete: function(){
|
|
|
50 |
trackEventWithGA('Widget', 'Empty Cart Message Show', '');
|
|
|
51 |
}
|
| 4237 |
varun.gupt |
52 |
});
|
|
|
53 |
});
|
| 4126 |
varun.gupt |
54 |
|
|
|
55 |
$('.common-widget-top-bar').live('click', function(){
|
|
|
56 |
var isColapsed = $(this).data('is_colapsed') == true ? true : false;
|
|
|
57 |
var widgetBox = $(this).siblings('.common-widget-content-area');
|
|
|
58 |
var controlBox = $(this).siblings('.common-widget-control-bar');
|
|
|
59 |
var controlBoxArrowImg = $(this).find('img');
|
| 4210 |
varun.gupt |
60 |
|
| 4126 |
varun.gupt |
61 |
if (isColapsed) {
|
|
|
62 |
if(controlBox.length > 0) {
|
|
|
63 |
$(controlBox).slideDown('fast', function(){
|
|
|
64 |
$(widgetBox).slideDown();
|
|
|
65 |
$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
|
|
|
66 |
});
|
|
|
67 |
} else {
|
|
|
68 |
$(widgetBox).slideDown();
|
|
|
69 |
$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
|
|
|
70 |
}
|
|
|
71 |
} else {
|
|
|
72 |
$(widgetBox).slideUp(function(){
|
|
|
73 |
$(controlBox).slideUp('fast');
|
|
|
74 |
$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
|
|
|
75 |
});
|
|
|
76 |
}
|
|
|
77 |
$(this).data('is_colapsed', !isColapsed);
|
|
|
78 |
});
|
|
|
79 |
|
|
|
80 |
/**
|
|
|
81 |
* Update count of products checked for comparison
|
|
|
82 |
**/
|
|
|
83 |
$('#myresearch input[type="checkbox"]').live('click', function(){
|
| 4798 |
varun.gupt |
84 |
updateCompareCount();
|
| 4126 |
varun.gupt |
85 |
});
|
|
|
86 |
|
|
|
87 |
$("#research_compare").live('click', function(){
|
|
|
88 |
var seldata = "";
|
|
|
89 |
var tot = 1;
|
|
|
90 |
var saprt = "";
|
|
|
91 |
var par = $('#myresearch').find('input[type=checkbox]:checked');
|
| 4926 |
varun.gupt |
92 |
var haveSameProductType = true;
|
|
|
93 |
var productType = null;
|
|
|
94 |
|
| 4126 |
varun.gupt |
95 |
$(par).each(function(){
|
| 4926 |
varun.gupt |
96 |
|
|
|
97 |
if(productType != null && productType != $(this).attr('producttype')) {
|
|
|
98 |
haveSameProductType = false;
|
|
|
99 |
}
|
|
|
100 |
productType = $(this).attr('producttype');
|
|
|
101 |
|
| 4126 |
varun.gupt |
102 |
if(tot == 1) {
|
|
|
103 |
seldata += "p" + tot + "=" + $(this).val();
|
|
|
104 |
} else {
|
|
|
105 |
seldata += "&p" + tot + "=" + $(this).val();
|
|
|
106 |
}
|
|
|
107 |
tot ++;
|
|
|
108 |
});
|
| 4984 |
varun.gupt |
109 |
|
| 4926 |
varun.gupt |
110 |
if(! haveSameProductType) {
|
|
|
111 |
alert("Only products of same category can be compared");
|
|
|
112 |
} else if(tot > 6) {
|
| 4126 |
varun.gupt |
113 |
alert("Can compare upto five products only.");
|
|
|
114 |
} else if(tot > 2) {
|
|
|
115 |
window.location = "/compare-mobile-phones?" + seldata;
|
|
|
116 |
} else {
|
|
|
117 |
alert("Please select atleast two products");
|
|
|
118 |
}
|
|
|
119 |
});
|
|
|
120 |
|
|
|
121 |
$("#research_delete").live('click', function(){
|
|
|
122 |
var research_tot = $("#research_total").val();
|
|
|
123 |
var seldata = [];
|
|
|
124 |
var tot = 0;
|
|
|
125 |
var saprt = "";
|
|
|
126 |
var par = $('#myresearch').find('input[type=checkbox]:checked');
|
|
|
127 |
|
|
|
128 |
$(par).each(function(){
|
|
|
129 |
seldata.unshift($(this).val());
|
|
|
130 |
tot ++;
|
|
|
131 |
});
|
|
|
132 |
|
|
|
133 |
if(tot > 0) {
|
|
|
134 |
var t = (research_tot * 1) - (tot * 1);
|
|
|
135 |
$("#research_total").val(t);
|
|
|
136 |
|
|
|
137 |
jQuery.ajax({
|
|
|
138 |
type: "GET",
|
|
|
139 |
url: "/deletefromresearch/[" + seldata + "]?_method=delete",
|
|
|
140 |
success: function(msg) {
|
|
|
141 |
jQuery.each(seldata, function(intIndex, objValue){
|
|
|
142 |
delete_from_storage_set("resitems", objValue);
|
|
|
143 |
$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
|
|
|
144 |
$(this).remove();
|
|
|
145 |
if(t === 0) {
|
|
|
146 |
$("#research_default").css("display", "block");
|
|
|
147 |
}
|
|
|
148 |
});
|
|
|
149 |
});
|
| 4984 |
varun.gupt |
150 |
|
| 4922 |
varun.gupt |
151 |
//Updating the count
|
|
|
152 |
$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
|
| 4984 |
varun.gupt |
153 |
|
|
|
154 |
if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0) {
|
|
|
155 |
$("#myresearch").children(".common-widget-top-bar").trigger('click');
|
|
|
156 |
}
|
| 4126 |
varun.gupt |
157 |
}
|
|
|
158 |
});
|
|
|
159 |
} else {
|
|
|
160 |
alert("Please select atleast one product");
|
|
|
161 |
}
|
|
|
162 |
});
|
|
|
163 |
|
|
|
164 |
// No uid cookie
|
|
|
165 |
if (!$.cookie("uid")) {
|
|
|
166 |
// No uid in storage
|
|
|
167 |
if (!$.Storage.get("uid")) {
|
|
|
168 |
if (!$.Storage.get("resitems")) {
|
|
|
169 |
$.Storage.set("resitems", "[]");
|
|
|
170 |
}
|
|
|
171 |
if (!$.Storage.get("histitems")) {
|
|
|
172 |
$.Storage.set("histitems", "[]");
|
|
|
173 |
}
|
|
|
174 |
}
|
|
|
175 |
else { // uid in storage : logout
|
|
|
176 |
$.Storage.remove("uid");
|
|
|
177 |
$.Storage.set("resitems", "[]");
|
|
|
178 |
$.Storage.set("histitems", "[]");
|
|
|
179 |
}
|
|
|
180 |
load_research_widget();
|
|
|
181 |
load_history_widget();
|
|
|
182 |
}
|
|
|
183 |
else { // With uid cookie
|
|
|
184 |
var cookie = $.cookie("uid");
|
|
|
185 |
// Just logged in merge storage items
|
|
|
186 |
if (!$.Storage.get("uid")) {
|
|
|
187 |
$.Storage.set("uid", cookie);
|
|
|
188 |
merge_history_items();
|
|
|
189 |
load_research_items();
|
|
|
190 |
}
|
|
|
191 |
else {
|
|
|
192 |
// UID changed
|
|
|
193 |
if ( cookie != $.Storage.get("uid")) {
|
|
|
194 |
$.Storage.set("uid", cookie);
|
|
|
195 |
$.Storage.set("resitems", "[]");
|
|
|
196 |
$.Storage.set("histitems", "[]");
|
|
|
197 |
merge_history_items();
|
|
|
198 |
load_research_items();
|
|
|
199 |
}
|
|
|
200 |
else { // Uid is same
|
|
|
201 |
if (!$.Storage.get("resitems")) {
|
|
|
202 |
$.Storage.set("resitems", "[]");
|
|
|
203 |
load_research_items();
|
|
|
204 |
}
|
|
|
205 |
else {
|
|
|
206 |
load_research_widget();
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
if (!$.Storage.get("histitems")) {
|
|
|
210 |
$.Storage.set("histitems", "[]");
|
|
|
211 |
merge_history_items();
|
|
|
212 |
}
|
|
|
213 |
else {
|
|
|
214 |
load_history_widget();
|
|
|
215 |
}
|
|
|
216 |
}
|
|
|
217 |
}
|
|
|
218 |
}
|
| 4798 |
varun.gupt |
219 |
|
|
|
220 |
function load_research_items(){
|
|
|
221 |
jQuery.ajax({
|
|
|
222 |
type: "GET",
|
|
|
223 |
url: "/myresearch",
|
|
|
224 |
cache: false,
|
|
|
225 |
success: function(json) {
|
|
|
226 |
$.Storage.set("resitems", json);
|
|
|
227 |
load_research_widget();
|
|
|
228 |
}
|
|
|
229 |
});
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
function load_research_widget(){
|
|
|
233 |
var myResearchWidgetContainer = $("#myresearch");
|
|
|
234 |
|
|
|
235 |
if($(myResearchWidgetContainer).length == 0) {
|
|
|
236 |
return;
|
|
|
237 |
}
|
|
|
238 |
var resitems = $.Storage.get("resitems");
|
|
|
239 |
|
|
|
240 |
if (resitems == "[]") {
|
|
|
241 |
var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
|
|
|
242 |
<tbody>\
|
|
|
243 |
<tr><td align="center"><b>Add items to compare list</b></td></tr>\
|
|
|
244 |
</tbody>\
|
|
|
245 |
</table>';
|
|
|
246 |
$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
|
|
|
247 |
$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
|
|
|
248 |
return;
|
|
|
249 |
}
|
|
|
250 |
var params = "/" + resitems;
|
|
|
251 |
|
|
|
252 |
jQuery.ajax({
|
|
|
253 |
type : "GET",
|
|
|
254 |
url : "/myresearch" + params,
|
|
|
255 |
cache: true,
|
|
|
256 |
success : function(html) {
|
|
|
257 |
$("#myresearch").html(html);
|
|
|
258 |
updateCompareCount();
|
|
|
259 |
|
|
|
260 |
// Product Title
|
|
|
261 |
$("#myresearch table td div a.truncate").each(function() {
|
|
|
262 |
$(this).truncate({addtitle : true});
|
|
|
263 |
});
|
|
|
264 |
|
|
|
265 |
// Product Price
|
|
|
266 |
$("#myresearch table td div div.price").each(function() {
|
|
|
267 |
$(this).truncate({addtitle : true});
|
|
|
268 |
});
|
|
|
269 |
|
|
|
270 |
// Product Details
|
|
|
271 |
$("#myresearch table td div div.text").each(function() {
|
|
|
272 |
$(this).truncate( {addtitle : true});
|
|
|
273 |
});
|
|
|
274 |
}
|
|
|
275 |
});
|
|
|
276 |
}
|
| 4126 |
varun.gupt |
277 |
});
|