Subversion Repositories SmartDukaan

Rev

Rev 2652 | Rev 2754 | 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();
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(){
1456 varun.gupt 32
		jQuery.ajax({
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{
40
					 alert(msg);
41
				 }			}
1456 varun.gupt 42
		});
43
	});
44
 
45
	$("#colorselector").change(function(){
46
		var itemid = $("#colorselector option:selected").val();
47
 
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() {
68
		$.fn.colorbox({inline:true, href:".colorSelLightBoxColor", open:true, onComplete:function(){
69
			var posLeft = (document.documentElement.clientWidth / 2) - (parseInt($('#colorbox').css('width')) / 2);
70
			var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
71
 
72
			$('#colorbox').css('top', posTop);
73
			$('#colorbox').css('left', posLeft);
74
		}});
75
	});
76
 
77
	/* This code is for compare with button */
78
	var availableNames = [];
79
	for (var k in productIdNames)availableNames.push(k);
2235 rajveer 80
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
2228 rajveer 81
        source: availableNames
82
    });
83
 
84
 
2236 rajveer 85
    $('#mobilename').keypress(function(e) {
86
    	if(e.keyCode == 13) {
87
    		return compareProducts();
88
        }
89
    });
90
 
91
 
2228 rajveer 92
    $("#compare_continue").click(function() {
2236 rajveer 93
    	return compareProducts();
2228 rajveer 94
    });
2236 rajveer 95
 
2320 rajveer 96
    $('.tooltip').each(function(index) {
97
    	   $(this).qtip({
98
    		style: { width: 300, overflow: 'auto',
99
    			tip: { corner: 'topLeft' }, 
100
    			border: { width: 2, radius: 2, color: '#DDDDDD' } },
101
    		show: { when: { event: 'click' } },
102
    		content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },
103
    		hide: { when: { event: 'unfocus' } },
104
    		position: { adjust: {screen: true} }
105
    		});
106
    	});
107
 
108
 
2236 rajveer 109
    function compareProducts(){
110
		var productName = $("#mobilename").val();
111
		var productTwo = productIdNames[productName];
112
		if(typeof productTwo == 'undefined'){
113
			alert("Please select a valid product");
114
			return false;
115
		}
116
		var productOne = $("#catelog_id").val();
117
		window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;	
118
	}
2228 rajveer 119
 
1456 varun.gupt 120
});
121
 
122
function changeSignInClass(){
123
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
124
		document.getElementById("signinClass").className = 'signin';
125
	} else	{
126
		document.getElementById("signinClass").className = 'signin1';
127
	}
128
}
129
 
2228 rajveer 130
 
1456 varun.gupt 131
function updateEstimate(itemId)	{
132
	itemId = itemId || $("#item_id").val();
133
 
134
	jQuery.ajax({
135
		type: "GET",
1919 rajveer 136
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 137
		beforeSend: function()	{
2652 rajveer 138
			$("#days").html("<img src='/images/loader_l.gif'>");
1456 varun.gupt 139
		},
140
		success: function(msg)	{
141
			$("#shipping_time").html(msg);
142
		}
143
	});
2228 rajveer 144
}
145
 
2652 rajveer 146
function load_accessories_widget(){
147
	jQuery.ajax({
148
		type : "GET",
149
		url : "/related-accessories/" + $("#product_id").val(),
150
		cache: false,
151
		success : function(html) {
152
   		    $("#accessories").html(html);
153
 
154
		    // Product Title
155
		    $("#accessories table td div a").each(function() {
156
					$(this).truncate({addtitle : true});
157
		    });
158
 
159
		    // Product Price
160
		    $("#accessories table td div div.price").each(function() {
161
					$(this).truncate({addtitle : true});
162
			});
163
 
164
		    // Product Details
165
		    $("#accessories table td div div.text").each(function() {
166
					$(this).truncate( {addtitle : true});
167
			});
168
	    }
169
	});
170
}