Subversion Repositories SmartDukaan

Rev

Rev 6671 | Rev 6792 | 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
 
6772 kshitij.so 39
	$('#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
 
6453 kshitij.so 156
 
6245 kshitij.so 157
	$('#pickupstoreInfo').click(function(){
158
		$.colorbox({
159
    		width: "550px",
160
    		height: "370px",
161
    		inline: true,
162
    		href: "<h3>Frequently Asked Questions</h3><br />" +
163
		"<b>Q)</b> What is 'Buy Online & Pickup in Store' ?<br /><br />" +
164
		"<b>A)</b> Buy Online from Saholic.Com and pickup your product from the nearest Spice Hotspot Retail Store.<br /><br />" +
165
		"<b>Q)</b> How do i avail this facility ?<br /><br />" +
166
		"<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 />"+
167
		"<b>Q)</b> When will the product be available for pickup ?<br /><br />" +
168
		"<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 />",
169
 
170
			onComplete: function(){
6262 amit.gupta 171
				var ev = "Product Page";
6303 amit.gupta 172
				var label = window.location.pathname;
6264 amit.gupta 173
				if (label=="" || label=="#")
6261 amit.gupta 174
				{
6303 amit.gupta 175
					label = "";
6262 amit.gupta 176
					ev = "Home Page";
6261 amit.gupta 177
				}
6262 amit.gupta 178
				else if (label.indexOf("shipping") != -1){
179
					ev = "Shipping Page";
180
					var blkstr = [];
6263 amit.gupta 181
					jQuery("#cartDetail").find("span.cart-item-name").each(function(key,str){
6262 amit.gupta 182
						blkstr.push(str);
183
					});
6303 amit.gupta 184
					label = blkstr.join(", ");
185
				} else if (label.substr(label.lastIndexOf('/') + 1).length==5 && typeof label.substr(label.lastIndexOf('/') + 1) =="number") {
186
					ev = "Category Page";
187
				} else if (label.substr(label.lastIndexOf('-') + 1).length==7  && typeof label.substr(label.lastIndexOf('-') + 1) =="number") {
188
					ev = "Product Page";
6262 amit.gupta 189
				}
6261 amit.gupta 190
				trackEventWithGA('Pickup in Store LightBox', ev, label);
6245 kshitij.so 191
			}
192
    	});
193
	});
4126 varun.gupt 194
 
5420 amit.gupta 195
	$('.common-widget-top-bar').live('click', function(e, callback){
4126 varun.gupt 196
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
197
		var widgetBox = $(this).siblings('.common-widget-content-area');
198
		var controlBox = $(this).siblings('.common-widget-control-bar');
199
		var controlBoxArrowImg = $(this).find('img');
4210 varun.gupt 200
 
4126 varun.gupt 201
		if (isColapsed)	{
202
			if(controlBox.length > 0)	{
203
				$(controlBox).slideDown('fast', function(){
5420 amit.gupta 204
					$(widgetBox).slideDown('fast', callback);
4126 varun.gupt 205
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
206
				});
207
			} else	{
208
				$(widgetBox).slideDown();
209
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
210
			}
211
		} else	{
212
			$(widgetBox).slideUp(function(){
213
				$(controlBox).slideUp('fast');
214
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
215
			});
216
		}
217
		$(this).data('is_colapsed', !isColapsed);
218
	});
219
 
220
	/**
221
	 * Update count of products checked for comparison
222
	 **/
223
	$('#myresearch input[type="checkbox"]').live('click', function(){
4798 varun.gupt 224
		updateCompareCount();
4126 varun.gupt 225
	});
226
 
227
	$("#research_compare").live('click', function(){
228
		var seldata = "";
5322 amit.gupta 229
		var prodnames = "";
4126 varun.gupt 230
		var tot = 1;
231
		var saprt = "";
232
		var par = $('#myresearch').find('input[type=checkbox]:checked');
4926 varun.gupt 233
		var haveSameProductType = true;
234
		var productType = null;
235
 
4126 varun.gupt 236
		$(par).each(function(){
4926 varun.gupt 237
 
238
			if(productType != null && productType != $(this).attr('producttype'))	{
239
				haveSameProductType = false;
240
			}
241
			productType = $(this).attr('producttype');
242
 
4126 varun.gupt 243
			if(tot == 1)	{
5358 amit.gupta 244
				prodnames += $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 245
				seldata += "p" + tot + "=" + $(this).val();
246
			} else	{
247
				seldata += "&p" + tot + "=" + $(this).val();
5358 amit.gupta 248
				prodnames += "-vs-" + $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 249
			}
250
			tot ++;
251
		});
4984 varun.gupt 252
 
4926 varun.gupt 253
		if(! haveSameProductType)	{
254
			alert("Only products of same category can be compared");
255
		} else if(tot > 6)	{
4126 varun.gupt 256
			alert("Can compare upto five products only.");
257
		} else if(tot > 2)	{
5552 phani.kuma 258
			window.location = "/compare-" + productType.replace(/ +/g, '-').toLowerCase() + "/" + prodnames + "?" + seldata+"&fromsrc=comparison_widget";
4126 varun.gupt 259
		} else	{
260
			alert("Please select atleast two products");
261
		}
262
	});
263
 
264
	$("#research_delete").live('click', function(){
265
		var research_tot = $("#research_total").val();
266
		var seldata = [];
267
		var tot = 0;
268
		var saprt = "";
269
		var par = $('#myresearch').find('input[type=checkbox]:checked');
270
 
271
		$(par).each(function(){
272
			seldata.unshift($(this).val());
273
			tot ++;
274
		});
275
 
276
		if(tot > 0)	{
277
			var t = (research_tot * 1) - (tot * 1);
278
			$("#research_total").val(t);
279
 
280
			jQuery.ajax({
281
				type: "GET",
282
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
283
				success: function(msg)	{
284
					jQuery.each(seldata, function(intIndex, objValue){
285
						delete_from_storage_set("resitems", objValue);
286
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
287
							$(this).remove();
288
							if(t === 0)	{
289
								$("#research_default").css("display", "block");
290
							}
291
						});
292
					});
4984 varun.gupt 293
 
4922 varun.gupt 294
					//Updating the count
295
					$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
4984 varun.gupt 296
 
297
					if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0)	{
298
						$("#myresearch").children(".common-widget-top-bar").trigger('click');
299
					}
4126 varun.gupt 300
				}
301
			});
302
		} else	{
303
			alert("Please select atleast one product");
304
		}
305
	});
306
 
307
	// No uid cookie
308
	if (!$.cookie("uid"))	{
309
		// No uid in storage
310
		if (!$.Storage.get("uid"))	{
311
			if (!$.Storage.get("resitems"))	{
312
				$.Storage.set("resitems", "[]");
313
			}
314
			if (!$.Storage.get("histitems"))	{
315
				$.Storage.set("histitems", "[]");
316
			}
317
		}
318
		else	{			// uid in storage : logout
319
			$.Storage.remove("uid");
320
			$.Storage.set("resitems", "[]");
321
			$.Storage.set("histitems", "[]");
322
		}
323
		load_research_widget();
324
		load_history_widget();
325
	}
326
	else	{				// With uid cookie
327
		var cookie = $.cookie("uid");
328
		// Just logged in merge storage items
329
		if (!$.Storage.get("uid"))	{
330
			$.Storage.set("uid", cookie);
331
			merge_history_items();
332
			load_research_items();
333
		}
334
		else	{
335
			// UID changed
336
			if ( cookie != $.Storage.get("uid"))	{
337
				$.Storage.set("uid", cookie);
338
				$.Storage.set("resitems", "[]");
339
				$.Storage.set("histitems", "[]");
340
				merge_history_items();
341
				load_research_items();
342
			}
343
			else	{		// Uid is same
344
				if (!$.Storage.get("resitems"))	{
345
					$.Storage.set("resitems", "[]");
346
					load_research_items();
347
				}
348
				else	{
349
					load_research_widget();
350
				}
351
 
352
				if (!$.Storage.get("histitems"))	{
353
					$.Storage.set("histitems", "[]");
354
					merge_history_items();
355
				}
356
				else	{
357
					load_history_widget();
358
				}
359
			}
360
		}
361
	}
4798 varun.gupt 362
 
363
	function load_research_items(){
364
		jQuery.ajax({
365
			type: "GET",
366
			url: "/myresearch",
367
			cache: false,
368
			success: function(json) {
369
			    $.Storage.set("resitems", json);
370
			    load_research_widget();
371
		    }
372
		});
373
	}
374
 
375
	function load_research_widget(){
376
		var myResearchWidgetContainer = $("#myresearch");
377
 
378
		if($(myResearchWidgetContainer).length == 0) {
379
			return;
380
		}
381
		var resitems = $.Storage.get("resitems");
382
 
383
		if (resitems == "[]") {
384
			var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
385
		      <tbody>\
386
		        <tr><td align="center"><b>Add items to compare list</b></td></tr>\
387
		       </tbody>\
388
		      </table>';
389
			$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
390
			$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
391
			return;
392
		}
393
		var params = "/" + resitems;
394
 
395
		jQuery.ajax({
396
			type : "GET",
397
			url : "/myresearch" + params,
398
			cache: true,
399
			success : function(html) {
400
	   		    $("#myresearch").html(html);
401
	   			updateCompareCount();
402
 
403
			    // Product Title
404
			    $("#myresearch table td div a.truncate").each(function() {
405
						$(this).truncate({addtitle : true});
406
			    });
407
 
408
			    // Product Price
409
			    $("#myresearch table td div div.price").each(function() {
410
						$(this).truncate({addtitle : true});
411
				});
412
 
413
			    // Product Details
414
			    $("#myresearch table td div div.text").each(function() {
415
						$(this).truncate( {addtitle : true});
416
				});
417
		    }
418
		});
419
	}
4126 varun.gupt 420
});