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