Subversion Repositories SmartDukaan

Rev

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