Changeset 1134


Ignore:
Timestamp:
11/25/08 18:39:03 (11 years ago)
Author:
douglas
Message:

FIXED Ticket #1330 We now adjust links to allow referencing Xinha resources...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/Dialogs/XinhaDialog.js

    r1119 r1134  
    197197  rootElem.appendChild(main); 
    198198  main.innerHTML = html; 
     199 
     200  // If the localizer is a string containing a plugin name, it can be used to 
     201  // lookup the plugin. 
     202  this.fixupDOM(main, localizer); 
    199203   
    200204  //make the first h1 to drag&drop the rootElem 
     
    11351139}; 
    11361140 
     1141/** 
     1142 * Fixup links in the elements to allow linking to Xinha resources 
     1143 */ 
     1144Xinha.Dialog.prototype.fixupDOM = function(root,plugin) 
     1145{ 
     1146  var dialog = this; 
     1147  if(typeof plugin != 'string') 
     1148  { 
     1149    plugin = 'GenericPlugin'; 
     1150  } 
     1151 
     1152  var linkReplace = function(fullString, resource) { 
     1153    switch(resource) { 
     1154      case "editor": 
     1155        return _editor_url; 
     1156      case "plugin": 
     1157        return Xinha.getPluginDir(plugin); 
     1158      case "images": 
     1159        return dialog.editor.imgURL('images'); 
     1160    }; 
     1161  }; 
     1162 
     1163  var images = Xinha.collectionToArray(root.getElementsByTagName('img')); 
     1164 
     1165  for (var index=0; index<images.length; ++index) { 
     1166    var image = images[index]; 
     1167    var reference = image.getAttribute('src'); 
     1168    if (reference) { 
     1169      var fixedReference = reference.replace(/^\[(editor|plugin|images)\]/, linkReplace); 
     1170      if (fixedReference != reference) { 
     1171        image.setAttribute('src', fixedReference); 
     1172      } 
     1173    } 
     1174  } 
     1175 
     1176  var links = Xinha.collectionToArray(root.getElementsByTagName('a')); 
     1177 
     1178  for (var index=0; index<links.length; ++index) { 
     1179    var link = links[index]; 
     1180    var reference = image.getAttribute('href'); 
     1181    if (reference) { 
     1182      var fixedReference = reference.replace(/^\[(editor|plugin|images)\]/, linkReplace); 
     1183      if (fixedReference != reference) { 
     1184        link.setAttribute('href', fixedReference); 
     1185      } 
     1186    } 
     1187  } 
     1188 
     1189}; 
     1190 
    11371191/** Use this function when adding an element with a new ID/name to a  
    11381192 *  dialog after it has already been created. This function ensures 
Note: See TracChangeset for help on using the changeset viewer.