Subversion Repositories SmartDukaan

Rev

Rev 6453 | Rev 6552 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 />" +
6173 kshitij.so 48
		"<b>4.</b> We use the best Internet Security technology - Your payment is 100% secure.<br />",
4372 varun.gupt 49
			onComplete: function(){
6261 amit.gupta 50
				trackEventWithGA('Widget', 'Safe shopping sticky banner is clicked', '');
4372 varun.gupt 51
			}
4237 varun.gupt 52
    	});
53
	});
6245 kshitij.so 54
 
6453 kshitij.so 55
	$('#emiInfo').click(function(){
56
		$.colorbox({
57
    		width: "550px",
6480 kshitij.so 58
    		height: "450px",
6453 kshitij.so 59
    		inline: true,
60
    		href: "<h3>EMI Details</h3><br />" +
61
    		"<ul style = 'list-style : disc inside none'>"+
62
		"<li>All Inclusive Processing Fee is as follows</li><br />" +
63
		"<table width='46%' cellspacing='0' cellpadding='0' border='0' id='emiwidget' style='padding-top: 2px; padding-bottom: 2px; border-top-width: 0px; border-left-width: 0px;margin-left: 13px'>" +
64
		"<thead>"+
65
		"<tr>"+
66
		"<th width='50%' style='border-left: 1px solid gray; border-top: 1px solid gray;border-bottom: 1px solid gray;text-align: center;'>Months</th>"+
67
		"<th width='50%' style='border:1px solid gray;text-align: center;'>Processing Fee*</th>"+
68
		"</tr>"+
69
		"</thead>"+
70
		"<tbody>"+
71
		"<tr>"+
72
		"<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>3</td>"+
73
		"<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>0</td>"+
74
		"</tr>"+
75
		"<tr>"+
76
		"<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>6</td>"+
77
		"<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>4.05%</td>"+		"</tr>"+
78
		"<tr>"+
79
		"<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>9</td>"+
80
		"<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>6.57%</td>"+
81
		"</tr>"+
82
		"<tr>"+
83
		"<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>12</td>"+
84
		"<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>8.82%</td>"+
85
		"</tr>"+
86
		"</tbody>"+
87
		"</table>"+
88
		"<span style='padding-left:13px'>*Inclusive of service tax.<br/></span>"+
89
		"<br />"+
6480 kshitij.so 90
		"<li>Select EMI on Make Payment Page to see Monthly EMI and Total Amount Paid.</li><br />" +
91
		"<li>Minimum purchase of Rs. 200</li><br />"+
92
		"<li>For HDFC Credit Card Holders, other Banks Coming Soon.</li><br />"+
93
		"<li>Credit limit of full amount is needed and blocked at the time of buying on EMI.</li><br />"+
94
		"<li>As you pay the installments, correspondingly your credit limit will increase.</li><br />"+
6453 kshitij.so 95
		"</ul>",
96
			onComplete: function(){
97
				trackEventWithGA('Widget', 'Emi info widget is clicked', '');
98
			}
99
    	});
100
	});
6245 kshitij.so 101
 
6453 kshitij.so 102
 
6245 kshitij.so 103
	$('#pickupstoreInfo').click(function(){
104
		$.colorbox({
105
    		width: "550px",
106
    		height: "370px",
107
    		inline: true,
108
    		href: "<h3>Frequently Asked Questions</h3><br />" +
109
		"<b>Q)</b> What is 'Buy Online & Pickup in Store' ?<br /><br />" +
110
		"<b>A)</b> Buy Online from Saholic.Com and pickup your product from the nearest Spice Hotspot Retail Store.<br /><br />" +
111
		"<b>Q)</b> How do i avail this facility ?<br /><br />" +
112
		"<b>A)</b> Simply select Pickup In Store On the Shipping Page and select your nearest store. Please note this facility is available only in Delhi/NCR.</a><br /><br />"+
113
		"<b>Q)</b> When will the product be available for pickup ?<br /><br />" +
114
		"<b>A)</b> You can enter your pin code on the Product Page to find estimated time to deliver. After placing the order we will also give you the estimated date for pickup.</a><br /><br />",
115
 
116
			onComplete: function(){
6262 amit.gupta 117
				var ev = "Product Page";
6303 amit.gupta 118
				var label = window.location.pathname;
6264 amit.gupta 119
				if (label=="" || label=="#")
6261 amit.gupta 120
				{
6303 amit.gupta 121
					label = "";
6262 amit.gupta 122
					ev = "Home Page";
6261 amit.gupta 123
				}
6262 amit.gupta 124
				else if (label.indexOf("shipping") != -1){
125
					ev = "Shipping Page";
126
					var blkstr = [];
6263 amit.gupta 127
					jQuery("#cartDetail").find("span.cart-item-name").each(function(key,str){
6262 amit.gupta 128
						blkstr.push(str);
129
					});
6303 amit.gupta 130
					label = blkstr.join(", ");
131
				} else if (label.substr(label.lastIndexOf('/') + 1).length==5 && typeof label.substr(label.lastIndexOf('/') + 1) =="number") {
132
					ev = "Category Page";
133
				} else if (label.substr(label.lastIndexOf('-') + 1).length==7  && typeof label.substr(label.lastIndexOf('-') + 1) =="number") {
134
					ev = "Product Page";
6262 amit.gupta 135
				}
6261 amit.gupta 136
				trackEventWithGA('Pickup in Store LightBox', ev, label);
6245 kshitij.so 137
			}
138
    	});
139
	});
4126 varun.gupt 140
 
5420 amit.gupta 141
	$('.common-widget-top-bar').live('click', function(e, callback){
4126 varun.gupt 142
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
143
		var widgetBox = $(this).siblings('.common-widget-content-area');
144
		var controlBox = $(this).siblings('.common-widget-control-bar');
145
		var controlBoxArrowImg = $(this).find('img');
4210 varun.gupt 146
 
4126 varun.gupt 147
		if (isColapsed)	{
148
			if(controlBox.length > 0)	{
149
				$(controlBox).slideDown('fast', function(){
5420 amit.gupta 150
					$(widgetBox).slideDown('fast', callback);
4126 varun.gupt 151
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
152
				});
153
			} else	{
154
				$(widgetBox).slideDown();
155
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
156
			}
157
		} else	{
158
			$(widgetBox).slideUp(function(){
159
				$(controlBox).slideUp('fast');
160
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
161
			});
162
		}
163
		$(this).data('is_colapsed', !isColapsed);
164
	});
165
 
166
	/**
167
	 * Update count of products checked for comparison
168
	 **/
169
	$('#myresearch input[type="checkbox"]').live('click', function(){
4798 varun.gupt 170
		updateCompareCount();
4126 varun.gupt 171
	});
172
 
173
	$("#research_compare").live('click', function(){
174
		var seldata = "";
5322 amit.gupta 175
		var prodnames = "";
4126 varun.gupt 176
		var tot = 1;
177
		var saprt = "";
178
		var par = $('#myresearch').find('input[type=checkbox]:checked');
4926 varun.gupt 179
		var haveSameProductType = true;
180
		var productType = null;
181
 
4126 varun.gupt 182
		$(par).each(function(){
4926 varun.gupt 183
 
184
			if(productType != null && productType != $(this).attr('producttype'))	{
185
				haveSameProductType = false;
186
			}
187
			productType = $(this).attr('producttype');
188
 
4126 varun.gupt 189
			if(tot == 1)	{
5358 amit.gupta 190
				prodnames += $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 191
				seldata += "p" + tot + "=" + $(this).val();
192
			} else	{
193
				seldata += "&p" + tot + "=" + $(this).val();
5358 amit.gupta 194
				prodnames += "-vs-" + $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 195
			}
196
			tot ++;
197
		});
4984 varun.gupt 198
 
4926 varun.gupt 199
		if(! haveSameProductType)	{
200
			alert("Only products of same category can be compared");
201
		} else if(tot > 6)	{
4126 varun.gupt 202
			alert("Can compare upto five products only.");
203
		} else if(tot > 2)	{
5552 phani.kuma 204
			window.location = "/compare-" + productType.replace(/ +/g, '-').toLowerCase() + "/" + prodnames + "?" + seldata+"&fromsrc=comparison_widget";
4126 varun.gupt 205
		} else	{
206
			alert("Please select atleast two products");
207
		}
208
	});
209
 
210
	$("#research_delete").live('click', function(){
211
		var research_tot = $("#research_total").val();
212
		var seldata = [];
213
		var tot = 0;
214
		var saprt = "";
215
		var par = $('#myresearch').find('input[type=checkbox]:checked');
216
 
217
		$(par).each(function(){
218
			seldata.unshift($(this).val());
219
			tot ++;
220
		});
221
 
222
		if(tot > 0)	{
223
			var t = (research_tot * 1) - (tot * 1);
224
			$("#research_total").val(t);
225
 
226
			jQuery.ajax({
227
				type: "GET",
228
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
229
				success: function(msg)	{
230
					jQuery.each(seldata, function(intIndex, objValue){
231
						delete_from_storage_set("resitems", objValue);
232
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
233
							$(this).remove();
234
							if(t === 0)	{
235
								$("#research_default").css("display", "block");
236
							}
237
						});
238
					});
4984 varun.gupt 239
 
4922 varun.gupt 240
					//Updating the count
241
					$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
4984 varun.gupt 242
 
243
					if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0)	{
244
						$("#myresearch").children(".common-widget-top-bar").trigger('click');
245
					}
4126 varun.gupt 246
				}
247
			});
248
		} else	{
249
			alert("Please select atleast one product");
250
		}
251
	});
252
 
253
	// No uid cookie
254
	if (!$.cookie("uid"))	{
255
		// No uid in storage
256
		if (!$.Storage.get("uid"))	{
257
			if (!$.Storage.get("resitems"))	{
258
				$.Storage.set("resitems", "[]");
259
			}
260
			if (!$.Storage.get("histitems"))	{
261
				$.Storage.set("histitems", "[]");
262
			}
263
		}
264
		else	{			// uid in storage : logout
265
			$.Storage.remove("uid");
266
			$.Storage.set("resitems", "[]");
267
			$.Storage.set("histitems", "[]");
268
		}
269
		load_research_widget();
270
		load_history_widget();
271
	}
272
	else	{				// With uid cookie
273
		var cookie = $.cookie("uid");
274
		// Just logged in merge storage items
275
		if (!$.Storage.get("uid"))	{
276
			$.Storage.set("uid", cookie);
277
			merge_history_items();
278
			load_research_items();
279
		}
280
		else	{
281
			// UID changed
282
			if ( cookie != $.Storage.get("uid"))	{
283
				$.Storage.set("uid", cookie);
284
				$.Storage.set("resitems", "[]");
285
				$.Storage.set("histitems", "[]");
286
				merge_history_items();
287
				load_research_items();
288
			}
289
			else	{		// Uid is same
290
				if (!$.Storage.get("resitems"))	{
291
					$.Storage.set("resitems", "[]");
292
					load_research_items();
293
				}
294
				else	{
295
					load_research_widget();
296
				}
297
 
298
				if (!$.Storage.get("histitems"))	{
299
					$.Storage.set("histitems", "[]");
300
					merge_history_items();
301
				}
302
				else	{
303
					load_history_widget();
304
				}
305
			}
306
		}
307
	}
4798 varun.gupt 308
 
309
	function load_research_items(){
310
		jQuery.ajax({
311
			type: "GET",
312
			url: "/myresearch",
313
			cache: false,
314
			success: function(json) {
315
			    $.Storage.set("resitems", json);
316
			    load_research_widget();
317
		    }
318
		});
319
	}
320
 
321
	function load_research_widget(){
322
		var myResearchWidgetContainer = $("#myresearch");
323
 
324
		if($(myResearchWidgetContainer).length == 0) {
325
			return;
326
		}
327
		var resitems = $.Storage.get("resitems");
328
 
329
		if (resitems == "[]") {
330
			var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
331
		      <tbody>\
332
		        <tr><td align="center"><b>Add items to compare list</b></td></tr>\
333
		       </tbody>\
334
		      </table>';
335
			$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
336
			$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
337
			return;
338
		}
339
		var params = "/" + resitems;
340
 
341
		jQuery.ajax({
342
			type : "GET",
343
			url : "/myresearch" + params,
344
			cache: true,
345
			success : function(html) {
346
	   		    $("#myresearch").html(html);
347
	   			updateCompareCount();
348
 
349
			    // Product Title
350
			    $("#myresearch table td div a.truncate").each(function() {
351
						$(this).truncate({addtitle : true});
352
			    });
353
 
354
			    // Product Price
355
			    $("#myresearch table td div div.price").each(function() {
356
						$(this).truncate({addtitle : true});
357
				});
358
 
359
			    // Product Details
360
			    $("#myresearch table td div div.text").each(function() {
361
						$(this).truncate( {addtitle : true});
362
				});
363
		    }
364
		});
365
	}
4126 varun.gupt 366
});