Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- if ($('#testislider').length > 0) {
- $('#testislider .item:first').addClass('active');
- }
- $('#btnemail').on('click', function() {
- var email = $("#news-email").val();
- var url = "Index/gravaremail"
- $.post(url, {
- email: email
- }, function(rs) {
- $('#col-form-news').html('<h4 class="text-success"><i class="fa fa-thumbs-up"></i> Seu email foi cadastrado! Obrigado</h4>');
- });
- });
- //altera faixa precos quando selecionado venda / locacao
- $('#finalidade').on('change', function(e) {
- e.preventDefault();
- if ($('#finalidade option:selected').val() == 2 || $('#finalidade option:selected').val() == 4) {
- $('.valor_venda').hide();
- $('.valor_locacao').show();
- } else {
- $('.valor_venda').show();
- $('.valor_locacao').hide();
- }
- })
- $('#panel-busca form').attr('onSubmit', 'return false');
- $('#btn-busca-codigo').on('click', function() {
- var ref = $.trim($('#codigo-referencia').val());
- if (ref != "") {
- var url = baseUri + '/busca/codigo-referencia/' + ref + '/';
- window.location = url;
- }
- });
- $('#btn-busca').on('click', function() {
- var finalidade = $('#imovel_negocio').val();
- var tipo = $('#imovel_tipo').val();
- var cidade = $.trim($('#imovel_cidade').val());
- var bairro = $('#imovel_bairro').val();
- var dormitorio = $('#imovel_dormitorio').val();
- var vaga = $('#imovel_vaga').val();
- var valormin = $('#imovel_preco_min').val();
- var valormax = $('#imovel_preco_max').val();
- if (finalidade == 2) {
- var valormax = $('#imovel_preco_max').val();
- var valormin = $('#imovel_preco_min').val();
- }
- if (baseUri !== null) {
- var url = baseUri + '/busca/';
- }
- if (baseUriMap !== null) {
- var url = baseUri + '/busca-mapa/';
- }
- if (finalidade != "") {
- url += 'finalidade/' + finalidade + '/';
- }
- if (tipo != "") {
- url += 'tipo/' + tipo + '/';
- }
- if (dormitorio >= 1) {
- url += 'dormitorio/' + dormitorio + '/';
- }
- if (vaga >= 1) {
- url += 'vaga/' + vaga + '/';
- }
- if (cidade != "") {
- url += 'cidade/' + cidade + '/';
- }
- if (bairro != "") {
- url += 'bairro/' + bairro + '/';
- }
- if (valormax >= 1) {
- url += 'preco-max/' + valormax + '/';
- }
- if (valormin >= 0) {
- url += 'preco-min/' + valormin + '/';
- }
- if (finalidade != "") {
- window.location = url;
- } else {
- }
- if (tipo != "") {
- window.location = url;
- }
- if (dormitorio >= 1) {
- window.location = url;
- }
- if (vaga >= 1) {
- window.location = url;
- }
- });
- $('#imovel_cidade').on('change', function() {
- var url = $.trim($(this).val());
- if (url != "") {
- var url = baseUri + '/imovelCliente/get_bairro_by_url/' + url + '/';
- $.getJSON(url, {
- url: url
- }, function(rs) {
- $('#imovel_bairro option').remove();
- $('<option/>').val('').text('Selecione Bairro...').appendTo($('#imovel_bairro'));
- if (rs != 'null') {
- $.each(rs, function(k, v) {
- console.log(v.bairro_url);
- $('<option/>').val(v.bairro_url).text(v.bairro_nome).appendTo($('#imovel_bairro'));
- });
- }
- });
- }
- });
- });
- if ($('#imovel_preco_max').length > 0) {
- var precoSlider = document.getElementById('imovel_preco_max');
- noUiSlider.create(precoSlider, {
- range: {
- 'min': 0,
- '10%': 100,
- '20%': 2000,
- '30%': 5000,
- '40%': 10000,
- '50%': 100000,
- '60%': 300000,
- '70%': 500000,
- '80%': 700000,
- '90%': 1000000,
- 'max': 5000000
- },
- snap: true,
- start: [0, 300000],
- format: {
- to: function(value) {
- return (Math.round(value) > 1) ? Math.round(value) : Math.round(value);
- },
- from: function(value) {
- return ((Math.round(value.replace(',-', ''))) > 1) ? Math.round(value.replace(',-', '')) : Math.round(value.replace(',-', ''));
- }
- },
- });
- precoSlider.noUiSlider.on('update', function(values, handle) {
- var value = values[handle];
- var preco_min = values[0];
- var preco_max = values[1];
- $('#imovel_preco_min').val(preco_min);
- $('#imovel_preco_max').val(preco_max);
- $('#slide-preco-min').text($.number(preco_min, 2));
- $('#slide-preco-max').text($.number(preco_max, 2));
- });
- var quartoSlider = document.getElementById('dorm-slider');
- noUiSlider.create(quartoSlider, {
- range: {
- 'min': 0,
- 'max': 10
- },
- step: 1,
- start: 0
- });
- quartoSlider.noUiSlider.on('update', function(values, handle) {
- var value = values[handle];
- var dorms = values[0].replace('.00', '');
- $('#imovel_dormitorio').val(dorms);
- if (dorms <= 0) {
- dorms = 'indiferente';
- }
- $('#slide-quartos').text(dorms);
- });
- var vagaSlider = document.getElementById('vaga-slider');
- noUiSlider.create(vagaSlider, {
- range: {
- 'min': 0,
- 'max': 10
- },
- step: 1,
- start: 0
- });
- vagaSlider.noUiSlider.on('update', function(values, handle) {
- var value = values[handle];
- var vagas = values[0].replace('.00', '');
- $('#imovel_vaga').val(vagas);
- if (vagas <= 0) {
- vagas = 'indiferente';
- }
- $('#slide-vaga').text(vagas);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement