Changeset 2874
- Timestamp:
- 05/27/10 15:57:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/js/expressolivre/expressolivre.js
r2802 r2874 1 //****c* ExpressoLivreAPI/ExpressoLivre 2 // NAME 3 // ExpressoLivre 4 // 5 // DESCRIPTION 6 // Composto pelas classes utilizadas no ExpressoLivre 7 // 8 // AUTHOR 9 // Rodrigo Souza dos Santos 10 // |html <br /><a href="mailto:%72%6f%64%72%69%67%6f%2e%73%6f%75%7a%61%40%63%65%6c%65%70%61%72%2e%70%72%2e%67%6f%76%2e%62%72">rodrigo.souza@celepar.pr.gov.br</a> 11 // |html <br /><a href="mailto:%72%6f%64%72%69%67%6f%73%6f%75%7a%61%64%6f%73%73%61%6e%74%6f%73%40%67%6d%61%69%6c%2e%63%6f%6d">rodrigosouzadossantos@gmail.com</a> 12 // 13 // NOTES 14 // A composição possui instâncias configuradas de forma a atender a maioria 15 // dos casos independente do módulo. 16 // 17 //****** 18 // You can use this space for remarks that should not be included 19 // in the documentation. 20 // 1 21 ( function( ) 2 22 { … … 14 34 15 35 var _loading = new Image( ); 36 37 var _events_registred = { 38 "onload" : null, 39 "onunload" : null 40 }; 41 42 function _events( ) 43 { 44 return ( new function( ) 45 { 46 //****m* ExpressoLivreAPI/ExpressoLivre/events/config 47 // NAME 48 // config 49 // 50 // DESCRIPTION 51 // Atribui uma ação a um evento em um objeto 52 // 53 // SYNOPSIS 54 // config( Object, String, Function ) 55 // 56 // INPUTS 57 // 58 // EXAMPLE 59 // function myHandler( ) 60 // { 61 // /*do something*/ 62 // } 63 // 64 // ExpressoLivre.config( node, "onclick", myHandler ); 65 // 66 // ExpressoLivre.config( node, "onclick", function( ) 67 // { 68 // /*do something*/ 69 // } ); 70 // 71 //****** 72 this.config = XEvents.add; 73 this.fire = ( new function( ) 74 { 75 this.onload = function( ) 76 { 77 if ( _events_registred.onload ) 78 { 79 _events_registred.onload( ); 80 _events_registred.onload = null; 81 } 82 }; 83 this.onunload = function( ) 84 { 85 if ( _events_registred.onunload ) 86 { 87 _events_registred.onunload( ); 88 _events_registred.onunload = null; 89 } 90 }; 91 } ); 92 this.onload = function( ) 93 { 94 if ( arguments.length && arguments[ 0 ] == null ) 95 return false; 96 97 if ( arguments[ 0 ].constructor == Boolean && arguments[ 0 ] == false ) 98 { 99 _events_registred.onload = null; 100 return true; 101 } 102 103 if ( arguments[ 0 ].constructor == Function ) 104 { 105 _events_registred.onload = arguments[ 0 ]; 106 return true; 107 } 108 109 return false; 110 }; 111 this.onunload = function( ) 112 { 113 if ( arguments.length && arguments[ 0 ] == null ) 114 return false; 115 116 if ( arguments[ 0 ].constructor == Boolean && arguments[ 0 ] == false ) 117 { 118 _events_registred.onunload = null; 119 return true; 120 } 121 122 if ( arguments[ 0 ].constructor == Function ) 123 { 124 _events_registred.onunload = arguments[ 0 ]; 125 return true; 126 } 127 128 return false; 129 }; 130 } ); 131 } 16 132 17 133 function _form( ) … … 64 180 function _path( ) 65 181 { 66 return window.location.protocol + "//" + window.location.host +_configuration.url;182 return _configuration.url; 67 183 } 68 184 … … 85 201 86 202 if ( _language[ _phrase.toLowerCase( ) ] ) 87 return_language[ _phrase.toLowerCase( ) ];203 _phrase = _language[ _phrase.toLowerCase( ) ]; 88 204 else 89 return _phrase + '*'; 205 _phrase += '*'; 206 207 if ( arguments.length > 1 ) 208 for ( var j = 1; j < arguments.length; j++ ) 209 if ( arguments[ j ] && arguments[ j ].constructor == String ) 210 _phrase = _phrase.replace( "%" + j, arguments[ j ] ); 211 212 return _phrase; 90 213 } 91 214 92 215 function _wait( ) 93 216 { 217 _ExpressoLivre.events.fire.onunload( ); 218 94 219 if ( _divAppboxHeader ) 95 220 _divAppboxHeader.innerHTML = ''; … … 105 230 } 106 231 107 function _ExpressoLivre( ) 108 { 109 return ( new function( ) 110 { 111 this.form = _form; 112 this.go = _go; 113 this.lang = _lang; 114 this.link = _link; 115 this.path = _path; 116 this.theme = _theme; 117 this.template = _template; 118 this.translate = _translate; 119 } ); 120 } 121 122 window.ExpressoLivre = _ExpressoLivre( ); 232 var _ExpressoLivre = ( new function( ) 233 { 234 //****m* ExpressoLivreAPI/ExpressoLivre/events 235 // NAME 236 // events 237 // 238 // DESCRIPTION 239 // Realiza uma requisição ao servidor. 240 // 241 // SYNOPSIS 242 // events( Object ) 243 // 244 // INPUTS 245 // 246 // EXAMPLE 247 // 248 //****** 249 this.events = _events( ); 250 251 //****m* ExpressoLivreAPI/ExpressoLivre/form 252 // NAME 253 // form 254 // 255 // DESCRIPTION 256 // Processa e envia um formulário, utilizando a URL do atributo "action". 257 // 258 // SYNOPSIS 259 // form( Form ) 260 // 261 // INPUTS 262 // Form : referencia ao formulário a ser enviado. 263 // 264 // EXAMPLE 265 // <form action="/url/to/action" onsubmit="ExpressoLivre.form( this );"> 266 // 267 // ExpressoLivre.form( document.forms[ 0 ] ); 268 // 269 // NOTES 270 // TODO: campo do tipo file não é tratado 271 // 272 //****** 273 this.form = _form; 274 275 //****m* ExpressoLivreAPI/ExpressoLivre/go 276 // NAME 277 // go 278 // 279 // DESCRIPTION 280 // Realiza uma requisição ao servidor. 281 // 282 // SYNOPSIS 283 // go( Object ) 284 // 285 // INPUTS 286 // { 287 // "access" : String, 288 // "handler" : Function, 289 // [ "params" : String ] 290 // } 291 // 292 // EXAMPLE 293 // function myHandler( ) 294 // { 295 // /*do something*/ 296 // } 297 // 298 // ExpressoLivre.go( { 299 // "access" : "module.class.method", 300 // "handler" : myHandler 301 // } ); 302 // 303 // ExpressoLivre.go( { 304 // "access" : "module.class.method", 305 // "handler" : function 306 // { 307 // /*do something*/ 308 // } 309 // } ); 310 // 311 //****** 312 this.go = _go; 313 314 //****m* ExpressoLivreAPI/ExpressoLivre/lang 315 // NAME 316 // lang 317 // 318 // DESCRIPTION 319 // Carrega a tradução para o módulo. 320 // 321 // SYNOPSIS 322 // lang( String ) 323 // 324 // INPUTS 325 // String : nome do módulo 326 // 327 // EXAMPLE 328 // ExpressoLivre.lang( 'expressoAdmin1_2' ); 329 // 330 // ExpressoLivre.lang( 'expressoMail1_2' ); 331 // 332 // ExpressoLivre.lang( 'filemager' ); 333 // 334 //****** 335 this.lang = _lang; 336 337 //****m* ExpressoLivreAPI/ExpressoLivre/link 338 // NAME 339 // link 340 // 341 // DESCRIPTION 342 // Realiza uma requisição ao servidor, trata o resultado interceptando os 343 // links existentes e carrega os javascripts externos uma única vez. 344 // 345 // SYNOPSIS 346 // link( String link, [[Boolean cache], [String post]] ) 347 // 348 // INPUTS 349 // String link : URL da requisição a ser realizada 350 // Boolean cache : 'true' para manter cache do resultado da requisição 351 // String post : query string que será enviada ao servidor 352 // 353 // EXAMPLE 354 // ExpressoLivre.link( ); 355 // 356 //****** 357 this.link = _link; 358 359 //****m* ExpressoLivreAPI/ExpressoLivre/path 360 // NAME 361 // path 362 // 363 // DESCRIPTION 364 // Retorna a URL base do servidor ExpressoLivre. 365 // 366 // SYNOPSIS 367 // String path( ) 368 // 369 // RESULT 370 // FQDN do servidor concatenado com o path do ExpressoLivre. 371 // 372 // EXAMPLE 373 // ExpressoLivre.path( ); 374 // 375 //****** 376 this.path = _path; 377 378 //****m* ExpressoLivreAPI/ExpressoLivre/theme 379 // NAME 380 // theme 381 // 382 // DESCRIPTION 383 // Retorna o tema que corrente do usuário. 384 // 385 // SYNOPSIS 386 // String theme( ) 387 // 388 // RESULT 389 // Nome do tema. 390 // 391 // EXAMPLE 392 // ExpressoLivre.theme( ); 393 // 394 //****** 395 this.theme = _theme; 396 397 //****m* ExpressoLivreAPI/ExpressoLivre/template 398 // NAME 399 // template 400 // 401 // DESCRIPTION 402 // Retorna o template que corrente do usuário. 403 // 404 // SYNOPSIS 405 // String template( ) 406 // 407 // RESULT 408 // Nome do template. 409 // 410 // EXAMPLE 411 // ExpressoLivre.template( ); 412 // 413 //****** 414 this.template = _template; 415 416 //****m* ExpressoLivreAPI/ExpressoLivre/translate 417 // NAME 418 // translate 419 // 420 // DESCRIPTION 421 // Realiza a tradução para o idioma corrente. 422 // 423 // SYNOPSIS 424 // String template( String phrase[, String ...] ) 425 // 426 // INPUTS 427 // String : frase a ser traduzida 428 // 429 // RESULT 430 // Frase traduzida ou, em caso de não haver a tradução, a frase com um 431 // asterisco concatenado ao final. 432 // 433 // EXAMPLE 434 // ExpressoLivre.translate( 'A phrase to translate' ); 435 // 436 //****** 437 this.translate = _translate; 438 } ); 439 window.ExpressoLivre = _ExpressoLivre; 123 440 124 441 _xlink = new XLink( _path( ) ); 125 442 _xlink.handler( { 443 "data" : function( _pData ) 444 { 445 return ( _pData + '<script>ExpressoLivre.events.fire.onload( );</script>' ); 446 }, 126 447 "before" : _wait, 127 448 "after" : function( ) … … 136 457 137 458 _xconnector = new XConnector( { 138 "path" : ExpressoLivre.path( ),459 "path" : _path( ), 139 460 "controller" : "?menuaction=" 140 461 } ); … … 160 481 if ( _scripts.item( i ).getAttribute( 'src' ) != null ) 161 482 _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr( 162 _path .length - 1,163 _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path .length + 1483 _path( ).length - 1, 484 _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path( ).length + 1 164 485 ); 165 486
Note: See TracChangeset
for help on using the changeset viewer.