Changeset 2601 for trunk/phpgwapi


Ignore:
Timestamp:
04/20/10 11:50:19 (14 years ago)
Author:
rodsouza
Message:

Ticket #1009 - Melhorando a forma de criar cache em uma requisição background.

Location:
trunk/phpgwapi/js/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/js/tools/xconnector.js

    r2583 r2601  
    333333        Connector.prototype.cache = function( ) 
    334334        { 
    335                 this._cache = true; 
     335                _cache = true; 
     336 
     337                if ( arguments.length == 1 && arguments[ 0 ].constructor == Boolean ) 
     338                        _cache = arguments[ 0 ]; 
     339 
     340                this._cache = _cache; 
     341 
     342                return this; 
    336343        }; 
    337344        window.XConnector = Connector; 
  • trunk/phpgwapi/js/tools/xlink.js

    r2578 r2601  
    2626                                _container.appendChild( _loading ); 
    2727 
    28                                 if ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) 
    29                                         _connector.cache( ); 
     28                                var _cacheit = ( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false ); 
    3029 
    31                                 var request = _connector.go( { 
     30                                var request = _connector.cache( _cacheit ).go( { 
    3231                                        'access' : action, 
    3332                                        'handler' : function( data ) 
     
    4342                                                var _loaded = _head.getElementsByTagName( 'script' ); 
    4443                                                var _scripts = el.getElementsByTagName( 'script' ); 
    45                                                 fix : for ( var i = 0; i < _scripts.length; i++ ) 
     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++ ) 
    4654                                                { 
    47                                                         var _script = _scripts.item( i ); 
     55                                                        var _script = _new_scripts[ i ]; 
    4856                                                        if ( _script.getAttribute( 'src' ) == null ) 
     57                                                        { 
     58                                                                _container.appendChild( _script ); 
    4959                                                                continue; 
     60                                                        } 
    5061                                                        else 
    5162                                                        { 
    5263                                                                for ( var j = 0; j < _loaded.length; j++ ) 
    5364                                                                        if ( _script.getAttribute( 'src' ) === _loaded.item( j ).getAttribute( 'src' )  ) 
    54                                                                         { 
    55                                                                                 el.removeChild( _script ); 
    5665                                                                                continue fix; 
    57                                                                         } 
    5866 
    5967                                                                _head.appendChild( _script ); 
    60                                                                 i--; 
    6168                                                        } 
    6269                                                } 
    63  
    64                                                 _container.innerHTML = ''; 
    65                                                 while ( el.hasChildNodes( ) ) 
    66                                                         _container.appendChild( el.firstChild ); 
    6770                                        } 
    6871                                } ); 
Note: See TracChangeset for help on using the changeset viewer.