/* * Codificación UTF-8 * Eventos asociados a generales de una ventana */ var gvh = gvh || {}; /* *********************************************** * MOSTRAR/OCULTAR PANELES *************************************************/ $('#gvhPage').offon( 'click', 'button[data-gvhFunction=gvhShowPanel]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); var estado = $('#'+ambito).attr('data-gvhEstadoPanel'); var claseM = $(this).attr('data-gvhClaseManejadora'); $('div[id^=P_][data-gvhWindow='+ambito+']').map(function() { var estadoPanel = $(this).attr('data-gvhEstadoPanel'); if ((estadoPanel != 'R') || (estado == undefined)) estado = estadoPanel; }); gvh.showConsoleMsg('log',$(this)); gvh.showConsoleMsg('log',' ** gvh_mainbar.js - gvhShowPanel -> estado: '+estado); //if (estado == 'R') //{ var panelAmbito = $(this).attr( 'data-gvhWindow' ); if( panelAmbito != ambito ) { return; } var panel = $(this).attr('data-target'); var divPanel = $('#'+panel+'[data-gvhWindow='+panelAmbito+']'); var button = $(this); if( divPanel.is(':hidden') ) { if( button.is('.effect-transfer') ) { divPanel.show( 'slide', {direction: "right"}, 250, function() { button.effect( 'transfer', { to: divPanel, className: "ui-effects-transfer" }, 250); } ); /* TODO : Probar a mover el scroll hasta que se vea el panel $('html, body').stop().animate({ scrollTop: divPanel.offset().top }, 300); */ } else { divPanel.show( 'slow' ); } if( panel == 'P_fil' ) { gvh.blockExit(true,'R',panel, claseM); } block = true; } else if( divPanel.is(':visible') ) { if( button.is('.effect-transfer') ) { divPanel.effect( 'transfer', { to: button, className: "ui-effects-transfer" }, 250, function() { divPanel.hide( 'slide', {direction: "right"}, 250); } ); } else { divPanel.hide( 'slow' ); } block = true; } //} //else { // console.error(' ¡¡¡ El panel está en modo activo (W/I) hay que acabar la acción o cancelarla para poder cambiar de panel!!! '); // gvh.showMessage( 'gvhlang_msjUI', 'alert' ); //} } ); /* *********************************************** * MOSTRAR/OCULTAR MENSAJE INFORMATIVO *************************************************/ $('#gvhPage').offon( 'click', 'a[data-gvhFunction=infoContenedor]', function(e) { e.stopPropagation(); e.stopImmediatePropagation(); var panelAmbito = $(this).attr('data-gvhwindow'); var target_button = $(this).attr('data-target'); var target = $(target_button); if( target.filter('[data-gvhWindow='+panelAmbito+']').is(':hidden') ) { target.show(); } else if( target.filter('[data-gvhWindow='+panelAmbito+']').is(':visible') ) { target.hide(); } } ); /* *********************************************** * MENSAJES CUANDO HAY CAMBIOS PENDIENTES *************************************************/ //Mensaje de aviso cuando se vuelve a la pantalla principal de la aplicación $('#gvhPage').offon( 'click', 'button[id=home]', function(e) { gvhExit = $(this).attr('data-gvhExit'); gvh.loading('on'); // Comprobamos si algún panel tiene cambios pendientes. let changed = false; let gvhchanged = $( '[data-gvhchanged=true]' ); if( gvhchanged.length > 0 ) { changed = true; } if( (gvhExit == true) || (gvhExit == 'true') || !changed ) { $(location).attr('href','phrame.php?action=volverPrincipal'); } else { gvh.showMessage('gvhlang_msjUI','alert'); } } ); // Mensaje de aviso cuando se vuelve a la pantalla principal de la aplicación $('#gvhPage').offon( 'click', 'button[id=close]', function(e) { inicio = $(this).attr('data-gvhInicio'); gvhExit = $(this).attr('data-gvhExit'); // Comprobamos si algún panel tiene cambios pendientes. let changed = false; let gvhchanged = $( '[data-gvhchanged=true]' ); if( gvhchanged.length > 0 ) { changed = true; } if( ((inicio == true) || (inicio == 'true')) || ((gvhExit == true) || (gvhExit == 'true')) || !changed ) { gvh.callControllerJS( $(this) ); } else { gvh.showMessage('gvhlang_msjUI','alert'); } } ); // Idioma $('#gvhPage').offon( 'click', 'a[data-gvhFunction=language]', function(e) { $(this).controllerJS({ id: $(this).attr('id'), panel: '', destino: $(this).attr('data-gvhDestino'), newWindow: 'false', confirm: '', claseM: '' } ); } ); $('#gvhPage').offon( 'click', 'div[id=capa_menuFalso]', function(e) { // Comprobamos si algún panel tiene cambios pendientes. let changed = false; let gvhchanged = $( '[data-gvhchanged=true]' ); if( gvhchanged.length > 0 ) { changed = true; } if( changed ) { gvh.showMessage( 'gvhlang_msjUI','alert' ); } } ); $('#gvhPage').offon( 'click', '[data-gvhOpenWindow]', function(e) { var size = $(this).attr('data-gvhSizeWindow'); // w,h vSize = size.split(','); gvh.popupWindow({ windowURL: $(this).attr('data-gvhOpenWindow'), scrollbars: 1, centerScreen: 1, height: vSize[1], width: vSize[0], windowName:'newWindow' } ); } ); /*$(document).ready(function() { // TODO : Revisar porque igual no funciona en modales u otras $('[data-toggle="popover"]').each(function () { alert('gvhMain '+$(this).attr('id')); $(this).popover({ trigger: 'manual', html: true, content: function() { $(this).attr('data-content').html() } }); }) });*/ /************************************/ /* CERRAMOS TODOS LOS cwinformation */ //TODO : Revisar porque igual no funciona en modales u otras $('body').on( { click: function(e) { $('[data-toggle="popover"]').each(function () { if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { $(this).popover('hide'); } } ); } } );