/** * PAQUETE JS con las clases que manejan los botones Tooltips * Clase objBotonToolTip * Clase objBTTLimpiar * Clase objBTTModificar * Clase objBTTInsertar * Clase objBTTEliminar * Clase objBTTAbrirVS * Clase objBTTBuscarVS * Clase objBTTRestaurar **/ Function.prototype.method = function (name, func) { this.prototype[name] = func; return this; }; Function.method('inherits', function (parent) { var d = 0, p = (this.prototype = new parent()); this.method('uber', function uber(name) { var f, r, t = d, v = parent.prototype; if (t) { while (t) { v = v.constructor.prototype; t -= 1; } f = v[name]; } else { f = p[name]; if (f == this[name]) { f = v[name]; } } d += 1; r = f.apply(this, Array.prototype.slice.apply(arguments, [1])); d -= 1; return r; }); return this; } ) /** * Clase que maneja los botones tooltips, se incluye la funcionalidad * global y de ella heredarán las distintas clases de botones posteriormente */ function objBotonToolTip(nomObjeto,idPanel,esMaestro,esDetalle) { this.constructor (nomObjeto,idPanel,esMaestro,esDetalle); } //Devuelve el obj HTML Form, formulario donde se encuentra el botón objBotonToolTip.method('constructor', function (nomObjeto,idPanel,esMaestro,esDetalle) { this.nomObj = nomObjeto; this.idPanel = idPanel; this.idForm = 'F_'+idPanel; this.formulario = eval('document.getElementById("'+this.idForm+'")'); /* Sólo se utilizan en las pantallas con Maestro Detalle */ this.idPanelMD = null; this.imagen = null; if (this.formulario === null) { this.formulario = null; this.idForm = ''; } this.nomClase = 'objBotonToolTip'; this.esMaestro = esMaestro; this.esDetalle = esDetalle; this.habilitado = true; return this; } ); ////////////////////////////////////////////////////////// //// MÉTODOS BOTON TOOLTIP //// ---------- //// getForm //// ---------- objBotonToolTip.method('getForm', function () { return (this.formulario); } ); //// ------------- //// getFormId //// ------------- //Devuelve una cadena que será el nombre del formulario donde se encuentra el botón objBotonToolTip.method('getFormId', function () { return (this.idForm); }); //// ------------ //// getPanel //// ------------ //Devuelve el nombre del panel donde se encuentra el botón objBotonToolTip.method('getPanel', function () { return (this.idPanel); }); //// ------------------- //// getNombreObj //// ------------------- //Devuelve una cadena que será el nombre de la instancia creada objBotonToolTip.method('getNombreObj', function () { return (this.nomObj); }); //// ----------- //// getClase //// ----------- //Devuelve el nombre de la clase de la q es instancia objBotonToolTip.method('getClase', function () { return (this.nomClase); }); //// -------------------- //// estoyEnMaestro //// -------------------- //Devuelve un true o false según este o no en un panel maestro objBotonToolTip.method('estoyEnMaestro', function () { return (this.esMaestro); }); //// -------------------- //// estoyEnDetalle //// -------------------- //Devuelve un true o false según este o no en un panel detalle objBotonToolTip.method('estoyEnDetalle', function () { return (this.esDetalle); }); //// -------------- //// esPanelMD //// -------------- objBotonToolTip.method('esPanelMD', function () { panelMD = false; // Existe detalle?? if ( (document.getElementById('P_ediDetalle')) || (document.getElementById('P_lisDetalle')) ) { // Soy panel dl detalle if ( (this.idPanel == 'ediDetalle') || (this.idPanel == 'lisDetalle') ) { // Oculto panel maestro if (document.getElementById('P_edi')) this.idPanelMD = 'edi' else this.idPanelMD = 'lis' panelMD = true; } else { // No soy el panel detalle // El panel detalle es de tipo 'edi' o 'lis'???? if (document.getElementById('P_ediDetalle')) this.idPanelMD = 'ediDetalle' else this.idPanelMD = 'lisDetalle' panelMD = true; } } return(panelMD); } ); //// -------------- //// activarGC (Activar los botones Guardar/Cancelar) //// -------------- objBotonToolTip.method('activarGC', function () { panel = this.idPanel; btnActivar = 'bn'+panel+'_guardar'; if (document.getElementById(btnActivar)) { bton = document.getElementById(btnActivar); bton.disabled = false; bton.style.display = 'inline'; } btnActivar = 'bn'+panel+'_cancelar'; if (document.getElementById(btnActivar)) { bton = document.getElementById(btnActivar); bton.disabled = false; bton.style.display = 'inline'; } } ); //// ---------------------- //// deshabilitarBoton //// ---------------------- objBotonToolTip.method('deshabilitarBoton', function () { //Si el boton ya está deshabilitado SALIMOS if (!this.habilitado) return; this.imagen = eval('document.getElementById("img_'+this.nomObj+'")'); this.habilitado = false; ruta = this.imagen.src; //La ruta puede ser gif o png v_rutas = ruta.split('.gif'); if (v_rutas.length <= 1)//Es un png { v_rutas = ruta.split('.png'); } nuevaRuta = v_rutas[0]+'off'+v_rutas[1]; this.imagen.src=nuevaRuta; this.habilitado = false; } ); //// ---------------------- //// habilitarBoton //// ---------------------- objBotonToolTip.method('habilitarBoton', function () { //Si el boton ya está habilitado SALIMOS if (this.habilitado) return; ruta = this.imagen.src; v_rutas = ruta.split('off'); nuevaRuta = v_rutas[0]+v_rutas[1]; this.imagen.src=nuevaRuta; this.habilitado = true; } ); //// --------------------------- //// deshabilitarHermanos //// --------------------------- objBotonToolTip.method('deshabilitarHermanos', function (cadenaBotones, separador) { if ((separador=='') || (separador==null)) { separador=','; } v_botones = cadenaBotones.split(separador); panelMD = this.esPanelMD(); for (i=0; i 2) prefijo= elemento.id.split('___')[0]; // prefijo del campo 'cam' o 'ins' else prefijo =''; //Estamos tratando el panel de búsqueda ¿dificil no? // sólo queremos actuar sobre los campos de usuario, es decir, eliminamos: // - Campos hidden de control de concurrencia // - Campos fijados de sólo lectura (readonly) // - Campos con el prefijo ant if ( (elemento.type != "hidden") && (elemento.readOnly != true) && (prefijo != 'ant') && ( (prefijo =='cam') || (prefijo =='ins') ) ) { nomCampo = elemento.id; sufijo = nomCampo.split('___')[2]; // sufijo del campo = FichaEdicion_pag (cam___nomCampo___FichaEdicion_pag) pagCampo = sufijo.split('_')[1]; // Encontramos un campo de la página activa if (pagCampo == pagActiva) { if (prefijo=='ins') { //Si es una inserción no hay valor anterior if ((elemento.type != 'select-one') && (elemento.type != 'select-multiple')) elemento.value=''; else elemento.selected = false; } else //estamos modificando { // opción volver a los valores anteriores nombreSinPrefijo = nomCampo.substr(3,nomCampo.length); if ((elemento.type != 'select-one') && (elemento.type != 'select-multiple')) { elemento.value = eval('formulario.ant'+nombreSinPrefijo+'.value'); } else // { listaActual = elemento; listaAnterior = eval('formulario.ant'+nombreSinPrefijo); listaActual.options.length = 0; for(j=0; j 2) nuevoClass = vClassCampo[0]+' '+vClassCampo[2]; eval('document.getElementById("'+id+'").className = "'+nuevoClass+'"'); } if ( ((vClassCampo[0] == "tablaModificar") || (vClassCampo[0] == "tablaInsertar") ) && ((elemento.readOnly == false) || (elemento.disabled == false)) ) { // opción reset = limpiar campos if (operacion=='reset') { switch (elemento.type) { case 'text': elemento.value = ''; break; case 'checkbox': elemento.checked = false; break; case 'select-one': elemento.options[0].selected = true; break; case 'radio': elemento.checked = false; break; } } else { // opción volver a los valores anteriores nombreSinPrefijo = id.substr(3,id.length); // sin cam switch (elemento.type) { case 'text': valorAnt = eval('formulario.ant'+nombreSinPrefijo+'.value'); elemento.value = valorAnt; elemento.readOnly = true; break; case 'checkbox': nombreSinPrefijo = id.substr(4,id.length); //ccam valorAnt = eval('formulario.ant'+nombreSinPrefijo+'.value'); valorActual = eval('formulario.cam'+nombreSinPrefijo+'.value'); if (valorAnt != valorActual) if (eval('document.getElementById("'+id+'").checked')) eval('document.getElementById("'+id+'").checked = "false"'); else eval('document.getElementById("'+id+'").checked = "true"'); eval('document.getElementById("'+id+'").disabled = "true"'); break; case 'select-one': valorAnt = eval('formulario.ant'+nombreSinPrefijo+'.value'); for(k=0;k 2) // ej. class="tablaEdi fila_on importante" { nuevoClass = nuevoClass+' '+vClassCampo[2]; } eval('document.getElementById("'+id+'").className = "'+nuevoClass+'"'); eval('document.getElementById("'+idFila+'").className="formularios"'); } // if campos } // if } // for break; default: //no se sabe aun };//Fin Switch marcaModificado = document.getElementById(this.idPanel+'_imgModificado'); if (marcaModificado != null) { marcaModificado.style.display="none"; } }); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////// CLASE PARA EL botón INSERTAR.- objBTTInsertar ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function objBTTInsertar (nomObjeto,idPanel,esMaestro,esDetalle) { //llamamos al constructor del padre this.uber('constructor',nomObjeto,idPanel,esMaestro,esDetalle); this.nomClase = 'objBTTInsertar'; } //DECLARACION DE HERENCIA objBTTInsertar.inherits(objBotonToolTip); // activarCampos para el botón insertar objBTTInsertar.method('activarCampos', function (prefijoCampo) { // prefijoCampo: ins - cins (insertar) / cam (modificar) / ant (valor anterior) // Nombre campo: 'prefijoCampo___' formulario = this.getForm(); for(i=0;i 3) ) { valueFinal += separador; textFinal += separador; } } // Añadimos el valor de la concatenación de todos los campos al select múltiple destino posicion = eval('document.getElementById("'+destino+'").length'); campoDestino = eval('document.getElementById("'+destino+'")'); campoDestino.options[posicion] = new Option(textFinal,valueFinal); campoDestino.options[posicion].selected = true; } } ); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////// CLASE PARA EL botón MODIFICAR.- objBTTModificar ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function objBTTModificar (nomObjeto,idPanel,esMaestro,esDetalle) { //llamamos al constructor del padre this.uber('constructor',nomObjeto,idPanel,esMaestro,esDetalle); this.nomClase = 'objBTTModificar'; } //DECLARACIÓN DE HERENCIA objBTTModificar.inherits(objBotonToolTip); objBTTModificar.method('modificarTabla', function () { var idFila = ""; var hayFoco = 0; //Activamos los botones inferiores!! this.activarGC(); formulario = this.getForm(); nomForm = this.getFormId(); // Tenemos un campo oculto q contendrá la acción realizada con los botones ToolTip accionActivaP = 'accionActivaP_'+nomForm; if (this.esPanelMD()) // Si es maestro o Detalle { this.deshabilitarMD(); //Deshabilito botones del palnel complementario } for(i=0;i idFila = "F_".$idTabla."_".$iterActual; valorId = String(formulario.elements[i].id); prefijo = valorId.split('_')[0]; tipoCampo = formulario.elements[i].type; //nombreCampo = formulario.elements[i].name; nombreCampo = formulario.elements[i].id; classCampo = formulario.elements[i].className; // PARA EL CASO DE UNA TABLA PQ TIENE UN CHECK Q LA IDENTIFICA if ( (prefijo== 'check') && (tipoCampo == 'checkbox') && (formulario.elements[i].checked) && (nombreCampo != 'seleccionarTodo') ) { // Las filas chequeadas se marcarán como modificadas idFila = valorId.split('check_')[1]; fila = eval('document.getElementById("'+idFila+'")'); // Campo oculto con el estado d la fila eval('formulario.est_'+idFila+'.value="modificada"'); // Estilo de la fila. Comentado pq se queda marcada la fila como seleccionada mientras se modifica //fila.className = "formularios"; // Oculto con la acción eval('formulario.'+accionActivaP+'.value="modificar"'); } // if checkbox idFilaCampo = nombreCampo.split('___')[2]; // Para el resto de campos que pueden estar dentro d una tabla if ( (idFilaCampo == idFila) && ( (tipoCampo == 'text') || (tipoCampo == 'textarea') || (tipoCampo == 'radio') || (tipoCampo == 'select-one') || ((prefijo != 'check') && (tipoCampo == 'checkbox') && (nombreCampo != 'seleccionarTodo')) ) ) { vClass = classCampo.split(" "); if (vClass[1] == 'undefined') vClass[1] = ''; if ( (!hayFoco) && (vClass[0] == "tablaEdi")) { hayFoco = 1; campoFoco = formulario.elements[i]; if (eval('document["cal_'+nombreCampo+'"]')) { src = eval('document["cal_'+nombreCampo+'"].src'); src = src.replace("pestanyas/pix_trans.gif","botones/17.gif"); eval('document["cal_'+nombreCampo+'"].src = "'+src+'"'); } // botón ventana selección /** nombreSinPrefijo = nombreCampo.substr(6,nombreCampo.length); if (eval('document["vs_'+nombreSinPrefijo+'"]')) { src = eval('document["vs_'+nombreSinPrefijo+'"].src'); src = src.replace("pestanyas/pix_trans.gif","botones/13.gif"); eval('document["vs_'+nombreSinPrefijo+'"].src = "'+src+'"'); } **/ } vClass = classCampo.split(" "); if (vClass[1] == null) vClass[1] = ''; else vClass[1] = " "+vClass[1]; if (vClass[0] == "tablaEdi") { if ((tipoCampo == 'radio') || (tipoCampo == 'checkbox') || (tipoCampo == 'select-one') || (tipoCampo == 'select-multiple') ){ formulario.elements[i].disabled = false; } formulario.elements[i].className = "tablaModificar"; if (tipoCampo == "text") formulario.elements[i].readOnly = false; } }// if } // for i if (hayFoco) eval('campoFoco.focus()'); marcaModificado = document.getElementById(this.idPanel+'_imgModificado'); if (marcaModificado != null) { capaMenuFalso = document.getElementById('capa_menuFalso'); capaMenuReal = document.getElementById('capa_menuReal'); capaMenuFalso.style.display="inline"; capaMenuReal.style.display="none"; marcaModificado.style.display="inline"; ocultoPerCerrarApli=document.getElementById('permitirCerrarAplicacion'); ocultoPerCerrarApli.value='no'; } if (eval(this.idPanel+'_paginacion')) { paginador = eval(this.idPanel+'_paginacion'); //Se marca la página como modificada... paginador.paginasModificadas[parseInt(this.getPaginaActiva(),10)] = true; } } ); objBTTModificar.method('modificarFicha', function () { if (this.habilitado == false) return; //Activamos los botones inferiores!! this.activarGC(); formulario = this.getForm(); var capas = formulario.getElementsByTagName("DIV"); var pagina = null; var soloLectura = true; var numCapas = capas.length; accionActivaP = 'accionActivaP_'+formulario.id; if (this.esPanelMD()) // Si es maestro o Detalle { if ((this.idPanel=='edi') || (this.idPanel == 'lis')) //Soy el panel maestro { // Deshabilitar mis hermanos if (this.idPanel == 'edi') //Soy el panel edi y soy un maestro this.deshabilitarHermanos('insertar,eliminar,modificar',','); } this.deshabilitarMD(); //Deshabilito botones del palnel complementario } for(i=0;i 0) campoDestino.options[campoDestino.options.selectedIndex] = null; } ); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////// CLASE PARA EL botón ELIMINAR.- objBTTEliminar ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function objBTTEliminar(nomObjeto,idPanel,esMaestro,esDetalle) { //llamamos al constructor del padre this.uber('constructor',nomObjeto,idPanel,esMaestro,esDetalle); this.nomClase = 'objBTTEliminar'; } //DECLARACION DE HERENCIA objBTTEliminar.inherits(objBotonToolTip); objBTTEliminar.method('eliminarTabla', function () { var idFila = ""; var hayFoco = 0; //Activamos los botones inferiores!! this.activarGC(); formulario = this.getForm(); nomForm = this.getFormId(); // Tenemos un campo oculto q contendrá la acción realizada con los botones ToolTip accionActivaP = 'accionActivaP_'+nomForm; if (this.esPanelMD()) // Si es maestro o Detalle { this.deshabilitarMD(); //Deshabilito botones del palnel complementario } for(i=0;i idFila = "F_".$idTabla."_".$iterActual; valorId = String(formulario.elements[i].id); prefijo = valorId.split('_')[0]; tipoCampo = formulario.elements[i].type; nombreCampo = formulario.elements[i].id; classCampo = formulario.elements[i].className; // PARA EL CASO DE UNA TABLA PQ TIENE UN CHECK Q LA IDENTIFICA if ( (prefijo== 'check') && (tipoCampo == 'checkbox') && (formulario.elements[i].checked) && (nombreCampo != 'seleccionarTodo') ) { // Las filas chequeadas se marcarán como modificadas idFila = valorId.split('check_')[1]; fila = eval('document.getElementById("'+idFila+'")'); // Campo oculto con el estado d la fila q miraremos que no sea un modificar estado = eval('formulario.est_'+idFila+'.value'); if (estado == "nada") { eval('formulario.est_'+idFila+'.value="borrada"'); //Se deschequea y y se desactiva el campo checked formulario.elements[i].checked = false; formulario.elements[i].disabled = true; // Estilo de la fila classCampo = eval('document.getElementById("'+idFila+'").className'); vClassCampo = classCampo.split(" "); fila.className = classCampo.replace(vClassCampo[0],"fila_borrada"); fila.className = "fila_borrada"; // Oculto con la acción eval('formulario.'+accionActivaP+'.value="borrar"'); } } // if checkbox idFilaCampo = nombreCampo.split('___')[2]; // Para el resto de campos que pueden estar dentro d una tabla estado = ''; if (idFilaCampo) estado = eval('formulario.est_'+idFilaCampo+'.value'); if ( ( (tipoCampo != 'hidden') && (estado == 'borrada') && (prefijo != 'check') && (nombreCampo != 'seleccionarTodo') && ((tipoCampo == 'text') || (tipoCampo == 'checkbox') || (tipoCampo == 'radio') || (tipoCampo == 'select-one')) ) && ((idFilaCampo == idFila) && (valorId.split('___')[0] != 'ant')) ) { classCampo = eval('document.getElementById("'+valorId+'").className'); vClassCampo = classCampo.split(" "); nuevoClass = "tablaBorrar"; if (vClassCampo.length > 2) nuevoClass = nuevoClass + vClassCampo[2]; formulario.elements[i].className = nuevoClass; }// if } // for i marcaModificado = document.getElementById(this.idPanel+'_imgModificado'); if (marcaModificado != null) { marcaModificado.style.display="inline"; capaMenuFalso = document.getElementById('capa_menuFalso'); capaMenuReal = document.getElementById('capa_menuReal'); capaMenuFalso.style.display="inline"; capaMenuReal.style.display="none"; ocultoPerCerrarApli=document.getElementById('permitirCerrarAplicacion'); ocultoPerCerrarApli.value='no'; } if (eval(this.idPanel+'_paginacion')) { paginador = eval(this.idPanel+'_paginacion'); //Se marca la página como modificada... paginador.paginasModificadas[parseInt(this.getPaginaActiva(),10)] = true; } } ); objBTTEliminar.method('eliminarFicha', function () { if (this.habilitado == false) return; //Activamos los botones inferiores!! this.activarGC(); formulario = this.getForm(); var capas = formulario.getElementsByTagName("DIV"); var pagina = null; var soloLectura = true; var numCapas = capas.length; accionActivaP = 'accionActivaP_'+formulario.id; if (this.esPanelMD()) // Si es maestro o Detalle { if ((this.idPanel=='edi') || (this.idPanel == 'lis')) //Soy el panel maestro { // Deshabilitar mis hermanos if (this.idPanel == 'edi') //Soy el panel edi y soy un maestro this.deshabilitarHermanos('insertar,eliminar,modificar',','); } this.deshabilitarMD(); //Deshabilito botones del palnel complementario } for(i=0;i 0) campoDestino.options[campoDestino.options.selectedIndex] = null; for(i=0;i