/usr/share/javascript/yui3/widget-child/widget-child.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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('widget-child', function(Y) {
/**
* Extension enabling a Widget to be a child of another Widget.
*
* @module widget-child
*/
var Lang = Y.Lang;
/**
* Widget extension providing functionality enabling a Widget to be a
* child of another Widget.
*
* @class WidgetChild
* @param {Object} config User configuration object.
*/
function Child() {
// Widget method overlap
Y.after(this._syncUIChild, this, "syncUI");
Y.after(this._bindUIChild, this, "bindUI");
}
Child.ATTRS = {
/**
* @attribute selected
* @type Number
* @default 0
*
* @description Number indicating if the Widget is selected. Possible
* values are:
* <dl>
* <dt>0</dt> <dd>(Default) Not selected</dd>
* <dt>1</dt> <dd>Fully selected</dd>
* <dt>2</dt> <dd>Partially selected</dd>
* </dl>
*/
selected: {
value: 0,
validator: Lang.isNumber
},
/**
* @attribute index
* @type Number
* @readOnly
*
* @description Number representing the Widget's ordinal position in its
* parent Widget.
*/
index: {
readOnly: true,
getter: function () {
var parent = this.get("parent"),
index = -1;
if (parent) {
index = parent.indexOf(this);
}
return index;
}
},
/**
* @attribute parent
* @type Widget
* @readOnly
*
* @description Retrieves the parent of the Widget in the object hierarchy.
*/
parent: {
readOnly: true
},
/**
* @attribute depth
* @type Number
* @default -1
* @readOnly
*
* @description Number representing the depth of this Widget relative to
* the root Widget in the object heirarchy.
*/
depth: {
readOnly: true,
getter: function () {
var parent = this.get("parent"),
root = this.get("root"),
depth = -1;
while (parent) {
depth = (depth + 1);
if (parent == root) {
break;
}
parent = parent.get("parent");
}
return depth;
}
},
/**
* @attribute root
* @type Widget
* @readOnly
*
* @description Returns the root Widget in the object hierarchy. If the
* ROOT_TYPE property is set, the search for the root Widget will be
* constrained to parent Widgets of the specified type.
*/
root: {
readOnly: true,
getter: function () {
var getParent = function (child) {
var parent = child.get("parent"),
FnRootType = child.ROOT_TYPE,
criteria = parent;
if (FnRootType) {
criteria = (parent && Y.instanceOf(parent, FnRootType));
}
return (criteria ? getParent(parent) : child);
};
return getParent(this);
}
}
};
Child.prototype = {
/**
* Constructor reference used to determine the root of a Widget-based
* object tree.
* <p>
* Currently used to control the behavior of the <code>root</code>
* attribute so that recursing up the object heirarchy can be constrained
* to a specific type of Widget. Widget authors should set this property
* to the constructor function for a given Widget implementation.
* </p>
*
* @property ROOT_TYPE
* @type Object
*/
ROOT_TYPE: null,
/**
* Returns the node on which to bind delegate listeners.
*
* Override of Widget's implementation of _getUIEventNode() to ensure that
* all event listeners are bound to the Widget's topmost DOM element.
* This ensures that the firing of each type of Widget UI event (click,
* mousedown, etc.) is facilitated by a single, top-level, delegated DOM
* event listener.
*
* @method _getUIEventNode
* @for Widget
* @protected
*/
_getUIEventNode: function () {
var root = this.get("root"),
returnVal;
if (root) {
returnVal = root.get("boundingBox");
}
return returnVal;
},
/**
* @method next
* @description Returns the Widget's next sibling.
* @param {Boolean} circular Boolean indicating if the parent's first child
* should be returned if the child has no next sibling.
* @return {Widget} Widget instance.
*/
next: function (circular) {
var parent = this.get("parent"),
sibling;
if (parent) {
sibling = parent.item((this.get("index")+1));
}
if (!sibling && circular) {
sibling = parent.item(0);
}
return sibling;
},
/**
* @method previous
* @description Returns the Widget's previous sibling.
* @param {Boolean} circular Boolean indicating if the parent's last child
* should be returned if the child has no previous sibling.
* @return {Widget} Widget instance.
*/
previous: function (circular) {
var parent = this.get("parent"),
index = this.get("index"),
sibling;
if (parent && index > 0) {
sibling = parent.item([(index-1)]);
}
if (!sibling && circular) {
sibling = parent.item((parent.size() - 1));
}
return sibling;
},
// Override of Y.WidgetParent.remove()
// Sugar implementation allowing a child to remove itself from its parent.
remove: function (index) {
var parent,
removed;
if (Lang.isNumber(index)) {
removed = Y.WidgetParent.prototype.remove.apply(this, arguments);
}
else {
parent = this.get("parent");
if (parent) {
removed = parent.remove(this.get("index"));
}
}
return removed;
},
/**
* @method isRoot
* @description Determines if the Widget is the root Widget in the
* object hierarchy.
* @return {Boolean} Boolean indicating if Widget is the root Widget in the
* object hierarchy.
*/
isRoot: function () {
return (this == this.get("root"));
},
/**
* @method ancestor
* @description Returns the Widget instance at the specified depth.
* @param {number} depth Number representing the depth of the ancestor.
* @return {Widget} Widget instance.
*/
ancestor: function (depth) {
var root = this.get("root"),
parent;
if (this.get("depth") > depth) {
parent = this.get("parent");
while (parent != root && parent.get("depth") > depth) {
parent = parent.get("parent");
}
}
return parent;
},
/**
* Updates the UI to reflect the <code>selected</code> attribute value.
*
* @method _uiSetChildSelected
* @protected
* @param {number} selected The selected value to be reflected in the UI.
*/
_uiSetChildSelected: function (selected) {
var box = this.get("boundingBox"),
sClassName = this.getClassName("selected");
if (selected === 0) {
box.removeClass(sClassName);
}
else {
box.addClass(sClassName);
}
},
/**
* Default attribute change listener for the <code>selected</code>
* attribute, responsible for updating the UI, in response to
* attribute changes.
*
* @method _afterChildSelectedChange
* @protected
* @param {EventFacade} event The event facade for the attribute change.
*/
_afterChildSelectedChange: function (event) {
this._uiSetChildSelected(event.newVal);
},
/**
* Synchronizes the UI to match the WidgetChild state.
* <p>
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
*
* @method _syncUIChild
* @protected
*/
_syncUIChild: function () {
this._uiSetChildSelected(this.get("selected"));
},
/**
* Binds event listeners responsible for updating the UI state in response
* to WidgetChild related state changes.
* <p>
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _bindUIChild
* @protected
*/
_bindUIChild: function () {
this.after("selectedChange", this._afterChildSelectedChange);
}
};
Y.WidgetChild = Child;
}, '3.5.1' ,{requires:['base-build', 'widget']});
|