Subversion Repositories SmartDukaan

Rev

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