Changeset 2802 for trunk/phpgwapi


Ignore:
Timestamp:
05/18/10 09:41:04 (14 years ago)
Author:
rodsouza
Message:

Ticket #1058 - Permitindo o envio de formulário por requisição background

Location:
trunk/phpgwapi/js
Files:
1 added
2 edited

Legend:

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

    r2732 r2802  
    1414 
    1515        var _loading = new Image( ); 
     16 
     17        function _form( ) 
     18        { 
     19                if ( ! arguments.length ) 
     20                        return false; 
     21 
     22                var _handler = null; 
     23 
     24                if ( arguments.length > 1 && arguments[ 1 ] && arguments[ 1 ].constructor == Function ) 
     25                        _handler = arguments[ 1 ]; 
     26                else 
     27                        _handler = _xlink.manipulator; 
     28 
     29                _wait( ); 
     30 
     31                return XForm( arguments[ 0 ], _handler ); 
     32        } 
    1633 
    1734        function _go( ) 
     
    7390        } 
    7491 
     92        function _wait( ) 
     93        { 
     94                if ( _divAppboxHeader ) 
     95                        _divAppboxHeader.innerHTML = ''; 
     96 
     97                if ( _divAppbox ) 
     98                { 
     99                        var _center = document.createElement( 'center' ); 
     100                        _center.appendChild( _loading ); 
     101 
     102                        _divAppbox.innerHTML = ''; 
     103                        _divAppbox.appendChild( _center ); 
     104                } 
     105        } 
     106 
    75107        function _ExpressoLivre( ) 
    76108        { 
    77109                return ( new function( ) 
    78110                { 
     111                        this.form = _form; 
    79112                        this.go = _go; 
    80113                        this.lang = _lang; 
     
    91124        _xlink = new XLink( _path( ) ); 
    92125        _xlink.handler( { 
    93                         "before" : function( ) 
    94                         { 
    95                                 if ( _divAppboxHeader ) 
    96                                         _divAppboxHeader.innerHTML = ''; 
     126                "before" : _wait, 
     127                "after" : function( ) 
     128                { 
     129                        if ( _divAppbox ) 
     130                                _divAppbox.innerHTML = ''; 
    97131 
    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                         } 
     132                        while ( arguments[ 0 ].hasChildNodes( ) ) 
     133                                _divAppbox.appendChild( arguments[ 0 ].firstChild ); 
     134                } 
    115135        } ); 
    116136 
     
    129149                _divAppbox = document.getElementById( 'divAppbox' ); 
    130150                _divAppbox.innerHTML = ''; 
     151 
     152                document.title = 'ExpressoLivre'; 
    131153 
    132154                document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; 
  • trunk/phpgwapi/js/tools/xlink.js

    r2756 r2802  
    33        var _connector = new XConnector; 
    44        var _script = new XScript; 
     5        var _location = window.location; 
    56 
    67        function Link( ) 
    78        { 
    89                var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/'; 
     10 
    911                var _last_request = null; 
    10  
    1112                var _before = null; 
    1213                var _after = null; 
    1314 
    14                 if ( window.location.protocol + '//' + window.location.host + window.location.pathname != _path ) 
     15                if ( _location.protocol + '//' + _location.host + _location.pathname != _path ) 
    1516                        window.location.href = _path + ( 
    16                                 ( window.location.hash ) ? 
    17                                         window.location.hash : '#' + String( window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search ).substr( _path.length ) 
     17                                ( _location.hash ) ? 
     18                                        _location.hash : '#' + String( _location.protocol + '//' + _location.host + _location.pathname + _location.search ).substr( _path.length ) 
    1819                        ); 
    1920 
    2021                function _click( _action, _cache ) 
    2122                { 
    22                         if ( _action.indexOf( window.location.host ) < 0 ) 
    23                                 _action = window.location.protocol + '//' + window.location.host + _action; 
     23                        if ( _action.indexOf( _location.host ) < 0 ) 
     24                                _action = _location.protocol + '//' + _location.host + _action; 
    2425 
    2526                        var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null; 
     
    3536                                'access' : _action, 
    3637                                'cache' : _cache, 
    37                                 'handler' : _handler, 
     38                                'handler' : _manipulator, 
    3839                                'post' : _post 
    3940                        } ); 
     
    6970                } 
    7071 
    71                 function _handler( data ) 
     72                function _manipulator( _data ) 
    7273                { 
    73                         data = data.trim( ); 
    74                         data = data.replace( /\n/g, '__LINE_FEED_CHARACTER__' ); 
    75                         data = data.replace( /\r|\t/g, '' ); 
    76                         var _js = data.match( /<script[^>]*>.*?<\/script>/gi ); 
     74                        if ( ! ( _data.constructor == String ) ) 
     75                                return false; 
     76 
     77                        var _line_feed = '__LINE_FEED_CHARACTER_' + ( Date.parse( new Date ) ) + '__'; 
     78 
     79                        _data = _data.trim( ).replace( /[\r\t]/g, '' ).replace( /\n/g, _line_feed ); 
     80 
     81                        _line_feed = new RegExp( _line_feed, 'g' ); 
     82 
     83                        var _js = _data.match( new RegExp( '<script[^>]*>.*?<\/script>', 'gi' ) ); 
     84 
    7785                        if ( _js ) 
    7886                        { 
    7987                                var _tag = /<script([^>]+src=["'](\S+)["'])?[^>]*>(.*?)<\/script>/i; 
     88 
    8089                                for ( var i = 0; i < _js.length; i++ ) 
    8190                                { 
    82                                         data = data.replace( _js[ i ], '' ); 
     91                                        _data = _data.replace( _js[ i ], '' ); 
    8392 
    8493                                        _js[ i ] = _tag.exec( _js[ i ] ); 
    8594 
    86                                         if ( _js[ i ][ 2 ] == undefined || _js[ i ][ 2 ].length == 0 ) 
    87                                                 _script.inline( _js[ i ][ 3 ].replace( /__LINE_FEED_CHARACTER__/g, '\n' ) ); 
     95                                        var _external = _js[ i ][ 2 ]; 
     96 
     97                                        if ( _external == undefined || _external.length == 0 ) 
     98                                                _script.inline( _js[ i ][ 3 ].replace( _line_feed, '\n' ) ); 
    8899                                        else 
    89100                                        { 
    90                                                 var _external = _js[ i ][ 2 ]; 
    91  
    92101                                                if ( _external.indexOf( window.location.host ) < 0 ) 
    93102                                                        _external = window.location.protocol + '//' + window.location.host + _external; 
     
    105114                                } 
    106115                        } 
    107                         data = data.replace( /__LINE_FEED_CHARACTER__|[\r\t]/g, '' ); 
    108116 
    109117                        var el = document.createElement( 'div' ); 
    110                         el.innerHTML = data; 
     118                        el.innerHTML = _data.replace( _line_feed, '' ); 
    111119 
    112120                        var _links = el.getElementsByTagName( 'a' ); 
     
    120128                } 
    121129 
    122                 function _manipulator( ) 
     130                function _handler( ) 
    123131                { 
    124132                        if ( arguments.length != 1 ) 
     
    156164 
    157165                this.intercept = _intercept; 
    158                 this.handler = _manipulator; 
     166                this.handler = _handler; 
     167                this.manipulator = _manipulator; 
    159168        } 
    160169 
Note: See TracChangeset for help on using the changeset viewer.