Subversion Repositories SmartDukaan

Rev

Rev 805 | Rev 839 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

// Ebizon Move script js into the file

$(document).ready(function() {
    if(document.getElementById("frmRegister")){
    $("#frmRegister").validate({
      rules: {
        nameOfUser: "required",
        email: {
          required: true,
          email: true
        },
        txtPassword: {
          required: true,
          minlength: 6,
          maxlength: 20
        },
        confirmPassword: {
          required: true,
          minlength: 6,
          maxlength: 20,
          equalTo: "#txtPassword"
        },
        communicationEmail: {
          required: true,
          email: true
        },
        mobileNumber: {
          required: false,
          digits: true,
          minlength: 10,
          maxlength: 10
        },
                conditions: {
                        required: true
                }
      }
    });}
    if(document.getElementById("txtDateOfBirth")){
    $("#txtDateOfBirth").datepicker({
      inline: true,
      changeMonth: true,
      changeYear: true,
      minDate: -20, 
      maxDate: "+1M +10D" 
    });
  }
  
  if(document.getElementById("#frmLogin")) {
                $("#frmLogin").validate({
                        rules: {
                                email: {
                                        required: true,
                                        email: true
                                },
                                password: {
                                        required: true,
                                        minlength: 6,
                                        maxlength: 20
                                }
                        }
                }); 
        }
        if(document.getElementById("#datepicker")) {     
    $("#datepicker").datepicker({ });
  }
  // Research "delete" Item
  $('.add-research-pane5').click(function() {
    addResearch('pane5', 'multi');
  });  
  $('.add-to-cart-pane5').click(function() {
    addToCart('pane5', 'multi')
  });
  $('.add-to-cart-pane1').click(function() {
    addToCart('pane1', 'multi')
  });
  $('#signinClass').click(function() {
    changeSignInClass();
  });    
  $('.add-to-cart-icon').click(function() {
    var items = this.id;
    var itemsarray = items.split('-');
    addToCart(itemsarray[1], itemsarray[0]); 
    return false;
  });  
  $('.add-to-research-icon').click(function() {
    var items = this.id;
    var itemsarray = items.split('-');
    addResearch(itemsarray[1], itemsarray[0]);
    return false;
  });      
  $("#research_delete").click(function(){
    var research_tot=$("#research_total").val();

    var seldata="";
    var tot=0;
    var saprt="";    
    var containerdiv = "#pane1";     
    var par= containerdiv + " input[type=checkbox]:checked";
    $(par).each(function(){
      saprt = (tot>0)? "_":"";
      seldata += saprt+$(this).val();
      tot++
    });
    if(tot>0){
      var t=(research_tot*1)-(tot*1);
      $("#research_total").val(t);

      //alert("AJAX request to delete products in research. Product ID: "+seldata+" and total: "+tot); 
      jQuery.ajax({
        type: "GET",
        url: "/myresearch/" + seldata + "?_method=delete",
        data: "productid="+seldata,
        success: function(msg){
        //   alert( "Data Saved: " + msg );
        }
      });
      var arrayprod_id=seldata.split("_");
      jQuery.each(arrayprod_id,function(intIndex, objValue){
        var tableref="#"+objValue;
        var tblid="#"+objValue+ " td";
        $(tblid).animate({ 
          backgroundColor: "#fcffb3" 
        }, 'slow');
        $(tblid).animate({ 
          backgroundColor: "#F5F5F5" 
        }, 'slow', function() { 
          $(this).fadeOut('slow', function() { 
            $(this).remove();
            if(t === 0){ 
              $("#research_default").css("display","block");
            } 
          } ) 
        }); 

      });
    }else{
      alert("Please select atleast one product");
    }
  });
});