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 _form( ) |
---|
18 | { |
---|
19 | if ( ! arguments.length ) |
---|
20 | return false; |
---|
21 | |
---|
22 | var _handler = null; |
---|
23 | |
---|
24 | if ( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Function ) |
---|
25 | _handler = arguments[ 1 ]; |
---|
26 | else |
---|
27 | _handler = _xlink.manipulator; |
---|
28 | |
---|
29 | _wait( ); |
---|
30 | |
---|
31 | return XForm( arguments[ 0 ], _handler ); |
---|
32 | } |
---|
33 | |
---|
34 | function _go( ) |
---|
35 | { |
---|
36 | _xconnector.go.apply( _xconnector, arguments ); |
---|
37 | } |
---|
38 | |
---|
39 | function _lang( ) |
---|
40 | { |
---|
41 | if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) ) |
---|
42 | return false; |
---|
43 | |
---|
44 | var module = arguments[ 0 ]; |
---|
45 | var lang = document.getElementsByTagName( 'html' ).item( 0 ).getAttribute( 'xml:lang' ); |
---|
46 | |
---|
47 | _xconnector.go( { |
---|
48 | 'access' : 'phpgwapi.expressolivre.lang&lang=' + lang + '&module=' + module, |
---|
49 | 'cache' : true, |
---|
50 | 'handler' : function( data ) |
---|
51 | { |
---|
52 | data = data.JSON( ); |
---|
53 | for ( var key in data ) |
---|
54 | window.array_lang[ key ] = _language[ key ] = data[ key ]; |
---|
55 | } |
---|
56 | } ); |
---|
57 | } |
---|
58 | |
---|
59 | function _link( ) |
---|
60 | { |
---|
61 | _xlink.click.apply( _xlink, arguments ); |
---|
62 | } |
---|
63 | |
---|
64 | function _path( ) |
---|
65 | { |
---|
66 | return window.location.protocol + "//" + window.location.host + _configuration.url; |
---|
67 | } |
---|
68 | |
---|
69 | function _template( ) |
---|
70 | { |
---|
71 | return _configuration.template; |
---|
72 | } |
---|
73 | |
---|
74 | function _theme( ) |
---|
75 | { |
---|
76 | return _configuration.theme; |
---|
77 | } |
---|
78 | |
---|
79 | function _translate( ) |
---|
80 | { |
---|
81 | if ( ! ( arguments.length && arguments[ 0 ].constructor == String ) ) |
---|
82 | return false; |
---|
83 | |
---|
84 | var _phrase = arguments[ 0 ]; |
---|
85 | |
---|
86 | if ( _language[ _phrase.toLowerCase( ) ] ) |
---|
87 | return _language[ _phrase.toLowerCase( ) ]; |
---|
88 | else |
---|
89 | return _phrase + '*'; |
---|
90 | } |
---|
91 | |
---|
92 | function _wait( ) |
---|
93 | { |
---|
94 | if ( _divAppboxHeader ) |
---|
95 | _divAppboxHeader.innerHTML = ''; |
---|
96 | |
---|
97 | if ( _divAppbox ) |
---|
98 | { |
---|
99 | var _center = document.createElement( 'center' ); |
---|
100 | _center.appendChild( _loading ); |
---|
101 | |
---|
102 | _divAppbox.innerHTML = ''; |
---|
103 | _divAppbox.appendChild( _center ); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
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( ); |
---|
123 | |
---|
124 | _xlink = new XLink( _path( ) ); |
---|
125 | _xlink.handler( { |
---|
126 | "before" : _wait, |
---|
127 | "after" : function( ) |
---|
128 | { |
---|
129 | if ( _divAppbox ) |
---|
130 | _divAppbox.innerHTML = ''; |
---|
131 | |
---|
132 | while ( arguments[ 0 ].hasChildNodes( ) ) |
---|
133 | _divAppbox.appendChild( arguments[ 0 ].firstChild ); |
---|
134 | } |
---|
135 | } ); |
---|
136 | |
---|
137 | _xconnector = new XConnector( { |
---|
138 | "path" : ExpressoLivre.path( ), |
---|
139 | "controller" : "?menuaction=" |
---|
140 | } ); |
---|
141 | |
---|
142 | _loading.src = _path( ) + 'phpgwapi/templates/' + _template( ) + '/images/loading.gif'; |
---|
143 | |
---|
144 | XEvents.add( window, 'onload', function( ) |
---|
145 | { |
---|
146 | _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); |
---|
147 | _divAppboxHeader.innerHTML = ''; |
---|
148 | |
---|
149 | _divAppbox = document.getElementById( 'divAppbox' ); |
---|
150 | _divAppbox.innerHTML = ''; |
---|
151 | |
---|
152 | document.title = 'ExpressoLivre'; |
---|
153 | |
---|
154 | document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; |
---|
155 | |
---|
156 | var _scripts = document.getElementsByTagName( 'head' ).item( 0 ).getElementsByTagName( 'script' ); |
---|
157 | var _loaded = [ ]; |
---|
158 | |
---|
159 | for ( var i = 0; i < _scripts.length; i++ ) |
---|
160 | if ( _scripts.item( i ).getAttribute( 'src' ) != null ) |
---|
161 | _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr( |
---|
162 | _path.length - 1, |
---|
163 | _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - _path.length + 1 |
---|
164 | ); |
---|
165 | |
---|
166 | new XScript( _loaded ); |
---|
167 | |
---|
168 | var _links = document.getElementsByTagName( 'a' ); |
---|
169 | for ( var i = 0; i < _links.length; i++ ) |
---|
170 | _xlink.intercept( _links.item( i ) ); |
---|
171 | } ); |
---|
172 | } )( ); |
---|