1 /** 2 * @namespace プラグインの登録とイベントに関する機能を管理する名前空間。 3 * <p class="org_comment" >Holds functionality related to running plugins.</p> 4 */ 5 JSDOC.PluginManager = { 6 } 7 8 /** 9 * プラグインをシステムに登録します。 10 * @param {String} name プラグインの名称。使用される全プラグインと重複しないものである必要があります。 11 * <p class="org_comment" >A unique name that identifies that plugin.</p> 12 * @param {Object} handlers 各イベントへのハンドラ関数をプロパティに持つオブジェクト。 13 * プロパティ名にはイベント名としてあらかじめ規定されたものを設定します。 14 * <p class="org_comment" >A collection of named functions. The names correspond to hooks in the core code.</p> 15 */ 16 JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) { 17 if (!defined(JSDOC.PluginManager.plugins)) 18 /** 19 * プラグイン名をキーとする、登録済みのプラグインのコレクション。 20 * <p class="org_comment" >The collection of all plugins. Requires a unique name for each.</p> 21 * @type Object[] 22 */ 23 JSDOC.PluginManager.plugins = {}; 24 25 26 JSDOC.PluginManager.plugins[name] = handlers; 27 } 28 29 /** 30 * イベントを発生させ、プラグイン内のハンドラを実行します。 31 * @param {String} hook 発生したイベントの名称 32 * <p class="org_comment" >The name of the hook that is being caught.</p> 33 * @param {*} target イベントの名称と一致するハンドラ関数に渡される引数。 34 * ハンドラは戻り値を返せないため、値の返却はここで渡されたオブジェクトの値を変更することで行わなければなりません。 35 * <p class="org_comment" > 36 * Any object. This will be passed as the only argument to the handler whose 37 * name matches the hook name. Handlers cannot return a value, so must modify the target 38 * object to have an effect. 39 * </p> 40 */ 41 JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) { 42 for (var name in JSDOC.PluginManager.plugins) { 43 if (defined(JSDOC.PluginManager.plugins[name][hook])) { 44 JSDOC.PluginManager.plugins[name][hook](target); 45 } 46 } 47 } 48