~lutostag/ubuntu/trusty/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/power_parameters.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-03-28 10:43:53 UTC
  • mto: This revision was merged to the branch mainline in revision 57.
  • Revision ID: package-import@ubuntu.com-20140328104353-ekpolg0pm5xnvq2s
Tags: upstream-1.5+bzr2204
ImportĀ upstreamĀ versionĀ 1.5+bzr2204

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2012 Canonical Ltd.  This software is licensed under the
 
1
/* Copyright 2012-2014 Canonical Ltd.  This software is licensed under the
2
2
 * GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 *
4
4
 * Power parameters utilities.
36
36
    * - cfg.driverNode is the node containing a 'select' element.  When
37
37
    *   the selected element will change, the srcNode HTML will be
38
38
    *   updated.
39
 
    * - cfg.driverEnum is an dictionary which contains all the possible values
40
 
    *   of the driverNode's select element.
41
 
    * - cfg.templatePrefix is the prefix string which will be used to fetch
42
 
    *   all the templates for each possible value of driverEnum.
 
39
    * - cfg.driverEnum is an array containing all possible values for the
 
40
    *   driverNode's select element.  Each value will have its own template to
 
41
    *   define additional parameter fields.  For example, each power type has
 
42
    *   its own set of power parameter fields, as defined by a template for
 
43
    *   that power type.  Selecting a power type on a node's edit page will
 
44
    *   reveal input fields for the power parameters associated with that power
 
45
    *   type.  Each power type has a template with an HTML ID like
 
46
    *   "power-parameter-form-<power type>" to define its power parameters.
 
47
    *   The templates are defined as script entries with a MIME type of
 
48
    *   "text/x-template".
 
49
    * - cfg.templatePrefix is a CSS selector prefix.  It will be used to select
 
50
    *   the templates for the respective enumeration values defined in
 
51
    *   driverEnum.
43
52
    *
44
53
    * @method initializer
45
54
    */
50
59
    },
51
60
 
52
61
   /**
53
 
    * Create a dictionary containing the templates for all the possible
54
 
    * values from 'this.driverEnum'.
 
62
    * Create a dictionary containing the respective templates for all values
 
63
    * in 'this.driverEnum'.
55
64
    *
56
65
    * @method initTemplates
57
66
    */
58
67
    initTemplates: function() {
 
68
        var counter;
59
69
        this.templates = {};
60
 
        var driverValue;
61
 
        for (driverValue in this.driverEnum) {
62
 
            if (this.driverEnum.hasOwnProperty(driverValue)) {
63
 
                var type = this.driverEnum[driverValue];
64
 
                var template = Y.one(
65
 
                    this.templatePrefix + type).getContent();
66
 
                this.templates[type] = template;
67
 
            }
 
70
        for (counter = 0; counter < this.driverEnum.length; counter++) {
 
71
            var driver = this.driverEnum[counter];
 
72
            var template = Y.one(this.templatePrefix + driver).getContent();
 
73
            this.templates[driver] = template;
68
74
        }
69
75
    },
70
76