Subversion Repositories SmartDukaan

Rev

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