Subversion Repositories SmartDukaan

Rev

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