var BaseDir = '/'; function getControl(elementId, elementTag) // Obtiene el control de la pagina especificando su id y tipo, // sin importar que comience por ctl00$content... { var hdnControl = document.getElementsByTagName(elementTag); for (var i = 0; i < hdnControl.length; i++) { var hdnLength = parseInt(hdnControl[i].id.length); if (hdnControl[i].id.substring((hdnLength - elementId.length), hdnLength) == elementId) return hdnControl[i]; } } function setFiltroFocus(filtro, divTextoFiltro) { var txtFiltro = getControl(filtro, 'input'); var divFiltro = getControl(divTextoFiltro, 'div'); if (txtFiltro != null && divFiltro != null) { divFiltro.style.display = 'none'; txtFiltro.focus(); } } function ocultarTextoFiltro(filtro, divTextoFiltro) { var txtFiltro = getControl(filtro, 'input'); var divFiltro = getControl(divTextoFiltro, 'div'); if (txtFiltro != null && divFiltro != null) if (txtFiltro.value != '') divFiltro.style.display = 'none'; } // Scripts para filtros en dropdowns function IncluirFiltro(selectId) { document.write(''); } var gTargetSelect; function ActivarFiltro(selectId) { var divFiltro = document.getElementById("divFiltro"); if (divFiltro == null) return; if (divFiltro.style.visibility == "visible") { DesactivarFiltro(); return; } gTargetSelect = document.getElementById(selectId); if (gTargetSelect == null) return; if (gTargetSelect.disabled) return; var inputFiltro = document.getElementById("inputFiltro"); inputFiltro.value = ""; LlenarSelectFiltro("", null); var x = GetAbsLeft(gTargetSelect); var y = GetAbsTop(gTargetSelect) + gTargetSelect.offsetHeight; if (navigator != null && navigator.appVersion != null && navigator.appVersion.indexOf("MSIE") >= 0) { OcultarSelects(x, y, x + divFiltro.offsetWidth, y + divFiltro.offsetHeight); } divFiltro.style.left = x + "px"; divFiltro.style.top = y + "px"; divFiltro.style.visibility = "visible"; inputFiltro.focus(); } function GetAbsLeft(elem) { var left = 0; while (elem != null) { left += elem.offsetLeft; elem = elem.offsetParent; } return left; } function GetAbsTop(elem) { var top = 0; while (elem != null) { top += elem.offsetTop; elem = elem.offsetParent; } return top; } var gHiddenSelects = null; function OcultarSelects(fx1, fy1, fx2, fy2) { gHiddenSelects = new Array(); for (var ifrm = 0; ifrm < document.forms.length; ifrm++) { for (var iele = 0; iele < document.forms[ifrm].elements.length; iele++) { var elem = document.forms[ifrm].elements[iele]; if (elem.type.indexOf("select") >= 0 && elem.name != "selectFiltro" && elem.name != gTargetSelect.name) { var x1 = GetAbsLeft(elem); var y1 = GetAbsTop(elem); var x2 = x1 + elem.offsetWidth; var y2 = y1 + elem.offsetHeight; if (x1 <= fx2 && x2 >= fx1 && y1 <= fy2 && y2 >= fy1) { elem.style.visibility = "hidden"; gHiddenSelects.length = gHiddenSelects.length + 1; gHiddenSelects[gHiddenSelects.length - 1] = elem; } } } } } function CargarSeleccionFiltro(value) { gTargetSelect.value = value; DesactivarFiltro(); gTargetSelect.focus(); try { gTargetSelect.onchange(gTargetSelect); } catch (e) { } } function LlenarSelectFiltro(patron, event) { var filterSelect = document.getElementById("selectFiltro"); if (event != null) { var keyCode = event.keyCode ? event.keyCode : event.charCode; if (keyCode == 13) { if (filterSelect.length == 1) { CargarSeleccionFiltro(filterSelect.options[0].value); return; } } if (keyCode == 27) { DesactivarFiltro(); gTargetSelect.focus(); return; } } patron = patron.toUpperCase(); filterSelect.options.length = 0; for (var i = 0; i < gTargetSelect.length; i++) { var opText = gTargetSelect.options[i].text; var posPatron = opText.toUpperCase().indexOf(patron); if (posPatron >= 0) { if (patron.length > 0) opText = opText.substr(0, posPatron) + ' < ' + opText.substr(posPatron, patron.length) + ' > ' + opText.substr(posPatron + patron.length, opText.length - posPatron + patron.length); filterSelect.options.length = filterSelect.options.length + 1; filterSelect.options[filterSelect.options.length - 1] = new Option(opText, gTargetSelect.options[i].value); // filterSelect.options[filterSelect.options.length-1].innerHTML = opText; } } if (filterSelect.options.length == 1) { var inputFiltro = document.getElementById("inputFiltro"); } return true; } function DesactivarFiltro() { document.getElementById("divFiltro").style.visibility = "hidden"; if (gHiddenSelects != null) { for (var isel = 0; isel < gHiddenSelects.length; isel++) { gHiddenSelects[isel].style.visibility = "visible"; } } } //Máscaras function DefinirMascaraNumero(inputId, mask) { var elem = document.getElementById(inputId); if (elem == null) { return; } var m = new Mask(mask,"number"); m.attach(elem); } function DefinirMascaraFecha(inputId, mask) { var elem = document.getElementById(inputId); if (elem == null) { return; } var m = new Mask(mask, "date"); m.attach(elem); } function DefinirMascaraHora(inputId, mask) { var elem = document.getElementById(inputId); if (elem == null) { return; } var m = new Mask(mask, "hour"); m.attach(elem); } function hapiGetElementsByClassName(classname, node) { if (!node) node = document.getElementsByTagName("body")[0]; var a = []; var re = new RegExp('\\b' + classname + '\\b'); var els = node.getElementsByTagName("*"); for (var i = 0, j = els.length; i < j; i++) if (re.test(els[i].className)) a.push(els[i]); return a; } function ValidarCheckBoxList(source, args) { var chkBoxList = getControl(source.title, "table"); var chkListInputs = chkBoxList.getElementsByTagName("input"); for (var i = 0; i < chkListInputs.length; i++) { if (chkListInputs[i].checked) { args.IsValid = true; return; } } args.IsValid = false; } function InsertTab(o, e) { var kC = e.keyCode ? e.keyCode : e.charCode ? e.charCode : e.which; if (kC == 9 && !e.shiftKey && !e.ctrlKey && !e.altKey) { var oS = o.scrollTop; if (o.setSelectionRange) { var sS = o.selectionStart; var sE = o.selectionEnd; o.value = o.value.substring(0, sS) + "\t" + o.value.substr(sE); o.setSelectionRange(sS + 1, sS + 1); o.focus(); } else if (o.createTextRange) { document.selection.createRange().text = "\t"; e.returnValue = false; } o.scrollTop = oS; if (e.preventDefault) { e.preventDefault(); } return false; } return true; } function FixParameterPanelHeight() { var table = $(".Table"); if (table.length == 0) { var table = $(".TableReportesHAF"); if (table.length == 0) return; } var div = table.find("div[class!='txtSubtitulo'][id$='_ParameterPanel']"); table = div.find("tbody"); if (table.length == 0) return; $(table[0]).append("
 
"); }