| 304 | | // we can strip the base href out of relative links to leave them relative, reason for this |
| | 304 | // when the editor is in different directory depth as the edited page relative image sources |
| | 305 | // will break the display of your images |
| | 306 | // this fixes an issue where Mozilla converts the urls of images and links that are on the same server |
| | 307 | // to relative ones (../) when dragging them around in the editor (Ticket #448) |
| | 308 | this.expandRelativeUrl = true; |
| | 309 | |
| | 310 | // we can strip the base href out of relative links to leave them relative, reason for this |
| | 5231 | if ( typeof this.config.expandRelativeUrl != 'undefined' && this.config.expandRelativeUrl ) |
| | 5232 | var src = html.match(/(src|href)="([^"]*)"/gi); |
| | 5233 | var b = document.location.href; |
| | 5234 | if ( src ) |
| | 5235 | { |
| | 5236 | var url,url_m,relPath,base_m,absPath |
| | 5237 | for ( var i=0;i<src.length;++i ) |
| | 5238 | { |
| | 5239 | url = src[i].match(/(src|href)="([^"]*)"/i); |
| | 5240 | url_m = url[2].match( /\.\.\//g ); |
| | 5241 | if ( url_m ) |
| | 5242 | { |
| | 5243 | relPath = new RegExp( "(.*?)(([^\/]*\/){"+ url_m.length+"})[^\/]*$" ); |
| | 5244 | base_m = b.match( relPath ); |
| | 5245 | absPath = url[2].replace(/(\.\.\/)*/,base_m[1]); |
| | 5246 | html = html.replace( new RegExp(url[2].replace( HTMLArea.RE_Specials, '\\$1' ) ),absPath ); |
| | 5247 | } |
| | 5248 | } |
| | 5249 | } |
| | 5250 | |