Subversion Repositories SmartDukaan

Rev

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