|
|
@ -2,21 +2,20 @@ import $ from "jquery"; |
|
|
|
|
|
|
|
|
window.getCookie = function(name) { |
|
|
window.getCookie = function(name) { |
|
|
var cookieValue = null; |
|
|
var cookieValue = null; |
|
|
if (document.cookie && document.cookie !== '') { |
|
|
if (document.cookie && document.cookie !== "") { |
|
|
var cookies = document.cookie.split(';'); |
|
|
var cookies = document.cookie.split(";"); |
|
|
for (var i = 0; i < cookies.length; i++) { |
|
|
for (var i = 0; i < cookies.length; i++) { |
|
|
var cookie = $.trim(cookies[i]); |
|
|
var cookie = $.trim(cookies[i]); |
|
|
if (cookie.substring(0, name.length + 1) === (name + '=')) { |
|
|
if (cookie.substring(0, name.length + 1) === name + "=") { |
|
|
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
|
|
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return cookieValue; |
|
|
return cookieValue; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
window.autorModal = function() { |
|
|
window.autorModal = function() { |
|
|
|
|
|
|
|
|
$(function() { |
|
|
$(function() { |
|
|
var dialog = $("#modal_autor").dialog({ |
|
|
var dialog = $("#modal_autor").dialog({ |
|
|
autoOpen: false, |
|
|
autoOpen: false, |
|
|
@ -25,7 +24,8 @@ window.autorModal = function() { |
|
|
height: 340, |
|
|
height: 340, |
|
|
show: { |
|
|
show: { |
|
|
effect: "blind", |
|
|
effect: "blind", |
|
|
duration: 500}, |
|
|
duration: 500 |
|
|
|
|
|
}, |
|
|
hide: { |
|
|
hide: { |
|
|
effect: "explode", |
|
|
effect: "explode", |
|
|
duration: 500 |
|
|
duration: 500 |
|
|
@ -33,11 +33,11 @@ window.autorModal = function() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$("#button-id-limpar").click(function() { |
|
|
$("#button-id-limpar").click(function() { |
|
|
$("#nome_autor").text(''); |
|
|
$("#nome_autor").text(""); |
|
|
|
|
|
|
|
|
function clean_if_exists(fieldname) { |
|
|
function clean_if_exists(fieldname) { |
|
|
if ($(fieldname).length > 0) { |
|
|
if ($(fieldname).length > 0) { |
|
|
$(fieldname).val(''); |
|
|
$(fieldname).val(""); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -46,87 +46,104 @@ window.autorModal = function() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$("#button-id-pesquisar").click(function() { |
|
|
$("#button-id-pesquisar").click(function() { |
|
|
$("#q").val(''); |
|
|
$("#q").val(""); |
|
|
$("#div-resultado").children().remove(); |
|
|
$("#div-resultado") |
|
|
$("#modal_autor").dialog( "open" ); |
|
|
.children() |
|
|
|
|
|
.remove(); |
|
|
|
|
|
$("#modal_autor").dialog("open"); |
|
|
$("#selecionar").attr("hidden", "hidden"); |
|
|
$("#selecionar").attr("hidden", "hidden"); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$("#pesquisar").click(function() { |
|
|
$("#pesquisar").click(function() { |
|
|
var name_in_query = $("#q").val() |
|
|
var name_in_query = $("#q").val(); |
|
|
//var q_0 = "q_0=nome__icontains"
|
|
|
//var q_0 = "q_0=nome__icontains"
|
|
|
//var q_1 = name_in_query
|
|
|
//var q_1 = name_in_query
|
|
|
//query = q_1
|
|
|
//query = q_1
|
|
|
|
|
|
|
|
|
$.get("/api/autor?q=" + name_in_query, function(data, status) { |
|
|
$.get("/api/autor?q=" + name_in_query, function(data) { |
|
|
$("#div-resultado").children().remove(); |
|
|
$("#div-resultado") |
|
|
if (data.pagination.total_entries == 0) { |
|
|
.children() |
|
|
$("#selecionar").attr("hidden", "hidden"); |
|
|
.remove(); |
|
|
$("#div-resultado").html( |
|
|
if (data.pagination.total_entries == 0) { |
|
|
"<span class='alert'><strong>Nenhum resultado</strong></span>"); |
|
|
$("#selecionar").attr("hidden", "hidden"); |
|
|
return; |
|
|
$("#div-resultado").html( |
|
|
} |
|
|
"<span class='alert'><strong>Nenhum resultado</strong></span>" |
|
|
|
|
|
); |
|
|
var select = $( |
|
|
return; |
|
|
'<select id="resultados" \ |
|
|
} |
|
|
style="min-width: 90%; max-width:90%;" size="5"/>'); |
|
|
|
|
|
|
|
|
var select = $( |
|
|
data.results.forEach(function(item, index) { |
|
|
'<select id="resultados" style="min-width: 90%; max-width:90%;" size="5"/>' |
|
|
select.append($("<option>").attr('value', item.value).text(item.text)); |
|
|
); |
|
|
}); |
|
|
|
|
|
|
|
|
data.results.forEach(function(item) { |
|
|
$("#div-resultado").append("<br/>").append(select); |
|
|
select.append( |
|
|
$("#selecionar").removeAttr("hidden", "hidden"); |
|
|
$("<option>") |
|
|
|
|
|
.attr("value", item.value) |
|
|
if (data.pagination.total_pages > 1) |
|
|
.text(item.text) |
|
|
$("#div-resultado").prepend('<span><br/>Mostrando 10 primeiros autores relativos a sua busca.<br/></span>'); |
|
|
); |
|
|
|
|
|
}); |
|
|
$("#selecionar").click(function() { |
|
|
|
|
|
let res = $("#resultados option:selected"); |
|
|
$("#div-resultado") |
|
|
let id = res.val(); |
|
|
.append("<br/>") |
|
|
let nome = res.text(); |
|
|
.append(select); |
|
|
|
|
|
$("#selecionar").removeAttr("hidden", "hidden"); |
|
|
$("#nome_autor").text(nome); |
|
|
|
|
|
|
|
|
if (data.pagination.total_pages > 1) |
|
|
// MateriaLegislativa pesquisa Autor via a tabela Autoria
|
|
|
$("#div-resultado").prepend( |
|
|
if ($('#id_autoria__autor').length) { |
|
|
"<span><br/>Mostrando 10 primeiros autores relativos a sua busca.<br/></span>" |
|
|
$('#id_autoria__autor').val(id); |
|
|
); |
|
|
} |
|
|
|
|
|
// Protocolo pesquisa a própria tabela de Autor
|
|
|
$("#selecionar").click(function() { |
|
|
if ($('#id_autor').length) { |
|
|
let res = $("#resultados option:selected"); |
|
|
$("#id_autor").val(id); |
|
|
let id = res.val(); |
|
|
} |
|
|
let nome = res.text(); |
|
|
|
|
|
|
|
|
dialog.dialog( "close" ); |
|
|
$("#nome_autor").text(nome); |
|
|
}); |
|
|
|
|
|
|
|
|
// MateriaLegislativa pesquisa Autor via a tabela Autoria
|
|
|
|
|
|
if ($("#id_autoria__autor").length) { |
|
|
|
|
|
$("#id_autoria__autor").val(id); |
|
|
|
|
|
} |
|
|
|
|
|
// Protocolo pesquisa a própria tabela de Autor
|
|
|
|
|
|
if ($("#id_autor").length) { |
|
|
|
|
|
$("#id_autor").val(id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dialog.dialog("close"); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
/*function get_nome_autor(fieldname) { |
|
|
|
|
|
if ($(fieldname).length > 0) { // se campo existir
|
|
|
/*function get_nome_autor(fieldname) { |
|
|
if ($(fieldname).val() != "") { // e não for vazio
|
|
|
if ($(fieldname).length > 0) { // se campo existir
|
|
|
var id = $(fieldname).val(); |
|
|
if ($(fieldname).val() != "") { // e não for vazio
|
|
|
$.get("/proposicao/get-nome-autor?id=" + id, function(data, status){ |
|
|
var id = $(fieldname).val(); |
|
|
$("#nome_autor").text(data.nome); |
|
|
$.get("/proposicao/get-nome-autor?id=" + id, function(data, status){ |
|
|
}); |
|
|
$("#nome_autor").text(data.nome); |
|
|
} |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
get_nome_autor("#id_autor"); |
|
|
get_nome_autor("#id_autor"); |
|
|
get_nome_autor("#id_autoria__autor");*/ |
|
|
get_nome_autor("#id_autoria__autor");*/ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
window.refreshMask = function () { |
|
|
window.refreshMask = function() { |
|
|
$('.telefone').mask("(99) 9999-9999", {placeholder:"(__) ____ -____"}); |
|
|
$(".telefone").mask("(99) 9999-9999", { placeholder: "(__) ____ -____" }); |
|
|
$('.cpf').mask("000.000.000-00", {placeholder:"___.___.___-__"}); |
|
|
$(".cpf").mask("000.000.000-00", { placeholder: "___.___.___-__" }); |
|
|
$('.cep').mask("00000-000", {placeholder:"_____-___"}); |
|
|
$(".cep").mask("00000-000", { placeholder: "_____-___" }); |
|
|
$('.rg').mask("0.000.000", {placeholder:"_.___.___"}); |
|
|
$(".rg").mask("0.000.000", { placeholder: "_.___.___" }); |
|
|
$('.titulo_eleitor').mask("0000.0000.0000.0000", {placeholder:"____.____.____.____"}); |
|
|
$(".titulo_eleitor").mask("0000.0000.0000.0000", { |
|
|
$('.dateinput').mask('00/00/0000', {placeholder:"__/__/____"}); |
|
|
placeholder: "____.____.____.____" |
|
|
$('.hora, input[name=hora_inicio], input[name=hora_fim]').mask("00:00", {placeholder:"hh:mm"}); |
|
|
}); |
|
|
$('.hora_hms').mask("00:00:00", {placeholder:"hh:mm:ss"}); |
|
|
$(".dateinput").mask("00/00/0000", { placeholder: "__/__/____" }); |
|
|
$('.timeinput').mask("00:00:00", {placeholder:"hh:mm:ss"}); |
|
|
$(".hora, input[name=hora_inicio], input[name=hora_fim]").mask("00:00", { |
|
|
$('.cronometro').mask("00:00:00", {placeholder:"hh:mm:ss"}); |
|
|
placeholder: "hh:mm" |
|
|
} |
|
|
}); |
|
|
|
|
|
$(".hora_hms").mask("00:00:00", { placeholder: "hh:mm:ss" }); |
|
|
|
|
|
$(".timeinput").mask("00:00:00", { placeholder: "hh:mm:ss" }); |
|
|
|
|
|
$(".cronometro").mask("00:00:00", { placeholder: "hh:mm:ss" }); |
|
|
|
|
|
}; |
|
|
|