//$('form:first *:input[disabled != disabled], [type != hidden] :first').focus(); $(document).ready(function () { SetTitle($('#page-title').text()); if (GetLS('openleftmenu') == 'true' || GetLS('openleftmenu') == '') { openLeftMenu(); } else { closeLeftMenu(); } $('input, select').bind("keypress", function (e) { var k = e.which || e.keyCode; if (k == 13) { e.preventDefault(); campo = $('input, select, textarea, button'); indice = campo.index(this); if (campo.eq(indice + 1).attr('readonly')) { for (i = 1; i < 100; i++) { if (!campo.eq(indice + i).attr('readonly')) { if (campo[indice + i] != null) { proximo = campo[indice + i]; proximo.focus(); proximo.select(); } break; } } } else { if (campo[indice + 1] != null) { proximo = campo[indice + 1]; proximo.focus(); proximo.select(); } } } }); $("#wrapper").toggleClass("toggle"); $('input[tp=time]').mask('00:00'); $('input[tp=datatime]').mask('00/00/0000 00:00:00'); $('input[tp=data]').mask('00/00/0000'); $('input[tp=rg]').mask('00.000.000-0'); $('input[tp=cep]').mask('00000-000'); $('input[tp=ie]').mask('000000000'); $('input[tp=cpf]').mask('000.000.000-00'); $('input[tp=cnpj]').mask('00.000.000/0000-00'); $('input[tp=mesano]').mask('00/0000'); $('input[tp=contabil]').mask('0.00.000'); $('input[tp=cpfcnpj]').mask('00000000000000', { reverse: true }); $('input[doc=cpfcnpj]').blur(function () { var vl = $(this).val(); if (vl.length == 10) { $(this).attr('tp', 'cpf'); } else if (vl.length == 14) { $(this).attr('tp', 'cpf'); } else { $(this).attr('tp', 'cpfcnpj'); } }); $('input[tp=float]').bind("keypress", function (e) { //console.log($(this).attr('readonly')); var tecla = e.which || e.keyCode; var texto = $(this).val(); var indexvir = texto.indexOf(","); var indexpon = texto.indexOf("."); if (tecla == 8 || tecla == 0) return true; if (tecla != 44 && tecla != 46 && tecla < 48 || tecla > 57) return false; if (tecla == 44) { if (indexvir !== -1 || indexpon !== -1) { return false } } if (tecla == 46) { if (indexvir !== -1 || indexpon !== -1) { return false } } }); var diaSemana = ['Domingo', 'Segunda-Feira', 'Terca-Feira', 'Quarta-Feira', 'Quinta-Feira', 'Sexta-Feira', 'Sabado']; var mesAno = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; var data = new Date(); var hoje = diaSemana[data.getDay()] + ', ' + mesAno[data.getMonth()] + ' de ' + data.getFullYear(); /**/ $("button[class*='btn-link']").click(function () { $("button[class*='btn-link']").removeClass('btn-active'); $(this).addClass('btn-active'); SetLS('active', $(this).attr("name")); }); $("button[name='" + GetLS('active') + "']").addClass('btn-active'); /**/ $("button[class*='link-side']").click(function () { $("button[class*='link-side']").removeClass('link-side-active'); $(this).addClass('link-side-active'); }); /**/ $("li*[tp='linkmenu']").click(function () { var page = $(this).attr('page'); OpenPage('?pg=' + page); $(this).removeClass('li-active'); SetLS('MenuPosition', page); }); /**/ var AtualPage = location.href.substring(location.href.lastIndexOf('?pg=') + 4).split('&')[0]; //console.log(AtualPage); $("li*[page='" + AtualPage.replace('cad_', 'lista_').replace('#', '') + "']").addClass('li-active'); $("li*[page='" + AtualPage + "']").addClass('li-active'); /**/ $('input[tp=integer]').keypress(function () { return onlynumber(); }); $('input[tp=integer]').blur(function () { var val = $(this).val(); $(this).val(apenasNumeros(val)); }); $('input[tp=float]').blur(function () { if (!$(this).attr('readonly')) { var val = $(this).val(); $(this).val(MoedaPrint(val)); //$(this).val(MoedaPrint(val)); } }); // $("input[valida='true']").focus(function () { $(this).removeClass('border-invalid'); }); $("select[valida='true']").focus(function () { $(this).removeClass('border-invalid'); }); /**/ var sFocus = setInterval(function () { $('input[autofocus]').select().bind('keyup blur', function () { clearInterval(sFocus); }); }, 300); /**/ if (GetLS('lm_cadastros') == 'false') { $('#lm_cadastros').slideToggle(); } if (GetLS('lm_apontamentos') == 'false') { $('#lm_apontamentos').slideToggle(); } if (GetLS('lm_configuracoes') == 'false') { $('#lm_configuracoes').slideToggle(); } /**/ $('#open-filter').click(function () { $('#cFiltro').slideToggle(); var aFilter = GetLS('filter'); if (aFilter == 'true') { SetLS('filter', 'false'); } else { SetLS('filter', 'true'); } }); var aFilter = GetLS('filter'); if (aFilter == 'true') { $('#cFiltro').show(); } /**/ LoadFiltro('form_filtro'); //document.body.style.zoom = "90%"; if ($('li[page="' + AtualPage.replace('cad_', '') + '"]').length) { setTimeout(function () { $('#mySidenav').animate({ scrollTop: $('li[page="' + AtualPage.replace('cad_', '') + '"]').offset().top - 500 }, 'slow'); }, 1000); } /* // Arguments : // verb : 'GET'|'POST' // target : an optional opening target (a name, or "_blank"), defaults to "_self" // io.open('POST', 'fileServer.jsp', {request: {key:"42", cols:[2, 3, 34]}}); //Para abrir em uma nova janela, defina o targetparâmetro: //io.open('POST', someURL, someArgs, 'newwin'); //ou para garantir que seja uma nova janela / guia a cada vez: //io.open('POST', someURL, someArgs, '_blank'); //https://www.javaer101.com/pt/article/2669872.html */ window.io = { open: function (verb, url, data, target) { var form = document.createElement("form"); form.action = url; form.method = verb; form.target = target || "_self"; if (data) { for (var key in data) { var input = document.createElement("textarea"); input.name = key; input.value = typeof data[key] === "object" ? JSON.stringify(data[key]) : data[key]; form.appendChild(input); } } form.style.display = 'none'; document.body.appendChild(form); form.submit(); document.body.removeChild(form); } }; /*CRIA UM COOKIE COM A URL ATUAL*/ var AtualURL = window.location.href; if (AtualURL.indexOf('exit') == -1) { setCookie('url_atual', window.location.href); } }); /*VERIFICA SE TEM EMPRESA SELECIONADA*/ GetSession().done(function (data) { var uPage = GetParamURL('pg'); var obj = JSON.parse(data); if ((obj.id_empresa == '' || isUndefined(obj.id_empresa)) && obj.id.trim() !== '') { /*SE NÃO TIVER EMPRES SELECIONA, VERIRFICA SE A PÁGINA PODE TER ACESSO SEM EMPRESA*/ if (uPage.trim() !== '' && uPage.indexOf('painel_administrativo') == -1 && uPage.indexOf('cad_empresa') == -1 && uPage.indexOf('lista_empresa') == -1 && uPage.indexOf('_acesso') == -1) { TrocaEmpresa(); } } if (obj.nivel == '3') { //Verifica se é empresa $('*[ac=not_emp]').remove(); //Remove os itens que tem esse parâmetro } else if (obj.nivel == '2') { $('*[acs=not_cons]').remove(); } });