Subversion Repositories SmartDukaan

Rev

Rev 2236 | Rev 2652 | 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
 
1922 varun.gupt 20
    /**
21
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
22
     */
23
	$('a.vt').click(function(){
24
		trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
25
	});
26
 
1761 vikas 27
    $("#addcart").click(function(){
1456 varun.gupt 28
		jQuery.ajax({
29
			type: "POST",
1614 rajveer 30
			url: "/addtocart",
1456 varun.gupt 31
			data: "productid=" + $("#item_id").val(),
32
			success: function(msg)	{
2036 rajveer 33
	   			 if(msg==""){
34
					 window.location = "/cart";
35
				 }else{
36
					 alert(msg);
37
				 }			}
1456 varun.gupt 38
		});
39
	});
40
 
41
	$("#colorselector").change(function(){
42
		var itemid = $("#colorselector option:selected").val();
43
 
44
		$('#sp').html(PARAMETERS[itemid].SP);
45
		$('#mrp').html(PARAMETERS[itemid].MRP);
46
		$('#saving').html(PARAMETERS[itemid].SAVING);
47
		$("#item_id").val(itemid);
48
		updateEstimate(itemid);
49
		return false;
50
	});
51
 
52
	$("a.colorselector").click(function() {
53
		$('.a.colorselector').addClass('deselect');
54
		$(this).addClass('deselect');
1567 vikas 55
		var itemid = $(this).attr('itemid');
1456 varun.gupt 56
		$('#sp').html(" "+PARAMETERS[itemid].SP);
57
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
58
		$('#saving').html(PARAMETERS[itemid].SAVING);
59
		$("#item_id").val(itemid);
60
		return false;
61
	});
2228 rajveer 62
 
63
	$("#util_compare").click(function() {
64
		$.fn.colorbox({inline:true, href:".colorSelLightBoxColor", open:true, onComplete:function(){
65
			var posLeft = (document.documentElement.clientWidth / 2) - (parseInt($('#colorbox').css('width')) / 2);
66
			var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
67
 
68
			$('#colorbox').css('top', posTop);
69
			$('#colorbox').css('left', posLeft);
70
		}});
71
	});
72
 
73
	/* This code is for compare with button */
74
	var availableNames = [];
75
	for (var k in productIdNames)availableNames.push(k);
2235 rajveer 76
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
2228 rajveer 77
        source: availableNames
78
    });
79
 
80
 
2236 rajveer 81
    $('#mobilename').keypress(function(e) {
82
    	if(e.keyCode == 13) {
83
    		return compareProducts();
84
        }
85
    });
86
 
87
 
2228 rajveer 88
    $("#compare_continue").click(function() {
2236 rajveer 89
    	return compareProducts();
2228 rajveer 90
    });
2236 rajveer 91
 
2320 rajveer 92
    $('.tooltip').each(function(index) {
93
    	   $(this).qtip({
94
    		style: { width: 300, overflow: 'auto',
95
    			tip: { corner: 'topLeft' }, 
96
    			border: { width: 2, radius: 2, color: '#DDDDDD' } },
97
    		show: { when: { event: 'click' } },
98
    		content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
99
    		hide: { when: { event: 'unfocus' } },
100
    		position: { adjust: {screen: true} }
101
    		});
102
    	});
103
 
104
 
2236 rajveer 105
    function compareProducts(){
106
		var productName = $("#mobilename").val();
107
		var productTwo = productIdNames[productName];
108
		if(typeof productTwo == 'undefined'){
109
			alert("Please select a valid product");
110
			return false;
111
		}
112
		var productOne = $("#catelog_id").val();
113
		window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;	
114
	}
2228 rajveer 115
 
1456 varun.gupt 116
});
117
 
118
function changeSignInClass(){
119
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
120
		document.getElementById("signinClass").className = 'signin';
121
	} else	{
122
		document.getElementById("signinClass").className = 'signin1';
123
	}
124
}
125
 
2228 rajveer 126
 
1456 varun.gupt 127
function updateEstimate(itemId)	{
128
	itemId = itemId || $("#item_id").val();
129
 
130
	jQuery.ajax({
131
		type: "GET",
1919 rajveer 132
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 133
		beforeSend: function()	{
134
			$("#days").html("<img src='../images/loader_l.gif'>");
135
		},
136
		success: function(msg)	{
137
			$("#shipping_time").html(msg);
138
		}
139
	});
2228 rajveer 140
}
141