1 | ( function( ) |
---|
2 | { |
---|
3 | var _connector = new XConnector; |
---|
4 | var _container = null; |
---|
5 | var _divAppboxHeader = null; |
---|
6 | var _loading = new Image( ); |
---|
7 | _loading.src = URL_SERVER + '/phpgwapi/images/loading.gif'; |
---|
8 | |
---|
9 | function handler( pLink ) |
---|
10 | { |
---|
11 | var action = pLink.href; |
---|
12 | if ( action == '' ) |
---|
13 | return false; |
---|
14 | |
---|
15 | var a = ( action.indexOf( 'javascript:' ) === 0 ); |
---|
16 | a = ( a || ( action.indexOf( '#' ) === 0 ) ); |
---|
17 | a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) ); |
---|
18 | a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) ); |
---|
19 | |
---|
20 | if ( ! a ) |
---|
21 | pLink.onclick = function( ) |
---|
22 | { |
---|
23 | _divAppboxHeader.innerHTML = ''; |
---|
24 | |
---|
25 | _container.innerHTML = ''; |
---|
26 | _container.appendChild( _loading ); |
---|
27 | |
---|
28 | var _cacheit = ( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false ); |
---|
29 | |
---|
30 | var request = _connector.cache( _cacheit ).go( { |
---|
31 | 'access' : action, |
---|
32 | 'handler' : function( data ) |
---|
33 | { |
---|
34 | var el = document.createElement( 'div' ); |
---|
35 | el.innerHTML = data; |
---|
36 | |
---|
37 | var _links = el.getElementsByTagName( 'a' ); |
---|
38 | for ( var i = 0; i < _links.length; i++ ) |
---|
39 | handler( _links.item( i ) ); |
---|
40 | |
---|
41 | var _head = document.getElementsByTagName( 'head' ).item( 0 ); |
---|
42 | var _loaded = _head.getElementsByTagName( 'script' ); |
---|
43 | var _scripts = el.getElementsByTagName( 'script' ); |
---|
44 | var _new_scripts = [ ]; |
---|
45 | |
---|
46 | while ( _scripts.length ) |
---|
47 | _new_scripts[ _new_scripts.length ] = el.removeChild( _scripts.item( 0 ) ); |
---|
48 | |
---|
49 | _container.innerHTML = ''; |
---|
50 | while ( el.hasChildNodes( ) ) |
---|
51 | _container.appendChild( el.firstChild ); |
---|
52 | |
---|
53 | fix : for ( var i = 0; i < _new_scripts.length; i++ ) |
---|
54 | { |
---|
55 | var _script = _new_scripts[ i ]; |
---|
56 | if ( _script.getAttribute( 'src' ) == null ) |
---|
57 | { |
---|
58 | _container.appendChild( _script ); |
---|
59 | continue; |
---|
60 | } |
---|
61 | else |
---|
62 | { |
---|
63 | for ( var j = 0; j < _loaded.length; j++ ) |
---|
64 | if ( _script.getAttribute( 'src' ) === _loaded.item( j ).getAttribute( 'src' ) ) |
---|
65 | continue fix; |
---|
66 | |
---|
67 | _head.appendChild( _script ); |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | } ); |
---|
72 | return false; |
---|
73 | }; |
---|
74 | } |
---|
75 | |
---|
76 | XEvents.add( window, 'onload', function( ) |
---|
77 | { |
---|
78 | var _center = document.createElement( 'center' ); |
---|
79 | _center.appendChild( _loading ); |
---|
80 | |
---|
81 | _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); |
---|
82 | _divAppboxHeader.innerHTML = ''; |
---|
83 | |
---|
84 | _container = document.getElementById( 'divAppbox' ); |
---|
85 | _loading = _center; |
---|
86 | |
---|
87 | document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; |
---|
88 | |
---|
89 | var _links = document.getElementsByTagName( 'a' ); |
---|
90 | for ( var i = 0; i < _links.length; i++ ) |
---|
91 | handler( _links.item( i ) ); |
---|
92 | } ); |
---|
93 | } )( ); |
---|