Subversion Repositories SmartDukaan

Rev

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