Subversion Repositories SmartDukaan

Rev

Rev 2694 | Rev 3550 | 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-research-icon').live('click', function() {
794 rajveer 132
    var items = this.id;
133
    var itemsarray = items.split('-');
1809 varun.gupt 134
 
794 rajveer 135
    addResearch(itemsarray[1], itemsarray[0]);
136
    return false;
878 rajveer 137
  });
1372 vikas 138
  $("#research_delete").live('click', function(){var research_tot = $("#research_total").val();
1761 vikas 139
    var seldata=[];
1109 varun.gupt 140
	var tot = 0;
141
	var saprt = "";
142
	var containerdiv = "#pane1";
143
	var par = containerdiv + " input[type=checkbox]:checked";
794 rajveer 144
 
1109 varun.gupt 145
	$(par).each(function(){
1761 vikas 146
		seldata.unshift($(this).val());
1109 varun.gupt 147
		tot ++;
148
	});
794 rajveer 149
 
1109 varun.gupt 150
	if(tot > 0)	{
151
		var t = (research_tot * 1) - (tot * 1);
152
		$("#research_total").val(t);
1047 vikas 153
 
1109 varun.gupt 154
		jQuery.ajax({
155
			type: "GET",
1826 vikas 156
			url: "/deletefromresearch/[" + seldata + "]?_method=delete",
1109 varun.gupt 157
			success: function(msg){
1761 vikas 158
				jQuery.each(seldata, function(intIndex, objValue){
159
					delete_from_storage_set("resitems", objValue);
1109 varun.gupt 160
					$("#pane1").find("#" + objValue).fadeOut('slow', function() {
161
						$(this).remove();
1372 vikas 162
						if(t === 0)	{
163
							$("#research_default").css("display", "block");
164
						}
1109 varun.gupt 165
					});
166
				});
167
			}
168
		});
169
	} else	{
170
		alert("Please select atleast one product");
171
	}
1047 vikas 172
  });
1614 rajveer 173
 
1778 rajveer 174
 $("#research_compare").live('click', function(){
175
        var seldata = "";
176
        var tot = 1;
177
        var saprt = "";
178
        var containerdiv = "#pane1";
179
        var par = containerdiv + " input[type=checkbox]:checked";
180
 
181
        $(par).each(function(){
182
        		if(tot == 1){
1821 rajveer 183
        			seldata +=  "p"+tot + "=" + $(this).val();
1778 rajveer 184
        		}else{
1821 rajveer 185
        			seldata +=  "&p"+tot + "=" + $(this).val();
1778 rajveer 186
        		}
187
                tot ++;
188
        });
189
 
1844 rajveer 190
	if(tot > 6){
1821 rajveer 191
		alert("Can compare upto five products only.");
192
	}else if(tot > 2)     {
1778 rajveer 193
                window.location="/compare-mobile-phones?" + seldata;
194
        } else  {
195
                alert("Please select atleast two products");
196
        }
197
});
198
 
1761 vikas 199
  // No uid cookie
200
  if (!$.cookie("uid")) {
201
	  // No uid in storage
202
	  if (!$.Storage.get("uid")) {
203
		  if (!$.Storage.get("resitems")) {
204
			  $.Storage.set("resitems", "[]");
205
		  }
206
		  if (!$.Storage.get("histitems")) {
207
			  $.Storage.set("histitems", "[]");
208
		  }
1623 rajveer 209
	  }
1761 vikas 210
	  // uid in storage : logout
211
	  else {
212
		  $.Storage.remove("uid");
213
		  $.Storage.set("resitems", "[]");
214
		  $.Storage.set("histitems", "[]");
1623 rajveer 215
	  }
1372 vikas 216
	  load_research_widget();
1761 vikas 217
	  load_history_widget();
1372 vikas 218
  }
1761 vikas 219
  // With uid cookie
1372 vikas 220
  else {
1761 vikas 221
	  var cookie = $.cookie("uid");
222
	  // Just logged in merge storage items
223
	  if (!$.Storage.get("uid")) {
224
		  $.Storage.set("uid", cookie);
225
		  merge_history_items();
226
		  load_research_items();
227
	  }
228
	  else {
229
		  // UID changed
230
		  if ( cookie != $.Storage.get("uid")) {
231
			  $.Storage.set("uid", cookie);
232
			  $.Storage.set("resitems", "[]");
233
			  $.Storage.set("histitems", "[]");
234
			  merge_history_items();
235
			  load_research_items();
236
		  }
237
		  // Uid is same
238
		  else {
239
			  if (!$.Storage.get("resitems")) {
240
				  $.Storage.set("resitems", "[]");
241
				  load_research_items();
242
			  }
243
			  else {
244
				  load_research_widget();
245
			  }
246
			  if (!$.Storage.get("histitems")) {
247
				  $.Storage.set("histitems", "[]");
248
				  merge_history_items();
249
			  }
250
			  else {
251
				  load_history_widget();
252
			  }
253
		  }
254
	  }
1372 vikas 255
  }
1761 vikas 256
 
1778 rajveer 257
});