/* * Codificación UTF-8 * Eventos asociados a generales de una ventana */ var gvh = gvh || {}; /* *********************************************** * MOSTRAR/OCULTAR PANELES *************************************************/ +function ($) { 'use strict'; if( !gvh.MainBar || gvh.versionCompare(gvh.MainBar.VERSION, gvh.VERSION) < 0 ) { gvh.showConsoleMsg( 'log', 'gvh.MainBar : Inicializando...' ); gvh.MainBar = function() { // REVIEW : De momento está vacío, pero debería convertirse en un componente. // NOP : No hacer nada } gvh.MainBar.VERSION = '5.0.0'; $('#gvhPage').offon( 'click.gvhShowPanel', 'button[data-gvhFunction=gvhShowPanel]', function( e ) { //click.gvhShowPanel let estado = $('#'+gvh.ambito).attr('data-gvhEstadoPanel'); let claseM = $(this).attr('data-gvhClaseManejadora'); $('div[id^=P_][data-gvhWindow='+gvh.ambito+']').map( function() { let 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') //{ // 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' ); // return; //} let panelAmbito = $(this).attr( 'data-gvhWindow' ); if( panelAmbito != gvh.ambito ) { return; } let panel = $(this).attr('data-target'); let divPanel = $('#'+panel+'[data-gvhWindow='+panelAmbito+']'); let 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; } } ); /* *********************************************** * MOSTRAR/OCULTAR MENSAJE INFORMATIVO *************************************************/ $('#gvhPage').offon( 'click.infoContenedor', 'a[data-gvhFunction=infoContenedor]', function( e ) { let panelAmbito = $(this).attr('data-gvhwindow'); let target_button = $(this).attr('data-target'); let 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.home', 'button[id=home]', function( e ) { // click.home let 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.close', 'button[id=close]', function( e ) { // click.close let inicio = $(this).attr( 'data-gvhInicio' ); let 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.language', 'a[data-gvhFunction=language]', function( e ) { //click.language $(this).controllerJS( { id: $(this).attr('id') , panel: '' , destino: $(this).attr('data-gvhDestino') , newWindow: 'false' , confirm: '' , claseM: '' } ); //gvh.controllerJS($(this).attr('id'), '', $(this).attr('data-gvhDestino'), '', 'false', '', gvh.msgLoad); } ); $('#gvhPage').offon( 'click.capa_menuFalso', 'div[id=capa_menuFalso]', function( e ) { //click.capa_menuFalso // 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.gvhOpenWindow', '[data-gvhOpenWindow]', function( e ) { //click.gvhOpenWindow let size = $(this).attr('data-gvhSizeWindow'); // w,h let vSize = size.split(','); gvh.popupWindow( { windowURL: $(this).attr( 'data-gvhOpenWindow' ), scrollbars: 1, centerScreen: 1, height: vSize[1], width: vSize[0], windowName: 'newWindow' } ); } ); /************************************/ /* 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' ); } } ); } } ); } //gvh.MainBar } (jQuery);