source: trunk/phpgwapi/js/expressolivre/expressolivre.js @ 2712

Revision 2712, 2.4 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Adaptando todo o expressoAdmin1_2 para não realizar reload.

Line 
1( function( )
2{
3        var _configuration = ExpressoLivre( ).JSON( );
4
5        var _xconnector = null;
6        var _xlink = null;
7
8        window.array_lang = [ ];
9
10        var _language = [ ]
11
12        function _go( )
13        {
14                _xconnector.go.apply( _xconnector, arguments );
15        }
16
17        function _lang( )
18        {
19                if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) )
20                        return false;
21
22                var module = arguments[ 0 ];
23                var lang = document.getElementsByTagName( 'html' ).item( 0 ).getAttribute( 'xml:lang' );
24
25                _xconnector.go( {
26                        'access' : 'phpgwapi.expressolivre.lang&lang=' + lang + '&module=' + module,
27                        'handler' : function( data )
28                        {
29                                data = data.JSON( );
30                                for ( var key in data )
31                                        window.array_lang[ key ] = _language[ key ] = data[ key ];
32                        }
33                } );
34        }
35
36        function _link( )
37        {
38                _xlink.click.apply( _xlink, arguments );
39        }
40
41        function _path( )
42        {
43                return window.location.protocol + "//" + window.location.host + _configuration.url;
44        }
45
46        function _template( )
47        {
48                return _configuration.template;
49        }
50
51        function _theme( )
52        {
53                return _configuration.theme;
54        }
55
56        function _translate( )
57        {
58                if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) )
59                        return false;
60
61                var _phrase = arguments[ 0 ];
62
63                if ( _language[ _phrase.toLowerCase( ) ] )
64                        return _language[ _phrase.toLowerCase( ) ];
65                else
66                        return _phrase + '*';
67        }
68
69        function _ExpressoLivre( )
70        {
71                return ( new function( )
72                {
73                        this.go = _go;
74                        this.lang = _lang;
75                        this.link = _link;
76                        this.path = _path;
77                        this.theme = _theme;
78                        this.template = _template;
79                        this.translate = _translate;
80                } );
81        }
82
83        window.ExpressoLivre = _ExpressoLivre( );
84
85        _xlink = new XLink( ExpressoLivre.path( ) );
86
87        _xconnector = new XConnector( {
88                "path" : ExpressoLivre.path( ),
89                "controller" : "?menuaction="
90        } );
91
92        XEvents.add( window, 'onload', function( )
93        {
94                document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll';
95
96                var _scripts = document.getElementsByTagName( 'head' ).item( 0 ).getElementsByTagName( 'script' );
97                var _loaded = [ ];
98
99                for ( var i = 0; i < _scripts.length; i++ )
100                        if ( _scripts.item( i ).getAttribute( 'src' ) != null )
101                                _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr(
102                                        _path.length - 1,
103                                        _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path.length + 1
104                                );
105
106                new XScript( _loaded );
107
108                var _links = document.getElementsByTagName( 'a' );
109                for ( var i = 0; i < _links.length; i++ )
110                        _xlink.intercept( _links.item( i ) );
111        } );
112} )( );
Note: See TracBrowser for help on using the repository browser.