Subversion Repositories SmartDukaan

Rev

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

Rev 2110 Rev 2633
Line 1... Line 1...
1
/* 
1
/* 
2
     Author: Binay Kumar
-
 
3
     Created on: 30.09.2010
-
 
4
     
-
 
5
     Example:
2
     Example:
6
     addResearch(refdivid,reqtype) refdivid=pane1, reqtype=single/multi
3
     addResearch(refdivid,reqtype) refdivid=pane1, reqtype=single/multi
7
     Multiple request: onclick="javascript:addResearch('pane2','multi');"
4
     Multiple request: onclick="javascript:addResearch('pane2','multi');"
8
     Single request: onclick="javascript:addResearch('','single');"
5
     Single request: onclick="javascript:addResearch('','single');"
9
     
6
     
Line 45... Line 42...
45
			var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
42
			var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
46
 
43
 
47
			$('#colorbox').css('top', posTop);
44
			$('#colorbox').css('top', posTop);
48
			$('#colorbox').css('left', posLeft);
45
			$('#colorbox').css('left', posLeft);
49
		}});
46
		}});
50
		
-
 
51
		/*
-
 
52
		var select = $('#colorselector');
-
 
53
		var options = select.attr('options');
-
 
54
		$('option', select).remove();
-
 
55
		$.each(eval(param), function(val, text) {
-
 
56
		    options[options.length] = new Option(text, val);
-
 
57
		    //alert(val + ": " + text);
-
 
58
		});
-
 
59
		$( "#dialog-form" ).dialog( "open" );
-
 
60
		*/
-
 
61
	});
47
	});
62
	
48
	
63
	/*
-
 
64
	$( "#dialog-form" ).dialog({
-
 
65
		autoOpen: false,
-
 
66
		height: 200,
-
 
67
		width: 250,
-
 
68
		modal: true,
-
 
69
		buttons: {
-
 
70
			Ok: function() {
-
 
71
				var bValid = true;
-
 
72
				var selected = $("#colorselector option:selected");
-
 
73
				var itemid = selected.val();
-
 
74
				addToCart(itemid,'list');
-
 
75
				$( this ).dialog( "close" );
-
 
76
				},
-
 
77
			Cancel: function() {
-
 
78
				$( this ).dialog( "close" );
-
 
79
				}
-
 
80
			},
-
 
81
			close: function() {
-
 
82
				
-
 
83
			}
-
 
84
		});
-
 
85
 	*/
-
 
86
});
49
});
87
 
50
 
88
function selectColor(){
51
function selectColor(){
89
	var bValid = true;
-
 
90
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
52
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
91
	var itemid = selected.val();
53
	var itemid = selected.val();
92
 
54
 
93
	trackEventWithGA('Order', 'Select Product Color', itemid);
55
	trackEventWithGA('Order', 'Select Product Color', itemid);
94
	
56
	
Line 98... Line 60...
98
		addToCart(itemid,'list');
60
		addToCart(itemid,'list');
99
		$.colorbox.close();
61
		$.colorbox.close();
100
	}
62
	}
101
}
63
}
102
 
64
 
103
function onSelectChange(itemid){
-
 
104
	//alert("selected color is"+itemid);
-
 
105
}
-
 
106
 
-
 
107
 
65
 
108
function addResearch(refdivid, reqtype){
66
function addResearch(refdivid, reqtype){
109
     var research_tot = $("#research_total").val();
67
     var research_tot = $("#research_total").val();
110
     var seldata = [];
68
     var seldata = [];
111
     var tot = 0;
69
     var tot = 0;
Line 117... Line 75...
117
               seldata.unshift($(this).val());
75
               seldata.unshift($(this).val());
118
               tot ++;
76
               tot ++;
119
          });
77
          });
120
     }else if(reqtype == "single")	{
78
     }else if(reqtype == "single")	{
121
    	  seldata.unshift($("#product_id").val());
79
    	  seldata.unshift($("#product_id").val());
122
          var tot = 1;
80
          tot = 1;
123
     }else if(reqtype == "list"){
81
     }else if(reqtype == "list"){
124
    	  seldata.unshift(refdivid);
82
    	  seldata.unshift(refdivid);
125
          var tot = 1;
83
          tot = 1;
126
     }
84
     }
127
 
85
 
128
     if(tot > 0)	{
86
     if(tot > 0)	{
129
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
87
          //alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
130
          jQuery.ajax({
88
          jQuery.ajax({
Line 140... Line 98...
140
                                $("#research_total").val(t);
98
                                $("#research_total").val(t);
141
                                if(t > 0){
99
                                if(t > 0){
142
                                     $("#research_default").css("display","none");
100
                                     $("#research_default").css("display","none");
143
                                }     
101
                                }     
144
                                $("#pane1").prepend(msg);
102
                                $("#pane1").prepend(msg);
145
                                // $('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
-
 
146
                                
103
                                
147
                                if(reqtype == "multi"){
104
                                if(reqtype == "multi"){
148
                                     jQuery.each(seldata,function(intIndex, objValue){
105
                                     jQuery.each(seldata,function(intIndex, objValue){
149
                                    	 trackEventWithGA('Research', 'Add to Research', objValue);
106
                                    	 trackEventWithGA('Research', 'Add to Research', objValue);
150
                                    	  add_to_storage_set("resitems", objValue);
107
                                    	  add_to_storage_set("resitems", objValue);
Line 176... Line 133...
176
                                     $(tblid + " div div.text").truncate({addtitle: true});
133
                                     $(tblid + " div div.text").truncate({addtitle: true});
177
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
134
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
178
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');     
135
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');     
179
                                }    
136
                                }    
180
                           }
137
                           }
181
                           //alert( "Data Saved: " + msg );
-
 
182
                      }
138
                      }
183
          });
139
          });
184
          
140
          
185
     }else{
141
     }else{
186
          alert("Please select atleast one product");
142
          alert("Please select atleast one product");
Line 197... Line 153...
197
          var par= containerdiv + " input[type=checkbox]:checked";
153
          var par= containerdiv + " input[type=checkbox]:checked";
198
          var isMulti = false;
154
          var isMulti = false;
199
          $(par).each(function(){
155
          $(par).each(function(){
200
        	  
156
        	  
201
	       	   var totalcolors = $(this).attr('totalcolors');
157
	       	   var totalcolors = $(this).attr('totalcolors');
202
	       	   //alert(totalcolors);
-
 
203
	           saprt = (tot>0)? "_":"";
158
	           saprt = (tot>0)? "_":"";
204
               seldata += saprt+$(this).attr('itemid');
159
               seldata += saprt+$(this).attr('itemid');
205
 
160
 
206
	           if(totalcolors != 1)	{
161
	           if(totalcolors != 1)	{
207
	        	   isMulti = true;
162
	        	   isMulti = true;
208
	       	   }
163
	       	   }
209
               tot++;
164
               tot++;
210
          });
165
          });
211
          //alert("ismulti" + isMulti + " seldata " + seldata + "   refdiv is "+ refdivid + "  par "+ par);
-
 
212
          if(isMulti == true){
166
          if(isMulti == true){
213
        	  alert("Some items are available in multiple colors. Please go to product page and select color you want.");
167
        	  alert("Some items are available in multiple colors. Please go to product page and select color you want.");
214
        	  return;
168
        	  return;
215
          } else	{
169
          } else	{
216
        	  var items = seldata.split('_');
170
        	  var items = seldata.split('_');
Line 225... Line 179...
225
     }else if(reqtype == "list"){
179
     }else if(reqtype == "list"){
226
    	  var seldata=refdivid;
180
    	  var seldata=refdivid;
227
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
181
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
228
          var tot=1;
182
          var tot=1;
229
     }
183
     }
230
     /*
-
 
231
     var historyitems = "";
-
 
232
     if($.Storage.get("historyitems")){
-
 
233
    	 historyitems = "&historyitems=" +  $.Storage.get("historyitems");
-
 
234
    	 $.Storage.remove("historyitems");
-
 
235
     }
-
 
236
     +historyitems
-
 
237
     */
-
 
238
 
184
 
239
     if(tot > 0)	{
185
     if(tot > 0)	{
240
    	 jQuery.ajax({
186
    	 jQuery.ajax({
241
    		 type: "POST",
187
    		 type: "POST",
242
    		 url: "/addtocart",
188
    		 url: "/addtocart",
Line 252... Line 198...
252
     } else	{
198
     } else	{
253
    	 alert("Please select atleast one product");
199
    	 alert("Please select atleast one product");
254
     }
200
     }
255
}
201
}
256
 
202
 
257
function selectProduct(itemId){
-
 
258
	//alert("Selected item is "+ itemId);
-
 
259
}
-
 
260
 
203
 
261
function scrollWinToTop(){
204
function scrollWinToTop(){
262
    $('html, body').animate({
205
    $('html, body').animate({
263
      scrollTop: $("body").offset().top
206
      scrollTop: $("body").offset().top
264
    }, 0);
207
    }, 0);
Line 282... Line 225...
282
   jQuery.ajax({
225
   jQuery.ajax({
283
      type: "POST",
226
      type: "POST",
284
      url: "/shipping",
227
      url: "/shipping",
285
      data: "action=change&addressid="+addressId,
228
      data: "action=change&addressid="+addressId,
286
      success: function(msg){
229
      success: function(msg){
287
         //alert( "Data Saved: " + msg );
-
 
288
         $("#addressid").val(msg);
230
         $("#addressid").val(msg);
289
      }
231
      }
290
   });
232
   });
291
  //$("#addressid").val(addressId);
-
 
292
  document.getElementById('shipAddressContainer').innerHTML = document.getElementById(id).innerHTML;
233
  document.getElementById('shipAddressContainer').innerHTML = document.getElementById(id).innerHTML;
293
	$(".proceed-bttn .yellow-image").removeClass('imgDisableButton').addClass('imgEnableButton');
234
	$(".proceed-bttn .yellow-image").removeClass('imgDisableButton').addClass('imgEnableButton');
294
	$(".proceed-bttn input[disabled='']").removeAttr('disabled');
235
	$(".proceed-bttn input[disabled='']").removeAttr('disabled');
295
	
236
 
296
  //document.getElementById('newShipAdr').style.display = 'none';
-
 
297
  $('#newShipAdr').hide();
237
	$('#newShipAdr').hide();
298
	scrollWinToTop();
238
	scrollWinToTop();
299
 
239
 
300
}
240
}
301
 
241
 
302
function merge_history_items(){
242
function merge_history_items(){