Changeset 2875 for trunk/phpgwapi


Ignore:
Timestamp:
05/27/10 16:57:02 (14 years ago)
Author:
rodsouza
Message:

Ticket #1058 - Flexibilizando a manipulação de dados das requisição capturadas.

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

Legend:

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

    r2420 r2875  
    1414                                else if ( pObj.attachEvent ) 
    1515                                        pObj.attachEvent( 'on' + pEvent, pHandler ); 
     16 
     17                                ( arguments[0].preventDefault ) ? 
     18                                        arguments[0].preventDefault( ) : arguments[0].returnValue = false; 
    1619                        } 
    1720                        else if ( arguments.length == 4 ) 
  • trunk/phpgwapi/js/tools/xlink.js

    r2802 r2875  
    99                var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/'; 
    1010 
     11                _path = ( 
     12                        ( ( _path.indexOf( _location.protocol ) != 0 ) ? _location.protocol + '//' : '' ) 
     13                        + ( ( _path.indexOf( _location.host ) != 0 ) ? _location.host : '' ) 
     14                        + ( ( _path.indexOf( '/' ) != 0 ) ? '/' : '' ) 
     15                ) + _path; 
     16 
    1117                var _last_request = null; 
    12                 var _before = null; 
    13                 var _after = null; 
     18                var _handlers_registred = { 
     19                        after : null, 
     20                        before : null, 
     21                        data : null 
     22                }; 
    1423 
    1524                if ( _location.protocol + '//' + _location.host + _location.pathname != _path ) 
     
    2130                function _click( _action, _cache ) 
    2231                { 
    23                         if ( _action.indexOf( _location.host ) < 0 ) 
    24                                 _action = _location.protocol + '//' + _location.host + _action; 
     32                        switch ( _action.indexOf( _location.pathname ) ) 
     33                        { 
     34                                case -1 : 
     35                                        _action = _path + ( ( _action.indexOf( '/' ) == 0 ) ? _action.substr( 1 ) : _action ); 
     36                                        break; 
     37                                case 0 : 
     38                                        _action = _action.replace( _location.pathname, _path ); 
     39                                        break; 
     40                                default : 
     41                                        if ( _action.indexOf( _path ) != 0 ) 
     42                                                _action = _path + _action; 
     43                        } 
    2544 
    2645                        var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null; 
     
    2948                                return false; 
    3049 
    31                         if ( _before ) 
    32                                 _before( ); 
     50                        if ( _handlers_registred.before ) 
     51                                _handlers_registred.before( ); 
    3352 
    3453                        _connector.go( 
     
    7089                } 
    7190 
    72                 function _manipulator( _data ) 
     91                function _manipulator( _pData ) 
    7392                { 
    74                         if ( ! ( _data.constructor == String ) ) 
     93                        if ( ! ( _pData.constructor == String ) ) 
    7594                                return false; 
     95 
     96                        if ( _handlers_registred.data ) 
     97                                _pData = _handlers_registred.data( _pData ); 
    7698 
    7799                        var _line_feed = '__LINE_FEED_CHARACTER_' + ( Date.parse( new Date ) ) + '__'; 
    78100 
    79                         _data = _data.trim( ).replace( /[\r\t]/g, '' ).replace( /\n/g, _line_feed ); 
     101                        _pData = _pData.trim( ).replace( /[\r\t]/g, '' ).replace( /\n/g, _line_feed ); 
    80102 
    81103                        _line_feed = new RegExp( _line_feed, 'g' ); 
    82104 
    83                         var _js = _data.match( new RegExp( '<script[^>]*>.*?<\/script>', 'gi' ) ); 
     105                        var _js = _pData.match( new RegExp( '<script[^>]*>.*?<\/script>', 'gi' ) ); 
    84106 
    85107                        if ( _js ) 
     
    89111                                for ( var i = 0; i < _js.length; i++ ) 
    90112                                { 
    91                                         _data = _data.replace( _js[ i ], '' ); 
     113                                        _pData = _pData.replace( _js[ i ], '' ); 
    92114 
    93115                                        _js[ i ] = _tag.exec( _js[ i ] ); 
     
    116138 
    117139                        var el = document.createElement( 'div' ); 
    118                         el.innerHTML = _data.replace( _line_feed, '' ); 
     140                        el.innerHTML = _pData.replace( _line_feed, '' ); 
    119141 
    120142                        var _links = el.getElementsByTagName( 'a' ); 
     
    122144                                _intercept( _links.item( i ) ); 
    123145 
    124                         if ( _after ) 
    125                                 _after( el ); 
     146                        if ( _handlers_registred.after ) 
     147                                _handlers_registred.after( el ); 
    126148 
    127149                        _script.load( ); 
     
    136158                        { 
    137159                                case Function : 
    138                                         _after = arguments[ 0 ]; 
     160                                        _handler.after = arguments[ 0 ]; 
    139161                                        break; 
    140162                                case Object : 
    141                                         if ( ! ( ( arguments[ 0 ].before && arguments[ 0 ].before.constructor == Function ) && ( arguments[ 0 ].after && arguments[ 0 ].after.constructor == Function ) ) ) 
    142                                                 return false; 
     163                                        if ( arguments[ 0 ].after && arguments[ 0 ].after.constructor == Function ) 
     164                                                _handlers_registred.after = arguments[ 0 ].after; 
    143165 
    144                                         _before = arguments[ 0 ].before; 
    145                                         _after = arguments[ 0 ].after; 
     166                                        if ( arguments[ 0 ].before && arguments[ 0 ].before.constructor == Function ) 
     167                                                _handlers_registred.before = arguments[ 0 ].before; 
     168 
     169                                        if ( arguments[ 0 ].data && arguments[ 0 ].data.constructor == Function ) 
     170                                                _handlers_registred.data = arguments[ 0 ].data; 
    146171                                        break; 
    147172                                default : return false; 
Note: See TracChangeset for help on using the changeset viewer.