const navText = [
'',
''
];
$(document).ready(function ()
{
if (typeof $.fn.dataTable != "undefined")
{
$.extend($.fn.dataTable.defaults,
{
"language":
{
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_",
"sZeroRecords": "No se han encontrado resultados",
"sEmptyTable": "Sin datos todavía",
"sInfo": "Mostrando de la entrada _START_ a la _END_ de un total de _TOTAL_ entradas",
"sInfoEmpty": "Todavía no hay ningún resultado",
"sInfoFiltered": "(filtrado de _MENU_ entradas)",
"sSearchPlaceholder": "Buscar",
"sInfoPostFix": "",
"sSearch": "",
"sUrl": "",
"oPaginate": {
"sFirst": " ",
"sPrevious": " ",
"sNext": " ",
"sLast": " "
}
}
});
}
});
class Web
{
static init(carga_banner)
{
jQuery.event.special.touchstart = {
setup: function (_, ns, handle)
{
this.addEventListener("touchstart", handle, {passive: !ns.includes("noPreventDefault")});
}
};
jQuery.event.special.touchmove = {
setup: function (_, ns, handle)
{
this.addEventListener("touchmove", handle, {passive: !ns.includes("noPreventDefault")});
}
};
jQuery.event.special.wheel = {
setup: function (_, ns, handle)
{
this.addEventListener("wheel", handle, {passive: true});
}
};
jQuery.event.special.mousewheel = {
setup: function (_, ns, handle)
{
this.addEventListener("mousewheel", handle, {passive: true});
}
};
var t;
var h;
$(document).ready(function (e)
{
$(".btnAbreLogin").click(abreLogin);
$(".btnAbreModalLogin").click(function (e)
{
e.preventDefault();
const href = $(this).attr("href") || $(this).attr("data-href") || "";
$("#loginEnlace").val(href);
ClassBlockUI.abrirBlockUIEstandar("bloqueAcceso", null, "Acceder", "modal330");
});
jQuery('#wrapper').linkify();
Utils.muestraBannerSegunCookie(carga_banner, 'mostrarBanner', abreBannerPromocional);
cargarImagenesGestina();
$(".abre-content-modal").click(function (e)
{
e.preventDefault();
const mdalId = ($(this).attr("href") || $(this).attr("data-modal")).replace("#", "");
const modalClass = $(this).attr("data-modal-class") || "";
ClassBlockUI.abrirBlockUIEstandar(mdalId, undefined, "", "content-modal "+modalClass, undefined, "custom-scroll-bar");
});
$("[class*='btn-modal-servicios-']").on("click", function(e) {
e.preventDefault();
const className = $(this).attr("class");
const id = className.match(/btn-modal-servicios-(\d+)/)[1];
$("#modal-servicios .bloque-servicio").addClass("d-none");
$("#modal-servicios .bloque-servicio[data-id='"+id+"']").removeClass("d-none");
});
$("body").on("click", ".dropdown > a[href='#']", function ()
{
$(this).parent().toggleClass("open");
});
$("body").on("click", ".dropdown > a:not([href='#'])", function (e)
{
const w = $(window).innerWidth();
const tagName = e.target.tagName.toLowerCase();
if (["span", "i", "svg"].indexOf(tagName) >= 0 && w <= 1365)
e.preventDefault();
$(this).parent(".dropdown").toggleClass("open");
});
$("body").on("click", "#cerrarMenu", function ()
{
$(".navbar-toggler").trigger("click");
});
});
//Desactivar boton derecho
$(document).bind("contextmenu", function (e)
{
e.preventDefault();
return false;
});
//Desactivar copiar/pegar
$(document).keydown(function (event)
{
if (event.ctrlKey == true &&
(
//PASTE (V | v)
(event.which == '118' || event.which == '86')
//COPY (C | c)
|| (event.which == '99' || event.which == '67')
)
)
{
event.preventDefault();
return false;
}
});
function abreLogin()
{
$("#user-menu-container").toggleClass("open");
$("#login-container").toggleClass("open");
}
function abreBannerPromocional()
{
bloqueBannerInicio = ClassBlockUI.abrirBlockUIEstandar("bloqueBannerInicioCookies", null, "", "modal1050");
}
function cargarImagenesGestina()
{
$('.imagenesTextoSeccion img').Lazy({
// your configuration goes here
scrollDirection: 'vertical',
effect: 'fadeIn',
visibleOnly: true,
});
}
}
static initApuntarseCurso()
{
$(document).ready(function ()
{
$("#frm-apuntate-eres-socio").change(function ()
{
if ($(this).val() == 0)
$(".form-group-num-socio").addClass("d-none");
else
$(".form-group-num-socio").removeClass("d-none");
});
$("#frm-apuntate-eres-alumno").change(function ()
{
if ($(this).val() == 0)
$(".form-group-escuela").addClass("d-none");
else
$(".form-group-escuela").removeClass("d-none");
});
var opciones_validacion = {showLabels: false};
var form_validacion = $("#frm-apuntate").validate(opciones_validacion);
$("#btn-registrarme-curso").click(function ()
{
var validation = $("#frm-apuntate").valid();
if (!validation)
{
ClassBlockUI.abrirBlockUIEstandarMensaje("Por favor revise los campos porque se han detectado los siguientes errores
" + form_validacion.invalidMessages("
"), true);
return;
}
var opcionesDatos =
{
type: "POST",
dataType: "json",
url: "ajax/Curso.apuntarse.php",
data: $("#frm-apuntate").serialize(),
success: function (data, textStatus, XMLHttpRequest)
{
if (data["error_number"] >= 0)
{
$(".modal").modal("hide");
$("#frm-apuntate")[0].reset();
}
ClassBlockUI.abrirBlockUIEstandarMensaje(data["error_message"], true);
}
};
ClassBlockUI.abrirBlockUIEsperePorFavor();
$.ajax(opcionesDatos);
});
});
}
static initColaboradores()
{
$(document).ready(function ()
{
const elementCarousel = $("#carousel-colaboradores");
if (elementCarousel.length > 0)
{
let numItems = elementCarousel.find(".item-partner").length;
elementCarousel.owlCarousel({
margin: 30,
nav: false,
dots: false,
autoplay: true,
autoplayHoverPause: true,
autoplayTimeout: 3000,
stagePadding: 1,
responsive: {
0: {
items: 3,
loop: numItems > 3,
stagePadding: 30,
margin: 15,
},
575: {
items: 3,
loop: numItems > 3,
stagePadding: 50,
},
992: {
items: 4,
loop: numItems > 4,
},
1200: {
items: 5,
loop: numItems > 5,
},
1600: {
items: 7,
loop: numItems > 7
}
}
});
}
});
}
static refrescaTabla(idTabla)
{
$(".tooltipStandard").not(".tooltipstered").tooltipster({animation: 'grow',interactive:true, position:'bottom', contentAsHTML: true});
$(".inputIconLupa, .inputMostrar, #filtros, .table-buttons").removeClass("d-none");
$(".form-control").removeClass().addClass("form-control-b");
$(".table-buttons").appendTo(".table-options");
var numItems = 0;
let tabla = eval("tabla"+idTabla);
if (typeof tabla != "undefined") {
numItems = tabla.page.info().recordsDisplay;
} else if ($.fn.dataTable.isDataTable( '#'+idTabla )) {
tabla = $('#'+idTabla).DataTable();
numItems = tabla.page.info().recordsDisplay;
}
let itemsMostrando = $("#"+idTabla+"_length select").length > 0 ? $("#"+idTabla+"_length select").val() : 10;
if (numItems > itemsMostrando) {
$("#"+idTabla+"_wrapper .pagination-footer").removeClass("opacity-0");
} else {
$("#"+idTabla+"_wrapper .pagination-footer").addClass("opacity-0");
}
//Formato movil
const numColumnaMv = 1; const numColumnas = tabla.columns()[0].length;
if ($("#"+idTabla).hasClass("tablaMovil"))
{
const w = $(window).outerWidth();
if (w <= 767) //Ocultar
{
for(let i = 0; i < numColumnas; i++)
{
tabla.column(i).visible((numColumnaMv == i ? true : false));
}
}
else //Mostrar
{
for(let i = 0; i < numColumnas; i++)
{
let txt = $(tabla.columns(i).header()).text();
tabla.column(i).visible((txt == "oculto" || numColumnaMv == i ? false : true));
}
}
}
}
static initResenas()
{
$(document).ready(function () {
const elementCarousel = $("#valoraciones");
if (elementCarousel.length > 0)
{
let numItems = elementCarousel.find(".item-resena").length;
elementCarousel.owlCarousel({
margin: 30,
nav: false,
navText: navText,
dots: true,
lazyLoad: true,
stagePadding: 3,
dotsContainer: "#dots-valoraciones",
responsive: {
0: {
items: 1,
loop: numItems > 1,
},
768: {
items: 1,
loop: numItems > 1,
},
992: {
items: numItems > 3 ? 1.5 : 2,
loop: numItems > 3,
},
1200: {
items: numItems > 4 ? 2.5 : 3,
loop: numItems > 6,
},
1600: {
items: 3,
loop: numItems > 3
}
}
});
$("body").on("click", ".btn-mas-valoracion", function () {
var padre = $(this).parents(".item-resena");
//$(padre).find(".valoracion-texto").addClass("d-none");
//$(padre).find(".valoracion-texto-completo").removeClass("d-none");
$("#bloque-resena .textoSeccion").html(padre.find(".valoracion-texto-completo").html());
ClassBlockUI.abrirBlockUIEstandar("bloque-resena", undefined, "Reseña de " + padre.find(".item-resena-usuario").text(), "modal622");
});
$("body").on("click", "#btn-cerrar-resena", function (e) {
$(".modal").modal("hide");
});
}
});
}
static initCalendar()
{
$(document).ready(function() {
$(".date-select .simula-select-item").click(function ()
{
const anyo = $(this).attr("data-anyo");
const mes = $(this).attr("data-mes");
const formattedDate = $(this).text();
$(this).parents(".simula-select").find(".simula-select-value").text(formattedDate);
Web.fullCalendar.gotoDate(anyo+"-"+mes+"-01");
});
Web.fullCalendar = new FullCalendar.Calendar($("#calendar")[0], {
//timeZone: "America/New_York",
timeZone: "Europe/Madrid",
schedulerLicenseKey: "0221401364-fcs-1627045855",
dayMaxEvents: 3,
//dayPopoverFormat: {month: 'long', day: 'numeric', year: 'numeric'},
locale: 'es',
allDaySlot: false,
initialDate: new Date().toISOString(),
initialView: 'dayGridMonth',
nowIndicator: true,
//showNonCurrentDates: false,
eventSources:
[
{
url: "ajax/Cursos.agenda.php",
method: 'POST',
extraParams: {"CSRF": CSRF,},
},
],
editable: false,
selectable: false,
//eventMouseEnter
eventClick: function (info) {
/*let infoCalendar = $('.infoCalendar');
if (infoCalendar.length !== 1) {
return;
}*/
let event = info.event;
let jsEvent = info.jsEvent;
let view = info.view;
$("#apuntate-curso-id").val(event.id);
$(".bloque-curso-titulo").html(event.title);
$(".bloque-curso-texto").html(event.extendedProps.descripcion);
if (event.extendedProps.unixtime < Math.ceil(Date.now() / 1000)) {
$("#container-apuntate-curso").addClass("d-none");
} else {
$("#container-apuntate-curso").removeClass("d-none");
}
ClassBlockUI.abrirBlockUIEstandar("modal-curso", undefined, "", "content-modal modal1050", undefined, "custom-scroll-bar");
return;
//
let parent = $(jsEvent.target).closest(view.type === "dayGridMonth" ? '.fc-daygrid-event' : '.fc-timegrid-event');
//let parent = $(jsEvent.target).closest('.fc-timegrid-event');
if (!parent.hasClass("tooltipstered")) {
let colorClass = $(".form-check-input[data-id=" + event.extendedProps.idUsuario + "]").attr("data-color");
colorClass = colorClass !== undefined ? colorClass : "ownAgenda";
//let childToolTipstered = null;
let content = $("