/* * Codificación UTF-8 * * FUNCIONES: * semaforoChange( funcion, objElemento ) * addList( campo, gvhLista, selectedValue ) * addListSelect2( campo, gvhLista, selectedValue ) * * showMessage( langCod, type, msg ) * showConfirm( id, codigo, descBreve, text, btnOk, btnCancel, destino, panel, claseM, destinoNO ) * * callControllerJS( objElemento ) * loading( modo, message ) * * buscar( objElemento ) * guardar( objElemento ) * cancelar( objElemento ) * okWS() * cancelarVS( objElemento ) * aceptarVS( objElemento ) * * getRulesFilter(idFilter, claseM, panel) * createTree(idTree, node, multiple, url, claseM, destino, actualizaA, idForm) * select2.defaults(width, allowClear, closeOnSelect, placeholder, containerCssClass, dropdownCssClass) * validateDate(id, fecha, separador, mascara) * showLinkTree(id,linkRama) * popupwindow() */ var gvh = gvh || {}; +function($) { 'use strict'; gvh.getUrlParameter = function(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; /** * semaforoChange: Método que activa eventos y los vuelve a activar para evitar la propagación de eventos en el dom * @access private * @var objElemento: elemento que lanza el cambio y es necesaria evitar la propagación */ gvh.semaforoChange = function( funcion, objElemento ) { objElemento.off( 'change', $.fn.funcion ); gvh.changeField( objElemento ); objElemento.on( 'change', $.fn.funcion ); } /** * addList() * FUNCIӓN: Crea una lista nueva con las opciones que se le pasan * @access private * @var gvhLista: array de opciones a añadir a la lista * @var selectedValue: valor seleccionado en la lista */ gvh.addList = function(campo, gvhLista, selectedValue) { console.log(' *** addList() - selected: '+selectedValue); var parentDetach = campo.parent(); campo.empty(); var $detachSelect = campo; $detachSelect.detach(); var lengthLista = gvhLista.length; console.log(gvhLista); for(var i=0;i'+descripcion+''); } else { $detachSelect.append(''); } } parentDetach.append($detachSelect); } /** * addListSelect2() * FUNCIӓN: Crea una lista nueva tipo select2 con las opciones que se le pasan * @access private * @var gvhLista: array de opciones a añadir a la lista * @var selectedValue: valor seleccionado en la lista */ gvh.addListSelect2 = function(campo, gvhLista, selectedValue) { console.log(' *** addListSelect2() - selected: '+selectedValue); var parentDetach = campo.parent(); campo.empty().trigger('change'); /*var $detachSelect = campo; $detachSelect.detach();*/ var lengthLista = gvhLista.length; for(var i=0;i '+type ); // Mostramos el progreso Pace.restart(); document.body.className = document.body.className; // Forzamos a actualizar la interfaz $.ajax( { url: urlLang , dataType: 'json', async: false , type: 'post' , success: function( data ) { var cod = desescapeIGEPjs( data[langCod]['cod'] ); var title = desescapeIGEPjs( data[langCod]['title'] ); var descrip = desescapeIGEPjs( data[langCod]['descr'] ); if( (msg) && (msg != '') ) { descrip += '
'+msg; } switch( type ) { case 'alert': alertify.alert( cod, title, descrip ); break; case 'error': alertify.error( cod, title, descrip ); break; case 'suggest': alertify.suggest( cod, title, descrip ); break; } }, error: function ( jqXHR, textStatus, errorThrown ) { alert( jqXHR ); } } ); } /** * showConfirm() * FUNCIÓN: mostrar mensaje de confirmación * defaults: id - del botón para el que se van a activar los campos * codigo - código del mensaje (ej. APL-1) * descBreve - descripción breve de la cabecera * text - texto del cuerpo del mensaje * btnOk - texto del botón OK * btnCancel - texto del botón Cancelar */ gvh.showConfirm = function( id, codigo, descBreve, text, btnOk, btnCancel, destino, panel, claseM, destinoNO ) { alertify.set( { labels : { ok : btnOk , cancel : btnCancel } } ); alertify.confirm( codigo, descBreve, text, function( e ) { if( e ) { $(this).controllerJS( { id: id , panel: panel , destino: destino , newWindow: 'false' , confirm: '' , claseM: claseM , message: msgLoad } ); } else { $(this).controllerJS( { id: id , panel: panel , destino: destinoNO , newWindow: 'false' , confirm: '' , claseM: claseM , message: msgLoad } ); } } , 'Default Value' ); } /** * callControllerJS: Llamada a negocio con los datos del panel * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * -> data-gvhNewWindow * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.callControllerJS = function( objElemento ) { console.log(' *** gvh_Function.js - callControlerJS()'); var className = objElemento.attr( 'class' ); if( className == 'btnTooltip' ) { return; } if( objElemento.attr('data-gvhConfirm') ) { var confirm = objElemento.attr( 'data-gvhConfirm' ); var vConfirm = confirm.split( '___' ); var destino = objElemento.attr( 'data-gvhDestino' ); var claseM = objElemento.attr( 'data-gvhClaseManejadora' ); var id = objElemento.attr( 'id' ); var panel = objElemento.attr( 'data-gvhPanelOn' ); this.showConfirm( id , vConfirm[0] , desescapeIGEPjs( vConfirm[1] ) , desescapeIGEPjs( vConfirm[2] ) , desescapeIGEPjs( vConfirm[3] ) , desescapeIGEPjs( vConfirm[4] ) , destino , claseM , panel ); } else { objElemento.controllerJS( { id: objElemento.attr( 'id' ) , panel: objElemento.attr( 'data-gvhPanelOn' ) , destino: objElemento.attr( 'data-gvhDestino' ) , newWindow: objElemento.attr( 'data-gvhNewWindow' ) , confirm: '' , claseM: objElemento.attr( 'data-gvhClaseManejadora' ) , message: 'cargando' } ); } } /** * loading: Muestra el cargando * @access private * @var modo: activar o desactivar ['on'|'off'] * @var message: cadena de texto si se quiere particularizar el mensaje "cargando" */ gvh.loading = function( modo, message ) { if( modo != 'on' ) { $( '#load-cover' ).hide(); $( '#load' ).hide(); $( '#load-cover' ).remove(); $( '#load' ).remove(); return; } if( $('#load-cover').length > 0 ) { $( '#load-cover' ).show(); $( '#load' ).show(); return; } var elCover = document.createElement( "div" ); elCover.setAttribute( "id", "load-cover" ); elCover.className = "load-cover"; document.body.appendChild( elCover ); var elLoad = document.createElement( "section" ); elLoad.setAttribute( "id", "load" ); elLoad.className = ""; document.body.appendChild( elLoad ); var contenido = '
'; contenido += '
    '; contenido += '
  • '; contenido += '
'; if( (message == '') || (message == undefined) ) { message = desescapeIGEPjs( msgLoad ); } else { message = desescapeIGEPjs( message) ; } contenido += '' + message + ''; contenido += '
'; $('#load').html( contenido ); } /** * buscar: buscar del panel filtro * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhFunction = 'buscar' * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * -> data-gvhNewWindow * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.buscar = function( objElemento ) { var idForm = objElemento.closest( 'form' ).attr( 'id' ); var panel = objElemento.attr( 'data-gvhPanelOn' ); var destino = objElemento.closest( 'form' ).attr( 'action' ); var claseM = objElemento.attr( 'data-gvhClaseManejadora' ); var id = objElemento.attr( 'id' ); var destinoLength = objElemento.attr( 'data-gvhDestino' ).length; if( destinoLength > 0 ) { destino = objElemento.attr( 'data-gvhDestino' ); } if( objElemento.attr( 'data-gvhConfirm' ) ) { var confirm = objElemento.attr( 'data-gvhConfirm' ); var vConfirm = confirm.split( '___' ); this.showConfirm( id , vConfirm[0] , desescapeIGEPjs( vConfirm[1] ) , desescapeIGEPjs( vConfirm[2] ) , desescapeIGEPjs( vConfirm[3] ) , desescapeIGEPjs( vConfirm[4] ) , destino , claseM , panel ); } else { var idDiv = $( 'div' ).filter(' [data-gvhCWSource=CWFilter] ').attr( 'id' ); if( idDiv != undefined ) { gvh.getRulesFilter($('#'+idDiv)); } this.callControllerJS( objElemento ); } } /** * guardar: Enviar a negocio los datos del panel para ser guardados * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhFunction = 'guardar' * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.guardar = function( objElemento ) { var accionActivaP = 'accionActivaP_'+objElemento.closest( 'form' ).attr( 'id' ); var modo = $( '#' + accionActivaP ).val(); var panel = objElemento.attr( 'data-gvhPanelOn' ); var idGuardar = objElemento.attr( 'id' ); var claseManejadora = objElemento.attr( 'data-gvhClaseManejadora' ); var estadoPanel = $( '#P_'+panel ).attr( 'data-gvhestadopanel' ); var destino = objElemento.closest( 'form' ).attr( 'action' ); var destinoLength = objElemento.attr( 'data-gvhDestino' ).length; if( destinoLength > 0 ) { destino = objElemento.attr( 'data-gvhDestino' ); } var fields = gvh.fieldsRequired(objElemento); if( fields != '' ) { this.showMessage( 'gvhlang_msj901', 'alert', fields ); return; } // TODO : FALTA data-gvhConfirm con JSON var confirm = objElemento.attr( 'data-gvhConfirm' ); if( (confirm != '') && (confirm != undefined) ) { var vConfirm = confirm.split( '___' ); var destinoNO = objElemento.attr( 'data-gvhConfirmCancel' ); this.showConfirm( idGuardar , vConfirm[0] , desescapeIGEPjs( vConfirm[1] ) , desescapeIGEPjs( vConfirm[2] ) , desescapeIGEPjs( vConfirm[3] ) , desescapeIGEPjs( vConfirm[4] ) , destino , claseManejadora , panel , destinoNO ); } else { this.callControllerJS( objElemento ); } } /** * cancelar: Cancelar la acción que se haya indicado realizar en el panel * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhFunction = 'guardar' * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * -> data-gvhNewWindow * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.cancelar = function( objElemento ) { var panel = objElemento.attr( 'data-gvhPanelOn' ); var claseM = objElemento.attr( 'data-gvhClaseManejadora' ); this.blockExit( true, 'R', panel, claseM ); var imgModificado = $( '#' + panel + '_imgModificado' ); if( imgModificado.length ) { imgModificado.hide(); } var destino = objElemento.attr( 'data-gvhDestino' ); if( (destino != 'cancelar') && (destino != '') ) { this.callControllerJS( objElemento ); } else { objElemento.loading( { message: 'Cancelando...' } ); setTimeout( 'window.top.location.reload()', 100 ); } } /** * cancelarVS: Cancelar la acción de la ventana de selección * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhFunction = ['cancelarvs'] * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.cancelarVS = function( objElemento ) { var panel = objElemento.attr( 'data-gvhPanelOn' ); if( objElemento.attr('data-gvhConfirm') ) { var confirm = objElemento.attr( 'data-gvhConfirm' ); var vConfirm = confirm.split( '___' ); var destino = objElemento.attr( 'data-gvhDestino' ); var claseM = objElemento.attr( 'data-gvhClaseManejadora' ); var id = objElemento.attr( 'id' ); this.showConfirm( id , vConfirm[0] , desescapeIGEPjs( vConfirm[1] ) , desescapeIGEPjs( vConfirm[2] ) , desescapeIGEPjs( vConfirm[3] ) , desescapeIGEPjs( vConfirm[4] ) , destino , claseM , panel ); } else { dialogWS.modal( 'hide' ); if( dialogIdWM.length <= 0 ) { ambito = 'gvhMain'; } else { ambito = 'gvhModal'; } } } /** * okWS: Aceptar la acción de la ventana de selección * @access private * @var actionOrigen: * @var fila: * @var panel: * @var fieldsSource: * @var fieldsWS: * @var claseMO: */ gvh.okWS = function(objElemento, actionOrigen, fila, panel, fieldsSource, fieldsWS, claseMO) { console.log(' *** gvh_Function.js - okWS() '); // DATOS DE LA VENTANA SELECCIÓN // Clase manejadora de ventana selección var claseM_WS = objElemento.attr('data-gvhClaseManejadora'); // Datos JSON de la ventana de selección var raizJSON_WS = gvh.getRoot(claseM_WS,'lis'); // DATOS DE LA VENTANA PADRE // Clase manejadora padre var ClaseMPadre = claseMO; console.log(claseMO); var raizJSON = gvh.getRoot(claseMO,panel); // Pág activa desde la que se ha invocado la ventana var indiceJSONPadre = 0; var regPadre = 0; if ((panel == 'lis') || (panel == 'lisDetalle')) { regPadre = $('#registroOrigen').val(); var indiceJSONPadre = gvh.indexDataJSON(raizJSON,regPadre); } var panelJSON = panel.substring(0,3); // Datos JSON de la ventana padre // Estado panel padre, id campo var prefijo = "cam___"; var estado = "modificada"; var modoPanelOn = objElemento.attr('data-gvhModoPanelOn'); if ((modoPanelOn == 'I') && (panel != 'fil')) { var prefijo = "ins___"; var estado = "insertada"; regPadre = raizJSON['panel']['pagActive']; }; // Var para marcar el panel como modificado var panelModif = false; var fieldActualiza = []; // Bucle de los campos a actualizar con los valores de la ventana de selección $.each(fieldsSource,function(index,value) { // Campo ventana padre var fSource = fieldsSource[index]; // Campo ventana de selección var fWS = fieldsWS[index]; // Cálculo del indiceJSON: registro seleccionado //var raizJSONWS = gvh.getRoot(claseM_WS,'lis'); var indiceJSONWS = gvh.indexDataJSON(raizJSON_WS,fila); //var indiceJSONWS = gvh.indexDataJSON(claseM_WS,'lis',fila); var newVal = gvh.getValue(raizJSON_WS,fWS,indiceJSONWS); var idSource = ''; // Actualización del objeto JSON de datos if (gvh.getExistField(raizJSON,fSource,indiceJSONPadre)) { gvh.setValue(raizJSON,fSource,indiceJSONPadre,newVal); if (panelJSON == 'fil') { idSource = gvh.getIdField(raizJSON,fSource,indiceJSONPadre); } else { idSource = prefijo+fSource+'___'+panel+'_'+regPadre; } $('#'+idSource+'[data-gvhClaseManejadora='+ClaseMPadre+']').val(newVal); gvh.setStateReg(raizJSON,'updated',indiceJSONPadre); if ((panelModif == false) && (panelJSON != 'fil')) { idSource = gvh.getIdField(raizJSON,fSource,indiceJSONPadre); if ($('#'+idSource).attr('readonly')) { panelModif = true; } } var funcion = ''; if ($('button[id='+value+']').attr('id')) { funcion = $('button[id='+value+']').attr('data-gvhFunction'); // Botón tooltip "updateField" } var actualizaA = $('#'+idSource).attr('data-gvhActualizaA'); if (((actualizaA != 'undefined') && (actualizaA != undefined)) || (funcion == 'updateField')) { fieldActualiza.push(idSource); } } else { console.log('¡¡¡ No existe el campo '+fSource+' para la clase manejadora '+claseM_WS); } }); if (fieldActualiza.length > 0) { $.each(fieldActualiza,function(index,value) { gvh.updateEvent($('#'+value)); }); } dialogWS.modal('hide'); if (dialogIdWM.length <= 0) ambito = 'gvhMain'; else ambito = 'gvhModal'; } /** * aceptarVS: Aceptar la acción de la ventana de selección * El elemento necesita tener los siguientes atributos si se crea de forma directa en html: * -> data-gvhFunction = ['cancelarvs'] * -> data-gvhClaseManejadora * -> data-gvhDestino * -> data-gvhPanelOn * -> data-gvhConfirm * @access private * @var objElemento: componente botón que se ha pulsado */ gvh.aceptarVS = function(objElemento ) { console.log(' *** gvh_Function.js - aceptarVS() '); console.log(objElemento); var panel = objElemento.attr( 'data-gvhPanelOn' ); if( objElemento.attr('data-gvhConfirm') ) { var confirm = objElemento.attr( 'data-gvhConfirm' ); var vConfirm = confirm.split( '___' ); var destino = objElemento.attr( 'data-gvhDestino' ); var claseM = objElemento.attr( 'data-gvhClaseManejadora' ); var id = objElemento.attr( 'id' ); this.showConfirm( id , vConfirm[0] , desescapeIGEPjs( vConfirm[1] ) , desescapeIGEPjs( vConfirm[2] ) , desescapeIGEPjs( vConfirm[3] ) , desescapeIGEPjs( vConfirm[4] ) , destino , claseM , panel ); } else { var destino = objElemento.attr( 'data-gvhDestino' ); var fieldsWS = objElemento.attr( 'data-gvhFieldsWS' ).split( ',' ); var fieldsSource = objElemento.attr( 'data-gvhFieldsSource' ).split( ',' ); var action = $( '#actionOrigen' ).val(); var id = $( 'input:radio[name=vsRadio]:checked' ).attr( 'id' ); if( id == undefined ) { $.getJSON( urlLang, function( data ) { var cod = desescapeIGEPjs( data['gvhlang_msj16']['cod'] ); var title = desescapeIGEPjs( data['gvhlang_msj16']['title'] ); var descrip = desescapeIGEPjs( data['gvhlang_msj16']['descr'] ); } ) .done( function() { alertify.suggest( cod, title, descrip ); } ); } else { var fila = id.split('_')[2]; // check_Tabla1_1 var modoPanel = objElemento.attr( 'data-gvhModoPanelOn' ); var claseMOrigen = objElemento.attr( 'data-gvhClaseMOrigen' ); gvh.okWS(objElemento, action,fila,panel,fieldsSource,fieldsWS,claseMOrigen); } } }; /** * floatBar() * FUNCIÓN: Función que permitirá que la barra superior del panel sea flotante. Necesita de la función checkVisible() * @access private * @var bar: barra a fijar como flotante * @var panel: panel al que corresponde la barra */ gvh.checkVisible = function(elm, evalType) { evalType = evalType || "visible"; if( typeof $(elm).offset() !== 'undefined' ) { var vpH = $(window).height(), // Viewport Height st = $(window).scrollTop(), // Scroll Top y = $(elm).offset().top, elementHeight = $(elm).height(); if (evalType === "visible") return ((y < (vpH + st)) && (y > (st - elementHeight))); if (evalType === "above") return ((y < (vpH + st))); } }; gvh.floatBar = function(bar = 'topBarPrimary', panel = 'P_lis') { $(window).bind("scroll", function() { var elem1 = $('#'+panel); var elem2 = $('#'+bar); elem2.removeClass('barraFlotante'); if( !$(window).checkVisible({ elm: elem2, evalType: 'visible'}) ) { elem2.addClass('barraFlotante'); } if( !$(window).checkVisible({ elm: elem1, evalType: 'visible'}) ) { elem2.removeClass('barraFlotante'); } }); } /** * getRulesFilter() * FUNCIÓN: Parsea los parámetros introducidos en el filtro avanzado en formato JSON y SQL para guardarlos en datosJSON * @access private * @var filter: objeto filtro */ gvh.getRulesFilter = function(filter) { var claseM = filter.attr('data-gvhClaseManejadora'); var panel = filter.attr('data-gvhPanelOn'); var idFilteer = filter.attr('id'); //JSON resultado = filter.queryBuilder('getRules', { get_flags: true, skip_empty: true } ); console.log(resultado); console.log(resultado['rules']); resultParseJSON = JSON.stringify(resultado, undefined, 2); console.log('parseJSON: '+resultParseJSON); // SQL parseSQL = ''; if (resultado['rules'].length > 0) { resultParseSQL = filter.queryBuilder('getSQL', false, false); parseSQL = resultParseSQL.sql + (resultParseSQL.params ? '\n\n' + JSON.stringify(resultParseSQL.params, undefined, 2) : ''); console.log('parseSQL: '+parseSQL); } panelJSON = filter.attr('data-gvhPanelJSON'); raizJSON = datosJSON[claseM][panelJSON]; if (panelJSON == 'fil') { raizJSON['data'][0]['gvhJS_fields'][idFilter]['rules'] = resultParseJSON; raizJSON['data'][0]['gvhJS_fields'][idFilter]['rulesSQL'] = parseSQL; } console.log(raizJSON); } /** * createTree() * FUNCIÓN: Crea un árbol jquery con el plugin jstree * @access private * @var objTree: objeto árbol * @var node: * @var multiple: selección múltiples valores * @var url * */ gvh.createTree = function(objTree, node, multiple, url) { var claseM = objTree.attr('data-gvhClaseManejadora'); var panel = objTree.attr('data-gvhPanelOn'); var actualizaA = objTree.attr('data-gvhActualizaA'); var idTree = objTree.attr('id'); var idForm = objTree.closest('form').attr('id'); if (multiple == "true") var multiple = true; else var multiple = false; // Comprobar si existe la variable datosJSON var raizJSON = datosJSON[claseM][panel]; var data = []; if (raizJSON['gvhJSON'] == 'false') { var data = JSON.stringify($("#"+idForm).serialize()); var url = url; } else { var data = datosJSON; var url = url+"&gvhcache=true&claseManejadora="+claseM+"&gvhpanel="+panel; } console.log(data); $('#'+idTree).jstree({ "types" : { "default" : { "icon" : "glyphicon glyphicon-flash" }, "root" : { "icon" : "fa fa-chevron-down" }, "users" : { "icon" : "fa fa-users" }, "volley" : { "icon" : "fa fa-anchor" }, "ciclismo" : { "icon" : "fa fa-bicycle" }, "child" : { "icon" : "fa fa-child" } }, "core" : { "multiple": multiple, "checkbox": true, "ajax": true, "worker": true, "data": { "url": url, //"url": "phrame.php?action=TreeSelector__treeAjax", "data": function(data) { console.log('data '+data); //json = node; return data;//{ "id" : node.id, "nodo": node }; }, "success": function (node) { console.log('success '+node); }, /*'data': function(node) { console.log('getJSONData '+node); json = node; return { "id" : node.id, "nodo": node }; }*/ "search": { "case_insensitive": true, "ajax" : { "url": "phrame.php?action=TreeSelector__treeAjax&value=search", 'dataType': 'json', 'type': 'POST', "data": function (node) { console.log('search '+node.id) return { "id": node.id }; } } }, }, "themes": { 'name': 'proton', 'responsive': true }, }, /*"changed": function (e, data) { console.log("Nodo seleccionado:"); selectedNodes = data.selected; if (selectedNodes.length > 0) { $.each(selectedNodes, function( index, value ) { console.log(value.id+' '+value.text); }); } else { console.log('no hay seleccionados'); } }, "search": { "case_insensitive": true, "ajax" : { "url": "phrame.php?action=TreeSelector__treeAjax&value=search", 'dataType': 'json', 'type': 'POST', "data": function (node) { console.log('search '+node.id) return { "id": node.id }; } } },*/ "plugins" : [ "types", "wholerow", "search", "themes", "html_data", "checkbox", "sort", "ui" ] }); } /** * validateDate() * FUNCIӓN: Comprobar que la fecha sea correcta * defaults: fecha - fecha introducida * separador */ gvh.validateDate = function(id,fecha,separador = '/',mascara='dd/mm/yyyy') { separador = separador; if (mascara.indexOf('/') != -1) separador = '/'; if (mascara.indexOf('-') != -1) separador = '-'; if ((mascara == 'dd/mm/yyyy') || (mascara == 'dd-mm-yyyy')) var dateDDMMYYYRegex = /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](18|19|20)\d\d$/; if ((mascara == 'mm/dd/yyyy') || (mascara == 'mm-dd-yyyy')) var dateDDMMYYYRegex = /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](18|19|20)\d\d$/; if (fecha != '') { correcto = fecha.match(dateDDMMYYYRegex); if (correcto) { fecha = fecha.split(separador); dia = fecha[0]; mes = fecha[1]; anio = fecha[2]; var error = 0; if ((mes==4 || mes==6 || mes==9 || mes==11) && dia==31) { correcto = false; } if (mes == 2) { // bisiesto var bisiesto = (anio % 4 == 0 && (anio % 100 != 0 || anio % 400 == 0)); if (dia > 29 || (dia==29 && !bisiesto)) { correcto = false; } } } if (!correcto) { //$('#'+id).showMessage('gvhlang_msj900','error'); gvh.showMessage('gvhlang_msj900','error'); $('#'+id).val(''); } return correcto; } }; /** * showLinkTree() * FUNCIӓN: mostrar la opción del árbol * */ var cont = 0; gvh.showLinkTree = function(id,linkRama) { console.log(' ** gvh_funcionesPaneles.js - showLinkTree() '); var linkRama = linkRama; if (linkRama != '') { console.log('Llamada ajax para mostrar el panel '+linkRama); /*var formulario = $('#'+id).closest('form'); console.log(formulario.attr('id')); formulario.submit(function() { var data = formulario.serialize();*/ // Mostramos el progreso Pace.restart(); document.body.className = document.body.className; // Forzamos a actualizar la interfaz $.ajax({ //data: data, type: "POST", cache: false, url: linkRama, beforeSend: function() { console.log(' ... Beforesend ...'); gvh.loading('on',message); }, success: function(response) { console.log(' ... Success: '+response); rspPhrame = $.parseJSON(response); /*$.ajax({ url: decodeURIComponent(rspPhrame.path), dataType: "html" , // Usamos el tipo 'html' para importar también los scripts embebidos cache: true }).done(function(resp) { $('.gvh-treeview-content').html( $(resp).filter('.gvh-treeview-content').contents() ); });*/ window.location.href = decodeURIComponent(rspPhrame.path); }, error:function( jqXHR, textStatus, errorThrown ) { console.log(' ... # ERROR showLinkTree'); }, complete:function( jqXHR, textStatus, errorThrown ) { console.log(' ... # COMPLETE showLinkTree'); gvh.loading('off'); } }) //return false; //}); } }; /* * popupWindow() * FUNCIÓN: Abrir una ventana emergente como respuesta a evento sobre el DOM */ gvh.popupWindow = function(instanceSettings) { console.log(' REVIEW: popupWindow() - gvh_funciones.js'); console.log(instanceSettings); var defaultSettings = { centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left height:500, // sets the height in pixels of the window. left:0, // left position when the window appears. location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}. menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}. resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable. scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}. status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}. width:500, // sets the width in pixels of the window. windowName:null, // name of window set from the name attribute of the element that invokes the click windowURL:null, // url used for the popup top:0, // top position when the window appears. toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}. }; gvh.loading( 'off' ); //settings = $.extend({}, defaultSettings, instanceSettings || {}); var height = instanceSettings.height; var width = instanceSettings.width; if (instanceSettings.height == '') var height = 500; if (instanceSettings.width == '') var width = 500; var windowFeatures = 'height=' + height + ',width=' + width + ',toolbar=' + defaultSettings.toolbar + ',scrollbars=' + defaultSettings.scrollbars + ',status=' + defaultSettings.status + ',resizable=' + defaultSettings.resizable + ',location=' + defaultSettings.location + ',menuBar=' + defaultSettings.menubar; var centeredY,centeredX; if(instanceSettings.centerBrowser) { if ($.browser.msie) {//hacked together for IE browsers centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (height/2))); centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (width/2))); } else { centeredY = window.screenY + (((window.outerHeight/2) - (height/2))); centeredX = window.screenX + (((window.outerWidth/2) - (width/2))); } window.open(instanceSettings.windowURL, instanceSettings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus(); } else if(instanceSettings.centerScreen) { centeredY = (screen.height - height)/2; centeredX = (screen.width - width)/2; window.open(instanceSettings.windowURL, instanceSettings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus(); } else { window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + defaultSettings.left +',top=' + defaultSettings.top).focus(); } return false; }; } (jQuery);