~ubuntu-branches/ubuntu/precise/maas/precise-security

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/attribute-extras/attribute-extras.js

Tags: 1.2+bzr1373+dfsg-0ubuntu1~12.04.4
* SECURITY UPDATE: failure to authenticate downloaded content (LP: #1039513)
  - debian/patches/CVE-2013-1058.patch: Authenticate downloaded files with
    GnuPG and MD5SUM files. Thanks to Julian Edwards.
  - CVE-2013-1058
* SECURITY UPDATE: configuration options may be loaded from current working
  directory (LP: #1158425)
  - debian/patches/CVE-2013-1057-1-2.patch: Do not load configuration
    options from the current working directory. Thanks to Julian Edwards.
  - CVE-2013-1057

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('attribute-extras', function(Y) {
 
8
 
 
9
    /**
 
10
     * The attribute module provides an augmentable Attribute implementation, which 
 
11
     * adds configurable attributes and attribute change events to the class being 
 
12
     * augmented. It also provides a State class, which is used internally by Attribute,
 
13
     * but can also be used independently to provide a name/property/value data structure to
 
14
     * store state.
 
15
     *
 
16
     * @module attribute
 
17
     */
 
18
 
 
19
    /**
 
20
     * The attribute-extras submodule provides less commonly used attribute methods, and can 
 
21
     * be augmented/mixed into an implemention which used attribute-core.
 
22
     *
 
23
     * @module attribute
 
24
     * @submodule attribute-extras
 
25
     */
 
26
    var BROADCAST = "broadcast",
 
27
        PUBLISHED = "published",
 
28
        INIT_VALUE = "initValue",
 
29
 
 
30
        MODIFIABLE = {
 
31
            readOnly:1,
 
32
            writeOnce:1,
 
33
            getter:1,
 
34
            broadcast:1
 
35
        };
 
36
 
 
37
    /**
 
38
     * A augmentable implementation for AttributeCore, providing less frequently used 
 
39
     * methods for Attribute management such as modifyAttrs(), removeAttr and reset()   
 
40
     *
 
41
     * @class AttributeExtras
 
42
     */
 
43
    function AttributeExtras() {}
 
44
 
 
45
    AttributeExtras.prototype = {
 
46
 
 
47
        /**
 
48
         * Updates the configuration of an attribute which has already been added.
 
49
         * <p>
 
50
         * The properties which can be modified through this interface are limited
 
51
         * to the following subset of attributes, which can be safely modified
 
52
         * after a value has already been set on the attribute: readOnly, writeOnce, 
 
53
         * broadcast and getter.
 
54
         * </p>
 
55
         * @method modifyAttr
 
56
         * @param {String} name The name of the attribute whose configuration is to be updated.
 
57
         * @param {Object} config An object with configuration property/value pairs, specifying the configuration properties to modify.
 
58
         */
 
59
        modifyAttr: function(name, config) {
 
60
            var host = this, // help compression
 
61
                prop, state;
 
62
 
 
63
            if (host.attrAdded(name)) {
 
64
 
 
65
                if (host._isLazyAttr(name)) {
 
66
                    host._addLazyAttr(name);
 
67
                }
 
68
 
 
69
                state = host._state;
 
70
                for (prop in config) {
 
71
                    if (MODIFIABLE[prop] && config.hasOwnProperty(prop)) {
 
72
                        state.add(name, prop, config[prop]);
 
73
 
 
74
                        // If we reconfigured broadcast, need to republish
 
75
                        if (prop === BROADCAST) {
 
76
                            state.remove(name, PUBLISHED);
 
77
                        }
 
78
                    }
 
79
                }
 
80
            }
 
81
 
 
82
        },
 
83
 
 
84
        /**
 
85
         * Removes an attribute from the host object
 
86
         *
 
87
         * @method removeAttr
 
88
         * @param {String} name The name of the attribute to be removed.
 
89
         */
 
90
        removeAttr: function(name) {
 
91
            this._state.removeAll(name);
 
92
        },
 
93
 
 
94
        /**
 
95
         * Resets the attribute (or all attributes) to its initial value, as long as
 
96
         * the attribute is not readOnly, or writeOnce.
 
97
         *
 
98
         * @method reset
 
99
         * @param {String} name Optional. The name of the attribute to reset.  If omitted, all attributes are reset.
 
100
         * @return {Object} A reference to the host object.
 
101
         * @chainable
 
102
         */
 
103
        reset : function(name) {
 
104
            var host = this;  // help compression
 
105
 
 
106
            if (name) {
 
107
                if (host._isLazyAttr(name)) {
 
108
                    host._addLazyAttr(name);
 
109
                }
 
110
                host.set(name, host._state.get(name, INIT_VALUE));
 
111
            } else {
 
112
                Y.each(host._state.data, function(v, n) {
 
113
                    host.reset(n);
 
114
                });
 
115
            }
 
116
            return host;
 
117
        },
 
118
 
 
119
        /**
 
120
         * Returns an object with the configuration properties (and value)
 
121
         * for the given attribute. If attrName is not provided, returns the
 
122
         * configuration properties for all attributes.
 
123
         *
 
124
         * @method _getAttrCfg
 
125
         * @protected
 
126
         * @param {String} name Optional. The attribute name. If not provided, the method will return the configuration for all attributes.
 
127
         * @return {Object} The configuration properties for the given attribute, or all attributes.
 
128
         */
 
129
        _getAttrCfg : function(name) {
 
130
            var o,
 
131
                state = this._state;
 
132
 
 
133
            if (name) {
 
134
                o = state.getAll(name) || {};
 
135
            } else {
 
136
                o = {};
 
137
                Y.each(state.data, function(v, n) {
 
138
                    o[n] = state.getAll(n);
 
139
                }); 
 
140
            }
 
141
 
 
142
            return o;
 
143
        }
 
144
    };
 
145
 
 
146
    Y.AttributeExtras = AttributeExtras;
 
147
 
 
148
 
 
149
}, '3.5.1' );