Changeset 1079 for trunk


Ignore:
Timestamp:
10/11/08 19:06:27 (10 years ago)
Author:
ray
Message:
  • #1301 loading should not fail if plugin omits _pluginInfo
  • #1300 create namespace for plugins within Xinha namespace
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1077 r1079  
    21142114    return false; 
    21152115  } 
    2116   else if ( typeof ColorPicker != 'undefined' && !this.plugins['colorPicker']) editor.registerPlugin('ColorPicker'); 
     2116  else if ( typeof Xinha.getPluginConstructor('ColorPicker') != 'undefined' && !this.plugins['colorPicker']) editor.registerPlugin('ColorPicker'); 
    21172117 
    21182118  var toolbar = editor.config.toolbar; 
     
    21322132            return false; 
    21332133          } 
    2134           else if ( typeof InsertImage != 'undefined' && !this.plugins['InsertImage']) editor.registerPlugin('InsertImage'); 
     2134          else if ( typeof Xinha.getPluginConstructor('InsertImage') != 'undefined' && !this.plugins['InsertImage']) editor.registerPlugin('InsertImage'); 
    21352135        break; 
    21362136        case "createlink": 
    21372137          url = _editor_url + 'modules/CreateLink/link.js'; 
    2138           if ( typeof Linker == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], function() { editor.generate(); } )) 
     2138          if ( typeof Xinha.getPluginConstructor('Linker') == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], function() { editor.generate(); } )) 
    21392139          { 
    21402140            return false; 
    21412141          } 
    2142           else if ( typeof CreateLink != 'undefined' && !this.plugins['CreateLink']) editor.registerPlugin('CreateLink'); 
     2142          else if ( typeof Xinha.getPluginConstructor('CreateLink') != 'undefined' && !this.plugins['CreateLink']) editor.registerPlugin('CreateLink'); 
    21432143        break; 
    21442144        case "inserttable": 
     
    21482148            return false; 
    21492149          } 
    2150           else if ( typeof InsertTable != 'undefined' && !this.plugins['InsertTable']) editor.registerPlugin('InsertTable'); 
     2150          else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins['InsertTable']) editor.registerPlugin('InsertTable'); 
    21512151        break; 
    21522152      } 
     
    32353235 *  Category: PLUGINS 
    32363236 ***************************************************/ 
    3237  
     3237/** Plugins may either reside in the golbal scope (not recommended) or in Xinha.plugins.  
     3238 *  This function looks in both locations and is used to check the loading status and finally retrieve the plugin's constructor 
     3239 * @private 
     3240 * @type {Function|undefined} 
     3241 * @param {String} pluginName 
     3242 */ 
     3243Xinha.getPluginConstructor = function(pluginName) 
     3244{ 
     3245  return Xinha.plugins[pluginName] || window[pluginName]; 
     3246} 
    32383247 
    32393248/** Create the specified plugin and register it with this Xinha 
     
    32483257 
    32493258  // We can only register plugins that have been succesfully loaded 
    3250   if ( plugin === null || typeof plugin == 'undefined' || (typeof plugin == 'string' && typeof window[plugin] == 'undefined') ) 
     3259  if ( plugin === null || typeof plugin == 'undefined' || (typeof plugin == 'string' && Xinha.getPluginConstructor(plugin) == 'undefined') ) 
    32513260  { 
    32523261    return false; 
     
    32673276Xinha.prototype.registerPlugin2 = function(plugin, args) 
    32683277{ 
    3269   if ( typeof plugin == "string" && typeof window[plugin] == 'function' ) 
    3270   { 
    3271     plugin = window[plugin]; 
     3278  if ( typeof plugin == "string" && typeof Xinha.getPluginConstructor(plugin) == 'function' ) 
     3279  { 
     3280    var pluginName = plugin; 
     3281    plugin = Xinha.getPluginConstructor(plugin); 
    32723282  } 
    32733283  if ( typeof plugin == "undefined" ) 
     
    32763286    return false; 
    32773287  } 
    3278  
     3288  if (!plugin._pluginInfo) plugin._pluginInfo =  {name:pluginName}; 
    32793289  var obj = new plugin(this, args); 
    32803290  if ( obj ) 
     
    33143324  if (forceUnsupported || 
    33153325      // If the plugin is fully loaded, it's supported status is already set. 
    3316       (window[plugin] && (typeof window[plugin].supported != 'undefined') && !window[plugin].supported)) 
     3326      (Xinha.getPluginConstructor(plugin) && (typeof Xinha.getPluginConstructor(plugin).supported != 'undefined') && !Xinha.getPluginConstructor(plugin).supported)) 
    33173327  { 
    33183328    return _editor_url + "unsupported_plugins/" + plugin ; 
     
    33333343 
    33343344  // Might already be loaded 
    3335   if ( typeof window[pluginName] != 'undefined' ) 
     3345  if ( typeof Xinha.getPluginConstructor(pluginName) != 'undefined' ) 
    33363346  { 
    33373347    if ( callback ) 
     
    34043414    function statusCallback(pluginName) 
    34053415    { 
    3406       window[pluginName].supported = stage.indexOf('unsupported') != 0; 
     3416      Xinha.getPluginConstructor(pluginName).supported = stage.indexOf('unsupported') != 0; 
    34073417      callback(pluginName); 
    34083418    } 
     
    34313441 */ 
    34323442Xinha._pluginLoadStatus = {}; 
    3433  
     3443/** Stores the paths to plugins that are not in the default location 
     3444 * @private 
     3445 * @type {Object} 
     3446 */ 
    34343447Xinha.externalPlugins = {}; 
     3448/** The namespace for plugins 
     3449 * @private 
     3450 * @type {Object} 
     3451 */ 
     3452Xinha.plugins = {}; 
    34353453 
    34363454/** Static function that loads the plugins (see xinha_plugins in NewbieGuide) 
     
    34723490          Xinha.setLoadingMessage (Xinha._lc("Finishing")); 
    34733491 
    3474           if ( typeof window[plugin] != 'undefined' ) 
     3492          if ( typeof Xinha.getPluginConstructor(plugin) != 'undefined' ) 
    34753493          { 
    34763494            Xinha._pluginLoadStatus[plugin] = 'ready'; 
Note: See TracChangeset for help on using the changeset viewer.