Subversion Repositories SmartDukaan

Rev

Rev 6795 | Rev 6840 | 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
 
6829 kshitij.so 39
	$('#otg_know_more','.otg_know_more').click(function(){
6552 kshitij.so 40
		$.colorbox({
41
    		width: "490px",
6772 kshitij.so 42
    		height: "420px",
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>"+
6772 kshitij.so 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>"+
6598 amit.gupta 56
        "<span class='right'><a target='_blank' href='/static/on-time-guarantee' style='margin-right: 12px';>Detailed Terms & Conditions</a></span>",
6552 kshitij.so 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 />" +
6772 kshitij.so 86
    		"<ul style='list-style : disc none none; padding-left: 20px; text-align:justify; padding-right: 10px;'><li>Select EMI on Make Payment Page to see Monthly EMI payable and Total Amount Payable.</li>"+
87
    		"<br>"+
88
            "<table width='94%' 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: 0px'>"+
89
            "<thead>"+
90
            "<tr>"+
91
            "<th width='9%' style='border-left: 1px solid gray; border-top: 1px solid gray;border-bottom: 1px solid gray;text-align: center;'>Duration</th>"+
92
            "<th width='42%' style='border:1px solid gray;text-align: center;' colspan='2'>All Inclusive 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;'>"+
98
            "</td>"+
99
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray;border-right: 1px solid gray;text-align: center;'>HDFC</td>"+
100
            "<td style='border-bottom: 1px solid gray;border-right: 1px solid gray;text-align: center;'>Citibank</td>"+
101
            "<tr>"+
102
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>3 months</td>"+
103
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>0</td>"+
104
            "<td style='border-bottom: 1px solid gray; border-right: 1px solid gray; text-align: center;'>0</td>"+
105
            "</tr><tr>"+
106
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>6 months</td>"+
107
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>4.22%</td>"+
108
            "<td style='border-bottom: 1px solid gray; border-right: 1px solid gray; text-align: center;'>4.22%</td>"+
109
            "</tr><tr>"+
110
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>9 months</td>"+
111
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>7.04%</td>"+
112
            "<td style='text-align: center; border-right: 1px solid gray; border-bottom: 1px solid gray;'>NA</td>"+
113
            "</tr>"+
114
            "<tr>"+
115
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>12 months</td>"+
116
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>9.67%</td>"+
117
            "<td style='border-bottom: 1px solid gray; border-right: 1px solid gray; text-align: center;'>NA</td>"+
118
            "</tr>"+
119
            "</tbody>"+
120
            "</table>"+
121
            "<span>*Inclusive of service tax.<br></span>"+
122
            "<br>"+
123
            "<li>Minimum Payment for EMI Option is as follows</li>"+
124
            "<br>"+
125
            "<table width='50%' 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: 0px'>"+
126
            "<thead>"+
127
            "<tr>"+
128
            "<th width='50%' style='border-left: 1px solid gray; border-top: 1px solid gray;border-bottom: 1px solid gray;text-align: center;'>Bank</th>"+
129
            "<th width='50%' style='border:1px solid gray;text-align: center;'>Minimum Amount</th>"+
130
            "</tr>"+
131
            "</thead>"+
132
            "<tbody>"+
133
            "<tr>"+
134
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>HDFC</td>"+
135
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>200</td>"+
136
            "</tr>"+
137
            "<tr>"+
138
            "<td style='border-bottom: 1px solid gray; border-left: 1px solid gray; text-align: center;'>Citibank</td>"+
139
            "<td style='border-right: 1px solid gray; border-bottom: 1px solid gray; border-left: 1px solid gray;text-align: center;'>200</td>"+
140
            "</tr>"+
141
            "</tbody>"+
142
            "</table>"+
143
            "<br>"+
144
            "<li>Credit limit of full amount is needed and blocked at the time of buying on EMI.</li>"+
145
            "<br>"+
146
            "<li>As you pay the installments, correspondingly your credit limit increases.</li>"+
147
            "<br>"+
148
            "<li>EMI option Coming Soon for ICICI, Standard Chartered, SBI, KOTAK, HSBC, IndusInd and Axis Bank.</li>"+
149
            "</ul>",
6453 kshitij.so 150
			onComplete: function(){
151
				trackEventWithGA('Widget', 'Emi info widget is clicked', '');
152
			}
153
    	});
154
	});
6245 kshitij.so 155
 
6792 vikram.rag 156
	$('a.mk_best_deal_detail').live('click', function(){
157
		var offerLinkHtml = '';
158
		if(OFFER_HELP_LINK!='$OFFER_DETAIL_LINK') {
6795 vikram.rag 159
			offerLinkHtml = '<a target="_blank" href="' +OFFER_HELP_LINK + '" style="z-index: 1; float: right; bottom: 0px; right: 0px; margin: 15px; position: relative;">More</a></span>';
6792 vikram.rag 160
		}
161
		$.colorbox({
162
			width: "550px",
163
    		height: "300px",
164
    		inline: true,
165
    		href: '<h3 style="text-align: left; padding: 10px;">Offer Details</h3>' +
166
    			'<p style="text-align: justify; line-height: 22px; margin: 12px;">' + OFFER_HELP_TEXT +
167
    			'</p><span class="right">' + offerLinkHtml 
168
		});
169
	});
6453 kshitij.so 170
 
6792 vikram.rag 171
 
6245 kshitij.so 172
	$('#pickupstoreInfo').click(function(){
173
		$.colorbox({
174
    		width: "550px",
175
    		height: "370px",
176
    		inline: true,
177
    		href: "<h3>Frequently Asked Questions</h3><br />" +
178
		"<b>Q)</b> What is 'Buy Online & Pickup in Store' ?<br /><br />" +
179
		"<b>A)</b> Buy Online from Saholic.Com and pickup your product from the nearest Spice Hotspot Retail Store.<br /><br />" +
180
		"<b>Q)</b> How do i avail this facility ?<br /><br />" +
181
		"<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 />"+
182
		"<b>Q)</b> When will the product be available for pickup ?<br /><br />" +
183
		"<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 />",
184
 
185
			onComplete: function(){
6262 amit.gupta 186
				var ev = "Product Page";
6303 amit.gupta 187
				var label = window.location.pathname;
6264 amit.gupta 188
				if (label=="" || label=="#")
6261 amit.gupta 189
				{
6303 amit.gupta 190
					label = "";
6262 amit.gupta 191
					ev = "Home Page";
6261 amit.gupta 192
				}
6262 amit.gupta 193
				else if (label.indexOf("shipping") != -1){
194
					ev = "Shipping Page";
195
					var blkstr = [];
6263 amit.gupta 196
					jQuery("#cartDetail").find("span.cart-item-name").each(function(key,str){
6262 amit.gupta 197
						blkstr.push(str);
198
					});
6303 amit.gupta 199
					label = blkstr.join(", ");
200
				} else if (label.substr(label.lastIndexOf('/') + 1).length==5 && typeof label.substr(label.lastIndexOf('/') + 1) =="number") {
201
					ev = "Category Page";
202
				} else if (label.substr(label.lastIndexOf('-') + 1).length==7  && typeof label.substr(label.lastIndexOf('-') + 1) =="number") {
203
					ev = "Product Page";
6262 amit.gupta 204
				}
6261 amit.gupta 205
				trackEventWithGA('Pickup in Store LightBox', ev, label);
6245 kshitij.so 206
			}
207
    	});
208
	});
4126 varun.gupt 209
 
5420 amit.gupta 210
	$('.common-widget-top-bar').live('click', function(e, callback){
4126 varun.gupt 211
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
212
		var widgetBox = $(this).siblings('.common-widget-content-area');
213
		var controlBox = $(this).siblings('.common-widget-control-bar');
214
		var controlBoxArrowImg = $(this).find('img');
4210 varun.gupt 215
 
4126 varun.gupt 216
		if (isColapsed)	{
217
			if(controlBox.length > 0)	{
218
				$(controlBox).slideDown('fast', function(){
5420 amit.gupta 219
					$(widgetBox).slideDown('fast', callback);
4126 varun.gupt 220
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
221
				});
222
			} else	{
223
				$(widgetBox).slideDown();
224
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
225
			}
226
		} else	{
227
			$(widgetBox).slideUp(function(){
228
				$(controlBox).slideUp('fast');
229
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
230
			});
231
		}
232
		$(this).data('is_colapsed', !isColapsed);
233
	});
234
 
235
	/**
236
	 * Update count of products checked for comparison
237
	 **/
238
	$('#myresearch input[type="checkbox"]').live('click', function(){
4798 varun.gupt 239
		updateCompareCount();
4126 varun.gupt 240
	});
241
 
242
	$("#research_compare").live('click', function(){
243
		var seldata = "";
5322 amit.gupta 244
		var prodnames = "";
4126 varun.gupt 245
		var tot = 1;
246
		var saprt = "";
247
		var par = $('#myresearch').find('input[type=checkbox]:checked');
4926 varun.gupt 248
		var haveSameProductType = true;
249
		var productType = null;
250
 
4126 varun.gupt 251
		$(par).each(function(){
4926 varun.gupt 252
 
253
			if(productType != null && productType != $(this).attr('producttype'))	{
254
				haveSameProductType = false;
255
			}
256
			productType = $(this).attr('producttype');
257
 
4126 varun.gupt 258
			if(tot == 1)	{
5358 amit.gupta 259
				prodnames += $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 260
				seldata += "p" + tot + "=" + $(this).val();
261
			} else	{
262
				seldata += "&p" + tot + "=" + $(this).val();
5358 amit.gupta 263
				prodnames += "-vs-" + $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 264
			}
265
			tot ++;
266
		});
4984 varun.gupt 267
 
4926 varun.gupt 268
		if(! haveSameProductType)	{
269
			alert("Only products of same category can be compared");
270
		} else if(tot > 6)	{
4126 varun.gupt 271
			alert("Can compare upto five products only.");
272
		} else if(tot > 2)	{
5552 phani.kuma 273
			window.location = "/compare-" + productType.replace(/ +/g, '-').toLowerCase() + "/" + prodnames + "?" + seldata+"&fromsrc=comparison_widget";
4126 varun.gupt 274
		} else	{
275
			alert("Please select atleast two products");
276
		}
277
	});
278
 
279
	$("#research_delete").live('click', function(){
280
		var research_tot = $("#research_total").val();
281
		var seldata = [];
282
		var tot = 0;
283
		var saprt = "";
284
		var par = $('#myresearch').find('input[type=checkbox]:checked');
285
 
286
		$(par).each(function(){
287
			seldata.unshift($(this).val());
288
			tot ++;
289
		});
290
 
291
		if(tot > 0)	{
292
			var t = (research_tot * 1) - (tot * 1);
293
			$("#research_total").val(t);
294
 
295
			jQuery.ajax({
296
				type: "GET",
297
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
298
				success: function(msg)	{
299
					jQuery.each(seldata, function(intIndex, objValue){
300
						delete_from_storage_set("resitems", objValue);
301
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
302
							$(this).remove();
303
							if(t === 0)	{
304
								$("#research_default").css("display", "block");
305
							}
306
						});
307
					});
4984 varun.gupt 308
 
4922 varun.gupt 309
					//Updating the count
310
					$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
4984 varun.gupt 311
 
312
					if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0)	{
313
						$("#myresearch").children(".common-widget-top-bar").trigger('click');
314
					}
4126 varun.gupt 315
				}
316
			});
317
		} else	{
318
			alert("Please select atleast one product");
319
		}
320
	});
321
 
322
	// No uid cookie
323
	if (!$.cookie("uid"))	{
324
		// No uid in storage
325
		if (!$.Storage.get("uid"))	{
326
			if (!$.Storage.get("resitems"))	{
327
				$.Storage.set("resitems", "[]");
328
			}
329
			if (!$.Storage.get("histitems"))	{
330
				$.Storage.set("histitems", "[]");
331
			}
332
		}
333
		else	{			// uid in storage : logout
334
			$.Storage.remove("uid");
335
			$.Storage.set("resitems", "[]");
336
			$.Storage.set("histitems", "[]");
337
		}
338
		load_research_widget();
339
		load_history_widget();
340
	}
341
	else	{				// With uid cookie
342
		var cookie = $.cookie("uid");
343
		// Just logged in merge storage items
344
		if (!$.Storage.get("uid"))	{
345
			$.Storage.set("uid", cookie);
346
			merge_history_items();
347
			load_research_items();
348
		}
349
		else	{
350
			// UID changed
351
			if ( cookie != $.Storage.get("uid"))	{
352
				$.Storage.set("uid", cookie);
353
				$.Storage.set("resitems", "[]");
354
				$.Storage.set("histitems", "[]");
355
				merge_history_items();
356
				load_research_items();
357
			}
358
			else	{		// Uid is same
359
				if (!$.Storage.get("resitems"))	{
360
					$.Storage.set("resitems", "[]");
361
					load_research_items();
362
				}
363
				else	{
364
					load_research_widget();
365
				}
366
 
367
				if (!$.Storage.get("histitems"))	{
368
					$.Storage.set("histitems", "[]");
369
					merge_history_items();
370
				}
371
				else	{
372
					load_history_widget();
373
				}
374
			}
375
		}
376
	}
4798 varun.gupt 377
 
378
	function load_research_items(){
379
		jQuery.ajax({
380
			type: "GET",
381
			url: "/myresearch",
382
			cache: false,
383
			success: function(json) {
384
			    $.Storage.set("resitems", json);
385
			    load_research_widget();
386
		    }
387
		});
388
	}
389
 
390
	function load_research_widget(){
391
		var myResearchWidgetContainer = $("#myresearch");
392
 
393
		if($(myResearchWidgetContainer).length == 0) {
394
			return;
395
		}
396
		var resitems = $.Storage.get("resitems");
397
 
398
		if (resitems == "[]") {
399
			var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
400
		      <tbody>\
401
		        <tr><td align="center"><b>Add items to compare list</b></td></tr>\
402
		       </tbody>\
403
		      </table>';
404
			$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
405
			$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
406
			return;
407
		}
408
		var params = "/" + resitems;
409
 
410
		jQuery.ajax({
411
			type : "GET",
412
			url : "/myresearch" + params,
413
			cache: true,
414
			success : function(html) {
415
	   		    $("#myresearch").html(html);
416
	   			updateCompareCount();
417
 
418
			    // Product Title
419
			    $("#myresearch table td div a.truncate").each(function() {
420
						$(this).truncate({addtitle : true});
421
			    });
422
 
423
			    // Product Price
424
			    $("#myresearch table td div div.price").each(function() {
425
						$(this).truncate({addtitle : true});
426
				});
427
 
428
			    // Product Details
429
			    $("#myresearch table td div div.text").each(function() {
430
						$(this).truncate( {addtitle : true});
431
				});
432
		    }
433
		});
434
	}
4126 varun.gupt 435
});