Subversion Repositories SmartDukaan

Rev

Rev 1831 | Rev 1844 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
794 rajveer 1
// Ebizon Move script js into the file
2
 
1809 varun.gupt 3
$(document).ready(function(){
4
	$('#frmProceedToPay').submit(function(){
1829 varun.gupt 5
		trackEventWithGA('Order', 'Proceed to Pay', "");
1809 varun.gupt 6
		return true;
7
	});
1773 varun.gupt 8
 
1109 varun.gupt 9
	$('#addAdrBtn').click(function(){
10
		$('#newShipAdr').show();
11
		scrollWin();
12
	});
1380 varun.gupt 13
	var lastQueryType = -1;
1109 varun.gupt 14
 
1047 vikas 15
  function scrollWin(){
16
    $('html, body').animate({
17
      scrollTop: $("#newShipAdr").offset().top
18
    }, 2000);
19
  }
20
 
878 rajveer 21
  $('.category-tabs').click(function() {
22
    var items = this.id;
23
    var title = this.title;
24
    var url = this.name;
25
    var itemsarray = items.split('-');
26
    var catId = itemsarray[1];
27
    removeLastActiveState();
28
    $('a.activeTab').each(function(index) {
29
      $('a.activeTab').removeClass('activeTab');
30
    });
31
    $(this).addClass('category-tabs activeTab');
32
    hideShowTabContent("otherTabContent", "show");
33
    setContentHeading(title);
34
    hideShowTabContent("multifacetedSearch", "hide");
35
    hideShowTabContent("browseContent", "hide");
36
    // Ajax call to fecth data in page class
1014 rajveer 37
    //alert("Ajax call to get best sellers");
878 rajveer 38
    jQuery.ajax({
39
      url: "../"+url,
40
      type: "GET",
41
      data: "categoryid="+catId,
42
      contentType: "text/html",
43
      cache: false,
44
      success: function(html){
45
        if(html!=1){
1014 rajveer 46
          //alert(html);
878 rajveer 47
          $('#productListCenter2').html(html);
1290 vikas 48
          $('#productListCenter2 ul.product-description li').truncate({addtitle: true});
878 rajveer 49
        }else{
1014 rajveer 50
          //alert("Sorry! Unexpected Error. Try again!");
878 rajveer 51
        }
52
      }
53
    });
54
    return false;
55
  });
56
  $('.showBrowse').click(function() {
57
    removeLastActiveState();
58
    activeTab("catTab1");
59
    hideShowTabContent("multifacetedSearch", "show");
60
    hideShowTabContent("browseContent", "show");
61
    hideShowTabContent("otherTabContent", "hide");
62
  });
1831 varun.gupt 63
 
878 rajveer 64
  if(document.getElementById("txtDateOfBirth")){
794 rajveer 65
    $("#txtDateOfBirth").datepicker({
66
      inline: true,
67
      changeMonth: true,
68
      changeYear: true,
878 rajveer 69
      minDate: -20,
70
      maxDate: "+1M +10D"
794 rajveer 71
    });
72
  }
878 rajveer 73
 
74
 
75
  if (document.getElementById("frmShippingAddress")) {
76
    $("#frmShippingAddress").validate( {
77
      rules : {
78
        name : "required",
79
        line1 : "required",
80
        state : {
81
          required : true,
82
          minlength : 1
83
        },
84
        city : "required",
85
        pincode : {
86
          required : true,
87
          digits : true,
88
          minlength : 6,
89
          maxlength : 6
90
        },
91
        phone : {
92
          required : true,
93
          digits : true,
94
          minlength : 10,
95
          maxlength : 10
96
        }
97
      }
98
    });
99
  }
100
 
794 rajveer 101
  if(document.getElementById("#frmLogin")) {
878 rajveer 102
    $("#frmLogin").validate({
103
      rules: {
104
        email: {
105
          required: true,
106
          email: true
107
        },
108
        password: {
109
          required: true,
110
          minlength: 6,
111
          maxlength: 20
112
        }
113
      }
114
    });
115
  }
116
  if(document.getElementById("#datepicker")) {
794 rajveer 117
    $("#datepicker").datepicker({ });
118
  }
119
  // Research "delete" Item
1372 vikas 120
  $('.add-research-pane5').live('click', function() {
794 rajveer 121
    addResearch('pane5', 'multi');
878 rajveer 122
  });
1372 vikas 123
  $('.add-to-cart-pane5').live('click', function() {
1254 vikas 124
    addToCart('pane5', 'multi');
794 rajveer 125
  });
1372 vikas 126
  $('.add-to-cart-pane1').live('click', function() {
1254 vikas 127
    addToCart('pane1', 'multi');
794 rajveer 128
  });
129
  $('#signinClass').click(function() {
130
    changeSignInClass();
878 rajveer 131
  });
1199 vikas 132
  $('.add-to-cart-icon').live('click', function() {
794 rajveer 133
    var items = this.id;
134
    var itemsarray = items.split('-');
878 rajveer 135
    addToCart(itemsarray[1], itemsarray[0]);
794 rajveer 136
    return false;
878 rajveer 137
  });
1199 vikas 138
  $('.add-to-research-icon').live('click', function() {
794 rajveer 139
    var items = this.id;
140
    var itemsarray = items.split('-');
1809 varun.gupt 141
 
794 rajveer 142
    addResearch(itemsarray[1], itemsarray[0]);
143
    return false;
878 rajveer 144
  });
1372 vikas 145
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
1761 vikas 146
    var seldata=[];
1109 varun.gupt 147
	var tot = 0;
148
	var saprt = "";
149
	var containerdiv = "#pane1";
150
	var par = containerdiv + " input[type=checkbox]:checked";
794 rajveer 151
 
1109 varun.gupt 152
	$(par).each(function(){
1761 vikas 153
		seldata.unshift($(this).val());
1109 varun.gupt 154
		tot ++;
155
	});
794 rajveer 156
 
1109 varun.gupt 157
	if(tot > 0)	{
158
		var t = (research_tot * 1) - (tot * 1);
159
		$("#research_total").val(t);
1047 vikas 160
 
1109 varun.gupt 161
		jQuery.ajax({
162
			type: "GET",
1826 vikas 163
			url: "/deletefromresearch/[" + seldata + "]?_method=delete",
1109 varun.gupt 164
			success: function(msg){
1761 vikas 165
				jQuery.each(seldata, function(intIndex, objValue){
166
					delete_from_storage_set("resitems", objValue);
1109 varun.gupt 167
					$("#pane1").find("#" + objValue).fadeOut('slow', function() {
168
						$(this).remove();
1372 vikas 169
						if(t === 0)	{
170
							$("#research_default").css("display", "block");
171
						}
1109 varun.gupt 172
					});
173
				});
174
			}
175
		});
176
	} else	{
177
		alert("Please select atleast one product");
178
	}
1047 vikas 179
  });
1614 rajveer 180
 
1778 rajveer 181
 $("#research_compare").live('click', function(){
182
        var seldata = "";
183
        var tot = 1;
184
        var saprt = "";
185
        var containerdiv = "#pane1";
186
        var par = containerdiv + " input[type=checkbox]:checked";
187
 
188
        $(par).each(function(){
189
        		if(tot == 1){
1821 rajveer 190
        			seldata +=  "p"+tot + "=" + $(this).val();
1778 rajveer 191
        		}else{
1821 rajveer 192
        			seldata +=  "&p"+tot + "=" + $(this).val();
1778 rajveer 193
        		}
194
                tot ++;
195
        });
196
 
1821 rajveer 197
	if(tot > 5){
198
		alert("Can compare upto five products only.");
199
	}else if(tot > 2)     {
1778 rajveer 200
                window.location="/compare-mobile-phones?" + seldata;
201
        } else  {
202
                alert("Please select atleast two products");
203
        }
204
});
205
 
1761 vikas 206
  // No uid cookie
207
  if (!$.cookie("uid")) {
208
	  // No uid in storage
209
	  if (!$.Storage.get("uid")) {
210
		  if (!$.Storage.get("resitems")) {
211
			  $.Storage.set("resitems", "[]");
212
		  }
213
		  if (!$.Storage.get("histitems")) {
214
			  $.Storage.set("histitems", "[]");
215
		  }
1623 rajveer 216
	  }
1761 vikas 217
	  // uid in storage : logout
218
	  else {
219
		  $.Storage.remove("uid");
220
		  $.Storage.set("resitems", "[]");
221
		  $.Storage.set("histitems", "[]");
1623 rajveer 222
	  }
1372 vikas 223
	  load_research_widget();
1761 vikas 224
	  load_history_widget();
1372 vikas 225
  }
1761 vikas 226
  // With uid cookie
1372 vikas 227
  else {
1761 vikas 228
	  var cookie = $.cookie("uid");
229
	  // Just logged in merge storage items
230
	  if (!$.Storage.get("uid")) {
231
		  $.Storage.set("uid", cookie);
232
		  merge_history_items();
233
		  load_research_items();
234
	  }
235
	  else {
236
		  // UID changed
237
		  if ( cookie != $.Storage.get("uid")) {
238
			  $.Storage.set("uid", cookie);
239
			  $.Storage.set("resitems", "[]");
240
			  $.Storage.set("histitems", "[]");
241
			  merge_history_items();
242
			  load_research_items();
243
		  }
244
		  // Uid is same
245
		  else {
246
			  if (!$.Storage.get("resitems")) {
247
				  $.Storage.set("resitems", "[]");
248
				  load_research_items();
249
			  }
250
			  else {
251
				  load_research_widget();
252
			  }
253
			  if (!$.Storage.get("histitems")) {
254
				  $.Storage.set("histitems", "[]");
255
				  merge_history_items();
256
			  }
257
			  else {
258
				  load_history_widget();
259
			  }
260
		  }
261
	  }
1372 vikas 262
  }
1761 vikas 263
 
1778 rajveer 264
});