').append(THeader2).addClass(Tthis.attr('class'));
THeader1.removeClass('table-advance');
THeader2.removeClass('table-advance');
divheader.append(divheader1);
divheader.append(divheader2);
divheader1.append(THeader1);
var anchoc1 = divheader1.outerWidth();
var divheader1button = $('');
divheader1button.width(anchoc1);
divheader1.append(divheader1button);
divheader1button.append(THeader1);
var altoc1 = divheader1.outerHeight() + 15;
divheaderScroll = $('').append(THeader2);
divheader2.append(divheaderScroll);
contenedor.append(divcenter);
divcenter.append(divcenterCols);
divcolsScroll = $('').append(TVisibleCols);
divcolsScroll.width(anchoc1);
divcenterCols.append(divcolsScroll);
divcenter.append(divcenterbody);
divbodyScroll = $('').append(Tthis);
divcenterbody.append(divbodyScroll);
let fncScroll = function (obj, $this, divheaderScroll, idx) {
if (idx) {
divheaderScroll.scrollLeft($this.scrollLeft());
}
obj.scrollTop($this.scrollTop());
};
divbodyScroll.mouseover(function () {
divbodyScroll.scroll(function () { fncScroll(divcolsScroll, divbodyScroll, divheaderScroll, true); });
});
divcolsScroll.mouseover(function () {
divcolsScroll.scroll(function () { fncScroll(divbodyScroll, divcolsScroll, divheaderScroll, false); });
});
divbodyScroll.mouseleave(function () {
divbodyScroll.unbind('scroll');
});
divcolsScroll.mouseleave(function () {
divcolsScroll.unbind('scroll');
});
let sizeoftablefunc = function () {
let widthtx = divheader1.outerWidth() + divheader2.outerWidth();
let widthtxb = divcenterCols.outerWidth() + divcenterbody.outerWidth();
divheader.css('width', widthtx);
divcenter.css('width', widthtx);
let sizetable = Tthis.outerHeight();
if (sizetable < divbodyScroll.height()) {
sizetable = sizetable + 20;
divcolsScroll.css('height', sizetable);
divbodyScroll.css('height', sizetable);
contenedor.css('width', sizetable + altoc1);
}
};
let resizefncscroller = function () {
//var widthGral = $(window).width() - WidthMenos;
/*console.log(widthGral);*/
//contenedor.css('width', 1);
//widthGral = Tthis.parent().parent().parent().parent().parent().width();
widthGral = Tthis.parent().parent().width();
/* console.log(widthGral);*/
var heightGral = $(window).height() - HeightMenos;
//console.log(heightGral);
if (Heightfijo > 0) { heightGral = Heightfijo; }
if (widthGral < 300) { widthGral = 300; }
if (heightGral < 300) { heightGral = 300; }
contenedor.css('width', widthGral);
divheader.css('width', widthGral);
divcenter.css('width', widthGral);
divheaderScroll.css('width', (widthGral - anchoc1));
divcolsScroll.css('height', (heightGral - altoc1 + 20));
divbodyScroll.css('width', (widthGral - anchoc1));
divbodyScroll.css('height', (heightGral - altoc1 + 20));
setTimeout(sizeoftablefunc, 100);
};
//$(window).resize(function () {
// setTimeout(resizefncscroller, 50);
// setTimeout(sizeoftablefunc, 150);
//});
$('table#ADCol' + Tid + ' tr').hover(
function () { $('table#' + Tid + ' tr:nth-child(' + ($(this).index() + 1) + ')').addClass('hover'); },
function () { $('table#' + Tid + ' tr:nth-child(' + ($(this).index() + 1) + ')').removeClass('hover'); });
$('table#' + Tid + ' tr').hover(
function () { $('table#ADCol' + Tid + ' tr:nth-child(' + ($(this).index() + 1) + ')').addClass('hover'); },
function () { $('table#ADCol' + Tid + ' tr:nth-child(' + ($(this).index() + 1) + ')').removeClass('hover'); });
setTimeout(sizeoftablefunc, 100);
Tthis.parent().parent().bind('resize', function () {
setTimeout(resizefncscroller, 100);
})
let found = adscrollerposition.find(element => element.id = 'C_Tab_TabNominas_GvNominas');
if (found != null) {
divheaderScroll.scrollLeft(found.scrollLeft);
divbodyScroll.scrollLeft(found.scrollLeft);
divcolsScroll.scrollTop(found.scrollTop);
divbodyScroll.scrollTop(found.scrollTop);
}
}
catch (err) {
console.log("ADSCROLLER2 Error:" + err.message);
}
});
}
function CargaPickers() {
if ($.datetimepicker) {
$.datetimepicker.setLocale('es');
$('input.ADDateTimePicker').each(function () {
let TThis = $(this);
let datetimeButton = TThis.attr('datetimeButton')
TThis.datetimepicker({
dayOfWeekStart: 1,
lang: 'es',
format: 'd/m/Y H:i',
formatDate: 'd/m/Y H:i',
step: 30
});
if (datetimeButton && datetimeButton.length) {
let button = $(datetimeButton);
if (button && button.length) {
button.unbind("click");
button.bind("click", function () {
TThis.datetimepicker('show')
});
} else {
console.error('no se encontro el boton :' + datetimeButton)
}
} else//creoBoton
{
var Div = TThis.parent()
var boton = document.createElement('span');
boton.className = "input-group-btn"
var subboton = document.createElement('a')
subboton.className = "btn default"
subboton.innerHTML = ""
subboton.addEventListener('click', function () {
TThis.datetimepicker('show')
});
boton.appendChild(subboton)
var agregar = true;
for (var i = 0; i < Div[0].children.length; i++) {
if (Div[0].children[i].isEqualNode(boton)) {
agregar = false;
}
}
if (agregar) {
//Div[0].appendChild(boton);
TThis.before(boton);
}
}
//Div[0].appendChild(boton)
});
} else {
console.error("caught TypeError: datetimepicker is undefined");
}
}
//function DataTablePaginatorScroll() {
// $('.table.ADScrollPaginator').each(function () {
// var Tthis = $(this);
// if (!$.fn.DataTable.isDataTable(Tthis) && Tthis.find("th").length > 0) {
// Tthis.prepend((""));
// Tthis.find('thead').append($("#C_GvBarra").find("tr:first"));
// Tthis.DataTable({
// deferRender: true,
// deferLoading: 100,
// scrollY: 130,
// scrollCollapse: true,
// scroller: {
// displayBuffer: 20
// },
// ordering: false
// });
// //Tthis.bind('mousewheel', function (e) {
// // if (e.originalEvent.wheelDelta < 0) {
// // //scroll down
// // $(".paginate_button.next").click()
// // } else {
// // //scroll up
// // $(".paginate_button.previous").click()
// // }
// // //prevent page fom scrolling
// // return false;
// //});
// var parent = Tthis.parent().parent().parent()
// $('.dataTables_scrollHeadInner > .table.ADScrollPaginator').find('th').addClass('importantth');
// parent.find(".dataTables_paginate").css("display", "none")
// parent.find(".dataTables_length").css("display", "none")
// }
// });
//}
function DataTablePaginatorScroll() {
$('.table.ADScrollPaginator').each(function () {
var Tthis = $(this);
if (!$.fn.DataTable.isDataTable(Tthis) && Tthis.find("th").length > 0) {
Tthis.prepend((""));
Tthis.find('thead').append($("#C_GvBarra").find("tr:first"));
Tthis.DataTable({
"sPagingType": "scroll",
"lengthMenu": [[5, 8, 10], [5, 8, 10]],
"bSort": false
});
Tthis.bind('mousewheel', function (e) {
if (e.originalEvent.wheelDelta < 0) {
//scroll down
$(".paginate_button.next").click()
} else {
//scroll up
$(".paginate_button.previous").click()
}
//prevent page fom scrolling
return false;
});
Tthis.find('th').addClass("importantth");
var parent = Tthis.parent()
parent.find(".dataTables_paginate").css("display", "none")
parent.find(".dataTables_length").css("display", "none")
}
});
}
function DataTablePaginatorScroll2() {
$('.table.ADScrollPaginator2').each(function () {
var Tthis = $(this);
if (!$.fn.DataTable.isDataTable(Tthis) && Tthis.find("th").length > 0) {
Tthis.prepend((""));
Tthis.find('thead').append($("#C_GvBarra").find("tr:first"));
//var table = Tthis.DataTable({
// deferRender: true,
// scrollY: 130,
// scrollCollapse: true,
// scroller: true,
// keys: true
//});
var table = Tthis.DataTable({
deferRender: true,
deferLoading: 100,
scrollY: 130,
scrollCollapse: true,
scroller: {
displayBuffer: 20
},
ordering: true
});
var tkeys = new $.fn.dataTable.KeyTable(table, {
// options
});
//tkeys.on('key', function (e, datatable, key, cell, originalEvent) {
// console.log("teclando.....");
// if (key === 13) { // return
// editor
// .one('close', function () {
// table.keys.enable();
// })
// .inline(cell);
// table.keys.disable();
// }
//});
//Tthis.bind('mousewheel', function (e) {
// if (e.originalEvent.wheelDelta < 0) {
// //scroll down
// $(".paginate_button.next").click()
// } else {
// //scroll up
// $(".paginate_button.previous").click()
// }
// //prevent page fom scrolling
// return false;
//});
var parent = Tthis.parent().parent().parent()
$('.dataTables_scrollHeadInner > .table.ADScrollPaginator2').find('th').addClass('importantth');
parent.find(".dataTables_paginate").css("display", "none")
parent.find(".dataTables_length").css("display", "none")
}
});
}
function loadadscroll() {
/*
$('table.ScrollAD').each(function (index) {
var freezecols = 0; //filas congeladas
var freezerows = 1;//columnascongeladas
var alto = 0;
if ($(this).data('freezecols')) {
freezecols = $(this).data('freezecols');
}
if ($(this).data('freezerows')) {
freezerows = $(this).data('freezerows');
}
if ($(this).data('height')) {
alto = $(this).data('height');
}
else {
var error = 300;
if ($(this).data('heighterror')) {
error = $(this).data('heighterror');
}
var Tam = TamañoVentana();
var alto = Tam.height - error;
if (alto < 100) {
alto = 100;
}
}
this.id = $(this).attr('id');
ADScroller(this.id, alto, freezerows, freezecols);
});
*/
var Tam = TamañoVentana();
$('table.ScrollAD').each(function () {
var height = 0;
var TThis = $(this);
if (TThis.data('freezerows')) {
TThis.data('rows', $(this).data('freezerows'));
}
if (Number(TThis.data('height'))) {
height = TThis.data('height');
}
else {
var error = 340;
if (Number(TThis.data('heighterror'))) {
error = TThis.data('heighterror');
}
height = Tam.height - error;
if (height < 200) {
height = 200;
}
TThis.data('height', height);
}
//ADSCROLLER2
var colVisibles = isNaN(Number(TThis.data('cols'))) ? 0 : Number(TThis.data('cols'));
if (colVisibles > 0) {
if ((Number(TThis.data('heighterror'))) && !(Number(TThis.data('heightmenos')))) { TThis.data('heightmenos', TThis.data('heighterror')); }
TThis.removeClass("ScrollAD");
TThis.addClass("ADSCROLLER2");
} else {
ADSScroll(TThis);
}
});
}
ADSScroll = function (tablescroll) {
if (tablescroll.is(':visible')) {
//tablescroll.unbind("resize");
// console.log(tablescroll.attr('id') + ' ' + tablescroll.width());
let fncafter = tablescroll.data('fncafter')
let sort = false;
try {
sort = tablescroll.data('sort') ? JSON.parse(tablescroll.data('sort')) : sort;
} catch (e) { }
if (sort && (tablescroll.find('>tbody > tr,>thead > tr').length > 0) && (!$(tablescroll.find('>tbody > tr,>thead > tr')[0]).hasClass('tsorter'))) {
$(tablescroll.find('>tbody > tr,>thead > tr')[0]).addClass('tsorter');
$(tablescroll.find('>tbody > tr,>thead > tr')[0]).find('>th').each(function () {
var html = $(this).html();
$(this).html('
' + html + '
');
});
}
sort = false;
let divcontainer = $('');
let divbody = $('');
let divheader = $('');
let divfooter = $('');
let tableheader = $('
').append($(''));
tableheader.attr('id', 'ADSH-' + tablescroll.attr('id'));
let tablefooter = $('
').append($(''));
tablefooter.attr('id', 'ADSF-' + tablescroll.attr('id'));
let trWwidth = $('
');
let idTheader = tablescroll.data('tableheader');
let scrollwidthrow = tablescroll.data('scrollwidthrow') ? tablescroll.data('scrollwidthrow') : "";
let rowVisibles = isNaN(Number(tablescroll.data('rows'))) ? 1 : Number(tablescroll.data('rows'));
let rowFooter = isNaN(Number(tablescroll.data('footer'))) ? 0 : Number(tablescroll.data('footer'));
let heightBody = isNaN(Number(tablescroll.data('height'))) ? 200 : Number(tablescroll.data('height'));
if (Number(tablescroll.data('height'))) {
heightBody = Number(tablescroll.data('height'));
}
else {
Tamheight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
var error = 300;
if (Number(tablescroll.data('heighterror'))) {
error = Number(tablescroll.data('heighterror'));
}
heightBody = Tamheight - error;
if (heightBody < 200) {
heightBody = 200;
}
}
if (sort) {
trWwidth.addClass('TRSort');
}
tablescroll.removeClass("ScrollAD");
tableheader.addClass(tablescroll.attr('class')).removeClass("table-advance");
tableheader.attr('style', tablescroll.attr('style'));
tablefooter.addClass(tablescroll.attr('class')).removeClass("table-advance");
tablefooter.attr('style', tablescroll.attr('style'));
/* Se Combinan las tablas titulo y cuerpo */
if (idTheader && idTheader.length) {
if ($(idTheader).length) {
$($(idTheader + "> tbody > tr," + idTheader + "> thead > tr," + idTheader + "> tr").get().reverse()).each(function () {
var trthis = $(this);
tablescroll.prepend(trthis);
rowVisibles += 1;
});
} else {
log("Tabla titulo No encontrada '" + idTheader + "'.");
}
}
let firsttr = null;
tablescroll.find('> tbody > tr' + scrollwidthrow + ',> thead > tr' + scrollwidthrow + ',> tr' + scrollwidthrow + '').each(function () {
var retorno = false;
firsttr = $(this);
if (firsttr.find(' > td[colspan], > th[colspan]').length) { retorno = true; }
return retorno;
});
if (firsttr == null) {
tablescroll.find('> tbody > tr,> thead > tr,> tr').each(function () {
var retorno = false;
firsttr = $(this);
if (firsttr.find(' > td[colspan], > th[colspan]').length) { retorno = true; }
return retorno;
});
}
tablescroll.before(divcontainer);
divcontainer.append(divheader);
divcontainer.append(divbody);
divcontainer.append(divfooter);
divbody.append(tablescroll);
divheader.append(tableheader);
divfooter.append(tablefooter);
//var objDiv = $('');
//tablescroll.before(objDiv);
//objDiv.append(tablescroll);
if (firsttr) {
let childitem = firsttr.find('> td,th').length;
let contador = 1
firsttr.find('> td,th').each(function () {
var thistd = $(this);
let widthitem = thistd.width();
if ((childitem == contador) && widthitem > 0) {
widthitem = widthitem - 10;
}
trWwidth.append($('
'));
contador++;
});
}
//objDiv.before(tablescroll);
//objDiv.remove();
var index = 1;
tablescroll.find('> tbody > tr,> thead > tr,> tr').each(function () {
firsttr = $(this);
tableheader.append(firsttr);
if (rowVisibles == index) return false;
index += 1;
});
index = 0;
$(tablescroll.find('> tbody > tr,> thead > tr,> tr').get().reverse()).each(function () {
if (rowFooter == index) return false;
firsttr = $(this);
tablefooter.prepend(firsttr);
index += 1;
});
tableheader.prepend(trWwidth);
tablefooter.prepend(trWwidth.clone().removeClass('TRSort').addClass('trfooter'));
tablescroll.prepend(trWwidth.clone().removeClass('TRSort'));
divbody.css('max-height', heightBody);
if (rowFooter == 0) {
divfooter.css('overflow-x', 'hidden');
divbody.scroll(function () {
divheader.scrollLeft($(this).scrollLeft());
});
} else {
divbody.css('overflow-x', 'hidden');
divfooter.scroll(function () {
divheader.scrollLeft($(this).scrollLeft());
divbody.scrollLeft($(this).scrollLeft());
});
}
if (fncafter) {
try {
eval(fncafter)
} catch (e) {
console.error('fncafter : ' + e)
}
}
}
//else {
// tablescroll.bind('resize', function () {
// let table = tablescroll
// setTimeout(
// function () {
// console.log(tablescroll.attr('id') + ' ' + tablescroll.width());
// ADSScroll(table)
// }, 10);
// })
//}
};
function ADScroller(tablaid, height, freezrows, freezcols) {
if (elementexist('#' + tablaid)) {
var tablita = $('#' + tablaid);
if (!(tablita.hasClass('ADScroller-table') || tablita.hasClass('ADScroller-header'))) {
var contenedor = $('');//contenedor de todos los objetos incluyendo la tabla
var body = $('');//este sera elcuerpo scrolleable
var headertable = $('
');//inicializo la tabla donde estara los titulos
contenedor.append(headertable);
contenedor.append(body);
tablita.before(contenedor);
body.append(tablita);
var inserted = 1;
if (elementexist('#' + tablaid + ' tr:nth-child(1) th')) {
var mywidthrow = $('