Changeset 734 for trunk


Ignore:
Timestamp:
02/13/07 16:43:06 (13 years ago)
Author:
htanaka
Message:

fix #950 all terms in ContextMenu? will be translated even if baseHref is specified.

  • _editor_url might be converted as absolute if it is relative.
  • _resolveRelativeUrl function was moved from insert_image.html to Xinha core class.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r732 r734  
    4242}; 
    4343 
     44Xinha._resolveRelativeUrl = function(base, url){ 
     45        if(url.match(/^([^:]+\:)?\//)){ 
     46                return url; 
     47        } 
     48        else{ 
     49                var b = base.split("/"); 
     50                if(b[b.length - 1] == ""){ 
     51                        b.pop(); 
     52                } 
     53                var p = url.split("/"); 
     54                if(p[0] == "."){ 
     55                        p.shift(); 
     56                } 
     57                while(p[0] == ".."){ 
     58                        b.pop(); 
     59                        p.shift(); 
     60                } 
     61                return b.join("/") + "/" + p.join("/"); 
     62        } 
     63} 
     64 
    4465if ( typeof _editor_url == "string" ) 
    4566{ 
    4667  // Leave exactly one backslash at the end of _editor_url 
    4768  _editor_url = _editor_url.replace(/\x2f*$/, '/'); 
     69   
     70  // convert _editor_url to absolute 
     71  if(!_editor_url.match(/^([^:]+\:)?\//)){ 
     72    var path = window.location.toString().split("/"); 
     73    path.pop(); 
     74    _editor_url = Xinha._resolveRelativeUrl(path.join("/"), _editor_url); 
     75  } 
    4876} 
    4977else 
  • trunk/modules/InsertImage/insert_image.html

    r733 r734  
    1414function i18n(str) { 
    1515  return (Xinha._lc(str, 'Xinha')); 
    16 } 
    17  
    18 function resolveRelativeUrl(base, url){ 
    19         if(url.match(/^([^:]+\:)?\//)){ 
    20                 return url; 
    21         } 
    22         else{ 
    23                 var b = base.split("/"); 
    24                 if(b[b.length - 1] == ""){ 
    25                         b.pop(); 
    26                 } 
    27                 var p = url.split("/"); 
    28                 if(p[0] == "."){ 
    29                         p.shift(); 
    30                 } 
    31                 while(p[0] == ".."){ 
    32                         b.pop(); 
    33                         p.shift(); 
    34                 } 
    35                 return b.join("/") + "/" + p.join("/"); 
    36         } 
    3716} 
    3817 
     
    5433  document.getElementById("f_horiz").value  = (typeof param["f_horiz"]!="undefined") ? param["f_horiz"] : ""; 
    5534  if (param["f_url"]) { 
    56       window.ipreview.location.replace(resolveRelativeUrl(param.f_base, param.f_url)); 
     35      window.ipreview.location.replace(Xinha._resolveRelativeUrl(param.f_base, param.f_url)); 
    5736  } 
    5837  document.getElementById("f_url").focus(); 
     
    9877    return false; 
    9978  } 
    100   window.ipreview.location.replace(resolveRelativeUrl(base, url)); 
     79  window.ipreview.location.replace(Xinha._resolveRelativeUrl(base, url)); 
    10180  return false; 
    10281} 
Note: See TracChangeset for help on using the changeset viewer.