Changeset 632


Ignore:
Timestamp:
01/08/07 19:21:48 (11 years ago)
Author:
ray
Message:

Ticket #448 Dragging an image in Firefox changes the url from absolute to relative

  • added config.expandRelativeUrl default true
  • if true relative src & href urls are expanded to absolute urls
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/htmlarea.js

    r631 r632  
    302302  this.baseHref = null; 
    303303 
    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 
    305311  //   especially if you don't specify a baseHref is that mozilla at least (& IE ?) will prefix 
    306312  //   the baseHref to any relative links to make them absolute, which isn't what you want most the time. 
     
    52235229HTMLArea.prototype.fixRelativeLinks = function(html) 
    52245230{ 
     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   
    52255251  if ( typeof this.config.stripSelfNamedAnchors != 'undefined' && this.config.stripSelfNamedAnchors ) 
    52265252  { 
Note: See TracChangeset for help on using the changeset viewer.