Subversion Repositories SmartDukaan

Rev

Rev 3037 | Rev 3406 | 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
 
2968 rajveer 12
    updateEstimate($("#colorselector option:selected").val());
1456 varun.gupt 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(){
2811 rajveer 32
    	jQuery.ajax({
1456 varun.gupt 33
			type: "POST",
1614 rajveer 34
			url: "/addtocart",
1456 varun.gupt 35
			data: "productid=" + $("#item_id").val(),
36
			success: function(msg)	{
2036 rajveer 37
	   			 if(msg==""){
2985 vikas 38
	   				 trackEventWithGA('Order', 'Add to Cart', $("#item_id").val() + '');
2036 rajveer 39
					 window.location = "/cart";
40
				 }else{
2810 rajveer 41
					 displayRelatedProducts(msg);
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
 
3305 rajveer 103
    $('.tooltip').click(function() {
104
    	trackEventWithGA('Product', 'Helpdoc Click', $(this).attr('name'));
105
    });
106
 
2320 rajveer 107
    $('.tooltip').each(function(index) {
108
    	   $(this).qtip({
109
    		style: { width: 300, overflow: 'auto',
110
    			tip: { corner: 'topLeft' }, 
111
    			border: { width: 2, radius: 2, color: '#DDDDDD' } },
112
    		show: { when: { event: 'click' } },
113
    		content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
114
    		hide: { when: { event: 'unfocus' } },
115
    		position: { adjust: {screen: true} }
116
    		});
117
    	});
118
 
119
 
2236 rajveer 120
    function compareProducts(){
121
		var productName = $("#mobilename").val();
122
		var productTwo = productIdNames[productName];
123
		if(typeof productTwo == 'undefined'){
124
			alert("Please select a valid product");
125
			return false;
126
		}
2827 rajveer 127
		var productOne = $("#catalog_id").val();
2236 rajveer 128
		window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;	
129
	}
2228 rajveer 130
 
2802 rajveer 131
    $("#accessories table td div a").live('click', function() {
132
    	var productId = $(this).parent().parent().parent().children().find('input[type=checkbox]').val();
133
    	trackEventWithGA('Widget', 'Accessory Click', productId);
134
    });
135
 
1456 varun.gupt 136
});
137
 
138
function changeSignInClass(){
139
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
140
		document.getElementById("signinClass").className = 'signin';
141
	} else	{
142
		document.getElementById("signinClass").className = 'signin1';
143
	}
144
}
145
 
2228 rajveer 146
 
1456 varun.gupt 147
function updateEstimate(itemId)	{
148
	itemId = itemId || $("#item_id").val();
149
 
150
	jQuery.ajax({
151
		type: "GET",
1919 rajveer 152
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 153
		beforeSend: function()	{
2931 rajveer 154
			$("#shipping_time").html("Within <img src='/images/loader_l.gif'> business days");
1456 varun.gupt 155
		},
156
		success: function(msg)	{
157
			$("#shipping_time").html(msg);
158
		}
159
	});
2228 rajveer 160
}
161