thirdparty/jsdoctoolkit/app/lib/JSDOC/PluginManager.js
author Mario Ferraro <fadinlight@gmail.com>
Sun, 15 Nov 2009 22:12:20 +0100
changeset 3093 d1be59b6b627
parent 3041 c8f47f0b6697
permissions -rw-r--r--
GMaps related JS changed to use new google namespace. Google is going to change permanently in the future the way to load its services, so better stay safe. Also this commit shows uses of the new melange.js module. Fixes Issue 634.

/**
	@namespace Holds functionality related to running plugins.
*/
JSDOC.PluginManager = {
}

/**
	@param name A unique name that identifies that plugin.
	@param handlers A collection of named functions. The names correspond to hooks in the core code.
*/
JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) {
	if (!defined(JSDOC.PluginManager.plugins))
		/** The collection of all plugins. Requires a unique name for each.
		*/
		JSDOC.PluginManager.plugins = {};
	
	
	JSDOC.PluginManager.plugins[name] = handlers;
}

/**
	@param hook The name of the hook that is being caught.
	@param target Any object. This will be passed as the only argument to the handler whose
	name matches the hook name. Handlers cannot return a value, so must modify the target
	object to have an effect.
*/
JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) {
	for (var name in JSDOC.PluginManager.plugins) {
		if (defined(JSDOC.PluginManager.plugins[name][hook])) {
			JSDOC.PluginManager.plugins[name][hook](target);
		}
	}
}