/* * 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.2'; $('#gvhPage').off('click.gvhShowPanel').on( 'click.gvhShowPanel', 'button[data-gvhFunction=gvhShowPanel]', function( e ) { //click.gvhShowPanel var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.gvhShowPanel' , callback: function() { var estado; // var estado = $('#'+gvh.ambito).attr('data-gvhEstadoPanel'); var claseM = $this.closest('[data-gvhClaseManejadora]').attr('data-gvhClaseManejadora'); $('div[id^=P_][data-gvhWindow='+gvh.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') //{ // 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; //} var panelAmbito = $this.attr( 'data-gvhWindow' ); if( panelAmbito != gvh.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; } } } ); } ); /* *********************************************** * MOSTRAR/OCULTAR MENSAJE INFORMATIVO *************************************************/ $('#gvhPage').off('click.infoContenedor').on( 'click.infoContenedor', 'a[data-gvhFunction=infoContenedor]', function( e ) { var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.infoContenedor' , callback: function() { 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').off('click.home').on( 'click.home', 'button[id=home]', function( e ) { // click.home var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.home' , callback: function() { var gvhExit = $this.attr( 'data-gvhExit' ); gvh.loading('on'); // Comprobamos si algún panel tiene cambios pendientes. var changed = false; var 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').off('click.close').on( 'click.close', 'button[id=close]', function( e ) { // click.close var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.close' , callback: function() { var inicio = $this.attr( 'data-gvhInicio' ); var gvhExit = $this.attr( 'data-gvhExit' ); // Comprobamos si algún panel tiene cambios pendientes. var changed = false; var 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').off('click.language').on( 'click.language', 'a[data-gvhFunction=language]', function( e ) { //click.language var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.language' , callback: function() { $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').off('click.capa_menuFalso').on( 'click.capa_menuFalso', 'div[id=capa_menuFalso]', function( e ) { //click.capa_menuFalso var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.capa_menuFalso' , callback: function() { // Comprobamos si algún panel tiene cambios pendientes. var changed = false; var gvhchanged = $( '[data-gvhchanged=true]' ); if( gvhchanged.length > 0 ) { changed = true; } if( changed ) { gvh.showMessage( 'gvhlang_msjUI','alert' ); } } } ); } ); $('#gvhPage').off('click.gvhOpenWindow').on( 'click.gvhOpenWindow', '[data-gvhOpenWindow]', function( e ) { //click.gvhOpenWindow var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.gvhOpenWindow' , callback: function() { var size = $this.attr('data-gvhSizeWindow'); // w,h var 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);