Subversion Repositories SmartDukaan

Rev

Rev 4284 | Rev 4798 | 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(){
2
	/** Sidebar Widgets **/
4237 varun.gupt 3
 
4
	$('#shoppingExpInfo').click(function(){
5
		$.colorbox({
4284 varun.gupt 6
    		width: "550px",
7
    		height: "320px",
4237 varun.gupt 8
    		inline: true,
9
    		href: "<h3>Shopping with Saholic.com is completely safe</h3><br />" +
4284 varun.gupt 10
		"<b>1.</b> We are part of Spice Group - India's # 1 Mobile retailer.<br /><br />" +
11
		"<b>2.</b> We procure directly from the Manufacturers - Hence we only sell genuine products with full Manufacturer Warranty.<br /><br />" +
12
		"<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 />" +
4372 varun.gupt 13
		"<b>4.</b> We use the best Internet Security technlology - Your payment is 100% secure.<br />",
14
			onComplete: function(){
15
				trackEventWithGA('Widget', 'Empty Cart Message Show', '');
16
			}
4237 varun.gupt 17
    	});
18
	});
4126 varun.gupt 19
 
20
	$('.common-widget-top-bar').live('click', function(){
21
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
22
		var widgetBox = $(this).siblings('.common-widget-content-area');
23
		var controlBox = $(this).siblings('.common-widget-control-bar');
24
		var controlBoxArrowImg = $(this).find('img');
4210 varun.gupt 25
 
4126 varun.gupt 26
		if (isColapsed)	{
27
			if(controlBox.length > 0)	{
28
				$(controlBox).slideDown('fast', function(){
29
					$(widgetBox).slideDown();
30
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
31
				});
32
			} else	{
33
				$(widgetBox).slideDown();
34
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
35
			}
36
		} else	{
37
			$(widgetBox).slideUp(function(){
38
				$(controlBox).slideUp('fast');
39
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
40
			});
41
		}
42
		$(this).data('is_colapsed', !isColapsed);
43
	});
44
 
45
	/**
46
	 * Update count of products checked for comparison
47
	 **/
48
	$('#myresearch input[type="checkbox"]').live('click', function(){
49
		$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length);
50
	});
51
 
52
	$("#research_compare").live('click', function(){
53
		var seldata = "";
54
		var tot = 1;
55
		var saprt = "";
56
		var par = $('#myresearch').find('input[type=checkbox]:checked');
57
 
58
		$(par).each(function(){
59
			if(tot == 1)	{
60
				seldata += "p" + tot + "=" + $(this).val();
61
			} else	{
62
				seldata += "&p" + tot + "=" + $(this).val();
63
			}
64
			tot ++;
65
		});
66
 
67
		if(tot > 6)	{
68
			alert("Can compare upto five products only.");
69
		} else if(tot > 2)	{
70
			window.location = "/compare-mobile-phones?" + seldata;
71
		} else	{
72
			alert("Please select atleast two products");
73
		}
74
	});
75
 
76
	$("#research_delete").live('click', function(){
77
		var research_tot = $("#research_total").val();
78
		var seldata = [];
79
		var tot = 0;
80
		var saprt = "";
81
		var par = $('#myresearch').find('input[type=checkbox]:checked');
82
 
83
		$(par).each(function(){
84
			seldata.unshift($(this).val());
85
			tot ++;
86
		});
87
 
88
		if(tot > 0)	{
89
			var t = (research_tot * 1) - (tot * 1);
90
			$("#research_total").val(t);
91
 
92
			jQuery.ajax({
93
				type: "GET",
94
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
95
				success: function(msg)	{
96
					jQuery.each(seldata, function(intIndex, objValue){
97
						delete_from_storage_set("resitems", objValue);
98
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
99
							$(this).remove();
100
							if(t === 0)	{
101
								$("#research_default").css("display", "block");
102
							}
103
						});
104
					});
105
				}
106
			});
107
		} else	{
108
			alert("Please select atleast one product");
109
		}
110
	});
111
 
112
	// No uid cookie
113
	if (!$.cookie("uid"))	{
114
		// No uid in storage
115
		if (!$.Storage.get("uid"))	{
116
			if (!$.Storage.get("resitems"))	{
117
				$.Storage.set("resitems", "[]");
118
			}
119
			if (!$.Storage.get("histitems"))	{
120
				$.Storage.set("histitems", "[]");
121
			}
122
		}
123
		else	{			// uid in storage : logout
124
			$.Storage.remove("uid");
125
			$.Storage.set("resitems", "[]");
126
			$.Storage.set("histitems", "[]");
127
		}
128
		load_research_widget();
129
		load_history_widget();
130
	}
131
	else	{				// With uid cookie
132
		var cookie = $.cookie("uid");
133
		// Just logged in merge storage items
134
		if (!$.Storage.get("uid"))	{
135
			$.Storage.set("uid", cookie);
136
			merge_history_items();
137
			load_research_items();
138
		}
139
		else	{
140
			// UID changed
141
			if ( cookie != $.Storage.get("uid"))	{
142
				$.Storage.set("uid", cookie);
143
				$.Storage.set("resitems", "[]");
144
				$.Storage.set("histitems", "[]");
145
				merge_history_items();
146
				load_research_items();
147
			}
148
			else	{		// Uid is same
149
				if (!$.Storage.get("resitems"))	{
150
					$.Storage.set("resitems", "[]");
151
					load_research_items();
152
				}
153
				else	{
154
					load_research_widget();
155
				}
156
 
157
				if (!$.Storage.get("histitems"))	{
158
					$.Storage.set("histitems", "[]");
159
					merge_history_items();
160
				}
161
				else	{
162
					load_history_widget();
163
				}
164
			}
165
		}
166
	}
167
});