Subversion Repositories SmartDukaan

Rev

Rev 1824 | Rev 1830 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1824 Rev 1829
Line 13... Line 13...
13
     
13
     
14
     NOTE: incase reqtype=list then refdivid should be product id
14
     NOTE: incase reqtype=list then refdivid should be product id
15
     
15
     
16
*/
16
*/
17
var _gaq;
17
var _gaq;
18
$(function() {
-
 
19
 
18
 
-
 
19
function trackEventWithGA(eventCategory, actionName, label)	{
-
 
20
	if(typeof _gaq != undefined && _gaq != null)	{
-
 
21
		_gaq.push(['_trackEvent', eventCategory, actionName, label, 2]);
-
 
22
	}
-
 
23
}
-
 
24
 
-
 
25
$(function() {
20
	$("a.addtocart").live('click', function() {
26
	$("a.addtocart").live('click', function() {
21
		var catalogid = $(this).attr('catalogid');
27
		var catalogid = $(this).attr('catalogid');
22
 
28
 
23
		//Tracking this click for Google Analytics
-
 
24
		if(_gaq && _gaq != null && _gaq != undefined)	{
-
 
25
			_gaq.push(['_trackEvent', 'Order', 'Add to Cart', catalogid, 2]);
29
		trackEventWithGA('Order', 'Add to Cart', catalogid);
26
		}
-
 
27
		
30
		
28
		var radBtn = "";
31
		var radBtn = "";
29
		var param = "PARAMETERS_" + catalogid;
32
		var param = "PARAMETERS_" + catalogid;
30
	
33
	
31
		$.each(eval(param), function(val, text) {
34
		$.each(eval(param), function(val, text) {
Line 77... Line 80...
77
				
80
				
78
			}
81
			}
79
		});
82
		});
80
 	*/
83
 	*/
81
});
84
});
82
	
-
 
83
 
85
 
84
function selectColor(){
86
function selectColor(){
85
	var bValid = true;
87
	var bValid = true;
86
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
88
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
87
	var itemid = selected.val();
89
	var itemid = selected.val();
88
	
90
 
89
	//Tracking this click for Google Analytics
-
 
90
	if(_gaq && _gaq != null && _gaq != undefined)	{
-
 
91
		_gaq.push(['_trackEvent', 'Order', 'Select Product Color', itemid, 2]);
91
	trackEventWithGA('Order', 'Select Product Color', itemid);
92
	}
-
 
93
	
92
	
94
	if(itemid == undefined)	{
93
	if(itemid == undefined)	{
95
		alert('Please select a color.');
94
		alert('Please select a color.');
96
	} else	{
95
	} else	{
97
		addToCart(itemid,'list');
96
		addToCart(itemid,'list');
Line 102... Line 101...
102
function onSelectChange(itemid){
101
function onSelectChange(itemid){
103
	//alert("selected color is"+itemid);
102
	//alert("selected color is"+itemid);
104
}
103
}
105
 
104
 
106
 
105
 
107
function addResearch(refdivid,reqtype){
106
function addResearch(refdivid, reqtype){
108
     var research_tot=$("#research_total").val();
107
     var research_tot = $("#research_total").val();
109
     var seldata=[];
108
     var seldata = [];
110
     var tot=0;
109
     var tot = 0;
111
     
110
     
112
     if(reqtype=="multi"){
111
     if(reqtype == "multi")	{
113
          var containerdiv = "#" + refdivid;     
112
          var containerdiv = "#" + refdivid;     
114
          var par= containerdiv + " input[type=checkbox]:checked";
113
          var par = containerdiv + " input[type=checkbox]:checked";
115
          $(par).each(function(){
114
          $(par).each(function(){
116
               seldata.unshift($(this).val());
115
               seldata.unshift($(this).val());
117
               tot++;
116
               tot ++;
118
          });
117
          });
119
     }else if(reqtype=="single"){
118
     }else if(reqtype == "single")	{
120
    	  seldata.unshift($("#product_id").val());
119
    	  seldata.unshift($("#product_id").val());
121
          var tot=1;
120
          var tot = 1;
122
     }else if(reqtype=="list"){
121
     }else if(reqtype == "list"){
123
    	  seldata.unshift(refdivid);
122
    	  seldata.unshift(refdivid);
124
          var tot=1;
123
          var tot = 1;
125
     }
124
     }
126
 
125
 
127
     //Tracking this click for Google Analytics
-
 
128
     if(_gaq && _gaq != null && _gaq != undefined)	{
-
 
129
     	_gaq.push(['_trackEvent', 'Research', 'Add to Research', seldata + "", 2]);
126
     trackEventWithGA('Research', 'Add to Research', seldata + "");
130
     }
-
 
131
     
127
     
132
     if(tot > 0)	{
128
     if(tot > 0)	{
133
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
129
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
134
          jQuery.ajax({
130
          jQuery.ajax({
135
               type: "POST",
131
               type: "POST",
136
                      url: "/addtoresearch",
132
                      url: "/addtoresearch",
137
                      data: "productid=["+seldata+"]",
133
                      data: "productid=[" + seldata +  "]",
138
                      success: function(msg){
134
                      success: function(msg){
139
                           
135
                           
140
                           if(msg == 0){
136
                           if(msg == 0){
141
                                alert( "Product is already in my research" );
137
                                alert( "Product is already in my research" );
142
                           }else {
138
                           }else {
143
                                var t=(research_tot*1)+(tot*1);
139
                                var t = (research_tot * 1) + (tot * 1);
144
                                $("#research_total").val(t);
140
                                $("#research_total").val(t);
145
                                if(t > 0){
141
                                if(t > 0){
146
                                     $("#research_default").css("display","none");
142
                                     $("#research_default").css("display","none");
147
                                }     
143
                                }     
148
                                $("#pane1").prepend(msg);
144
                                $("#pane1").prepend(msg);