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

Revision 2732, 3.3 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Removendo procedimento para manipulação de interface do local inapropriado.

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        var _divAppboxHeader = null;
13        var _divAppbox = null;
14
15        var _loading = new Image( );
16
17        function _go( )
18        {
19                _xconnector.go.apply( _xconnector, arguments );
20        }
21
22        function _lang( )
23        {
24                if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) )
25                        return false;
26
27                var module = arguments[ 0 ];
28                var lang = document.getElementsByTagName( 'html' ).item( 0 ).getAttribute( 'xml:lang' );
29
30                _xconnector.go( {
31                        'access' : 'phpgwapi.expressolivre.lang&lang=' + lang + '&module=' + module,
32                        'cache' : true,
33                        'handler' : function( data )
34                        {
35                                data = data.JSON( );
36                                for ( var key in data )
37                                        window.array_lang[ key ] = _language[ key ] = data[ key ];
38                        }
39                } );
40        }
41
42        function _link( )
43        {
44                _xlink.click.apply( _xlink, arguments );
45        }
46
47        function _path( )
48        {
49                return window.location.protocol + "//" + window.location.host + _configuration.url;
50        }
51
52        function _template( )
53        {
54                return _configuration.template;
55        }
56
57        function _theme( )
58        {
59                return _configuration.theme;
60        }
61
62        function _translate( )
63        {
64                if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) )
65                        return false;
66
67                var _phrase = arguments[ 0 ];
68
69                if ( _language[ _phrase.toLowerCase( ) ] )
70                        return _language[ _phrase.toLowerCase( ) ];
71                else
72                        return _phrase + '*';
73        }
74
75        function _ExpressoLivre( )
76        {
77                return ( new function( )
78                {
79                        this.go = _go;
80                        this.lang = _lang;
81                        this.link = _link;
82                        this.path = _path;
83                        this.theme = _theme;
84                        this.template = _template;
85                        this.translate = _translate;
86                } );
87        }
88
89        window.ExpressoLivre = _ExpressoLivre( );
90
91        _xlink = new XLink( _path( ) );
92        _xlink.handler( {
93                        "before" : function( )
94                        {
95                                if ( _divAppboxHeader )
96                                        _divAppboxHeader.innerHTML = '';
97
98                                if ( _divAppbox )
99                                {
100                                        var _center = document.createElement( 'center' );
101                                        _center.appendChild( _loading );
102
103                                        _divAppbox.innerHTML = '';
104                                        _divAppbox.appendChild( _center );
105                                }
106                        },
107                        "after" : function( )
108                        {
109                                if ( _divAppbox )
110                                        _divAppbox.innerHTML = '';
111
112                                while ( arguments[ 0 ].hasChildNodes( ) )
113                                        _divAppbox.appendChild( arguments[ 0 ].firstChild );
114                        }
115        } );
116
117        _xconnector = new XConnector( {
118                "path" : ExpressoLivre.path( ),
119                "controller" : "?menuaction="
120        } );
121
122        _loading.src = _path( ) + 'phpgwapi/templates/' + _template( ) + '/images/loading.gif';
123
124        XEvents.add( window, 'onload', function( )
125        {
126                _divAppboxHeader = document.getElementById( 'divAppboxHeader' );
127                _divAppboxHeader.innerHTML = '';
128
129                _divAppbox = document.getElementById( 'divAppbox' );
130                _divAppbox.innerHTML = '';
131
132                document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll';
133
134                var _scripts = document.getElementsByTagName( 'head' ).item( 0 ).getElementsByTagName( 'script' );
135                var _loaded = [ ];
136
137                for ( var i = 0; i < _scripts.length; i++ )
138                        if ( _scripts.item( i ).getAttribute( 'src' ) != null )
139                                _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr(
140                                        _path.length - 1,
141                                        _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path.length + 1
142                                );
143
144                new XScript( _loaded );
145
146                var _links = document.getElementsByTagName( 'a' );
147                for ( var i = 0; i < _links.length; i++ )
148                        _xlink.intercept( _links.item( i ) );
149        } );
150} )( );
Note: See TracBrowser for help on using the repository browser.