Subversion Repositories SmartDukaan

Rev

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