~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/yui/3.4.1/pluginhost-config/pluginhost-config-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('pluginhost-config', function(Y) {
8
 
 
9
 
    /**
10
 
     * Adds pluginhost constructor configuration and static configuration support
11
 
     * @submodule pluginhost-config
12
 
     */
13
 
 
14
 
    var PluginHost = Y.Plugin.Host,
15
 
        L = Y.Lang;
16
 
 
17
 
    /**
18
 
     * A protected initialization method, used by the host class to initialize
19
 
     * plugin configurations passed the constructor, through the config object.
20
 
     * 
21
 
     * Host objects should invoke this method at the appropriate time in their
22
 
     * construction lifecycle.
23
 
     * 
24
 
     * @method _initConfigPlugins
25
 
     * @param {Object} config The configuration object passed to the constructor
26
 
     * @protected
27
 
     * @for Plugin.Host
28
 
     */
29
 
    PluginHost.prototype._initConfigPlugins = function(config) {
30
 
 
31
 
        // Class Configuration
32
 
        var classes = (this._getClasses) ? this._getClasses() : [this.constructor],
33
 
            plug = [],
34
 
            unplug = {},
35
 
            constructor, i, classPlug, classUnplug, pluginClassName;
36
 
 
37
 
        // TODO: Room for optimization. Can we apply statically/unplug in same pass?
38
 
        for (i = classes.length - 1; i >= 0; i--) {
39
 
            constructor = classes[i];
40
 
 
41
 
            classUnplug = constructor._UNPLUG;
42
 
            if (classUnplug) {
43
 
                // subclasses over-write
44
 
                Y.mix(unplug, classUnplug, true);
45
 
            }
46
 
 
47
 
            classPlug = constructor._PLUG;
48
 
            if (classPlug) {
49
 
                // subclasses over-write
50
 
                Y.mix(plug, classPlug, true);
51
 
            }
52
 
        }
53
 
 
54
 
        for (pluginClassName in plug) {
55
 
            if (plug.hasOwnProperty(pluginClassName)) {
56
 
                if (!unplug[pluginClassName]) {
57
 
                    this.plug(plug[pluginClassName]);
58
 
                }
59
 
            }
60
 
        }
61
 
 
62
 
        // User Configuration
63
 
        if (config && config.plugins) {
64
 
            this.plug(config.plugins);
65
 
        }
66
 
    };
67
 
    
68
 
    /**
69
 
     * Registers plugins to be instantiated at the class level (plugins 
70
 
     * which should be plugged into every instance of the class by default).
71
 
     *
72
 
     * @method plug
73
 
     * @static
74
 
     *
75
 
     * @param {Function} hostClass The host class on which to register the plugins
76
 
     * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
77
 
     * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
78
 
     * @for Plugin.Host
79
 
     */
80
 
    PluginHost.plug = function(hostClass, plugin, config) {
81
 
        // Cannot plug into Base, since Plugins derive from Base [ will cause infinite recurrsion ]
82
 
        var p, i, l, name;
83
 
    
84
 
        if (hostClass !== Y.Base) {
85
 
            hostClass._PLUG = hostClass._PLUG || {};
86
 
    
87
 
            if (!L.isArray(plugin)) {
88
 
                if (config) {
89
 
                    plugin = {fn:plugin, cfg:config};
90
 
                }
91
 
                plugin = [plugin];
92
 
            }
93
 
    
94
 
            for (i = 0, l = plugin.length; i < l;i++) {
95
 
                p = plugin[i];
96
 
                name = p.NAME || p.fn.NAME;
97
 
                hostClass._PLUG[name] = p;
98
 
            }
99
 
        }
100
 
    };
101
 
 
102
 
    /**
103
 
     * Unregisters any class level plugins which have been registered by the host class, or any
104
 
     * other class in the hierarchy.
105
 
     *
106
 
     * @method unplug
107
 
     * @static
108
 
     *
109
 
     * @param {Function} hostClass The host class from which to unregister the plugins
110
 
     * @param {Function | Array} plugin The plugin class, or an array of plugin classes
111
 
     * @for Plugin.Host
112
 
     */
113
 
    PluginHost.unplug = function(hostClass, plugin) {
114
 
        var p, i, l, name;
115
 
    
116
 
        if (hostClass !== Y.Base) {
117
 
            hostClass._UNPLUG = hostClass._UNPLUG || {};
118
 
    
119
 
            if (!L.isArray(plugin)) {
120
 
                plugin = [plugin];
121
 
            }
122
 
    
123
 
            for (i = 0, l = plugin.length; i < l; i++) {
124
 
                p = plugin[i];
125
 
                name = p.NAME;
126
 
                if (!hostClass._PLUG[name]) {
127
 
                    hostClass._UNPLUG[name] = p;
128
 
                } else {
129
 
                    delete hostClass._PLUG[name];
130
 
                }
131
 
            }
132
 
        }
133
 
    };
134
 
 
135
 
 
136
 
}, '3.4.1' ,{requires:['pluginhost-base']});