var gvh = gvh || {}; +function ($) { 'use strict'; $(".gvhModal").on('load', function () { alert('The modal is fully shown.'); } ); $(document).ready(function() { if(gvh.DEBUG) console.time('gvh_onready.ready...'); gvh.orderTable = gvh.getUrlParameter( 'orderTable' ); gvh.orderFieldTable = gvh.getUrlParameter( 'orderField' ); // // TODO : Revisar para opción de cargar dinámicamente javascript: // // * https://stackoverflow.com/questions/11803215/how-to-include-multiple-js-files-using-jquery-getscript-method // /** * Debounce para el redimensionado (aka. resize) de la página. */ if( !gvh.resizeDebounce ) { gvh.resizeDebounce = function( e ) { var timeoutDelta = 250; // milliseconds clearTimeout( gvh.resizeTimer ); gvh.resizeTimer = setTimeout( function() { $( '#gvhPage' ).trigger( "resizeEnd" ); }, timeoutDelta); } //gvh.resizeDebounce } $(window).off( 'resize.gvh' ).on( 'resize.gvh', gvh.resizeDebounce ); /** * Muestra una alerta al usuario indicando que hay cambios pendientes de guardar/cancelar. */ gvh.showAlertaCambiosPendientes = function() { if( gvh.showMessage ) { gvh.showMessage( 'gvhlang_msjUI', 'alert' ); } } //gvh.showAlertaCambiosPendientes gvh.initModal = function(idVentana) { $('[data-toggle=popover]').each( function() { $(this).popover( { trigger: 'manual', html: true, content: function() { $(this).attr('data-content').html() } } ); } ); gvh.rewireMain(); } //gvh.initModal gvh.initTypeFields = function() { gvh.showConsoleMsg('log', ' - Inicializando tipos...' ); var items; items = $('select[data-gvhAutocomplete=true][data-gvhWindow='+gvh.ambito+']') if( items.length ) { gvh.showConsoleMsg( 'beginGroup', ' - Inicializando select2...' ); var listsSelect2 = new Array( items.length ); items.each( function(index) { var params = gvh.configParamsSelect2( $(this) ); $(this).select2( params ); listsSelect2[index] = $(this).attr('id'); }); gvh.showConsoleMsg('log', listsSelect2 ); gvh.showConsoleMsg( 'endGroup' ); listsSelect2 = null; } items = $('input[data-gvhtypedata=numeric][data-gvhWindow='+gvh.ambito+']'); if( items.length ) { gvh.showConsoleMsg('beginGroup', ' - Inicializando numéricos...'); var numericos = new Array( items.length ); items.each( function(index) { // PARA CUANDO SE CREE LA TPL DEL CAMPO DE TEXTO. REVIEW //$(this).inputmask(); numericos[index] = $(this).attr('id'); }); gvh.showConsoleMsg('log', numericos ); gvh.showConsoleMsg( 'endGroup' ); numericos = null; } items = $('input[data-gvhTypeData=float][data-gvhWindow='+gvh.ambito+']'); if( items.length ) { gvh.showConsoleMsg('beginGroup', ' - Inicializando numéricos flotantes...'); var flotantes = new Array( items.length ); items.each( function(index) { // PARA CUANDO SE CREE LA TPL DEL CAMPO DE TEXTO. REVIEW /*$(this).inputmask({ 'alias': 'decimal', 'rightAlign': true, 'groupSeparator': '.', 'radixPoint': ',', 'autoGroup': true });*/ flotantes[index] = $(this).attr('id'); }); gvh.showConsoleMsg('log', flotantes ); gvh.showConsoleMsg( 'endGroup' ); flotantes = null; } items = null; $('textarea[data-textEditor=true][data-gvhWindow='+gvh.ambito+']').each( function() { var id = $(this).attr('id'); // $("div[id*=editor_"+id+"]").attr('contenteditable','false'); $('textarea[data-gvhposition=panel_fil]').each( function() { var idFil = $(this).attr('id'); $("div[id*='editor_"+idFil+"']").attr('contenteditable','true'); }) if ( ($('textarea[id*='+id+']').hasClass('noEdit') == true) || ($('textarea[id*='+id+']').hasClass('tableNoEdit') == true) ) { $('div[id=editor_'+id+']').attr('contenteditable','false'); } if (($('textarea[id*='+id+']').hasClass('modify') == true)) { $('div[id=editor_'+id+']').attr('contenteditable','true'); } }); //REVIEW: VERO Eliminar cuando el nuevo árbol esté acabado $('[data-gvhArbolLink]').on({ click: function() { gvh.showConsoleMsg('log',$(this).attr('data-gvhArbolLink')); gvh.showLinkTree($(this).attr('id'),$(this).attr('data-gvhArbolLink')); } }); $.getScript( 'igep/smarty/plugins/gvh_calendar/js/jquery-ui-sliderAccess.js', function() { gvh.showConsoleMsg('log','Load jquery-ui-sliderAccess.js performed.'); $.getScript( 'igep/smarty/plugins/gvh_calendar/js/jquery-ui-timepicker-addon.js', function() { gvh.showConsoleMsg('log','Load jquery-ui-timepicker-addon.js performed.'); $.getScript( 'igep/js/gvh_calendar.js', function() { gvh.showConsoleMsg('log','Load gvh_calendar.js performed.'); } ); } ); } ); } //gvh.initTypeFields /** * Permite maximizar/restaurar una ventana modal */ gvh.resizeModal = function() { // REVIEW : Ya no es necesario prevent+stop, debido a .off('click.gvh_resizeModal').on('click.gvh_resizeModal' //e.preventDefault(); //e.stopImmediatePropagation(); $('#gvhPage').toggleClass( 'modal-fullscreen' ); } //gvh.resizeModal /** * Permite actualizar la interfaz de las clases manejadoras de los paneles en pantalla, de modo que al cargar (o recargar) un panel * se actualice el estado de los controles, y se des/habiliten y se muestren/oculten de acuerdo a las reglas que el programador alla * programado para ese panel. */ gvh.rewirePage_onready = function() { gvh.showConsoleMsg ('log','Lanzamos la dinámica de interacción de la página recién cargada.'); gvh.semaphoreAddLevel ('rewirePage_onready'); // setTimeout (function() { gvh.showConsoleMsg ('time','rewirePage_onready'); var ar = gvh.rewireUI; var len = ar.length; if (len) { for (var i = 0; i < len; i++) { var nameFuncion = ar[i]['funcion']; var claseM = ar[i]['clase']; if (($.isArray(gvh.datosJSON[claseM])) && (gvh.datosJSON[claseM].length == 0)) // si existe la clase manejadora en gvh.datosJSON pero está vacía { gvh.showConsoleMsg('log', ' ¡¡¡SE DA DE BAJA LA SUBSCRIPCIÓN DE LA CLASE MANEJADORA '+ar[i]['clase']+'!!!' ); var index = ar.inArray(ar[i]['clase'], "clase"); if (index != -1) ar.splice( index ,1 ); } else { // en gvh.datosJSON debe existir la clase manejadora y length > 0 contenido gvh.showConsoleMsg('log', ' ... actualización de la interfaz de la clase manejadora '+ar[i]['clase'] ); gvh.subscribeRewireUI( claseM, nameFuncion ); } } } gvh.showConsoleMsg ('timeEnd','rewirePage_onready'); gvh.semaphoreSubLevel ('rewirePage_onready'); // }, 100); } //gvh.rewirePage_onready /** * Para resolver las recargas de página en gvHidra. * Debe contener toda funcionalidad que deba ser inicializada expresamente, * y debe invocarse tras regenerar una página (especialmente si se destruye el * cuerpo/main de la página. */ gvh.rewireMain = function() { console.groupCollapsed('gvh_onready : gvh.rewireMain'); // Inicializamos la barra de progreso Pace.start(); gvh.initTypeFields(); // // Liberamos el desplegable de la multi-selección de tabla (si lo hay) // if( gvh.checkAllMultiSelectDropdownMenu ) { gvh.checkAllMultiSelectDropdownMenu.detach(); gvh.checkAllMultiSelectDropdownMenu.hide(); delete gvh.checkAllMultiSelectDropdownMenu; gvh.checkAllMultiSelectDropdownMenu = undefined; } // // Activamos tooltips de bootstrap (+ gvHidra) // if ($.fn.tooltip) { gvh.showConsoleMsg('log', ' - tooltip : Inicializando...' ); $('[data-toggle=tooltip]').tooltip(); $('.gvh-tooltip').tooltip(); $('[data-toggle=popover]').each(function () { if ($(this).attr('data-content') != '') { $(this).popover({ trigger: 'manual', html: true, content: function() { $(this).attr('data-content').html() } }); } }) } else if(gvh.DEBUG) { console.warn( 'gvh_onready : WARNING : $.fn.tooltip no disponible' ); if(gvh.STOPONWARNING) { debugger; } } // // Activamos el menú principal // if ($.fn.dropdown) { gvh.showConsoleMsg('log', ' - gvh_menu : Inicializando menú principal...' ); $('#gvhHeader .dropdown-toggle').dropdown(); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : $.fn.dropdown no disponible' ); if(gvh.STOPONWARNING) { debugger; } } // // Activamos los submenús para el menú principal // // For v2 [data-toggle=dropdown] is required for [data-submenu]. // For v2 .dropdown-submenu > [data-toggle=dropdown] is forbidden. if ($.fn.submenupicker) { gvh.showConsoleMsg('log', ' - gvh_menu : Inicializando submenús...' ); $('#gvhHeader [data-submenu]').submenupicker(); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : $.fn.submenupicker no disponible' ); //if(gvh.STOPONWARNING) { debugger; } } // // Permite maximizar/restaurar un panel // if (gvh.resizePanel) { gvh.showConsoleMsg('log', ' - gvh_resizePanel : Inicializando...' ); $('#gvhPage').off('click.gvh_ResizePanel').on( 'click.gvh_ResizePanel', '[data-toggle=panel-fullscreen]', function( e ) { var $this = $(this); gvh.semaphoreEnqueue ( { id: 'click.gvh_ResizePanel' , callback: function() { gvh.resizePanel ($this); } } ); } ); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.resizePanel no disponible' ); if(gvh.STOPONWARNING) { debugger; } } // // Permite maximizar/restaurar una ventana modal // if (gvh.resizeModal) { gvh.showConsoleMsg('log', ' - gvh_resizeModal : Inicializando...' ); $('#gvhPage').off('click.gvh_resizeModal').on( 'click.gvh_resizeModal', '[data-toggle=modal-fullscreen]', function( e ) { gvh.semaphoreEnqueue ( { id: 'click.gvh_resizeModal' , callback: function() { gvh.resizeModal (); } } ); } ); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.resizeModal no disponible' ); if(gvh.STOPONWARNING) { debugger; } } // // Activamos el menú lateral // if (gvh.collapseSidebarBranch) { $('#gvhPage').off('hidden.bs.collapse').on('hidden.bs.collapse', '#gvhSidebar ul.collapse', function( e ) { var $this = $(this); gvh.semaphoreEnqueue ( { id: 'hidden.bs.collapse' , callback: function() { gvh.collapseSidebarBranch ($this); } } ); } ); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.activateSidebarToggler no disponible' ); //if(gvh.STOPONWARNING) { debugger; } } if (gvh.activateSidebarToggler) { gvh.showConsoleMsg('log', ' - gvh_side-bar : Enlazando gvh.activateSidebarToggler ...' ); $('#gvhPage').off('click.gvh_side-bar').on('click.gvh_side-bar', '#gvhSidebar-toggler', function ( e ) { var $window = $(window); gvh.semaphoreEnqueue ( { id: 'click.gvh_side-bar' , callback: function() { gvh.activateSidebarToggler ($window); } } ); } ); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.activateSidebarToggler no disponible' ); //if(gvh.STOPONWARNING) { debugger; } } if (gvh.determineSidebar) { gvh.showConsoleMsg('log', ' - gvh_side-bar : Enlazando gvh.determineSidebar ...' ); $(window).bind("load resize", gvh.determineSidebar); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.determineSidebar no disponible' ); //if(gvh.STOPONWARNING) { debugger; } } /* if (gvh.calculateContentMinHeight) { gvh.showConsoleMsg('log', ' - gvh_side-bar : Enlazando calculateContentMinHeight ...' ); $(window).bind("load resize scroll", function () { gvh.calculateContentMinHeight(); }); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.calculateContentMinHeight no disponible' ); if(gvh.STOPONWARNING) { debugger; } } */ // REVIEW : Éste código se ha movido a 'gvh_controller.ajaxStop', aunque se mantiene aquí una copia // por si acaso fuera necesario en algún caso. En principio, ya no debe hacer falta y sobra. /* if( gvh.rewirePage_onready ) { gvh.rewirePage_onready(); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh_onready : WARNING : gvh.rewirePage no disponible' ); if(gvh.STOPONWARNING) { debugger; } } */ console.groupEnd(); } //gvh.rewireMain if( gvh.rewireMain ) { gvh.rewireMain(); } else if(gvh.DEBUG) { gvh.showConsoleMsg('warn','gvh.rewireMain : WARNING : gvh.rewireMain no disponible' ); if(gvh.STOPONWARNING) { debugger; } } if(gvh.DEBUG) console.timeEnd('gvh_onready.ready...'); } ); // document.ready } (jQuery); /** * DevTools Snippets - Console log. * @author Brian Grinstead */ (function(console){ console.save = function(data, filename) { if( !data ) { console.error('Console.save: No data') return; } if( !filename ) filename = 'console.json' if( typeof data === "object" ) { data = JSON.stringify( data, undefined, 4 ) } var blob = new Blob( [data], {type: 'text/json'} ) , e = document.createEvent( 'MouseEvents' ) , a = document.createElement( 'a' ) a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join( ':' ) e.initMouseEvent( 'click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null ) a.dispatchEvent( e ) } })(console);