Subversion Repositories SmartDukaan

Rev

Rev 2762 | Rev 2810 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1456 varun.gupt 1
$(function(){
2
	$('#loopedSlider').loopedSlider();
3
 
4
	runEffect();
5
 
6
	$(".controls").tabs();
7
 
8
	$('#forgot_username_link').tipsy({gravity: 'w'});
9
 
10
	$("#zipcode").val($("#defaultpincode").val());
11
 
12
    updateEstimate();
13
 
1761 vikas 14
    var prodid = $("#product_id").val();
15
 
16
	add_to_storage_set("histitems", prodid);
17
 
1623 rajveer 18
    load_history_widget();
1761 vikas 19
 
2652 rajveer 20
    load_accessories_widget();
2754 rajveer 21
 
2731 varun.gupt 22
    myNotes.getNotes();
23
 
1922 varun.gupt 24
    /**
25
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
26
     */
27
	$('a.vt').click(function(){
28
		trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
29
	});
30
 
1761 vikas 31
    $("#addcart").click(function(){
2762 rajveer 32
    	var catalogid = $("#product_id").val();
1456 varun.gupt 33
		jQuery.ajax({
34
			type: "POST",
1614 rajveer 35
			url: "/addtocart",
1456 varun.gupt 36
			data: "productid=" + $("#item_id").val(),
37
			success: function(msg)	{
2036 rajveer 38
	   			 if(msg==""){
39
					 window.location = "/cart";
40
				 }else{
2762 rajveer 41
					 displayRelatedProducts(msg, catalogid);
2754 rajveer 42
				 }			
43
	   		}
1456 varun.gupt 44
		});
45
	});
46
 
47
	$("#colorselector").change(function(){
48
		var itemid = $("#colorselector option:selected").val();
49
		$('#sp').html(PARAMETERS[itemid].SP);
50
		$('#mrp').html(PARAMETERS[itemid].MRP);
51
		$('#saving').html(PARAMETERS[itemid].SAVING);
52
		$("#item_id").val(itemid);
53
		updateEstimate(itemid);
54
		return false;
55
	});
56
 
57
	$("a.colorselector").click(function() {
58
		$('.a.colorselector').addClass('deselect');
59
		$(this).addClass('deselect');
1567 vikas 60
		var itemid = $(this).attr('itemid');
1456 varun.gupt 61
		$('#sp').html(" "+PARAMETERS[itemid].SP);
62
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
63
		$('#saving').html(PARAMETERS[itemid].SAVING);
64
		$("#item_id").val(itemid);
65
		return false;
66
	});
2228 rajveer 67
 
68
	$("#util_compare").click(function() {
2755 rajveer 69
		$.colorbox({
70
			inline:true, 
71
			href:"#compareLightBox",
72
    		width:"350px",
73
    		height:"230px",
74
 
75
    		onComplete: function(){
76
    			$('#compareLightBox').show();
77
    		},
78
    		onCleanup: function(){
79
    			$('#compareLightBox').hide();
80
    		}
81
    	});
2228 rajveer 82
	});
83
 
84
	/* This code is for compare with button */
85
	var availableNames = [];
86
	for (var k in productIdNames)availableNames.push(k);
2235 rajveer 87
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
2228 rajveer 88
        source: availableNames
89
    });
90
 
91
 
2236 rajveer 92
    $('#mobilename').keypress(function(e) {
93
    	if(e.keyCode == 13) {
94
    		return compareProducts();
95
        }
96
    });
97
 
98
 
2228 rajveer 99
    $("#compare_continue").click(function() {
2236 rajveer 100
    	return compareProducts();
2228 rajveer 101
    });
2236 rajveer 102
 
2320 rajveer 103
    $('.tooltip').each(function(index) {
104
    	   $(this).qtip({
105
    		style: { width: 300, overflow: 'auto',
106
    			tip: { corner: 'topLeft' }, 
107
    			border: { width: 2, radius: 2, color: '#DDDDDD' } },
108
    		show: { when: { event: 'click' } },
109
    		content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
110
    		hide: { when: { event: 'unfocus' } },
111
    		position: { adjust: {screen: true} }
112
    		});
113
    	});
114
 
115
 
2236 rajveer 116
    function compareProducts(){
117
		var productName = $("#mobilename").val();
118
		var productTwo = productIdNames[productName];
119
		if(typeof productTwo == 'undefined'){
120
			alert("Please select a valid product");
121
			return false;
122
		}
123
		var productOne = $("#catelog_id").val();
124
		window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;	
125
	}
2228 rajveer 126
 
2802 rajveer 127
    $("#accessories table td div a").live('click', function() {
128
    	var productId = $(this).parent().parent().parent().children().find('input[type=checkbox]').val();
129
    	trackEventWithGA('Widget', 'Accessory Click', productId);
130
    });
131
 
1456 varun.gupt 132
});
133
 
134
function changeSignInClass(){
135
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
136
		document.getElementById("signinClass").className = 'signin';
137
	} else	{
138
		document.getElementById("signinClass").className = 'signin1';
139
	}
140
}
141
 
2228 rajveer 142
 
1456 varun.gupt 143
function updateEstimate(itemId)	{
144
	itemId = itemId || $("#item_id").val();
145
 
146
	jQuery.ajax({
147
		type: "GET",
1919 rajveer 148
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 149
		beforeSend: function()	{
2652 rajveer 150
			$("#days").html("<img src='/images/loader_l.gif'>");
1456 varun.gupt 151
		},
152
		success: function(msg)	{
153
			$("#shipping_time").html(msg);
154
		}
155
	});
2228 rajveer 156
}
157
 
2652 rajveer 158
function load_accessories_widget(){
159
	jQuery.ajax({
160
		type : "GET",
161
		url : "/related-accessories/" + $("#product_id").val(),
162
		cache: false,
163
		success : function(html) {
164
   		    $("#accessories").html(html);
165
 
166
		    // Product Title
167
		    $("#accessories table td div a").each(function() {
168
					$(this).truncate({addtitle : true});
169
		    });
170
 
171
		    // Product Price
172
		    $("#accessories table td div div.price").each(function() {
173
					$(this).truncate({addtitle : true});
174
			});
175
 
176
		    // Product Details
177
		    $("#accessories table td div div.text").each(function() {
178
					$(this).truncate( {addtitle : true});
179
			});
180
	    }
181
	});
182
}