Subversion Repositories SmartDukaan

Rev

Rev 1796 | Rev 1807 | 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
 
1778 rajveer 3
$(document).ready(function() {
1806 rajveer 4
  var SelectID;
5
  var subtract;
6
  var check = 0;
1778 rajveer 7
  var count = $('.comparision-product-column').length;
8
  if(count < 4) {
9
    if(count == 3) {
1806 rajveer 10
      subtract = 6;
1778 rajveer 11
    } else if(count == 2) {
1806 rajveer 12
      subtract = 3;
1778 rajveer 13
    } else {
1806 rajveer 14
      subtract = 0;
1778 rajveer 15
    }
16
    var parentWidth = $('#comparision-right').width();
17
    var width = (parentWidth - subtract)/count;
18
    var newWidth = parseInt(width);
19
    $('.product-name').width(newWidth);
20
    $('.comparision-product-column').width(newWidth);
21
  }
1806 rajveer 22
  var styleTrack = $('.jspTrack').attr('style');
23
  $('.jspTrackbottom').attr('style', styleTrack);
24
  var styleDrag = $('.jspDrag').attr('style');
25
  $('.jspDragbottom').attr('style', styleDrag);
1778 rajveer 26
  $('.ui-state-default').click(function(){
27
    var aID = $("li.ui-state-active").children('a:first').attr('href');
28
    var array = aID.split("#");
29
    var displayID = array[1];
30
    var new_aID = $(this).children('a:first').attr('href');
31
    var new_array = new_aID.split("#");
32
    var new_displayID = new_array[1];
33
    $('.'+displayID).each(function(){
34
      this.style.display = 'none';
35
      $(this).removeClass("comparision-block").addClass('comparision-hide');
36
    });
37
    if(new_displayID == 'vtab-1') {
1806 rajveer 38
   //   $('#comparision-right').removeClass("product-comparision-internal").addClass('product-comparision-home');
39
    //  $('.scroller-columns').hide();
40
    //  $('#comparision-summary-content').show();
41
    //  $('.comparision-page-title').hide();
1778 rajveer 42
    } else {
1806 rajveer 43
//      $('#comparision-right').removeClass("product-comparision-home").addClass('product-comparision-internal');
44
//      $('.scroller-columns').show();
45
 //     $('#comparision-summary-content').hide();
46
  //    $('.comparision-page-title').show();
1778 rajveer 47
    }
48
    $('.comparision-page-title').html(this.title);
49
    $('.ui-state-active').removeClass("ui-tabs-selected ui-state-active");
50
    $(this).addClass("ui-tabs-selected ui-state-active");
51
    $('.'+new_displayID).each(function() {
1806 rajveer 52
      var new_count = $('.'+new_displayID).length;
53
      if(new_count !== count) {
54
        $('.comparision-product-column').each(function(){
55
          var check_childern = $(this).find('.'+new_displayID).html();
56
          if(check_childern == null && check == 0) {
57
            $(this).append("<div class='"+new_displayID+" comparision-hide comparision-empty-column'><div class='featureslisting'><ul><li class='mainFeature'>No features listed.</li></ul></div></div>");
58
            check = 1;
59
          }
60
        });
61
      }
1778 rajveer 62
      $(this).removeClass("comparision-hide").addClass('comparision-block');
63
      this.style.display = 'block';
64
    });
65
    return false;
66
  });
67
  $('.comparision-hide').each(function(){
68
    this.style.display = 'none';
69
  });
70
});
71
 
1806 rajveer 72
$('#frmProceedToPay').submit(function(){
73
	  //Tracking this click for Google Analytics
74
	  _gaq.push(['_trackEvent', 'Order', 'Proceed to Pay', "", 2]);
75
	  return true;
76
});
77
 
78
 
1109 varun.gupt 79
$(document).ready(function(){
1773 varun.gupt 80
 
81
	//For Registration Page
82
	$('#frmRegister #email').change(function(){
83
		$('#communicationEmail').val($(this).val());
84
	});
85
 
1109 varun.gupt 86
	$('#addAdrBtn').click(function(){
87
		$('#newShipAdr').show();
88
		scrollWin();
89
	});
1380 varun.gupt 90
	var lastQueryType = -1;
1109 varun.gupt 91
 
1047 vikas 92
  function scrollWin(){
93
    $('html, body').animate({
94
      scrollTop: $("#newShipAdr").offset().top
95
    }, 2000);
96
  }
97
 
878 rajveer 98
  $('.category-tabs').click(function() {
99
    var items = this.id;
100
    var title = this.title;
101
    var url = this.name;
102
    var itemsarray = items.split('-');
103
    var catId = itemsarray[1];
104
    removeLastActiveState();
105
    $('a.activeTab').each(function(index) {
106
      $('a.activeTab').removeClass('activeTab');
107
    });
108
    $(this).addClass('category-tabs activeTab');
109
    hideShowTabContent("otherTabContent", "show");
110
    setContentHeading(title);
111
    hideShowTabContent("multifacetedSearch", "hide");
112
    hideShowTabContent("browseContent", "hide");
113
    // Ajax call to fecth data in page class
1014 rajveer 114
    //alert("Ajax call to get best sellers");
878 rajveer 115
    jQuery.ajax({
116
      url: "../"+url,
117
      type: "GET",
118
      data: "categoryid="+catId,
119
      contentType: "text/html",
120
      cache: false,
121
      success: function(html){
122
        if(html!=1){
1014 rajveer 123
          //alert(html);
878 rajveer 124
          $('#productListCenter2').html(html);
1290 vikas 125
          $('#productListCenter2 ul.product-description li').truncate({addtitle: true});
878 rajveer 126
        }else{
1014 rajveer 127
          //alert("Sorry! Unexpected Error. Try again!");
878 rajveer 128
        }
129
      }
130
    });
131
    return false;
132
  });
133
  $('.showBrowse').click(function() {
134
    removeLastActiveState();
135
    activeTab("catTab1");
136
    hideShowTabContent("multifacetedSearch", "show");
137
    hideShowTabContent("browseContent", "show");
138
    hideShowTabContent("otherTabContent", "hide");
139
  });
1771 varun.gupt 140
	$('#frmLogin').validate({
141
		loginEmail: {
142
			required: true,
143
			email: true
144
		},
145
		loginPassword: {
146
			required: true,
147
			minlength: 6,
148
			maxlength: 20
149
		}
150
	});
1773 varun.gupt 151
  if(document.getElementById("frmRegister")){
1771 varun.gupt 152
 
794 rajveer 153
    $("#frmRegister").validate({
154
      rules: {
155
        nameOfUser: "required",
156
        email: {
157
          required: true,
158
          email: true
159
        },
160
        txtPassword: {
161
          required: true,
162
          minlength: 6,
163
          maxlength: 20
164
        },
165
        confirmPassword: {
166
          required: true,
167
          minlength: 6,
168
          maxlength: 20,
169
          equalTo: "#txtPassword"
170
        },
171
        communicationEmail: {
172
          required: true,
173
          email: true
174
        },
175
        mobileNumber: {
176
          required: false,
177
          digits: true,
178
          minlength: 10,
179
          maxlength: 10
805 rajveer 180
        },
878 rajveer 181
        conditions: {
182
          required: true
183
        }
794 rajveer 184
      }
878 rajveer 185
    });
186
  }
187
  if(document.getElementById("txtDateOfBirth")){
794 rajveer 188
    $("#txtDateOfBirth").datepicker({
189
      inline: true,
190
      changeMonth: true,
191
      changeYear: true,
878 rajveer 192
      minDate: -20,
193
      maxDate: "+1M +10D"
794 rajveer 194
    });
195
  }
878 rajveer 196
 
197
 
198
  if (document.getElementById("frmShippingAddress")) {
199
    $("#frmShippingAddress").validate( {
200
      rules : {
201
        name : "required",
202
        line1 : "required",
203
        state : {
204
          required : true,
205
          minlength : 1
206
        },
207
        city : "required",
208
        pincode : {
209
          required : true,
210
          digits : true,
211
          minlength : 6,
212
          maxlength : 6
213
        },
214
        phone : {
215
          required : true,
216
          digits : true,
217
          minlength : 10,
218
          maxlength : 10
219
        }
220
      }
221
    });
222
  }
223
 
794 rajveer 224
  if(document.getElementById("#frmLogin")) {
878 rajveer 225
    $("#frmLogin").validate({
226
      rules: {
227
        email: {
228
          required: true,
229
          email: true
230
        },
231
        password: {
232
          required: true,
233
          minlength: 6,
234
          maxlength: 20
235
        }
236
      }
237
    });
238
  }
239
  if(document.getElementById("#datepicker")) {
794 rajveer 240
    $("#datepicker").datepicker({ });
241
  }
242
  // Research "delete" Item
1372 vikas 243
  $('.add-research-pane5').live('click', function() {
794 rajveer 244
    addResearch('pane5', 'multi');
878 rajveer 245
  });
1372 vikas 246
  $('.add-to-cart-pane5').live('click', function() {
1254 vikas 247
    addToCart('pane5', 'multi');
794 rajveer 248
  });
1372 vikas 249
  $('.add-to-cart-pane1').live('click', function() {
1254 vikas 250
    addToCart('pane1', 'multi');
794 rajveer 251
  });
252
  $('#signinClass').click(function() {
253
    changeSignInClass();
878 rajveer 254
  });
1199 vikas 255
  $('.add-to-cart-icon').live('click', function() {
794 rajveer 256
    var items = this.id;
257
    var itemsarray = items.split('-');
878 rajveer 258
    addToCart(itemsarray[1], itemsarray[0]);
794 rajveer 259
    return false;
878 rajveer 260
  });
1199 vikas 261
  $('.add-to-research-icon').live('click', function() {
794 rajveer 262
    var items = this.id;
263
    var itemsarray = items.split('-');
264
    addResearch(itemsarray[1], itemsarray[0]);
265
    return false;
878 rajveer 266
  });
1372 vikas 267
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
1761 vikas 268
    var seldata=[];
1109 varun.gupt 269
	var tot = 0;
270
	var saprt = "";
271
	var containerdiv = "#pane1";
272
	var par = containerdiv + " input[type=checkbox]:checked";
794 rajveer 273
 
1109 varun.gupt 274
	$(par).each(function(){
1761 vikas 275
		seldata.unshift($(this).val());
1109 varun.gupt 276
		tot ++;
277
	});
794 rajveer 278
 
1109 varun.gupt 279
	if(tot > 0)	{
280
		var t = (research_tot * 1) - (tot * 1);
281
		$("#research_total").val(t);
1047 vikas 282
 
1109 varun.gupt 283
		jQuery.ajax({
284
			type: "GET",
1761 vikas 285
			url: "/deletefromresearch/[" + seldata + "]",
1109 varun.gupt 286
			success: function(msg){
1761 vikas 287
				jQuery.each(seldata, function(intIndex, objValue){
288
					delete_from_storage_set("resitems", objValue);
1109 varun.gupt 289
					$("#pane1").find("#" + objValue).fadeOut('slow', function() {
290
						$(this).remove();
1372 vikas 291
						if(t === 0)	{
292
							$("#research_default").css("display", "block");
293
						}
1109 varun.gupt 294
					});
295
				});
296
			}
297
		});
298
	} else	{
299
		alert("Please select atleast one product");
300
	}
1047 vikas 301
  });
1614 rajveer 302
 
1778 rajveer 303
 $("#research_compare").live('click', function(){
304
        var seldata = "";
305
        var tot = 1;
306
        var saprt = "";
307
        var containerdiv = "#pane1";
308
        var par = containerdiv + " input[type=checkbox]:checked";
309
 
310
        $(par).each(function(){
311
        		if(tot == 1){
312
        			seldata +=  "mobile"+tot + "=" + $(this).val();
313
        		}else{
314
        			seldata +=  "&mobile"+tot + "=" + $(this).val();
315
        		}
316
                tot ++;
317
        });
318
 
319
        if(tot > 2)     {
320
                window.location="/compare-mobile-phones?" + seldata;
321
        } else  {
322
                alert("Please select atleast two products");
323
        }
324
});
325
 
326
 
1761 vikas 327
  // Clear old cache keys. These two lines can be deleted after June 5, 2011.  
328
  $.Storage.remove("history");
329
  $.Storage.remove("research");
1372 vikas 330
 
1761 vikas 331
  // No uid cookie
332
  if (!$.cookie("uid")) {
333
	  // No uid in storage
334
	  if (!$.Storage.get("uid")) {
335
		  if (!$.Storage.get("resitems")) {
336
			  $.Storage.set("resitems", "[]");
337
		  }
338
		  if (!$.Storage.get("histitems")) {
339
			  $.Storage.set("histitems", "[]");
340
		  }
1623 rajveer 341
	  }
1761 vikas 342
	  // uid in storage : logout
343
	  else {
344
		  $.Storage.remove("uid");
345
		  $.Storage.set("resitems", "[]");
346
		  $.Storage.set("histitems", "[]");
1623 rajveer 347
	  }
1372 vikas 348
	  load_research_widget();
1761 vikas 349
	  load_history_widget();
1372 vikas 350
  }
1761 vikas 351
  // With uid cookie
1372 vikas 352
  else {
1761 vikas 353
	  var cookie = $.cookie("uid");
354
	  // Just logged in merge storage items
355
	  if (!$.Storage.get("uid")) {
356
		  $.Storage.set("uid", cookie);
357
		  merge_history_items();
358
		  load_research_items();
359
	  }
360
	  else {
361
		  // UID changed
362
		  if ( cookie != $.Storage.get("uid")) {
363
			  $.Storage.set("uid", cookie);
364
			  $.Storage.set("resitems", "[]");
365
			  $.Storage.set("histitems", "[]");
366
			  merge_history_items();
367
			  load_research_items();
368
		  }
369
		  // Uid is same
370
		  else {
371
			  if (!$.Storage.get("resitems")) {
372
				  $.Storage.set("resitems", "[]");
373
				  load_research_items();
374
			  }
375
			  else {
376
				  load_research_widget();
377
			  }
378
			  if (!$.Storage.get("histitems")) {
379
				  $.Storage.set("histitems", "[]");
380
				  merge_history_items();
381
			  }
382
			  else {
383
				  load_history_widget();
384
			  }
385
		  }
386
	  }
1372 vikas 387
  }
1761 vikas 388
 
1778 rajveer 389
});