Subversion Repositories SmartDukaan

Rev

Rev 1043 | Rev 1109 | 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
 
3
$(document).ready(function() {
1047 vikas 4
  $('#addAdrBtn').click(function(){
5
    $('#newShipAdr').show();			 
6
    scrollWin();
7
  });
8
 
9
  function scrollWin(){
10
    $('html, body').animate({
11
      scrollTop: $("#newShipAdr").offset().top
12
    }, 2000);
13
  }
14
 
878 rajveer 15
  $('.category-tabs').click(function() {
16
    var items = this.id;
17
    var title = this.title;
18
    var url = this.name;
19
    var itemsarray = items.split('-');
20
    var catId = itemsarray[1];
21
    removeLastActiveState();
22
    $('a.activeTab').each(function(index) {
23
      $('a.activeTab').removeClass('activeTab');
24
    });
25
    $(this).addClass('category-tabs activeTab');
26
    hideShowTabContent("otherTabContent", "show");
27
    setContentHeading(title);
28
    hideShowTabContent("multifacetedSearch", "hide");
29
    hideShowTabContent("browseContent", "hide");
30
    // Ajax call to fecth data in page class
1014 rajveer 31
    //alert("Ajax call to get best sellers");
878 rajveer 32
    jQuery.ajax({
33
      url: "../"+url,
34
      type: "GET",
35
      data: "categoryid="+catId,
36
      contentType: "text/html",
37
      cache: false,
38
      success: function(html){
39
        if(html!=1){
1014 rajveer 40
          //alert(html);
878 rajveer 41
          $('#productListCenter2').html(html);
42
        }else{
1014 rajveer 43
          //alert("Sorry! Unexpected Error. Try again!");
878 rajveer 44
        }
45
      }
46
    });
47
    return false;
48
  });
49
  $('.showBrowse').click(function() {
50
    removeLastActiveState();
51
    activeTab("catTab1");
52
    hideShowTabContent("multifacetedSearch", "show");
53
    hideShowTabContent("browseContent", "show");
54
    hideShowTabContent("otherTabContent", "hide");
55
  });
56
  if(document.getElementById("frmRegister")){
794 rajveer 57
    $("#frmRegister").validate({
58
      rules: {
59
        nameOfUser: "required",
60
        email: {
61
          required: true,
62
          email: true
63
        },
64
        txtPassword: {
65
          required: true,
66
          minlength: 6,
67
          maxlength: 20
68
        },
69
        confirmPassword: {
70
          required: true,
71
          minlength: 6,
72
          maxlength: 20,
73
          equalTo: "#txtPassword"
74
        },
75
        communicationEmail: {
76
          required: true,
77
          email: true
78
        },
79
        mobileNumber: {
80
          required: false,
81
          digits: true,
82
          minlength: 10,
83
          maxlength: 10
805 rajveer 84
        },
878 rajveer 85
        conditions: {
86
          required: true
87
        }
794 rajveer 88
      }
878 rajveer 89
    });
90
  }
91
  if(document.getElementById("txtDateOfBirth")){
794 rajveer 92
    $("#txtDateOfBirth").datepicker({
93
      inline: true,
94
      changeMonth: true,
95
      changeYear: true,
878 rajveer 96
      minDate: -20,
97
      maxDate: "+1M +10D"
794 rajveer 98
    });
99
  }
878 rajveer 100
 
101
 
102
  if (document.getElementById("frmShippingAddress")) {
103
    $("#frmShippingAddress").validate( {
104
      rules : {
105
        name : "required",
106
        line1 : "required",
107
        state : {
108
          required : true,
109
          minlength : 1
110
        },
111
        city : "required",
112
        pincode : {
113
          required : true,
114
          digits : true,
115
          minlength : 6,
116
          maxlength : 6
117
        },
118
        phone : {
119
          required : true,
120
          digits : true,
121
          minlength : 10,
122
          maxlength : 10
123
        }
124
      }
125
    });
126
  }
127
 
794 rajveer 128
  if(document.getElementById("#frmLogin")) {
878 rajveer 129
    $("#frmLogin").validate({
130
      rules: {
131
        email: {
132
          required: true,
133
          email: true
134
        },
135
        password: {
136
          required: true,
137
          minlength: 6,
138
          maxlength: 20
139
        }
140
      }
141
    });
142
  }
143
  if(document.getElementById("#datepicker")) {
794 rajveer 144
    $("#datepicker").datepicker({ });
145
  }
146
  // Research "delete" Item
147
  $('.add-research-pane5').click(function() {
148
    addResearch('pane5', 'multi');
878 rajveer 149
  });
794 rajveer 150
  $('.add-to-cart-pane5').click(function() {
151
    addToCart('pane5', 'multi')
152
  });
809 rajveer 153
  $('.add-to-cart-pane1').click(function() {
794 rajveer 154
    addToCart('pane1', 'multi')
155
  });
156
  $('#signinClass').click(function() {
157
    changeSignInClass();
878 rajveer 158
  });
794 rajveer 159
  $('.add-to-cart-icon').click(function() {
160
    var items = this.id;
161
    var itemsarray = items.split('-');
878 rajveer 162
    addToCart(itemsarray[1], itemsarray[0]);
794 rajveer 163
    return false;
878 rajveer 164
  });
794 rajveer 165
  $('.add-to-research-icon').click(function() {
166
    var items = this.id;
167
    var itemsarray = items.split('-');
168
    addResearch(itemsarray[1], itemsarray[0]);
169
    return false;
878 rajveer 170
  });
1047 vikas 171
  $("#research_delete").click(function(){
172
    var research_tot=$("#research_total").val();
794 rajveer 173
 
1047 vikas 174
    var seldata="";
175
    var tot=0;
176
    var saprt="";
177
    var containerdiv = "#pane1";
178
    var par= containerdiv + " input[type=checkbox]:checked";
179
    $(par).each(function(){
180
      saprt = (tot>0)? "_":"";
181
      seldata += saprt+$(this).val();
182
      tot++
183
    });
184
    if(tot>0){
185
      var t=(research_tot*1)-(tot*1);
186
      $("#research_total").val(t);
794 rajveer 187
 
1047 vikas 188
      //alert("AJAX request to delete products in research. Product ID: "+seldata+" and total: "+tot);
189
      jQuery.ajax({
190
        type: "GET",
191
        url: "/myresearch/" + seldata + "?_method=delete",
192
        data: "productid="+seldata,
193
        success: function(msg){
194
        //   alert( "Data Saved: " + msg );
195
        }
196
      });
197
      var arrayprod_id=seldata.split("_");
198
      jQuery.each(arrayprod_id,function(intIndex, objValue){
199
        var tableref="#"+objValue;
200
        $(tableref).animate({
201
          backgroundColor: "#fcffb3"
202
        }, 'slow');
203
        $(tableref).animate({
204
          backgroundColor: "#F5F5F5"
205
        }, 'slow', function() {
206
          $(this).fadeOut('slow', function() {
207
            $(this).remove();
208
            if(t === 0){
209
              $("#research_default").css("display","block");
210
            }
211
          } )
212
        });
213
 
214
      });
215
    }else{
216
      alert("Please select atleast one product");
217
    }
218
  });
219
});
220
 
221