Changeset 2732 for trunk/phpgwapi


Ignore:
Timestamp:
05/07/10 11:16:25 (14 years ago)
Author:
rodsouza
Message:

Ticket #1058 - Removendo procedimento para manipulação de interface do local inapropriado.

Location:
trunk/phpgwapi/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/js/expressolivre/expressolivre.js

    r2729 r2732  
    99 
    1010        var _language = [ ] 
     11 
     12        var _divAppboxHeader = null; 
     13        var _divAppbox = null; 
     14 
     15        var _loading = new Image( ); 
    1116 
    1217        function _go( ) 
     
    8489        window.ExpressoLivre = _ExpressoLivre( ); 
    8590 
    86         _xlink = new XLink( ExpressoLivre.path( ) ); 
     91        _xlink = new XLink( _path( ) ); 
     92        _xlink.handler( { 
     93                        "before" : function( ) 
     94                        { 
     95                                if ( _divAppboxHeader ) 
     96                                        _divAppboxHeader.innerHTML = ''; 
     97 
     98                                if ( _divAppbox ) 
     99                                { 
     100                                        var _center = document.createElement( 'center' ); 
     101                                        _center.appendChild( _loading ); 
     102 
     103                                        _divAppbox.innerHTML = ''; 
     104                                        _divAppbox.appendChild( _center ); 
     105                                } 
     106                        }, 
     107                        "after" : function( ) 
     108                        { 
     109                                if ( _divAppbox ) 
     110                                        _divAppbox.innerHTML = ''; 
     111 
     112                                while ( arguments[ 0 ].hasChildNodes( ) ) 
     113                                        _divAppbox.appendChild( arguments[ 0 ].firstChild ); 
     114                        } 
     115        } ); 
    87116 
    88117        _xconnector = new XConnector( { 
     
    91120        } ); 
    92121 
     122        _loading.src = _path( ) + 'phpgwapi/templates/' + _template( ) + '/images/loading.gif'; 
     123 
    93124        XEvents.add( window, 'onload', function( ) 
    94125        { 
     126                _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); 
     127                _divAppboxHeader.innerHTML = ''; 
     128 
     129                _divAppbox = document.getElementById( 'divAppbox' ); 
     130                _divAppbox.innerHTML = ''; 
     131 
    95132                document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; 
    96133 
  • trunk/phpgwapi/js/tools/xlink.js

    r2729 r2732  
    11( function( ) 
    22{ 
    3         var _path = null; 
    4         var _last_request = null; 
    5  
    6         var _connector = null; 
     3        var _connector = new XConnector; 
    74        var _script = new XScript; 
    8  
    9         var _container = null; 
    10         var _divAppboxHeader = null; 
    11  
    12         var _loading = new Image( ); 
    13  
    14         function _click( _action, _cache ) 
    15         { 
    16                 if ( _action.indexOf( window.location.host ) < 0 ) 
    17                         _action = window.location.protocol + '//' + window.location.host + _action; 
    18  
    19                 var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null; 
    20  
    21                 if ( _post == null && _action == _last_request ) 
    22                         return false; 
    23  
    24                 if ( _divAppboxHeader ) 
    25                         _divAppboxHeader.innerHTML = ''; 
    26  
    27                 if ( _container ) 
    28                 { 
    29                         var _center = document.createElement( 'center' ); 
    30                         _center.appendChild( _loading ); 
    31  
    32                         _container.innerHTML = ''; 
    33                         _container.appendChild( _center ); 
    34                 } 
    35  
    36                 _connector.go( 
    37                 { 
    38                         'access' : _action, 
    39                         'cache' : _cache, 
    40                         'handler' : _handler, 
    41                         'post' : _post 
    42                 } ); 
    43  
    44                 _last_request = _action; 
    45  
    46                 window.location = '#' + ( 
    47                         ( _action.indexOf( _path ) < 0 ) ? 
    48                                 _action : _action.substr( _action.indexOf( _path ) + URL_SERVER.length ) 
    49                 ); 
    50         } 
    51  
    52         function _intercept( pLink ) 
    53         { 
    54                 var action = pLink.href; 
    55                 if ( action == '' ) 
    56                         return false; 
    57  
    58                 var a = ( action.indexOf( 'javascript:' ) === 0 ); 
    59                 a = ( a || ( action.indexOf( '#' ) === 0 ) ); 
    60                 a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) ); 
    61                 a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) ); 
    62  
    63                 if ( ! a ) 
    64                         pLink.onclick = function( ) 
    65                         { 
    66                                 var _cacheit = false;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false ); 
    67  
    68                                 _click( action, _cacheit ); 
    69  
    70                                 return false; 
    71                         }; 
    72         } 
    73  
    74         function _handler( data ) 
    75         { 
    76                 var js = data.match( /<script[^>]*>.*?<\/script>/g ); 
    77                 var _new_scripts = [ ]; 
    78                 if ( js ) 
    79                 { 
    80                         var tag = /<script([^>]*src="(\S+)"[^>]*|[^>]*)>(.*?)<\/script>/; 
    81                         for ( var i = 0; i < js.length; i++ ) 
    82                         { 
    83                                 var type = tag.exec( js[ i ] ); 
    84                                 data = data.replace( type[ 0 ], '' ); 
    85                                 _new_scripts[ _new_scripts.length ] = type; 
    86                         } 
    87                 } 
    88  
    89                 var el = document.createElement( 'div' ); 
    90                 el.innerHTML = data; 
    91  
    92                 var _links = el.getElementsByTagName( 'a' ); 
    93                 for ( var i = 0; i < _links.length; i++ ) 
    94                         _intercept( _links.item( i ) ); 
    95  
    96                 _container.innerHTML = ''; 
    97                 while ( el.hasChildNodes( ) ) 
    98                         _container.appendChild( el.firstChild ); 
    99  
    100                 for ( var i = 0; i < _new_scripts.length; i++ ) 
    101                 { 
    102                         if ( _new_scripts[ i ][ 2 ] == undefined || _new_scripts[ i ][ 2 ].length == 0 ) 
    103                                 _script.inline( _new_scripts[ i ][ 3 ] ); 
    104                         else 
    105                         { 
    106                                 if ( _new_scripts[ i ][ 2 ].indexOf( window.location.host ) < 0 ) 
    107                                         _new_scripts[ i ][ 2 ] = window.location.protocol + '//' + window.location.host + _new_scripts[ i ][ 2 ]; 
    108  
    109                                 _script.external( 
    110                                         _new_scripts[ i ][ 2 ].substr( 
    111                                                 _path.length - 1, 
    112                                                 _new_scripts[ i ][ 2 ].length - _path.length + 1 - ( 
    113                                                         ( _new_scripts[ i ][ 2 ].indexOf( '?' ) < 0 ) ? 
    114                                                                 0 : ( _new_scripts[ i ][ 2 ].length - _new_scripts[ i ][ 2 ].indexOf( '?' ) ) 
    115                                                 ) 
    116                                         ) 
    117                                 ); 
    118                         } 
    119                 } 
    120  
    121                 _script.load( ); 
    122         } 
    1235 
    1246        function Link( ) 
    1257        { 
    126                 _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/'; 
     8                var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/'; 
     9                var _last_request = null; 
     10 
     11                var _before = null; 
     12                var _after = null; 
    12713 
    12814                if ( window.location.protocol + '//' + window.location.host + window.location.pathname != _path ) 
     
    13218                        ); 
    13319 
    134                 _loading.src = _path + 'phpgwapi/templates/'+template+'/images/loading.gif'; 
    135                 _connector = new XConnector; 
     20                function _click( _action, _cache ) 
     21                { 
     22                        if ( _action.indexOf( window.location.host ) < 0 ) 
     23                                _action = window.location.protocol + '//' + window.location.host + _action; 
     24 
     25                        var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null; 
     26 
     27                        if ( _post == null && _action == _last_request ) 
     28                                return false; 
     29 
     30                        if ( _before ) 
     31                                _before( ); 
     32 
     33                        _connector.go( 
     34                        { 
     35                                'access' : _action, 
     36                                'cache' : _cache, 
     37                                'handler' : _handler, 
     38                                'post' : _post 
     39                        } ); 
     40 
     41                        _last_request = _action; 
     42 
     43                        window.location = '#' + ( 
     44                                ( _action.indexOf( _path ) < 0 ) ? 
     45                                        _action : _action.substr( _action.indexOf( _path ) + _path.length ) 
     46                        ); 
     47                } 
     48 
     49                function _intercept( pLink ) 
     50                { 
     51                        var action = pLink.href; 
     52                        if ( action == '' ) 
     53                                return false; 
     54 
     55                        var a = ( action.indexOf( 'javascript:' ) === 0 ); 
     56                        a = ( a || ( action.indexOf( '#' ) === 0 ) ); 
     57                        a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) ); 
     58                        a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) ); 
     59 
     60                        if ( ! a ) 
     61                                pLink.onclick = function( ) 
     62                                { 
     63                                        var _cacheit = false;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false ); 
     64 
     65                                        _click( action, _cacheit ); 
     66 
     67                                        return false; 
     68                                }; 
     69                } 
     70 
     71                function _handler( data ) 
     72                { 
     73                        var js = data.match( /<script[^>]*>.*?<\/script>/gi ); 
     74                        if ( js ) 
     75                        { 
     76                                var _tag = /<script([^>]*src="(\S+)"[^>]*|[^>]*)>(.*?)<\/script>/i; 
     77                                for ( var i = 0; i < js.length; i++ ) 
     78                                { 
     79                                        var _type = _tag.exec( js[ i ] ); 
     80                                        data = data.replace( _type[ 0 ], '' ); 
     81 
     82                                        if ( _type[ 2 ] == undefined || _type[ 2 ].length == 0 ) 
     83                                                _script.inline( _type[ 3 ] ); 
     84                                        else 
     85                                        { 
     86                                                if ( _type[ 2 ].indexOf( window.location.host ) < 0 ) 
     87                                                        _type[ 2 ] = window.location.protocol + '//' + window.location.host + _type[ 2 ]; 
     88 
     89                                                _script.external( 
     90                                                        _type[ 2 ].substr( 
     91                                                                _path.length - 1, 
     92                                                                _type[ 2 ].length - _path.length + 1 - ( 
     93                                                                        ( _type[ 2 ].indexOf( '?' ) < 0 ) ? 
     94                                                                                0 : ( _type[ 2 ].length - _type[ 2 ].indexOf( '?' ) ) 
     95                                                                ) 
     96                                                        ) 
     97                                                ); 
     98                                        } 
     99                                } 
     100                        } 
     101 
     102                        var el = document.createElement( 'div' ); 
     103                        el.innerHTML = data; 
     104 
     105                        var _links = el.getElementsByTagName( 'a' ); 
     106                        for ( var i = 0; i < _links.length; i++ ) 
     107                                _intercept( _links.item( i ) ); 
     108 
     109                        if ( _after ) 
     110                                _after( el ); 
     111 
     112                        _script.load( ); 
     113                } 
     114 
     115                function _manipulator( ) 
     116                { 
     117                        if ( arguments.length != 1 ) 
     118                                return false; 
     119 
     120                        switch ( arguments[ 0 ].constructor ) 
     121                        { 
     122                                case Function : 
     123                                        _after = arguments[ 0 ]; 
     124                                        break; 
     125                                case Object : 
     126                                        if ( ! ( ( arguments[ 0 ].before && arguments[ 0 ].before.constructor == Function ) && ( arguments[ 0 ].after && arguments[ 0 ].after.constructor == Function ) ) ) 
     127                                                return false; 
     128 
     129                                        _before = arguments[ 0 ].before; 
     130                                        _after = arguments[ 0 ].after; 
     131                                        break; 
     132                                default : return false; 
     133                        } 
     134                } 
     135 
     136                this.click = function( ) 
     137                { 
     138                        _click( arguments[ 0 ], 
     139                                ( 
     140                                        ( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Boolean ) ? 
     141                                                arguments[ 1 ] : false 
     142                                ), 
     143                                ( 
     144                                        ( arguments.length > 2 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? 
     145                                                arguments[ 2 ] : null 
     146                                ) 
     147                        ); 
     148                }; 
     149 
     150                this.intercept = _intercept; 
     151                this.handler = _manipulator; 
    136152        } 
    137153 
    138         Link.prototype.click = function( ) 
    139         { 
    140                 _click( arguments[ 0 ], 
    141                         ( 
    142                                 ( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Boolean ) ? 
    143                                         arguments[ 1 ] : false 
    144                         ), 
    145                         ( 
    146                                 ( arguments.length > 2 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? 
    147                                         arguments[ 2 ] : null 
    148                         ) 
    149                 ); 
    150         }; 
    151         Link.prototype.intercept = _intercept; 
    152  
    153154        window.XLink = Link; 
    154  
    155         XEvents.add( window, 'onload', function( ) 
    156         { 
    157                 _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); 
    158                 _divAppboxHeader.innerHTML = ''; 
    159  
    160                 _container = document.getElementById( 'divAppbox' ); 
    161         } ); 
    162155} )( ); 
Note: See TracChangeset for help on using the changeset viewer.