//****c* ExpressoLivreAPI/ExpressoLivre // NAME // ExpressoLivre // // DESCRIPTION // Composto pelas classes utilizadas no ExpressoLivre // // AUTHOR // Rodrigo Souza dos Santos // |html
rodrigo.souza@celepar.pr.gov.br // |html
rodrigosouzadossantos@gmail.com // // NOTES // A composição possui instâncias configuradas de forma a atender a maioria // dos casos independente do módulo. // //****** // You can use this space for remarks that should not be included // in the documentation. // ( function( ) { var _configuration = ExpressoLivre( ).JSON( ); var _xconnector = null; var _xlink = null; window.array_lang = [ ]; var _language = [ ]; var _divAppboxHeader = null; var _divAppbox = null; var _loading = new Image( ); var _events_registred = { "onload" : null, "onunload" : null }; function _events( ) { return ( new function( ) { //****m* ExpressoLivreAPI/ExpressoLivre/events/config // NAME // config // // DESCRIPTION // Atribui uma ação a um evento em um objeto // // SYNOPSIS // config( Object, String, Function ) // // INPUTS // // EXAMPLE // function myHandler( ) // { // /*do something*/ // } // // ExpressoLivre.config( node, "onclick", myHandler ); // // ExpressoLivre.config( node, "onclick", function( ) // { // /*do something*/ // } ); // //****** this.config = XEvents.add; this.fire = ( new function( ) { this.onload = function( ) { if ( _events_registred.onload ) { _events_registred.onload( ); _events_registred.onload = null; } }; this.onunload = function( ) { if ( _events_registred.onunload ) { _events_registred.onunload( ); _events_registred.onunload = null; } }; } ); this.onload = function( ) { if ( arguments.length && arguments[ 0 ] == null ) return false; if ( arguments[ 0 ].constructor == Boolean && arguments[ 0 ] == false ) { _events_registred.onload = null; return true; } if ( arguments[ 0 ].constructor == Function ) { _events_registred.onload = arguments[ 0 ]; return true; } return false; }; this.onunload = function( ) { if ( arguments.length && arguments[ 0 ] == null ) return false; if ( arguments[ 0 ].constructor == Boolean && arguments[ 0 ] == false ) { _events_registred.onunload = null; return true; } if ( arguments[ 0 ].constructor == Function ) { _events_registred.onunload = arguments[ 0 ]; return true; } return false; }; } ); } function _form( ) { if ( ! arguments.length ) return false; var _handler = null; if ( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Function ) _handler = arguments[ 1 ]; else _handler = _xlink.manipulator; _wait( ); return XForm( arguments[ 0 ], _handler ); } function _go( ) { _xconnector.go.apply( _xconnector, arguments ); } function _lang( ) { if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) ) return false; var module = arguments[ 0 ]; var lang = document.getElementsByTagName( 'html' ).item( 0 ).getAttribute( 'xml:lang' ); _xconnector.go( { 'access' : 'phpgwapi.expressolivre.lang&lang=' + lang + '&module=' + module, 'cache' : true, 'handler' : function( data ) { data = data.JSON( ); for ( var key in data ) window.array_lang[ key ] = _language[ key ] = data[ key ]; } } ); } function _link( ) { _xlink.click.apply( _xlink, arguments ); } function _path( ) { return _configuration.url; } function _template( ) { return _configuration.template; } function _theme( ) { return _configuration.theme; } function _translate( ) { if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) ) return false; var _phrase = arguments[ 0 ]; if ( _language[ _phrase.toLowerCase( ) ] ) _phrase = _language[ _phrase.toLowerCase( ) ]; else _phrase += '*'; if ( arguments.length > 1 ) for ( var j = 1; j < ( arguments.length ); j++ ) if ( arguments[ j ] && ( arguments[ j ].constructor == String || arguments[ j ].constructor == Number)) _phrase = _phrase.replace( "%" + j, arguments[ j ] ); return _phrase; } function _wait( ) { _ExpressoLivre.events.fire.onunload( ); if ( _divAppboxHeader ) _divAppboxHeader.innerHTML = ''; if ( _divAppbox ) { var _center = document.createElement( 'center' ); _center.appendChild( _loading ); _divAppbox.innerHTML = ''; _divAppbox.appendChild( _center ); } } var _ExpressoLivre = ( new function( ) { //****m* ExpressoLivreAPI/ExpressoLivre/events // NAME // events // // DESCRIPTION // Realiza uma requisição ao servidor. // // SYNOPSIS // events( Object ) // // INPUTS // // EXAMPLE // //****** this.events = _events( ); //****m* ExpressoLivreAPI/ExpressoLivre/form // NAME // form // // DESCRIPTION // Processa e envia um formulário, utilizando a URL do atributo "action". // // SYNOPSIS // form( Form ) // // INPUTS // Form : referencia ao formulário a ser enviado. // // EXAMPLE //
// // ExpressoLivre.form( document.forms[ 0 ] ); // // NOTES // TODO: campo do tipo file não é tratado // //****** this.form = _form; //****m* ExpressoLivreAPI/ExpressoLivre/go // NAME // go // // DESCRIPTION // Realiza uma requisição ao servidor. // // SYNOPSIS // go( Object ) // // INPUTS // { // "access" : String, // "handler" : Function, // [ "params" : String ] // } // // EXAMPLE // function myHandler( ) // { // /*do something*/ // } // // ExpressoLivre.go( { // "access" : "module.class.method", // "handler" : myHandler // } ); // // ExpressoLivre.go( { // "access" : "module.class.method", // "handler" : function // { // /*do something*/ // } // } ); // //****** this.go = _go; //****m* ExpressoLivreAPI/ExpressoLivre/lang // NAME // lang // // DESCRIPTION // Carrega a tradução para o módulo. // // SYNOPSIS // lang( String ) // // INPUTS // String : nome do módulo // // EXAMPLE // ExpressoLivre.lang( 'expressoAdmin1_2' ); // // ExpressoLivre.lang( 'expressoMail1_2' ); // // ExpressoLivre.lang( 'filemager' ); // //****** this.lang = _lang; //****m* ExpressoLivreAPI/ExpressoLivre/link // NAME // link // // DESCRIPTION // Realiza uma requisição ao servidor, trata o resultado interceptando os // links existentes e carrega os javascripts externos uma única vez. // // SYNOPSIS // link( String link, [[Boolean cache], [String post]] ) // // INPUTS // String link : URL da requisição a ser realizada // Boolean cache : 'true' para manter cache do resultado da requisição // String post : query string que será enviada ao servidor // // EXAMPLE // ExpressoLivre.link( ); // //****** this.link = _link; //****m* ExpressoLivreAPI/ExpressoLivre/path // NAME // path // // DESCRIPTION // Retorna a URL base do servidor ExpressoLivre. // // SYNOPSIS // String path( ) // // RESULT // FQDN do servidor concatenado com o path do ExpressoLivre. // // EXAMPLE // ExpressoLivre.path( ); // //****** this.path = _path; //****m* ExpressoLivreAPI/ExpressoLivre/theme // NAME // theme // // DESCRIPTION // Retorna o tema que corrente do usuário. // // SYNOPSIS // String theme( ) // // RESULT // Nome do tema. // // EXAMPLE // ExpressoLivre.theme( ); // //****** this.theme = _theme; //****m* ExpressoLivreAPI/ExpressoLivre/template // NAME // template // // DESCRIPTION // Retorna o template que corrente do usuário. // // SYNOPSIS // String template( ) // // RESULT // Nome do template. // // EXAMPLE // ExpressoLivre.template( ); // //****** this.template = _template; //****m* ExpressoLivreAPI/ExpressoLivre/translate // NAME // translate // // DESCRIPTION // Realiza a tradução para o idioma corrente. // // SYNOPSIS // String template( String phrase[, String ...] ) // // INPUTS // String : frase a ser traduzida // // RESULT // Frase traduzida ou, em caso de não haver a tradução, a frase com um // asterisco concatenado ao final. // // EXAMPLE // ExpressoLivre.translate( 'A phrase to translate' ); // //****** this.translate = _translate; } ); window.ExpressoLivre = _ExpressoLivre; _xlink = new XLink( _path( ) ); _xlink.handler( { "data" : function( _pData ) { return ( _pData + '' ); }, "before" : _wait, "after" : function( ) { if ( _divAppbox ) _divAppbox.innerHTML = ''; while ( arguments[ 0 ].hasChildNodes( ) ) _divAppbox.appendChild( arguments[ 0 ].firstChild ); } } ); _xconnector = new XConnector( { "path" : _path( ), "controller" : "?menuaction=" } ); _loading.src = _path( ) + 'phpgwapi/templates/' + _template( ) + '/images/loading.gif'; XEvents.add( window, 'onload', function( ) { _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); _divAppboxHeader.innerHTML = ''; _divAppbox = document.getElementById( 'divAppbox' ); _divAppbox.innerHTML = ''; document.title = 'ExpressoLivre'; document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; var _scripts = document.getElementsByTagName( 'head' ).item( 0 ).getElementsByTagName( 'script' ); var _loaded = [ ]; for ( var i = 0; i < _scripts.length; i++ ) if ( _scripts.item( i ).getAttribute( 'src' ) != null ) _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr( _path( ).length - 1, _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path( ).length + 1 ); new XScript( _loaded ); var _links = document.getElementsByTagName( 'a' ); for ( var i = 0; i < _links.length; i++ ) _xlink.intercept( _links.item( i ) ); } ); } )( );