Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.   if ($('#testislider').length > 0) {
  3.     $('#testislider .item:first').addClass('active');
  4.   }
  5.   $('#btnemail').on('click', function() {
  6.     var email = $("#news-email").val();
  7.     var url = "Index/gravaremail"
  8.     $.post(url, {
  9.       email: email
  10.     }, function(rs) {
  11.       $('#col-form-news').html('<h4 class="text-success"><i class="fa fa-thumbs-up"></i> Seu email foi cadastrado! Obrigado</h4>');
  12.     });
  13.   });
  14.  
  15.   //altera faixa precos quando selecionado venda / locacao
  16.   $('#finalidade').on('change', function(e) {
  17.     e.preventDefault();
  18.     if ($('#finalidade option:selected').val() == 2 || $('#finalidade option:selected').val() == 4) {
  19.       $('.valor_venda').hide();
  20.       $('.valor_locacao').show();
  21.     } else {
  22.       $('.valor_venda').show();
  23.       $('.valor_locacao').hide();
  24.     }
  25.   })
  26.   $('#panel-busca form').attr('onSubmit', 'return false');
  27.  
  28.   $('#btn-busca-codigo').on('click', function() {
  29.     var ref = $.trim($('#codigo-referencia').val());
  30.     if (ref != "") {
  31.       var url = baseUri + '/busca/codigo-referencia/' + ref + '/';
  32.       window.location = url;
  33.     }
  34.   });
  35.  
  36.   $('#btn-busca').on('click', function() {
  37.     var finalidade = $('#imovel_negocio').val();
  38.     var tipo = $('#imovel_tipo').val();
  39.  
  40.     var cidade = $.trim($('#imovel_cidade').val());
  41.     var bairro = $('#imovel_bairro').val();
  42.     var dormitorio = $('#imovel_dormitorio').val();
  43.     var vaga = $('#imovel_vaga').val();
  44.     var valormin = $('#imovel_preco_min').val();
  45.     var valormax = $('#imovel_preco_max').val();
  46.     if (finalidade == 2) {
  47.       var valormax = $('#imovel_preco_max').val();
  48.       var valormin = $('#imovel_preco_min').val();
  49.     }
  50.     if (baseUri !== null) {
  51.       var url = baseUri + '/busca/';
  52.     }
  53.  
  54.     if (baseUriMap !== null) {
  55.       var url = baseUri + '/busca-mapa/';
  56.     }
  57.  
  58.     if (finalidade != "") {
  59.       url += 'finalidade/' + finalidade + '/';
  60.     }
  61.  
  62.     if (tipo != "") {
  63.       url += 'tipo/' + tipo + '/';
  64.     }
  65.  
  66.     if (dormitorio >= 1) {
  67.       url += 'dormitorio/' + dormitorio + '/';
  68.     }
  69.  
  70.     if (vaga >= 1) {
  71.       url += 'vaga/' + vaga + '/';
  72.     }
  73.  
  74.     if (cidade != "") {
  75.       url += 'cidade/' + cidade + '/';
  76.     }
  77.     if (bairro != "") {
  78.       url += 'bairro/' + bairro + '/';
  79.     }
  80.  
  81.     if (valormax >= 1) {
  82.       url += 'preco-max/' + valormax + '/';
  83.     }
  84.     if (valormin >= 0) {
  85.       url += 'preco-min/' + valormin + '/';
  86.     }
  87.     if (finalidade != "") {
  88.       window.location = url;
  89.     } else {
  90.  
  91.     }
  92.  
  93.     if (tipo != "") {
  94.       window.location = url;
  95.     }
  96.     if (dormitorio >= 1) {
  97.       window.location = url;
  98.     }
  99.     if (vaga >= 1) {
  100.       window.location = url;
  101.     }
  102.   });
  103.   $('#imovel_cidade').on('change', function() {
  104.     var url = $.trim($(this).val());
  105.     if (url != "") {
  106.       var url = baseUri + '/imovelCliente/get_bairro_by_url/' + url + '/';
  107.       $.getJSON(url, {
  108.         url: url
  109.       }, function(rs) {
  110.         $('#imovel_bairro option').remove();
  111.         $('<option/>').val('').text('Selecione Bairro...').appendTo($('#imovel_bairro'));
  112.         if (rs != 'null') {
  113.           $.each(rs, function(k, v) {
  114.             console.log(v.bairro_url);
  115.             $('<option/>').val(v.bairro_url).text(v.bairro_nome).appendTo($('#imovel_bairro'));
  116.           });
  117.         }
  118.       });
  119.     }
  120.   });
  121. });
  122.  
  123. if ($('#imovel_preco_max').length > 0) {
  124.   var precoSlider = document.getElementById('imovel_preco_max');
  125.   noUiSlider.create(precoSlider, {
  126.     range: {
  127.       'min': 0,
  128.       '10%': 100,
  129.       '20%': 2000,
  130.       '30%': 5000,
  131.       '40%': 10000,
  132.       '50%': 100000,
  133.       '60%': 300000,
  134.       '70%': 500000,
  135.       '80%': 700000,
  136.       '90%': 1000000,
  137.       'max': 5000000
  138.     },
  139.     snap: true,
  140.     start: [0, 300000],
  141.     format: {
  142.       to: function(value) {
  143.         return (Math.round(value) > 1) ? Math.round(value) : Math.round(value);
  144.       },
  145.       from: function(value) {
  146.         return ((Math.round(value.replace(',-', ''))) > 1) ? Math.round(value.replace(',-', '')) : Math.round(value.replace(',-', ''));
  147.       }
  148.     },
  149.   });
  150.   precoSlider.noUiSlider.on('update', function(values, handle) {
  151.     var value = values[handle];
  152.     var preco_min = values[0];
  153.     var preco_max = values[1];
  154.     $('#imovel_preco_min').val(preco_min);
  155.     $('#imovel_preco_max').val(preco_max);
  156.     $('#slide-preco-min').text($.number(preco_min, 2));
  157.     $('#slide-preco-max').text($.number(preco_max, 2));
  158.   });
  159.  
  160.   var quartoSlider = document.getElementById('dorm-slider');
  161.   noUiSlider.create(quartoSlider, {
  162.     range: {
  163.       'min': 0,
  164.       'max': 10
  165.     },
  166.     step: 1,
  167.     start: 0
  168.   });
  169.   quartoSlider.noUiSlider.on('update', function(values, handle) {
  170.     var value = values[handle];
  171.     var dorms = values[0].replace('.00', '');
  172.     $('#imovel_dormitorio').val(dorms);
  173.     if (dorms <= 0) {
  174.       dorms = 'indiferente';
  175.     }
  176.     $('#slide-quartos').text(dorms);
  177.   });
  178.  
  179.   var vagaSlider = document.getElementById('vaga-slider');
  180.   noUiSlider.create(vagaSlider, {
  181.     range: {
  182.       'min': 0,
  183.       'max': 10
  184.     },
  185.     step: 1,
  186.     start: 0
  187.   });
  188.   vagaSlider.noUiSlider.on('update', function(values, handle) {
  189.     var value = values[handle];
  190.     var vagas = values[0].replace('.00', '');
  191.     $('#imovel_vaga').val(vagas);
  192.     if (vagas <= 0) {
  193.       vagas = 'indiferente';
  194.     }
  195.     $('#slide-vaga').text(vagas);
  196.   });
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement