Subversion Repositories SmartDukaan

Rev

Rev 1174 | Rev 1254 | 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(){
        $('#addAdrBtn').click(function(){
                $('#newShipAdr').show();
                scrollWin();
        });

        $('#communication_category').change(function(){
                $('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();
                $('#frmContactUs input[name="submit"]').removeAttr('disabled');
                
                switch(parseInt($(this).val())) {

                        case 1:
                                $('#orderComponent, #productComponent, #subjectComponent, #msgComponent').show();
                                $('#lblSubject').html('Reason to Return');
                                break;

                        case 2:
                                $('#orderComponent, #subjectComponent, #msgComponent').show();
                                $('#lblSubject').html('Reason for Cancellation');
                                break;

                        case 3:
                                $('#orderComponent, #subjectComponent, #msgComponent').show();
                                $('#lblSubject').html('Problem Type');
                                break;

                        case 4:
                                $('#orderComponent, #msgComponent').show();
                                break;

                        case 5:
                                $('#orderComponent, #msgComponent').show();
                                break;

                        case 6:
                                $('#subjectComponent, #msgComponent').show();
                                $('#lblSubject').html('Product Title');
                                break;

                        case 7:
                                $('#orderComponent, #msgComponent').show();
                                $('#lblSubject').html('Subject');
                                break;

                        default:
                                $('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();
                                break;
                }
        });

  function scrollWin(){
    $('html, body').animate({
      scrollTop: $("#newShipAdr").offset().top
    }, 2000);
  }

  $('.category-tabs').click(function() {
    var items = this.id;
    var title = this.title;
    var url = this.name;
    var itemsarray = items.split('-');
    var catId = itemsarray[1];
    removeLastActiveState();
    $('a.activeTab').each(function(index) {
      $('a.activeTab').removeClass('activeTab');
    });
    $(this).addClass('category-tabs activeTab');
    hideShowTabContent("otherTabContent", "show");
    setContentHeading(title);
    hideShowTabContent("multifacetedSearch", "hide");
    hideShowTabContent("browseContent", "hide");
    // Ajax call to fecth data in page class
    //alert("Ajax call to get best sellers");
    jQuery.ajax({
      url: "../"+url,
      type: "GET",
      data: "categoryid="+catId,
      contentType: "text/html",
      cache: false,
      success: function(html){
        if(html!=1){
          //alert(html);
          $('#productListCenter2').html(html);
          $('ul.product-description li').textOverflow();
        }else{
          //alert("Sorry! Unexpected Error. Try again!");
        }
      }
    });
    return false;
  });
  $('.showBrowse').click(function() {
    removeLastActiveState();
    activeTab("catTab1");
    hideShowTabContent("multifacetedSearch", "show");
    hideShowTabContent("browseContent", "show");
    hideShowTabContent("otherTabContent", "hide");
  });
  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("frmShippingAddress")) {
    $("#frmShippingAddress").validate( {
      rules : {
        name : "required",
        line1 : "required",
        state : {
          required : true,
          minlength : 1
        },
        city : "required",
        pincode : {
          required : true,
          digits : true,
          minlength : 6,
          maxlength : 6
        },
        phone : {
          required : true,
          digits : true,
          minlength : 10,
          maxlength : 10
        }
      }
    });
  }

  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').live('click', function() {
    var items = this.id;
    var itemsarray = items.split('-');
    addToCart(itemsarray[1], itemsarray[0]);
    return false;
  });
  $('.add-to-research-icon').live('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);

                jQuery.ajax({
                        type: "GET",
                        url: "/myresearch/" + seldata + "?_method=delete",
                        data: "productid=" + seldata,
                        success: function(msg){
                                jQuery.each(seldata.split("_"), function(intIndex, objValue){
                                        $("#pane1").find("#" + objValue).fadeOut('slow', function() {
                                                $(this).remove();
                                                if(t === 0)     $("#research_default").css("display", "block");
                                        });
                                });
                        }
                });
        } else  {
                alert("Please select atleast one product");
        }
  });
});