Subversion Repositories SmartDukaan

Rev

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