From b74d5f266133d9dee44e13eb493b3f535a92e81c Mon Sep 17 00:00:00 2001
From: Paolo Nesti Poggi "," * An augmentable class, which provides the augmented class with the ability to host plugins."," * It adds plug and unplug methods to the augmented class, which can"," * be used to add or remove plugins from instances of the class."," * Plugins can also be added through the constructor configuration object passed to the host class' constructor using"," * the \"plugins\" property. Supported values for the \"plugins\" property are those defined by the plug method."," *"," * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host):"," *
"," * Plug.Host's protected _initPlugins and _destroyPlugins"," * methods should be invoked by the host class at the appropriate point in the host's lifecyle."," *
"," *"," * @class Plugin.Host"," */",""," var L = Y.Lang;",""," function PluginHost() {"," this._plugins = {};"," }",""," PluginHost.prototype = {",""," /**"," * Adds a plugin to the host object. This will instantiate the"," * plugin and attach it to the configured namespace on the host object."," *"," * @method plug"," * @chainable"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," *"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," *
"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @return {Base} A reference to the host object"," */"," plug: function(Plugin, config) {"," var i, ln, ns;",""," if (L.isArray(Plugin)) {"," for (i = 0, ln = Plugin.length; i < ln; i++) {"," this.plug(Plugin[i]);"," }"," } else {"," if (Plugin && !L.isFunction(Plugin)) {"," config = Plugin.cfg;"," Plugin = Plugin.fn;"," }",""," // Plugin should be fn by now"," if (Plugin && Plugin.NS) {"," ns = Plugin.NS;",""," config = config || {};"," config.host = this;",""," if (this.hasPlugin(ns)) {"," // Update config"," if (this[ns].setAttrs) {"," this[ns].setAttrs(config);"," }"," } else {"," // Create new instance"," this[ns] = new Plugin(config);"," this._plugins[ns] = Plugin;"," }"," }"," }"," return this;"," },",""," /**"," * Removes a plugin from the host object. This will destroy the"," * plugin instance and delete the namespace from the host object."," *"," * @method unplug"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @return {Base} A reference to the host object"," * @chainable"," */"," unplug: function(plugin) {"," var ns = plugin,"," plugins = this._plugins;",""," if (plugin) {"," if (L.isFunction(plugin)) {"," ns = plugin.NS;"," if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {"," ns = null;"," }"," }",""," if (ns) {"," if (this[ns]) {"," if (this[ns].destroy) {"," this[ns].destroy();"," }"," delete this[ns];"," }"," if (plugins[ns]) {"," delete plugins[ns];"," }"," }"," } else {"," for (ns in this._plugins) {"," if (this._plugins.hasOwnProperty(ns)) {"," this.unplug(ns);"," }"," }"," }"," return this;"," },",""," /**"," * Determines if a plugin has plugged into this host."," *"," * @method hasPlugin"," * @param {String} ns The plugin's namespace"," * @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not."," */"," hasPlugin : function(ns) {"," return (this._plugins[ns] && this[ns]);"," },",""," /**"," * Initializes static plugins registered on the host (using the"," * Base.plug static method) and any plugins passed to the"," * instance through the \"plugins\" configuration property."," *"," * @method _initPlugins"," * @param {Object} config The configuration object with property name/value pairs."," * @private"," */",""," _initPlugins: function(config) {"," this._plugins = this._plugins || {};",""," if (this._initConfigPlugins) {"," this._initConfigPlugins(config);"," }"," },",""," /**"," * Unplugs and destroys all plugins on the host"," * @method _destroyPlugins"," * @private"," */"," _destroyPlugins: function() {"," this.unplug();"," }"," };",""," Y.namespace(\"Plugin\").Host = PluginHost;","","","}, '@VERSION@', {\"requires\": [\"yui-base\"]});","","}());"]}; + __coverage__['build/pluginhost-base/pluginhost-base.js'] = {"path":"build/pluginhost-base/pluginhost-base.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":46}}},"2":{"name":"PluginHost","line":38,"loc":{"start":{"line":38,"column":4},"end":{"line":38,"column":26}}},"3":{"name":"(anonymous_3)","line":61,"loc":{"start":{"line":61,"column":14},"end":{"line":61,"column":39}}},"4":{"name":"(anonymous_4)","line":110,"loc":{"start":{"line":110,"column":16},"end":{"line":110,"column":33}}},"5":{"name":"(anonymous_5)","line":150,"loc":{"start":{"line":150,"column":20},"end":{"line":150,"column":33}}},"6":{"name":"(anonymous_6)","line":164,"loc":{"start":{"line":164,"column":22},"end":{"line":164,"column":39}}},"7":{"name":"(anonymous_7)","line":177,"loc":{"start":{"line":177,"column":25},"end":{"line":177,"column":36}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":185,"column":44}},"2":{"start":{"line":36,"column":4},"end":{"line":36,"column":19}},"3":{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},"4":{"start":{"line":39,"column":8},"end":{"line":39,"column":27}},"5":{"start":{"line":42,"column":4},"end":{"line":180,"column":6}},"6":{"start":{"line":62,"column":12},"end":{"line":62,"column":26}},"7":{"start":{"line":64,"column":12},"end":{"line":96,"column":13}},"8":{"start":{"line":65,"column":16},"end":{"line":67,"column":17}},"9":{"start":{"line":66,"column":20},"end":{"line":66,"column":41}},"10":{"start":{"line":69,"column":16},"end":{"line":72,"column":17}},"11":{"start":{"line":70,"column":20},"end":{"line":70,"column":40}},"12":{"start":{"line":71,"column":20},"end":{"line":71,"column":39}},"13":{"start":{"line":75,"column":16},"end":{"line":95,"column":17}},"14":{"start":{"line":76,"column":20},"end":{"line":76,"column":35}},"15":{"start":{"line":78,"column":20},"end":{"line":78,"column":42}},"16":{"start":{"line":79,"column":20},"end":{"line":79,"column":39}},"17":{"start":{"line":81,"column":20},"end":{"line":92,"column":21}},"18":{"start":{"line":83,"column":24},"end":{"line":87,"column":25}},"19":{"start":{"line":84,"column":28},"end":{"line":84,"column":54}},"20":{"start":{"line":90,"column":24},"end":{"line":90,"column":54}},"21":{"start":{"line":91,"column":24},"end":{"line":91,"column":51}},"22":{"start":{"line":97,"column":12},"end":{"line":97,"column":24}},"23":{"start":{"line":111,"column":12},"end":{"line":112,"column":40}},"24":{"start":{"line":114,"column":12},"end":{"line":139,"column":13}},"25":{"start":{"line":115,"column":16},"end":{"line":120,"column":17}},"26":{"start":{"line":116,"column":20},"end":{"line":116,"column":35}},"27":{"start":{"line":117,"column":20},"end":{"line":119,"column":21}},"28":{"start":{"line":118,"column":24},"end":{"line":118,"column":34}},"29":{"start":{"line":122,"column":16},"end":{"line":132,"column":17}},"30":{"start":{"line":123,"column":20},"end":{"line":128,"column":21}},"31":{"start":{"line":124,"column":24},"end":{"line":126,"column":25}},"32":{"start":{"line":125,"column":28},"end":{"line":125,"column":47}},"33":{"start":{"line":127,"column":24},"end":{"line":127,"column":40}},"34":{"start":{"line":129,"column":20},"end":{"line":131,"column":21}},"35":{"start":{"line":130,"column":24},"end":{"line":130,"column":43}},"36":{"start":{"line":134,"column":16},"end":{"line":138,"column":17}},"37":{"start":{"line":135,"column":20},"end":{"line":137,"column":21}},"38":{"start":{"line":136,"column":24},"end":{"line":136,"column":40}},"39":{"start":{"line":140,"column":12},"end":{"line":140,"column":24}},"40":{"start":{"line":151,"column":12},"end":{"line":151,"column":51}},"41":{"start":{"line":165,"column":12},"end":{"line":165,"column":48}},"42":{"start":{"line":167,"column":12},"end":{"line":169,"column":13}},"43":{"start":{"line":168,"column":16},"end":{"line":168,"column":48}},"44":{"start":{"line":178,"column":12},"end":{"line":178,"column":26}},"45":{"start":{"line":182,"column":4},"end":{"line":182,"column":44}}},"branchMap":{"1":{"line":64,"type":"if","locations":[{"start":{"line":64,"column":12},"end":{"line":64,"column":12}},{"start":{"line":64,"column":12},"end":{"line":64,"column":12}}]},"2":{"line":69,"type":"if","locations":[{"start":{"line":69,"column":16},"end":{"line":69,"column":16}},{"start":{"line":69,"column":16},"end":{"line":69,"column":16}}]},"3":{"line":69,"type":"binary-expr","locations":[{"start":{"line":69,"column":20},"end":{"line":69,"column":26}},{"start":{"line":69,"column":30},"end":{"line":69,"column":51}}]},"4":{"line":75,"type":"if","locations":[{"start":{"line":75,"column":16},"end":{"line":75,"column":16}},{"start":{"line":75,"column":16},"end":{"line":75,"column":16}}]},"5":{"line":75,"type":"binary-expr","locations":[{"start":{"line":75,"column":20},"end":{"line":75,"column":26}},{"start":{"line":75,"column":30},"end":{"line":75,"column":39}}]},"6":{"line":78,"type":"binary-expr","locations":[{"start":{"line":78,"column":29},"end":{"line":78,"column":35}},{"start":{"line":78,"column":39},"end":{"line":78,"column":41}}]},"7":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":20},"end":{"line":81,"column":20}},{"start":{"line":81,"column":20},"end":{"line":81,"column":20}}]},"8":{"line":83,"type":"if","locations":[{"start":{"line":83,"column":24},"end":{"line":83,"column":24}},{"start":{"line":83,"column":24},"end":{"line":83,"column":24}}]},"9":{"line":114,"type":"if","locations":[{"start":{"line":114,"column":12},"end":{"line":114,"column":12}},{"start":{"line":114,"column":12},"end":{"line":114,"column":12}}]},"10":{"line":115,"type":"if","locations":[{"start":{"line":115,"column":16},"end":{"line":115,"column":16}},{"start":{"line":115,"column":16},"end":{"line":115,"column":16}}]},"11":{"line":117,"type":"if","locations":[{"start":{"line":117,"column":20},"end":{"line":117,"column":20}},{"start":{"line":117,"column":20},"end":{"line":117,"column":20}}]},"12":{"line":117,"type":"binary-expr","locations":[{"start":{"line":117,"column":24},"end":{"line":117,"column":26}},{"start":{"line":117,"column":31},"end":{"line":117,"column":43}},{"start":{"line":117,"column":47},"end":{"line":117,"column":69}}]},"13":{"line":122,"type":"if","locations":[{"start":{"line":122,"column":16},"end":{"line":122,"column":16}},{"start":{"line":122,"column":16},"end":{"line":122,"column":16}}]},"14":{"line":123,"type":"if","locations":[{"start":{"line":123,"column":20},"end":{"line":123,"column":20}},{"start":{"line":123,"column":20},"end":{"line":123,"column":20}}]},"15":{"line":124,"type":"if","locations":[{"start":{"line":124,"column":24},"end":{"line":124,"column":24}},{"start":{"line":124,"column":24},"end":{"line":124,"column":24}}]},"16":{"line":129,"type":"if","locations":[{"start":{"line":129,"column":20},"end":{"line":129,"column":20}},{"start":{"line":129,"column":20},"end":{"line":129,"column":20}}]},"17":{"line":135,"type":"if","locations":[{"start":{"line":135,"column":20},"end":{"line":135,"column":20}},{"start":{"line":135,"column":20},"end":{"line":135,"column":20}}]},"18":{"line":151,"type":"binary-expr","locations":[{"start":{"line":151,"column":20},"end":{"line":151,"column":37}},{"start":{"line":151,"column":41},"end":{"line":151,"column":49}}]},"19":{"line":165,"type":"binary-expr","locations":[{"start":{"line":165,"column":28},"end":{"line":165,"column":41}},{"start":{"line":165,"column":45},"end":{"line":165,"column":47}}]},"20":{"line":167,"type":"if","locations":[{"start":{"line":167,"column":12},"end":{"line":167,"column":12}},{"start":{"line":167,"column":12},"end":{"line":167,"column":12}}]}},"code":["(function () { YUI.add('pluginhost-base', function (Y, NAME) {",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost"," */",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost-base"," */",""," /**"," *"," * An augmentable class, which provides the augmented class with the ability to host plugins."," * It adds plug and unplug methods to the augmented class, which can"," * be used to add or remove plugins from instances of the class."," *
"," *"," *Plugins can also be added through the constructor configuration object passed to the host class' constructor using"," * the \"plugins\" property. Supported values for the \"plugins\" property are those defined by the plug method."," *"," * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host):"," *
"," * Plug.Host's protected _initPlugins and _destroyPlugins"," * methods should be invoked by the host class at the appropriate point in the host's lifecyle."," *
"," *"," * @class Plugin.Host"," */",""," var L = Y.Lang;",""," function PluginHost() {"," this._plugins = {};"," }",""," PluginHost.prototype = {",""," /**"," * Adds a plugin to the host object. This will instantiate the"," * plugin and attach it to the configured namespace on the host object."," *"," * @method plug"," * @chainable"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," *"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," *
"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @return {Base} A reference to the host object"," */"," plug: function(Plugin, config) {"," var i, ln, ns;",""," if (L.isArray(Plugin)) {"," for (i = 0, ln = Plugin.length; i < ln; i++) {"," this.plug(Plugin[i]);"," }"," } else {"," if (Plugin && !L.isFunction(Plugin)) {"," config = Plugin.cfg;"," Plugin = Plugin.fn;"," }",""," // Plugin should be fn by now"," if (Plugin && Plugin.NS) {"," ns = Plugin.NS;",""," config = config || {};"," config.host = this;",""," if (this.hasPlugin(ns)) {"," // Update config"," if (this[ns].setAttrs) {"," this[ns].setAttrs(config);"," }"," else {"," }"," } else {"," // Create new instance"," this[ns] = new Plugin(config);"," this._plugins[ns] = Plugin;"," }"," }"," else {"," }"," }"," return this;"," },",""," /**"," * Removes a plugin from the host object. This will destroy the"," * plugin instance and delete the namespace from the host object."," *"," * @method unplug"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @return {Base} A reference to the host object"," * @chainable"," */"," unplug: function(plugin) {"," var ns = plugin,"," plugins = this._plugins;",""," if (plugin) {"," if (L.isFunction(plugin)) {"," ns = plugin.NS;"," if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {"," ns = null;"," }"," }",""," if (ns) {"," if (this[ns]) {"," if (this[ns].destroy) {"," this[ns].destroy();"," }"," delete this[ns];"," }"," if (plugins[ns]) {"," delete plugins[ns];"," }"," }"," } else {"," for (ns in this._plugins) {"," if (this._plugins.hasOwnProperty(ns)) {"," this.unplug(ns);"," }"," }"," }"," return this;"," },",""," /**"," * Determines if a plugin has plugged into this host."," *"," * @method hasPlugin"," * @param {String} ns The plugin's namespace"," * @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not."," */"," hasPlugin : function(ns) {"," return (this._plugins[ns] && this[ns]);"," },",""," /**"," * Initializes static plugins registered on the host (using the"," * Base.plug static method) and any plugins passed to the"," * instance through the \"plugins\" configuration property."," *"," * @method _initPlugins"," * @param {Object} config The configuration object with property name/value pairs."," * @private"," */",""," _initPlugins: function(config) {"," this._plugins = this._plugins || {};",""," if (this._initConfigPlugins) {"," this._initConfigPlugins(config);"," }"," },",""," /**"," * Unplugs and destroys all plugins on the host"," * @method _destroyPlugins"," * @private"," */"," _destroyPlugins: function() {"," this.unplug();"," }"," };",""," Y.namespace(\"Plugin\").Host = PluginHost;","","","}, '@VERSION@', {\"requires\": [\"yui-base\"]});","","}());"]}; } var __cov_dDY1oPzWlroRs49oPPuh3Q = __coverage__['build/pluginhost-base/pluginhost-base.js']; __cov_dDY1oPzWlroRs49oPPuh3Q.s['1']++;YUI.add('pluginhost-base',function(Y,NAME){__cov_dDY1oPzWlroRs49oPPuh3Q.f['1']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['2']++;var L=Y.Lang;__cov_dDY1oPzWlroRs49oPPuh3Q.s['3']++;function PluginHost(){__cov_dDY1oPzWlroRs49oPPuh3Q.f['2']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['4']++;this._plugins={};}__cov_dDY1oPzWlroRs49oPPuh3Q.s['5']++;PluginHost.prototype={plug:function(Plugin,config){__cov_dDY1oPzWlroRs49oPPuh3Q.f['3']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['6']++;var i,ln,ns;__cov_dDY1oPzWlroRs49oPPuh3Q.s['7']++;if(L.isArray(Plugin)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['1'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['8']++;for(i=0,ln=Plugin.length;i