Subversion Repositories SmartDukaan

Rev

Rev 2755 | Rev 2802 | 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
 
2754 rajveer 127
 
1456 varun.gupt 128
});
129
 
130
function changeSignInClass(){
131
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
132
		document.getElementById("signinClass").className = 'signin';
133
	} else	{
134
		document.getElementById("signinClass").className = 'signin1';
135
	}
136
}
137
 
2228 rajveer 138
 
1456 varun.gupt 139
function updateEstimate(itemId)	{
140
	itemId = itemId || $("#item_id").val();
141
 
142
	jQuery.ajax({
143
		type: "GET",
1919 rajveer 144
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 145
		beforeSend: function()	{
2652 rajveer 146
			$("#days").html("<img src='/images/loader_l.gif'>");
1456 varun.gupt 147
		},
148
		success: function(msg)	{
149
			$("#shipping_time").html(msg);
150
		}
151
	});
2228 rajveer 152
}
153
 
2652 rajveer 154
function load_accessories_widget(){
155
	jQuery.ajax({
156
		type : "GET",
157
		url : "/related-accessories/" + $("#product_id").val(),
158
		cache: false,
159
		success : function(html) {
160
   		    $("#accessories").html(html);
161
 
162
		    // Product Title
163
		    $("#accessories table td div a").each(function() {
164
					$(this).truncate({addtitle : true});
165
		    });
166
 
167
		    // Product Price
168
		    $("#accessories table td div div.price").each(function() {
169
					$(this).truncate({addtitle : true});
170
			});
171
 
172
		    // Product Details
173
		    $("#accessories table td div div.text").each(function() {
174
					$(this).truncate( {addtitle : true});
175
			});
176
	    }
177
	});
178
}