Index: trunk/phpgwapi/js/tools/xlink.js
===================================================================
--- trunk/phpgwapi/js/tools/xlink.js	(revision 2729)
+++ trunk/phpgwapi/js/tools/xlink.js	(revision 2732)
@@ -1,128 +1,14 @@
 ( function( )
 {
-	var _path = null;
-	var _last_request = null;
-
-	var _connector = null;
+	var _connector = new XConnector;
 	var _script = new XScript;
-
-	var _container = null;
-	var _divAppboxHeader = null;
-
-	var _loading = new Image( );
-
-	function _click( _action, _cache )
-	{
-		if ( _action.indexOf( window.location.host ) < 0 )
-			_action = window.location.protocol + '//' + window.location.host + _action;
-
-		var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null;
-
-		if ( _post == null && _action == _last_request )
-			return false;
-
-		if ( _divAppboxHeader )
-			_divAppboxHeader.innerHTML = '';
-
-		if ( _container )
-		{
-			var _center = document.createElement( 'center' );
-			_center.appendChild( _loading );
-
-			_container.innerHTML = '';
-			_container.appendChild( _center );
-		}
-
-		_connector.go(
-		{
-			'access' : _action,
-			'cache' : _cache,
-			'handler' : _handler,
-			'post' : _post
-		} );
-
-		_last_request = _action;
-
-		window.location = '#' + (
-			( _action.indexOf( _path ) < 0 ) ?
-				_action : _action.substr( _action.indexOf( _path ) + URL_SERVER.length )
-		);
-	}
-
-	function _intercept( pLink )
-	{
-		var action = pLink.href;
-		if ( action == '' )
-			return false;
-
-		var a = ( action.indexOf( 'javascript:' ) === 0 );
-		a = ( a || ( action.indexOf( '#' ) === 0 ) );
-		a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) );
-		a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) );
-
-		if ( ! a )
-			pLink.onclick = function( )
-			{
-				var _cacheit = false;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false );
-
-				_click( action, _cacheit );
-
-				return false;
-			};
-	}
-
-	function _handler( data )
-	{
-		var js = data.match( /<script[^>]*>.*?<\/script>/g );
-		var _new_scripts = [ ];
-		if ( js )
-		{
-			var tag = /<script([^>]*src="(\S+)"[^>]*|[^>]*)>(.*?)<\/script>/;
-			for ( var i = 0; i < js.length; i++ )
-			{
-				var type = tag.exec( js[ i ] );
-				data = data.replace( type[ 0 ], '' );
-				_new_scripts[ _new_scripts.length ] = type;
-			}
-		}
-
-		var el = document.createElement( 'div' );
-		el.innerHTML = data;
-
-		var _links = el.getElementsByTagName( 'a' );
-		for ( var i = 0; i < _links.length; i++ )
-			_intercept( _links.item( i ) );
-
-		_container.innerHTML = '';
-		while ( el.hasChildNodes( ) )
-			_container.appendChild( el.firstChild );
-
-		for ( var i = 0; i < _new_scripts.length; i++ )
-		{
-			if ( _new_scripts[ i ][ 2 ] == undefined || _new_scripts[ i ][ 2 ].length == 0 )
-				_script.inline( _new_scripts[ i ][ 3 ] );
-			else
-			{
-				if ( _new_scripts[ i ][ 2 ].indexOf( window.location.host ) < 0 )
-					_new_scripts[ i ][ 2 ] = window.location.protocol + '//' + window.location.host + _new_scripts[ i ][ 2 ];
-
-				_script.external(
-					_new_scripts[ i ][ 2 ].substr(
-						_path.length - 1,
-						_new_scripts[ i ][ 2 ].length - _path.length + 1 - (
-							( _new_scripts[ i ][ 2 ].indexOf( '?' ) < 0 ) ?
-								0 : ( _new_scripts[ i ][ 2 ].length - _new_scripts[ i ][ 2 ].indexOf( '?' ) )
-						)
-					)
-				);
-			}
-		}
-
-		_script.load( );
-	}
 
 	function Link( )
 	{
-		_path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/';
+		var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/';
+		var _last_request = null;
+
+		var _before = null;
+		var _after = null;
 
 		if ( window.location.protocol + '//' + window.location.host + window.location.pathname != _path )
@@ -132,31 +18,138 @@
 			);
 
-		_loading.src = _path + 'phpgwapi/templates/'+template+'/images/loading.gif';
-		_connector = new XConnector;
+		function _click( _action, _cache )
+		{
+			if ( _action.indexOf( window.location.host ) < 0 )
+				_action = window.location.protocol + '//' + window.location.host + _action;
+
+			var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null;
+
+			if ( _post == null && _action == _last_request )
+				return false;
+
+			if ( _before )
+				_before( );
+
+			_connector.go(
+			{
+				'access' : _action,
+				'cache' : _cache,
+				'handler' : _handler,
+				'post' : _post
+			} );
+
+			_last_request = _action;
+
+			window.location = '#' + (
+				( _action.indexOf( _path ) < 0 ) ?
+					_action : _action.substr( _action.indexOf( _path ) + _path.length )
+			);
+		}
+
+		function _intercept( pLink )
+		{
+			var action = pLink.href;
+			if ( action == '' )
+				return false;
+
+			var a = ( action.indexOf( 'javascript:' ) === 0 );
+			a = ( a || ( action.indexOf( '#' ) === 0 ) );
+			a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) );
+			a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) );
+
+			if ( ! a )
+				pLink.onclick = function( )
+				{
+					var _cacheit = false;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false );
+
+					_click( action, _cacheit );
+
+					return false;
+				};
+		}
+
+		function _handler( data )
+		{
+			var js = data.match( /<script[^>]*>.*?<\/script>/gi );
+			if ( js )
+			{
+				var _tag = /<script([^>]*src="(\S+)"[^>]*|[^>]*)>(.*?)<\/script>/i;
+				for ( var i = 0; i < js.length; i++ )
+				{
+					var _type = _tag.exec( js[ i ] );
+					data = data.replace( _type[ 0 ], '' );
+
+					if ( _type[ 2 ] == undefined || _type[ 2 ].length == 0 )
+						_script.inline( _type[ 3 ] );
+					else
+					{
+						if ( _type[ 2 ].indexOf( window.location.host ) < 0 )
+							_type[ 2 ] = window.location.protocol + '//' + window.location.host + _type[ 2 ];
+
+						_script.external(
+							_type[ 2 ].substr(
+								_path.length - 1,
+								_type[ 2 ].length - _path.length + 1 - (
+									( _type[ 2 ].indexOf( '?' ) < 0 ) ?
+										0 : ( _type[ 2 ].length - _type[ 2 ].indexOf( '?' ) )
+								)
+							)
+						);
+					}
+				}
+			}
+
+			var el = document.createElement( 'div' );
+			el.innerHTML = data;
+
+			var _links = el.getElementsByTagName( 'a' );
+			for ( var i = 0; i < _links.length; i++ )
+				_intercept( _links.item( i ) );
+
+			if ( _after )
+				_after( el );
+
+			_script.load( );
+		}
+
+		function _manipulator( )
+		{
+			if ( arguments.length != 1 )
+				return false;
+
+			switch ( arguments[ 0 ].constructor )
+			{
+				case Function :
+					_after = arguments[ 0 ];
+					break;
+				case Object :
+					if ( ! ( ( arguments[ 0 ].before && arguments[ 0 ].before.constructor == Function ) && ( arguments[ 0 ].after && arguments[ 0 ].after.constructor == Function ) ) )
+						return false;
+
+					_before = arguments[ 0 ].before;
+					_after = arguments[ 0 ].after;
+					break;
+				default : return false;
+			}
+		}
+
+		this.click = function( )
+		{
+			_click( arguments[ 0 ],
+				(
+					( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Boolean ) ?
+						arguments[ 1 ] : false
+				),
+				(
+					( arguments.length > 2 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ?
+						arguments[ 2 ] : null
+				)
+			);
+		};
+
+		this.intercept = _intercept;
+		this.handler = _manipulator;
 	}
 
-	Link.prototype.click = function( )
-	{
-		_click( arguments[ 0 ],
-			(
-				( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Boolean ) ?
-					arguments[ 1 ] : false
-			),
-			(
-				( arguments.length > 2 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ?
-					arguments[ 2 ] : null
-			)
-		);
-	};
-	Link.prototype.intercept = _intercept;
-
 	window.XLink = Link;
-
-	XEvents.add( window, 'onload', function( )
-	{
-		_divAppboxHeader = document.getElementById( 'divAppboxHeader' );
-		_divAppboxHeader.innerHTML = '';
-
-		_container = document.getElementById( 'divAppbox' );
-	} );
 } )( );
Index: trunk/phpgwapi/js/expressolivre/expressolivre.js
===================================================================
--- trunk/phpgwapi/js/expressolivre/expressolivre.js	(revision 2729)
+++ trunk/phpgwapi/js/expressolivre/expressolivre.js	(revision 2732)
@@ -9,4 +9,9 @@
 
 	var _language = [ ]
+
+	var _divAppboxHeader = null;
+	var _divAppbox = null;
+
+	var _loading = new Image( );
 
 	function _go( )
@@ -84,5 +89,29 @@
 	window.ExpressoLivre = _ExpressoLivre( );
 
-	_xlink = new XLink( ExpressoLivre.path( ) );
+	_xlink = new XLink( _path( ) );
+	_xlink.handler( {
+			"before" : function( )
+			{
+				if ( _divAppboxHeader )
+					_divAppboxHeader.innerHTML = '';
+
+				if ( _divAppbox )
+				{
+					var _center = document.createElement( 'center' );
+					_center.appendChild( _loading );
+
+					_divAppbox.innerHTML = '';
+					_divAppbox.appendChild( _center );
+				}
+			},
+			"after" : function( )
+			{
+				if ( _divAppbox )
+					_divAppbox.innerHTML = '';
+
+				while ( arguments[ 0 ].hasChildNodes( ) )
+					_divAppbox.appendChild( arguments[ 0 ].firstChild );
+			}
+	} );
 
 	_xconnector = new XConnector( {
@@ -91,6 +120,14 @@
 	} );
 
+	_loading.src = _path( ) + 'phpgwapi/templates/' + _template( ) + '/images/loading.gif';
+
 	XEvents.add( window, 'onload', function( )
 	{
+		_divAppboxHeader = document.getElementById( 'divAppboxHeader' );
+		_divAppboxHeader.innerHTML = '';
+
+		_divAppbox = document.getElementById( 'divAppbox' );
+		_divAppbox.innerHTML = '';
+
 		document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll';
 
