Advertisement
Remote

Untitled

Sep 8th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /**
  2.      * Formularz zamówienia przesyki
  3.      */
  4.     $(".postal").mask("99-999");
  5.     $(".nip").mask("999-999-99-99");
  6.     $('.toggles label, .new-radio label:not(.none)').click(function()
  7.     {
  8.         var dataID      = $(this).children().attr('name');
  9.         var dataValue   = $(this).children().attr('value');
  10.         $('input#' +dataID+ '_data').attr('value',dataValue);
  11.         $(this).trigger('checkPrice');
  12.         if(dataID == 'usluga') {
  13.             var openForm = $(this).children().attr('id');
  14.             $('div#przesylki div#koperta, div#przesylki div#paczka, div#przesylki div#paleta').slideUp();
  15.             $('div#przesylki div#' +openForm).slideDown();
  16.         }
  17.  
  18.     });
  19.     $('#send input.ajaxCheck').focusout(function()
  20.     {
  21.         $(this).trigger('checkPrice');
  22.     });
  23.  
  24.     $('article#send').on('checkPrice',function()
  25.     {
  26.         $('#send #price strong').remove();
  27.  
  28.         var priceBox        = $('#send #price span');
  29.         var getPrice        = parseFloat($(priceBox).text().replace(",", "."));
  30.         var Usluga          = $('input#usluga_data').val();
  31.         var Ubezp           = $('#send input[name=ubezp]').val();
  32.         var Pobranie        = $('input#pobranie_data').val();
  33.         var getContents     = $('form#send').serializeArray();
  34.  
  35.         $.ajax({
  36.             type: "POST",
  37.             url:  "../../assets/price.php",
  38.             data:
  39.             {
  40.                 Usluga      : Usluga,
  41.                 Ubezp       : Ubezp,
  42.                 Pobranie    : Pobranie,
  43.                 getContents : getContents
  44.             },
  45.             success: function(theResponse)
  46.             {
  47.                 if(theResponse != 0)
  48.                 {
  49.                     $(priceBox).stop().animate({opacity:.05},400);
  50.                     setTimeout(function()
  51.                     {
  52.                         $(priceBox).stop().text(theResponse.toString().replace(".", ",")).animate({opacity:1},400);
  53.                     },400);
  54.                 }
  55.                 var newPrice = Math.round(((theResponse.toString().replace(",", ".")) - getPrice) * 100) / 100;
  56.  
  57.                 if(theResponse == 0)
  58.                 {
  59.                     $('#send #price strong').stop().animate({top:'0',opacity:0},0);
  60.                 }
  61.                 else if(theResponse > getPrice)
  62.                 {
  63.                     $(priceBox).after('<strong>+ ' +parseFloat(newPrice)+ ' zł</strong>');
  64.                     $('#send #price strong').stop().animate({top:'-50px',opacity:0},1000);
  65.                 }
  66.                 else
  67.                 {
  68.                     $(priceBox).after('<strong>' +parseFloat(newPrice)+ ' zł</strong>');
  69.                     $('#send #price strong').stop().animate({top:'70px',opacity:0},1000);
  70.                 }
  71.             }
  72.         });
  73.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement