include("lib.prototype"); include("lib.onload"); include("lib.css3hacks"); include("fitbank.util"); include("fitbank.logger"); include("fitbank.evento"); include("fitbank.escaneo"); include("fitbank.validar"); include("fitbank.ui.estatus"); include("fitbank.ui.ventana"); include("lib.jquery"); include("lib.jquerynoconflicts"); include("lib.datepicker.datepicker"); include("lib.shiftzoom.shiftzoom"); include("lib.simpledateformat"); include("lib.nprogress"); include("lib.fastclick"); try { include("fitbank.proc.clases"); include("fitbank.proc.mensajes"); include("fitbank.proc.parametros"); } catch (e) { addOnLoad(function() { include("fitbank.ui.ventana"); new Ventana({ titulo: "Prueba", contenido: "Error fatal al cargar los javascripts: " + e }).ver(); }); } include("fitbank.contexto"); include("fitbank.ui.barra"); include("fitbank.ui.informacion"); include("fitbank.ui.listaformularios"); include("fitbank.ui.menu"); include("fitbank.ui.notificaciones"); include("fitbank.ui.notificacionescomentarios"); include("fitbank.ui.teclas"); include("fitbank.ui.tooltips"); /** * Variable c - Usado en los formularios para acceder a elementos en el contexto * actual. FIXME: debe setearse antes de ejecutar calculos, js inicial, o * cualquier evento de los elementos. */ var c = null; /** * Namespace Entorno - Contiene funciones para manejar el entorno. */ var Entorno = { /** * @private */ activo: false, /** * @private */ init: function() { if (window.opener && window.opener.Entorno) { Entorno.ventanas = window.opener.Entorno.ventanas; } else { Entorno.ventanas = $H(); } Entorno.id = Math.random(); Entorno.ventanas.set(Entorno.id, window); Event.on(window, "unload", function() { Entorno.ventanas.unset(Entorno.id); }); Estatus.init("entorno-estatus-contenido"); ListaFormularios.init("entorno-lista-formularios"); Entorno.contexto = new Contexto("entorno-formulario"); c = Entorno.contexto; Barra.init("entorno-barra-botones"); Informacion.init.tryCatch(); //Por defecto desabilitar las notificaciones FitBank (query cada 60 segundos). if (Parametros['fitbank.notificaciones.ENABLED'] == "true") { Notificaciones.init.tryCatch(); } if (Parametros['fitbank.notificacionescomentarios.ENABLED'] == "true") { NotificacionesComentarios.init("entorno-barra"); } Menu.init.tryCatch(); Element.insert(document.body, new Element("iframe", { name: "entorno-iframe-ajax" }).hide()); }, /** * @private */ activar: function() { var pt = $("entorno-pt"); var tran = $("entorno-transaccion"); var reloj = $("entorno-reloj"); if (Entorno.activo) { pt && pt.activate(); return; } Entorno.activo = true; Teclas.init("entorno-teclas"); if (pt && tran) { Entorno._initPT(pt, tran); } if (reloj) { Entorno._initClock(reloj); } if (document.location.hash) { Entorno.contexto.cargar({ st: document.location.hash.split("/")[1] }); } else if (Parametros["fitbank.entorno.INITIAL"]) { Entorno.contexto.cargar({ st: Parametros["fitbank.entorno.INITIAL"] }); } else { pt && pt.activate(); } }, _initPT: function(pt, tran) { var enter = function(e) { e = $E(e); if (e.tecla == e.ENTER) { Entorno.contexto.cargar({ st: pt.value }); e.elemento.blur(); } }; var img = new Element("img", { className: "entono-pt-activar", src: "img/activar.png", alt: "activar", title: "activar" }); pt.insert( { after: img }); tran.show(); img.on("click", function() { Entorno.contexto.cargar({ st: pt.value }); }); pt.on("keypress", enter); pt.on("keyup", function(e) { e = $E(e); if (pt.value.length >= 2 && e.tecla != e.BACKSPACE) { var value = pt.value.replace(/[^\d]/g, ""); pt.value = value.substring(0, 2) + "-" + value.substring(2); } else if (pt.value.length == 2 && e.tecla == e.BACKSPACE) { pt.value = pt.value.substring(0, 1); } if (pt.value.length > 7) { pt.value = pt.value.substring(0, 7); } }); }, /** * Inicializa un reloj del sistema */ _initClock: function(elemento) { var now = new Date(); var nowString = now.getHours().toPaddedString(2) + ":" + now.getMinutes().toPaddedString(2) + ":" + now.getSeconds().toPaddedString(2); elemento.update(nowString); setInterval(function(){ var now = new Date(); var nowString = now.getHours().toPaddedString(2) + ":" + now.getMinutes().toPaddedString(2) + ":" + now.getSeconds().toPaddedString(2); elemento.update(nowString); }, 1000); }, /** * Determina si hay procesos activos y está bloqueado el estatus. */ bloqueado: function() { return !Estatus.activo(); }, /** * Función que se encarga de cerrar la sesión * * @param e Evento */ caducar: function(e) { if (Entorno.ventanas.size() > 1) { return; } new Ventana({ titulo: "Caducar", contenido: "Caducando la sesion, por favor espere..." }).ver(); Estatus.enviarLog(true); new Ajax.Request("proc/" + GeneralRequestTypes.CADUCAR, { asynchronous: false, onComplete: function(response) { Logger.log(response.responseText); } }); }, respuestaCaducar: function(e) { var res = e && e.responseJSON || e && e.mensajeUsuario || { mensajeUsuario: "La sesion web se ha perdido", stackTrace: "Su sesion web se ha perdido, posiblemente por" + " limpieza de la cache del explorador o" + " se ha perdido la conexion con el servidor." }; alert("Error:\n\n" + (res.mensajeUsuario || res.mensaje) + "\n\nStackTrace:\n\n" + res.stackTrace); caducar(); }, cambiarCursor: function(esperando) { if (esperando) { document.body.addClassName('bloqueado'); } else { document.body.removeClassName('bloqueado'); } } }; document.onhelp = function() { event.cancelBubble = true; event.returnValue = false; }; //Corrección temporal para el bug de chrome #45465 y #974: //Backspace hace que se vaya a la página anterior. document.observe('keydown', function (event) { var stop = false; if (event.keyCode === Event.KEY_BACKSPACE) { var d = Event.element(event); var tag = d.tagName && d.tagName.toUpperCase(); if (tag == 'BODY') { stop = true; } else { var type = d.type && d.type.toUpperCase(); if ((tag === 'INPUT' && (type === 'TEXT' || type === 'PASSWORD')) || tag === 'TEXTAREA') { stop = d.readOnly || d.disabled; } else { stop = true; } } } if (Parametros["fitbank.entorno.INITIAL"]) { var keyEvent = $E(event); if (keyEvent.esFuncion()) { stop = true; } } if (stop) { Event.stop(event); } }); document.observe('click', function (event) { var element = Event.element(event); if (element && element.tagName.toLowerCase() == "input" && !element.hasClassName('current-focus')) { $$(' .current-focus').invoke('removeClassName','current-focus'); element.addClassName('current-focus'); } }); addOnLoad(Entorno.init);