﻿var employer = { VERSION: function () { return 1.2 }, VERSION_DATE: function () { return new Date("11-7-2008") } }; employer.util = { findControl: function (control) { return $("[id$=" + control + "]") }, findClientID: function (control) { return eventcontrol.util.findControl(control).attr("id") }, findClientIDControle: function (control) { return employer.util.findClientID(control + "_txtValor") }, acf: false, isArray: function (e) { return (typeof (e.length) == "undefined") ? false : true }, fixBugModal: function () { var ovf = $get("conteudo").style.overflow; if (!ovf || ovf == "" || ovf == "auto") { $get("conteudo").style.overflow = "visible" } else { $get("conteudo").style.overflow = "auto" } }, getSelectionSize: function (e) { if (document.selection) { var textRange = document.selection.createRange(); return textRange.text.length } else { if (typeof e.selectionStart == "number") { return e.selectionEnd - e.selectionStart } } }, validPwd: function (source, args) { var txt = args.Value; var c_num = 0; var c_str = 0; for (var i = 0; i < txt.length; i++) { if (isNaN(+(txt.charAt(i)))) { if (txt.charCodeAt(i) >= 65 && txt.charCodeAt(i) <= 90) { c_str++ } else { if (txt.charCodeAt(i) >= 97 && txt.charCodeAt(i) <= 122) { c_str++ } } } else { if (typeof +(txt.charAt(i)) == "number") { c_num++ } } } if (c_num == 4 && c_str == 4) { args.IsValid = true } else { args.IsValid = false } } }; employer.util.date = { isEarlier: function (arg1, arg2) { var dt1, dt2; if (typeof arg1 == "string" && typeof arg2 == "string") { var splitter; for (var i = 0; i < arg1.length; i++) { if (arg1.charCodeAt(i) < 48 || arg1.charCodeAt(i) > 57) { splitter = arg1.charAt(i); break } } if (splitter) { var t1 = arg1.split(splitter); dt1 = new Date(t1[2], t1[1] - 1, t1[0]); var t2 = arg2.split(splitter); dt2 = new Date(t2[2], t2[1] - 1, t2[0]) } else { return false } } else { dt1 = arg1; dt2 = arg2 } if (dt1.getTime() < dt2.getTime()) { return true } else { return false } }, isEqual: function (arg1, arg2) { var dt1, dt2; if (typeof arg1 == "string" && typeof arg2 == "string") { var splitter; for (var i = 0; i < arg1.length; i++) { if (arg1.charCodeAt(i) < 48 || arg1.charCodeAt(i) > 57) { splitter = arg1.charAt(i); break } } var t1 = arg1.split(splitter); dt1 = new Date(t1[2], t1[1] - 1, t1[0]); var t2 = arg2.split(splitter); dt2 = new Date(t2[2], t2[1] - 1, t2[0]) } else { dt1 = arg1; dt2 = arg2 } if (dt1.getTime() == dt2.getTime()) { return true } else { return false } }, calcDiferencaMilisegundos: function (data1, data2) { return Math.abs(data1.getTime() - data2.getTime()) }, calcDiferencaDias: function (data1, data2) { var diferencaDias = employer.util.date.calcDiferencaMilisegundos(data1, data2) / 86400000; var diferencaDiasArredondado = Math.round(diferencaDias); return (diferencaDiasArredondado > diferencaDias) ? diferencaDiasArredondado - 1 : diferencaDiasArredondado }, calcDiferencaAnos: function (data1, data2) { var diferencaAnos = employer.util.date.calcDiferencaDias(data1, data2) / 365; var diferencaAnosArredondado = Math.round(diferencaAnos); return (diferencaAnosArredondado > diferencaAnos) ? diferencaAnosArredondado - 1 : diferencaAnosArredondado } }; employer.util.string = { toNumber: function (string) { var i = 0; var negativo = false; while (string.charAt(i) == " ") { i++ } if (string.charAt(i) == "-") { negativo = true } var temp = string.replace(/\./g, ""); temp = temp.replace(/,/g, "."); temp = temp.replace(/[^0-9.]/g, ""); if (negativo) { return -(+temp) } else { return (+temp) } }, trim: function (str) { return str.replace(/^\s+|\s+$/g, "") }, shortTrim: function (str) { return str.replace(/^\s\s*/, "").replace(/\s\s*$/, "") }, longTrim: function (str) { var str = str.replace(/^\s\s*/, ""), ws = /\s/, i = str.length; while (ws.test(str.charAt(--i))) { } return str.slice(0, i + 1) }, replace: function (p, t) { var _p; var _pg; var _tt = t; var _ocur = []; var _val = []; if (typeof p == "string") { _p = new RegExp(p); _pg = new RegExp(p, "g") } if (t.match(_p)) { for (var i = 2; i < arguments.length; i++) { if (i == 2) { if (typeof arguments[2] == "string") { _val.push(arguments[2]) } else { _val = arguments[2] } } else { if (typeof arguments[i] == "object" && employer.util.isArray(arguments[i])) { for (var j = 0; j < arguments[i].length; j++) { _val.push(arguments[i][j]) } } else { _val.push(arguments[i]) } } } var _tmp_s = 0; while (t.indexOf(p, _tmp_s) > -1) { _ocur.push(t.indexOf(p, _tmp_s)); _tmp_s = t.indexOf(p, _tmp_s) + p.length } if (_ocur.length != _val.length) { return "Lista de valores informados (" + _val.length + ") diferente da quantidade de ocorrência (" + _ocur.length + ") no contexto informado." } for (var k = 0; k < _val.length; k++) { _tt = _tt.replace(_p, _val[k]) } return _tt } } }; employer.form = { nav: function (evt) { var k = employer.event.getKey(evt)[0]; var t = employer.event.getTarget(evt); var ac = employer.form.util.hasBehaviorAutoComplete(t); var selectok = true; var tag = String(t.nodeName).toLowerCase(); var type = String(t.type).toLowerCase(); var id = t.id; var mod = employer.key.hasModifierKeyPressed(evt); if (employer.key.isArrow(k) && k == employer.key._arrows.UP_ARROW) { employer.event.cancel(evt); if (t.tagName.toLowerCase() == "select") { if (!employer.form.util.isSelectedIndexAtMinMaxRange(t, "min")) { selectok = false; t.selectedIndex-- } } if (ac[0] && !ac[1] && selectok) { t.blur(); window.setTimeout(function () { employer.form.previous(t) }, 300) } else { if (!ac[0] && selectok) { t.blur(); window.setTimeout(function () { employer.form.previous(t) }, 200) } } } else { if (employer.key.isArrow(k) && k == employer.key._arrows.DOWN_ARROW) { employer.event.cancel(evt); if (t.tagName.toLowerCase() == "select") { if (!employer.form.util.isSelectedIndexAtMinMaxRange(t, "max")) { selectok = false; t.selectedIndex++ } } if (ac[0] && !ac[1] && selectok) { t.blur(); window.setTimeout(function () { employer.form.next(t) }, 300) } else { if (!ac[0] && selectok) { t.blur(); window.setTimeout(function () { employer.form.next(t) }, 200) } } } else { if (k == employer.key._commands.TAB || (k == employer.key._commands.ENTER && (id != "ctl00_txtFiltroPesquisa_txtValor" && id != "ctl00_cphConteudo_txtFiltroPesquisa_txtValor"))) { employer.event.cancel(evt); if (!evt.shiftKey && !evt.shiftLeft) { if (t.tagName.toLowerCase() == "select") { if (!employer.form.util.isSelectedIndexAtMinMaxRange(t, "max")) { selectok = false; t.selectedIndex++ } } if (ac[0] && !ac[1] && selectok) { t.blur(); window.setTimeout(function () { employer.form.next(t) }, 300) } else { if (!ac[0] && selectok) { t.blur(); window.setTimeout(function () { employer.form.next(t) }, 200) } } } else { if (evt.shiftKey || evt.shiftLeft) { if (t.tagName.toLowerCase() == "select") { if (!employer.form.util.isSelectedIndexAtMinMaxRange(t, "min")) { selectok = false; t.selectedIndex-- } } if (ac[0] && !ac[1] && selectok) { t.blur(); window.setTimeout(function () { employer.form.previous(t) }, 300) } else { if (!ac[0] && selectok) { t.blur(); window.setTimeout(function () { employer.form.previous(t) }, 200) } } } } } } } }, getNavigationListFromElement: function (e) { var parent = e.parentNode; while (parent != null && parent.id != "conteudo" && parent.id != "conteudoRodape" && parent.id != "topo") { var pClass = parent.className; if (pClass.match("painel_resultado_padrao") || pClass == "uc_cep") { break } parent = parent.parentNode } var container; if (parent == null) { container = "#conteudo" } else { if (typeof parent.id == "string" && parent.id) { container = "#" + parent.id } else { container = "." + parent.className } } return $(container).find(":input:visible:not(:image)") }, getNavigationList: function () { return $("#conteudo").find(":input:visible:not(:image)") }, getFirstElement: function () { var list = employer.form.getNavigationList(); for (var i = 0; i < list.length; i++) { if (employer.form.util.canHaveFocus(list[i])) { return list[i]; break } } }, getLastElement: function () { var list = employer.form.getNavigationList(); for (var i = list.length - 1; i >= 0; i--) { if (employer.form.util.canHaveFocus(list[i])) { return list[i]; break } } }, getLastFocus: function () { var temp = $get("ctl00_hfUltimoFoco"); if (temp != null) { if (temp.value != "") { var lastFocus = $get(temp.value); if (lastFocus != null) { return lastFocus } } } return null }, setLastFocus: function (event) { var t = employer.event.getTarget(event); if (t != null) { var lastFocus = $get("ctl00_hfUltimoFoco"); if (lastFocus != null) { lastFocus.value = t.id } } }, next: function (e) { if (e == $get(e.id)) { var eform = employer.form.getNavigationListFromElement(e); var foundElement = false; var nextElement; var n; if (e.className.match("loader")) { return } if (!employer.form.util.validateFocusOnError(e)) { for (var i = 0; i < eform.length; i++) { if (eform[i].id == e.id) { foundElement = true } if (foundElement && eform[i].id != e.id && employer.form.util.canHaveFocus(eform[i])) { nextElement = eform[i]; break } } } if (typeof nextElement == "object") { p = nextElement } else { p = e } p.focus(); if ((p.type && p.type != "button" && p.type != "reset" && p.type != "submit") && p.select) { p.select() } } }, previous: function (e) { if (e == $get(e.id)) { var eform = employer.form.getNavigationListFromElement(e); var foundElement = false; var previousElement; var p; if (!employer.form.util.validateFocusOnError(e)) { for (var i = eform.length - 1; i >= 0; i--) { if (eform[i].id == e.id) { foundElement = true } if (foundElement && eform[i].id != e.id && employer.form.util.canHaveFocus(eform[i])) { previousElement = eform[i]; break } } } if (typeof previousElement == "object") { p = previousElement } else { p = e } p.focus(); if ((p.type && p.type != "button" && p.type != "reset" && p.type != "submit") && p.select) { p.select() } } } }; employer.form.util = { truncate: function (evt) { var fc = function () { var e = employer.event.getTarget(evt); e.value = employer.util.string.trim(e.value); var tstart = 0, tend = e.value.length; var maxlength = (+e.getAttribute("MaxLength")); if (maxlength == 0) { maxlength = (+e.parentNode.getAttribute("MaxLength")); if (maxlength == 0) { maxlength = (+e.getAttribute("rows")) * (+e.getAttribute("cols")) } } if (tend > maxlength) { tend = maxlength } if (maxlength > 0) { e.value = e.value.substring(tstart, tend) } switch (Sys.Browser.agent) { case Sys.Browser.InternetExplorer: if ("fireEvent" in e) { try { e.fireEvent("onChange") } catch (error) { } } return; default: var newevt = document.createEvent("HTMLEvents"); newevt.initEvent("change", true, true); e.dispatchEvent(newevt); return } }; window.setTimeout(fc, 300) }, disableComponent: function (c) { var e; var validators = []; if (typeof c == "string") { e = $get(c) } else { e = c } if (e) { for (var i = 0; i < e.children.length; i++) { if (e.children[i].id.toLowerCase().indexOf("validador") > -1) { for (var j = 0; j < e.children[i].children.length; j++) { if (e.children[i].children[0].enabled) { ValidatorEnable(e.children[i].children[0], false) } } } else { if (employer.form.util.isValidFormElement(e.children[i])) { if (!e.children[i].disabled) { e.children[i].disabled = true } } } } } }, enableComponent: function (c) { var e; var validators = []; if (typeof c == "string") { e = $get(c) } else { e = c } if (e) { for (var i = 0; i < e.children.length; i++) { if (e.children[i].id.toLowerCase().indexOf("validador") > -1) { for (var j = 0; j < e.children[i].children.length; j++) { if (!e.children[i].children[0].enabled) { ValidatorEnable(e.children[i].children[0], true) } } } else { if (employer.form.util.isValidFormElement(e.children[i])) { if (e.children[i].disabled) { e.children[i].disabled = false } } } } } }, getValidators: function (e) { if (typeof (e.Validators) != "undefined") { return e.Validators } }, isBtnPesquisa: function (e) { var idPesquisa = "ctl00_txtFiltroPesquisa_txtValor"; var idPesquisaConteudo = "ctl00_cphConteudo_txtFiltroPesquisa_txtValor"; if (typeof e == "string") { if (e == idPesquisa || e == idPesquisaConteudo) { return true } } else { if (e.id == idPesquisa || e.id == idPesquisaConteudo) { return true } } return false }, focusid: false, ffe: function (e) { var id; if (typeof e == "string") { if ($get(e).tagName == "INPUT") { id = e } else { id = RecuperarComponenteValor($get(e)).id } } else { if (typeof e == "object") { if (e.tagName == "SPAN") { id = RecuperarComponenteValor(e).id } else { id = e.id } } else { id = this.getFirstElement().id } } employer.form.util.focusid = id }, hadFocusBtnPesquisa: "", focusBtnPesquisa: function (evt) { if (this.hadFocusBtnPesquisa != "") { var lf = $get(this.hadFocusBtnPesquisa); lf.focus(); if (lf.select) { lf.select() } this.hadFocusBtnPesquisa = "" } else { this.hadFocusBtnPesquisa = employer.event.getTarget(evt).id; var bp = $get("ctl00_txtFiltroPesquisa_txtValor"); bp.focus(); if (bp.select) { bp.select() } } }, isValidFormElement: function (e) { if (String(e.nodeName).toLowerCase() == "input" && String(e.type).toLowerCase() == "text") { return true } else { if (String(e.nodeName).toLowerCase() == "input" && String(e.type).toLowerCase() == "submit") { return true } else { if (String(e.nodeName).toLowerCase() == "textarea") { return true } else { if (String(e.nodeName).toLowerCase() == "select") { return true } else { return false } } } } }, isSelectedIndexAtMinMaxRange: function (e, axis) { var node = e.nodeName.toLowerCase(); var type = String(e.type).toLowerCase(); if (e && node == "select" && type == "select-one") { if (e.selectedIndex == "0" && axis.toLowerCase() == "min") { return true } else { if (e.selectedIndex == e.length - 1 && axis.toLowerCase() == "max") { return true } else { return false } } } else { return true } }, hasBehaviorAutoComplete: function (e) { var listBehavior = Sys.UI.Behavior.getBehaviors(e); var hasAutoComplete = false; var hasFlyout = false; if (listBehavior.length > 0) { for (var i = 0; i < listBehavior.length; i++) { if (listBehavior[i].get_name() == "AutoCompleteBehavior") { hasAutoComplete = true; if (listBehavior[i]._completionListElement.childNodes.length > 0) { hasFlyout = true } break } } } return [hasAutoComplete, hasFlyout] }, hasVisibleParent: function (e) { if (!e.disabled && (e.type && (e.type != "hidden")) && (e.style && e.style.display != "none")) { var eparent = e.parentNode; while (eparent.id != "conteudo" && eparent.id != "topo" && (eparent.style && eparent.style.display != "none") && eparent.id != "conteudoRodape") { eparent = eparent.parentNode } if (eparent.style.display != "none") { return true } else { return false } } else { return false } }, canHaveFocus: function (e) { if (employer.form.util.hasVisibleParent(e) && !employer.form.util.ignoreElement(e) && !e.disabled) { return true } else { return false } }, autoCompleteClientSelected: function (source, eventArgs) { var t = source.get_element(); employer.form.next(t) }, ignoreElement: function (e) { if (typeof e == "object" && e.id && e.id.match(".*_ign.*")) { return true } else { if (typeof e == "string" && e.match(".*_ign.*")) { return true } else { return false } } }, validateFocusOnError: function (e) { var validator = e.getAttribute("Validators"); var pattern = /(\d|[a-z]|[A-Z]|[_])+(([_][r][e])|([_][c][v])|([_][r][v]))(\d|[A-Z]|[a-z])+$/; if (typeof (validator) == "object" && validator) { for (var i = 0; i < validator.length; i++) { if (pattern.exec(validator[i].id)) { var focusOnError = validator[i].getAttribute("focusOnError"); var isValid = validator[i].getAttribute("isValid"); if ((typeof (isValid) == "boolean" && isValid == false) && (typeof (focusOnError) == "string" && focusOnError === "t")) { return true } } } } return false }, searchInvalidValidator: function (e, vg) { if (!e.isDisabled) { employer.form.util.validarPagina(vg); for (var i = 0; i < Page_Validators.length; i++) { if (!Page_Validators[i].isvalid) { document.getElementById(Page_Validators[siv].controltovalidate).focus(); return false } } return true } else { return false } }, validarPagina: function (vg) { for (var i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].validationGroup == vg) { ValidatorValidate(Page_Validators[i]) } } }, getValueListaSugestao: function (tls, pos) { var _FIRST = -1; var _LAST = -2; var _ls = employer.form.util.parseListaSugestaoToArray(tls); if (pos == _FIRST && _ls.length > 0) { return _ls[0] } else { if (pos == _LAST && _ls.length > 0) { return _ls[_ls.length - 1] } else { if (_ls.length > 0) { return _ls[pos] } else { return false } } } }, setValueListaSugestao: function (tls, pos) { var _FIRST = -1; var _LAST = -2; var val; var _ls = employer.form.util.parseListaSugestaoToArray(tls); if (pos == _FIRST && _ls.length > 0) { val = _ls[0] } else { if (pos == _LAST && _ls.length > 0) { val = _ls[_ls.length - 1] } else { if (_ls.length > 0) { val = _ls[pos] } } } var lsgt = tls.parentNode.parentNode; for (var i = 0; i < lsgt.children.length; i++) { if (lsgt.children[i].id.match("/*txtValor$")) { lsgt.children[i].value = val.codigo } else { if (lsgt.children[i].id.match("/*lblValor$")) { lsgt.children[i].childNodes[0].nodeValue = val.descricao } } } }, parseListaSugestaoToArray: function (table) { var cells = table.cells; var json = "[ "; for (var i = 0; i < cells.length; i++) { if (cells[i].className) { var str_id = cells[i].className; var val_id = cells[i].firstChild.data; i++; var str_desc = cells[i].className; var val_desc = cells[i].firstChild.data; json += "{ " + str_id + " : " + val_id + " , " + str_desc + ' : "' + val_desc + '" }'; if (i + 1 != cells.length) { json += " , " } } } json += " ]"; return eval(json) } }; function AjustarValidadores() { $(".validador[style*='inline']").css("display", "block") } function AjustarMenuCortina() { $(".botao_puxador_tela").css("left", $(".logo_sistema_simbolo").offset().left); $(".menu_cortina").css("left", $(".logo_sistema_simbolo").offset().left) } function AjustarBotoesLateralDireita() { $(".painel_botoes_lateral_direita").css("left", ($(window).width() - ((($(window).width() - $(".conteudo .interna").width()) / 2) / 2) - ($(".painel_botoes_lateral_direita a").width() / 2))); var t = 0; $(".painel_botoes_lateral_direita a").each(function () { t += $(this).outerHeight() + parseInt($(this).css("margin-top")) + parseInt($(this).css("margin-bottom")) }); $(".painel_botoes_lateral_direita").css("top", $(window).height() / 2 - t / 2) } function AjustarRadGrid() { $("*[id*='FilterTextBox']").addClass("textbox_filtro"); $("*[id*='FilterTextBox']").parent().css("text-align", "center"); $("*[id*='FilterTextBox']").each(function () { var parent_width; var border_right_width; var border_left_width; parent_width = $(this).parent().width(); border_right_width = $(this).css("border-right-width"); border_left_width = $(this).css("border-left-width"); $(this).width(parent_width - 4); $(this).parent().width(parent_width + parseFloat(border_left_width) + parseFloat(border_right_width)) }); $(".RadGrid").each(function () { $(this).find(".rgPagerCell:first").css("border-style", "none none solid none").css("border-width", "0 0 1px 0").css("border-color", "#5d8cc9") }) } function AplicarBotoesPadraoNovo() { $(".botao_padrao_novo,.painel_botoes_secao a").each(function () { var texto_original_botao; var texto_novo_botao; var icone_botao; var icone_botao_url; var icone_botao_inativo_url; var possui_icone; texto_original_botao = $(this).text(); if ($(this).hasClass("avancar")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_avancar.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_avancar_inativo.png" } if ($(this).hasClass("cancelar")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_cancelar.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_cancelar_inativo.png" } if ($(this).hasClass("enviar_por_email")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_enviar_email.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_enviar_email_inativo.png" } if ($(this).hasClass("excel")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_excel.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_excel_inativo.png" } if ($(this).hasClass("excluir")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_excluir.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_excluir_inativo.png" } if ($(this).hasClass("imprimir")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_imprimir.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_imprimir_inativo.png" } if ($(this).hasClass("limpar_tela")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_limpar_tela.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_limpar_tela_inativo.png" } if ($(this).hasClass("pdf")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_pdf.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_pdf_inativo.png" } if ($(this).hasClass("pesquisar")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_pesquisar.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_pesquisar_inativo.png" } if ($(this).hasClass("salvar")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_salvar.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_salvar_inativo.png" } if ($(this).hasClass("voltar")) { icone_botao_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_voltar.png"; icone_botao_inativo_url = "/PadronizacaoInterface/img/icones/ico_botao_padrao_voltar_inativo.png" } if (icone_botao_url != undefined) { if ($(this).hasClass("inativo")) { icone_botao = '<img alt="" src="' + icone_botao_inativo_url + '" />'; $(this).attr("href", "javascript:;") } else { icone_botao = '<img alt="" src="' + icone_botao_url + '" />' } } else { icone_botao = "" } texto_novo_botao = '<span class="BotaoPadraoEsq">&nbsp;</span><span class="BotaoPadrao">' + icone_botao + texto_original_botao + '</span><span class="BotaoPadraoDir">&nbsp;</span>'; $(this).html(texto_novo_botao) }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").focus(function () { if ($(this).hasClass("inativo") != true) { $(this).addClass("mouseover") } }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").blur(function () { $(this).removeClass("mousedown"); $(this).removeClass("mouseover") }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").mouseover(function () { if ($(this).hasClass("inativo") != true) { $(this).addClass("mouseover") } }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").mouseleave(function () { $(this).removeClass("mousedown"); $(this).removeClass("mouseover") }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").mousedown(function () { if ($(this).hasClass("inativo") != true) { $(this).addClass("mousedown") } }); $(".botao_padrao_novo,.painel_botoes_secao a, .painel_botoes_lateral_direita .salvar, .painel_botoes_lateral_direita .voltar").mouseup(function () { $(this).removeClass("mousedown") }) } function ArredondarPainelPadrao() { radius = 6; style_css = '<style type="text/css">'; style_css += ".CantosArredondadosTopLeft"; style_css += "{"; style_css += "clear: both"; style_css += "width: 100%;"; style_css += "height: 16px;"; style_css += "background-image: url('/Global/img/CantosArredondados/" + radius + "px_top_left.png');"; style_css += "background-repeat: no-repeat;"; style_css += "background-position: top left;"; style_css += "}"; style_css += ".CantosArredondadosTopRight"; style_css += "{"; style_css += "width: 100%;"; style_css += "height: 100%;"; style_css += "background-image: url('/Global/img/CantosArredondados/" + radius + "px_top_right.png');"; style_css += "background-repeat: no-repeat;"; style_css += "background-position: top right;"; style_css += "}"; style_css += ".CantosArredondadosBottomRight"; style_css += "{"; style_css += "clear: both"; style_css += "width: 100%;"; style_css += "height: 16px;"; style_css += "background-image: url('/Global/img/CantosArredondados/" + radius + "px_bottom_right.png');"; style_css += "background-repeat: no-repeat;"; style_css += "background-position: bottom right;"; style_css += "}"; style_css += ".CantosArredondadosBottomLeft"; style_css += "{"; style_css += "width: 100%;"; style_css += "height: 100%;"; style_css += "background-image: url('/Global/img/CantosArredondados/" + radius + "px_bottom_left.png');"; style_css += "background-repeat: no-repeat;"; style_css += "background-position: bottom left;"; style_css += "}"; style_css += "</style>"; $("head").append(style_css); $(".painel_padrao").each(function () { if (($(this).find("div:first-child").attr("class")).indexOf("CantosArredondadosTopLeft") < 0) { pnl_top = '<div class="CantosArredondadosTopLeft" style="clear: both">'; pnl_top += '    <div class="CantosArredondadosTopRight"></div>'; pnl_top += "</div>"; pnl_bottom = '<div class="CantosArredondadosBottomRight" style="clear: both">'; pnl_bottom += '    <div class="CantosArredondadosBottomLeft"></div>'; pnl_bottom += "</div>"; $(this).prepend(pnl_top); $(this).append(pnl_bottom) } }) } $(document).ready(function () { $(window).resize(function () { AjustarBotoesLateralDireita() }); AjustarBotoesLateralDireita(); AjustarRadGrid(); AplicarBotoesPadraoNovo(); CarregarEventos() }); function CarregarEventos() { $(".botao_puxador_tela").click(function () { $(".menu_cortina").slideToggle() }); $(".botao_puxador_menu").click(function () { $(".menu_cortina").slideToggle() }) } employer.event = { cancel: function (evt) { if (window.event) { window.event.cancelBubble = true; window.event.returnValue = false } else { evt.preventDefault(); evt.stopPropagation() } if (evt.originalEvent) { evt.preventDefault(); evt.stopPropagation() } }, getTarget: function (evt) { if (window.event) { return window.event.srcElement } else { if (evt.srcElement) { return evt.srcElement } else { return (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target } } }, getEvent: function (evt) { return (window.event) ? window.event : evt }, getKey: function (evt) { var k, c; if (window.event) { k = (window.event.keyCode) ? window.event.keyCode : null; if (window.event.type == "keypress") { c = k; k = 0 } } else { k = (evt.keyCode) ? evt.keyCode : null; c = (evt.charCode) ? evt.charCode : null } return [k, c] } }; employer.key = { isSpecial: function (code) { if (employer.key.isCommand(code)) { return true } else { if (employer.key.isArrow(code)) { return true } else { if (employer.key.isFunction(code)) { return true } else { return false } } } }, isEnter: function (code) { if (code == employer.key._commands.ENTER) { return true } else { return false } }, isSpace: function (code) { if (code == employer.key._space.SPACE) { return true } else { return false } }, isArrow: function (code) { var is = false; var list = employer.key._arrows; for (var property in list) { if (list[property] == code) { return true } } return is }, isNumber: function (code) { var is = false; var list = employer.key._numbers; for (var property in list) { if (list[property] == code) { return true } } return is }, isUpperCaseLetter: function (code) { var is = false; var list = employer.key._upperLetters; for (var property in list) { if (list[property] == code) { return true } } return is }, isLowerCaseLetter: function (code) { var is = false; var list = employer.key._lowerLetters; for (var property in list) { if (list[property] == code) { return true } } return is }, isUpperAccentedCharacter: function (code) { var is = false; var list = employer.key._upperAccented; for (var property in list) { if (list[property] == code) { return true } } return is }, isLowerAccentedCharacter: function (code) { var is = false; var list = employer.key._lowerAccented; for (var property in list) { if (list[property] == code) { return true } } return is }, isCommand: function (code) { var is = false; var list = employer.key._commands; for (var property in list) { if (list[property] == code) { return true } } return is }, isModifier: function (code) { var is = false; var list = employer.key._modifier; for (var property in list) { if (list[property] == code) { return true } } return is }, isFunction: function (code) { var is = false; var list = employer.key._functions; for (var property in list) { if (list[property] == code) { return true } } return is }, isCtrlV: function (evt) { if (window.event) { if (window.event.ctrlKey) { return true } else { return false } } else { if (evt.ctrlKey) { return true } else { return false } } }, hasModifierKeyPressed: function (e) { if (e.originalEvent != null) { e = e.originalEvent } var modifier = null; if (e.altKey == true) { modifier = "ALT" } else { if (e.altLeft == true) { modifier = "ALT" } else { if (e.ctrlKey == true) { modifier = "CTRL" } else { if (e.ctrlLeft == true) { modifier = "CTRL" } else { if (e.shiftKey == true) { modifier = "SHIFT" } else { if (e.shiftLeft == true) { modifier = "SHIFT" } } } } } } return modifier }, shortcuts: function (evt) { var type = evt.type; var k = employer.event.getKey(evt)[0]; var mod = employer.key.hasModifierKeyPressed(evt); if (type == "keydown" || type == "keyup") { if (k == 113) { var btnF2 = $get("ctl00_btnAtalhoF2"); if (btnF2 != null) { employer.event.cancel(evt); btnF2.click() } } else { if (k == 119) { var btnF8 = $get("ctl00_btnAtalhoF8"); if (btnF8 != null) { employer.event.cancel(evt); btnF8.click() } } else { if (k == 120) { var tempF9 = $get("ctl00_btnAtalhoF9"); if (tempF9 != null) { employer.event.cancel(evt); employer.form.util.focusBtnPesquisa(evt) } } else { if (k == 123) { var tempF12 = $get("ctl00_hfIDBtnF12"); if (tempF12 != null) { if (tempF12.value != "") { var btnF12 = $get(tempF12.value); if (btnF12 != null) { employer.event.cancel(evt); btnF12.click() } } } } } } } if (mod === "ALT") { if (k == 68) { var tempAltD = $get("ctl00_hfIDBtnAltD"); if (tempAltD != null) { if (tempAltD.value != "") { var btnAltD = $get(tempAltD.value); if (btnAltD != null) { var confirm = window.confirm("Tem certeza que deseja excluir?"); if (confirm) { btnAltD.click(); employer.event.cancel(evt) } } } } } else { if (k == 83) { if (employer.form.util.searchInvalidValidator("Salvar")) { var tempAltS = $get("ctl00_hfIDBtnAltS"); if (typeof tempAltS == "object") { if (tempAltS.value != "") { var btnAltS = $get(tempAltS.value); if (typeof btnAltS == "object") { btnAltS.click(); employer.event.cancel(evt) } } } } } } } } }, disableKeys: function (evt) { var k, t, ty, ro; if (window.event) { k = window.event.keyCode; t = window.event.srcElement.nodeName; e = window.event.srcElement; id = window.event.srcElement.id; ty = window.event.srcElement.type; ro = window.event.srcElement.getAttribute("readonly") } else { if (evt.which) { k = evt.which; t = evt.target.nodeName; e = evt.target; id = evt.target.id; ty = evt.target.type; ro = evt.target.getAttribute("readonly") } } if (k == 8 && (!(t == "INPUT" && (ty == "text" || ty == "password")) && t !== "TEXTAREA") || ro == true) { return false } else { if (k == 13 && (t !== "TEXTAREA" && ty !== "submit") && (id != "ctl00_txtFiltroPesquisa_txtValor" && id != "ctl00_cphConteudo_txtFiltroPesquisa_txtValor")) { return false } else { if (k == 13 && id == "ctl00_txtFiltroPesquisa_txtValor") { $get("ctl00_btiPesquisar").click() } else { if (k == 13 && id == "ctl00_cphConteudo_txtFiltroPesquisa_txtValor") { $get("ctl00_cphConteudo_btiPesquisar").click() } } } } }, disableCapsLock: function (evt) { var k, t, ty, ro, s; if (window.event) { k = window.event.keyCode; t = window.event.srcElement.nodeName; e = window.event.srcElement; id = window.event.srcElement.id; ty = window.event.srcElement.type; ro = window.event.srcElement.getAttribute("readonly"); s = window.event.shiftKey } else { if (evt.which) { k = evt.which; t = evt.target.nodeName; e = evt.target; id = evt.target.id; ty = evt.target.type; ro = evt.target.getAttribute("readonly"); s = evt.shiftKey } } if (k >= 65 && k <= 90 && !s && e.parentNode.className != "lista_sugestoes") { setMensagemAviso("Por favor, não digite informações apenas em MAIÚSCULAS! Desligue a tecla Caps Lock.", "error"); return false } }, invertToCase: function (evt) { if (evt.type == "keypress") { var key = employer.event.getKey(evt)[1]; var evtMaker = function (newKey) { if (evt.which) { var newEvt = document.createEvent("KeyboardEvent"); newEvt.initKeyEvent(evt.type, true, true, document.defaultView, evt.ctrlKey, evt.altKey, evt.shiftKey, evt.metaKey, 0, newKey); evt.preventDefault(); evt.target.dispatchEvent(newEvt) } else { evt.keyCode = newKey } }; if ((key >= 97 && key <= 122) || (key >= 224 && key <= 255)) { evtMaker(key - 32) } else { if ((key >= 65 && key <= 90) || (key >= 192 && key <= 223)) { evtMaker(key + 32) } } } } }; employer.key._numbers = { ZERO: 48, ONE: 49, TWO: 50, THREE: 51, FOUR: 52, FIVE: 53, SIX: 54, SEVEN: 55, EIGHT: 56, NINE: 57 }; employer.key._upperLetters = { A: 65, B: 66, C: 67, D: 68, E: 69, F: 70, G: 71, H: 72, I: 73, J: 74, K: 75, L: 76, M: 77, N: 78, O: 79, P: 80, Q: 81, R: 82, S: 83, T: 84, U: 85, V: 86, W: 87, X: 88, Y: 89, Z: 90 }; employer.key._lowerLetters = { a: 97, b: 98, c: 99, d: 100, e: 101, f: 102, g: 103, h: 104, i: 105, j: 106, k: 107, l: 108, m: 109, n: 110, o: 111, p: 112, q: 113, r: 114, s: 115, t: 116, u: 117, v: 118, w: 119, x: 120, y: 121, z: 122 }; employer.key._upperAccented = { A_GRAVE: 192, A_ACUTE: 193, A_CIRCUMFLEX: 194, A_TILDE: 195, A_DIAERESIS: 196, A_ring_above: 197, AE: 198, C_CEDILLA: 199, E_GRAVE: 200, E_ACUTE: 201, E_CIRCUMFLEX: 202, E_DIAERESIS: 203, I_GRAVE: 204, I_ACUTE: 205, I_ACUTE: 206, I_DIAERESIS: 207, ETH: 208, N_tild: 209, O_GRAVE: 210, O_ACUTE: 211, O_CIRCUMFLEX: 212, O_TILDE: 213, O_DIAERESIS: 214, multiplication: 215, O_STROKE: 216, U_GRAVE: 217, U_ACUTE: 218, U_CIRCUMFLEX: 219, U_DIAERESIS: 220, Y_ACUTE: 221, THORN: 222, SHARP_s: 223 }; employer.key._lowerAccented = { a_GRAVE: 192, a_ACUTE: 193, a_CIRCUMFLEX: 194, a_TILDE: 195, a_DIAERESIS: 196, a_ring_above: 197, ae: 198, c_CEDILLA: 199, e_GRAVE: 200, e_ACUTE: 201, e_CIRCUMFLEX: 202, e_DIAERESIS: 203, i_GRAVE: 204, i_ACUTE: 205, i_CIRCIMFLEX: 206, i_DIAERESIS: 207, eth: 208, n_tild: 209, o_GRAVE: 210, o_ACUTE: 211, o_CIRCUMFLEX: 212, o_TILDE: 213, o_DIAERESIS: 214, multiplication: 215, o_STROKE: 216, u_GRAVE: 217, u_ACUTE: 218, u_CIRCUMFLEX: 219, u_DIAERESIS: 220, y_ACUTE: 221, thron: 222, y_DIAERESIS: 223 }; employer.key._space = { SPACE: 23 }; employer.key._modifiers = { SHIFT: 16, CTRL: 17, ALT: 18 }; employer.key._commands = { BACKSPACE: 8, TAB: 9, ENTER: 13, PAUSE_BREAK: 19, CAPS_LOCK: 20, ESCAPE: 27, PAGE_UP: 33, PAGE_DOWN: 34, END: 35, HOME: 36, INSERT_KEY: 45, DELETE_KEY: 46, LEFT_WINDOW_KEY: 91, RIGHT_WINDOW_KEY: 92, SELECT_KEY: 93 }; employer.key._arrows = { LEFT_ARROW: 37, UP_ARROW: 38, RIGHT_ARROW: 39, DOWN_ARROW: 40 }; employer.key._functions = { F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123 }; var Controle = { Interno: "_txtValor", Telerik: "_Input" }; var ControlType = { Aspnet: "aspnet", Component: "component", Telerik: "telerik" }; employer.controles = { lastFocus: function () { return employer.util.findControl("hfUltimoFoco").val() }, setFocus: function (control) { employer.util.findControl(control).focus() }, setFocusControle: function (control) { employer.util.findControl(control + Controle.Interno).focus() }, recuperarValor: function (control) { return employer.util.findControl(control).val() }, recuperarValorControle: function (control) { return employer.controles.recuperarValor(control + Controle.Interno) }, setValor: function (control, value) { employer.util.findControl(control).val(value) }, setValorControle: function (control, value) { employer.controles.setValor(control + Controle.Interno, value) }, limparValor: function (control) { employer.util.findControl(control).val("") }, limparValorControle: function (control) { employer.controles.limparValor(control + Controle.Interno) }, enable: function (control, status) { employer.util.findControl(control).attr("disabled", !status) }, enableControle: function (control, status) { employer.controles.enable(control, status); employer.controles.enable(control + Controle.Interno, status) }, enableControleTlk: function (control, status) { employer.controles.enable(control, status); employer.controles.enable(control + Controle.Telerik, status) }, enableValidatorControleVal: function (control, validator, status, validar) { employer.controles.enableValidatorVal(control + "_" + validator, status, validar) }, enableValidatorControle: function (control, validator, status) { employer.controles.enableValidator(control + "_" + validator, status) }, enableValidatorVal: function (validator, status, validar) { var control = employer.util.findControl(validator)[0]; control.enable = status; if (!validar) { return } ValidatorEnable(control, status); ValidatorValidate(control) }, enableValidator: function (validator, status) { var control = employer.util.findControl(validator)[0]; control.enable = status; ValidatorEnable(control, status) }, setAttr: function (control, attr, valor) { employer.util.findControl(control).attr(attr, valor) }, isEnable: function (control) { return !employer.util.findControl(control).attr("disabled") }, isEnableControle: function (control) { return employer.controles.isEnable(control + Controle.Interno) }, enableComponenteTelefone: function (control, status, clearvalue) { employer.controles.enable(control + "_txtDDD", status); employer.controles.enable(control + "_txtFone", status); if (!clearvalue) { return } employer.controles.limparValor(control + "_txtDDD"); employer.controles.limparValor(control + "_txtFone") }, setValorComponenteTelefone: function (control, ddd, telefone) { employer.controles.setValor(control + "_txtDDD", ddd); employer.controles.setValor(control + "_txtFone", telefone) }, enableControlesArr: function (controles, status) { for (i = 0; i < controles.length; i++) { if (controles[i].tipo == ControlType.Aspnet) { employer.controles.enable(controles[i].id, !status ? controles[i].enable : status) } else { if (controles[i].tipo == ControlType.Component) { employer.controles.enableControle(controles[i].id, !status ? controles[i].enable : status) } else { if (controles[i].tipo == ControlType.Telerik) { employer.controles.enableControleTlk(controles[i].id, !status ? controles[i].enable : status) } } } } controles.length = 0 }, enableValidatorsControlesArr: function (controles, status, validar) { if (validar) { for (i = 0; i < controles.length; i++) { if (controles[i].tipo == ControlType.Aspnet) { employer.controles.enableValidatorVal(controles[i].id, !status ? controles[i].enable : status) } else { if (controles[i].tipo == ControlType.Component) { employer.controles.enableValidatorControleVal(controles[i].id, !status ? controles[i].enable : status) } } } } else { for (i = 0; i < controles.length; i++) { if (controles[i].tipo == ControlType.Aspnet) { employer.controles.enableValidator(controles[i].id, !status ? controles[i].enable : status) } else { if (controles[i].tipo == ControlType.Component) { employer.controles.enableValidatorControle(controles[i].id, !status ? controles[i].enable : status) } } } } controles.length = 0 } }; employer.util.number = { mask: function (val, mask) { var prefix; var rad; var sufix; var negative = false; if (val < 0) { negative = true } if (typeof val == "number") { val = String(val); val = val.replace(/\./g, ","); prefix = mask.substring(0, mask.indexOf("#")); sufix = mask.substring(mask.lastIndexOf("#") + 1, mask.length); mask = mask.substring(mask.indexOf("#"), mask.length); if (sufix) { if (sufix.indexOf(",") > -1) { ts = sufix.split(","); tv = val.split(","); if (ts.length == tv.length) { if (tv[1].length < ts[1].length) { for (var i = 0; i < ts[1].length; i++) { if (tv[1].charAt(i) == "") { tv[1] += ts[i].charAt(i) } } val = tv[0] + "," + tv[1] } else { if (tv[1].length > ts[1].length) { val = val.substring(0, val.length - (tv[1].length - ts[1].length)) } } } else { if (tv.length < ts.length) { val += "," + ts[1] } } } } var im = 0; if (val.length - sufix.length > 0) { for (var j = val.length - sufix.length - 1; j > -1; j--) { if (val.charAt(j) != "") { if (mask.charAt(mask.length - sufix.length - 1 - im) != "#") { val = val.substring(0, j + 1) + mask.charAt(mask.length - sufix.length - 1 - im) + val.substring(j + 1, val.length) } } im++ } } if (typeof val == "string") { if (negative) { return "( " + prefix + val + " )" } else { return prefix + val } } else { return null } } else { return null } } };
