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

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

Ticket #1058 - Corrigindo problema do caregamento do contactcenter.

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