Changeset 2875 for trunk/phpgwapi
- Timestamp:
- 05/27/10 16:57:02 (14 years ago)
- Location:
- trunk/phpgwapi/js/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/js/tools/xevent.js
r2420 r2875 14 14 else if ( pObj.attachEvent ) 15 15 pObj.attachEvent( 'on' + pEvent, pHandler ); 16 17 ( arguments[0].preventDefault ) ? 18 arguments[0].preventDefault( ) : arguments[0].returnValue = false; 16 19 } 17 20 else if ( arguments.length == 4 ) -
trunk/phpgwapi/js/tools/xlink.js
r2802 r2875 9 9 var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/'; 10 10 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 11 17 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 }; 14 23 15 24 if ( _location.protocol + '//' + _location.host + _location.pathname != _path ) … … 21 30 function _click( _action, _cache ) 22 31 { 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 } 25 44 26 45 var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null; … … 29 48 return false; 30 49 31 if ( _ before )32 _ before( );50 if ( _handlers_registred.before ) 51 _handlers_registred.before( ); 33 52 34 53 _connector.go( … … 70 89 } 71 90 72 function _manipulator( _ data )91 function _manipulator( _pData ) 73 92 { 74 if ( ! ( _ data.constructor == String ) )93 if ( ! ( _pData.constructor == String ) ) 75 94 return false; 95 96 if ( _handlers_registred.data ) 97 _pData = _handlers_registred.data( _pData ); 76 98 77 99 var _line_feed = '__LINE_FEED_CHARACTER_' + ( Date.parse( new Date ) ) + '__'; 78 100 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 ); 80 102 81 103 _line_feed = new RegExp( _line_feed, 'g' ); 82 104 83 var _js = _ data.match( new RegExp( '<script[^>]*>.*?<\/script>', 'gi' ) );105 var _js = _pData.match( new RegExp( '<script[^>]*>.*?<\/script>', 'gi' ) ); 84 106 85 107 if ( _js ) … … 89 111 for ( var i = 0; i < _js.length; i++ ) 90 112 { 91 _ data = _data.replace( _js[ i ], '' );113 _pData = _pData.replace( _js[ i ], '' ); 92 114 93 115 _js[ i ] = _tag.exec( _js[ i ] ); … … 116 138 117 139 var el = document.createElement( 'div' ); 118 el.innerHTML = _ data.replace( _line_feed, '' );140 el.innerHTML = _pData.replace( _line_feed, '' ); 119 141 120 142 var _links = el.getElementsByTagName( 'a' ); … … 122 144 _intercept( _links.item( i ) ); 123 145 124 if ( _ after )125 _ after( el );146 if ( _handlers_registred.after ) 147 _handlers_registred.after( el ); 126 148 127 149 _script.load( ); … … 136 158 { 137 159 case Function : 138 _ after = arguments[ 0 ];160 _handler.after = arguments[ 0 ]; 139 161 break; 140 162 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; 143 165 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; 146 171 break; 147 172 default : return false;
Note: See TracChangeset
for help on using the changeset viewer.