/usr/share/javascript/yui3/widget-position/widget-position.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 | /*
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-position', function(Y) {
/**
* Provides basic XY positioning support for Widgets, though an extension
*
* @module widget-position
*/
var Lang = Y.Lang,
Widget = Y.Widget,
XY_COORD = "xy",
POSITION = "position",
POSITIONED = "positioned",
BOUNDING_BOX = "boundingBox",
RELATIVE = "relative",
RENDERUI = "renderUI",
BINDUI = "bindUI",
SYNCUI = "syncUI",
UI = Widget.UI_SRC,
XYChange = "xyChange";
/**
* Widget extension, which can be used to add positioning support to the base Widget class,
* through the <a href="Base.html#method_build">Base.build</a> method.
*
* @class WidgetPosition
* @param {Object} config User configuration object
*/
function Position(config) {
this._posNode = this.get(BOUNDING_BOX);
// WIDGET METHOD OVERLAP
Y.after(this._renderUIPosition, this, RENDERUI);
Y.after(this._syncUIPosition, this, SYNCUI);
Y.after(this._bindUIPosition, this, BINDUI);
}
/**
* Static property used to define the default attribute
* configuration introduced by WidgetPosition.
*
* @property ATTRS
* @static
* @type Object
*/
Position.ATTRS = {
/**
* @attribute x
* @type number
* @default 0
*
* @description Page X co-ordinate for the widget. This attribute acts as a facade for the
* xy attribute. Changes in position can be monitored by listening for xyChange events.
*/
x: {
setter: function(val) {
this._setX(val);
},
getter: function() {
return this._getX();
},
lazyAdd:false
},
/**
* @attribute y
* @type number
* @default 0
*
* @description Page Y co-ordinate for the widget. This attribute acts as a facade for the
* xy attribute. Changes in position can be monitored by listening for xyChange events.
*/
y: {
setter: function(val) {
this._setY(val);
},
getter: function() {
return this._getY();
},
lazyAdd: false
},
/**
* @attribute xy
* @type Array
* @default [0,0]
*
* @description Page XY co-ordinate pair for the widget.
*/
xy: {
value:[0,0],
validator: function(val) {
return this._validateXY(val);
}
}
};
/**
* Default class used to mark the boundingBox of a positioned widget.
*
* @property POSITIONED_CLASS_NAME
* @type String
* @default "yui-widget-positioned"
* @static
*/
Position.POSITIONED_CLASS_NAME = Widget.getClassName(POSITIONED);
Position.prototype = {
/**
* Creates/Initializes the DOM to support xy page positioning.
* <p>
* This method in invoked after renderUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _renderUIPosition
* @protected
*/
_renderUIPosition : function() {
this._posNode.addClass(Position.POSITIONED_CLASS_NAME);
},
/**
* Synchronizes the UI to match the Widgets xy page position state.
* <p>
* This method in invoked after syncUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _syncUIPosition
* @protected
*/
_syncUIPosition : function() {
var posNode = this._posNode;
if (posNode.getStyle(POSITION) === RELATIVE) {
this.syncXY();
}
this._uiSetXY(this.get(XY_COORD));
},
/**
* Binds event listeners responsible for updating the UI state in response to
* Widget position related state changes.
* <p>
* This method in invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _bindUIPosition
* @protected
*/
_bindUIPosition :function() {
this.after(XYChange, this._afterXYChange);
},
/**
* Moves the Widget to the specified page xy co-ordinate position.
*
* @method move
*
* @param {Number} x The new x position
* @param {Number} y The new y position
* <p>Or</p>
* @param {Array} x, y values passed as an array ([x, y]), to support
* simple pass through of Node.getXY results
*/
move: function () {
var args = arguments,
coord = (Lang.isArray(args[0])) ? args[0] : [args[0], args[1]];
this.set(XY_COORD, coord);
},
/**
* Synchronizes the Panel's "xy", "x", and "y" properties with the
* Widget's position in the DOM.
*
* @method syncXY
*/
syncXY : function () {
this.set(XY_COORD, this._posNode.getXY(), {src: UI});
},
/**
* Default validator for the XY attribute
*
* @method _validateXY
* @protected
* @param {Array} val The XY page co-ordinate value which is being set.
* @return {boolean} true if valid, false if not.
*/
_validateXY : function(val) {
return (Lang.isArray(val) && Lang.isNumber(val[0]) && Lang.isNumber(val[1]));
},
/**
* Default setter for the X attribute. The setter passes the X value through
* to the XY attribute, which is the sole store for the XY state.
*
* @method _setX
* @protected
* @param {Number} val The X page co-ordinate value
*/
_setX : function(val) {
this.set(XY_COORD, [val, this.get(XY_COORD)[1]]);
},
/**
* Default setter for the Y attribute. The setter passes the Y value through
* to the XY attribute, which is the sole store for the XY state.
*
* @method _setY
* @protected
* @param {Number} val The Y page co-ordinate value
*/
_setY : function(val) {
this.set(XY_COORD, [this.get(XY_COORD)[0], val]);
},
/**
* Default getter for the X attribute. The value is retrieved from
* the XY attribute, which is the sole store for the XY state.
*
* @method _getX
* @protected
* @return {Number} The X page co-ordinate value
*/
_getX : function() {
return this.get(XY_COORD)[0];
},
/**
* Default getter for the Y attribute. The value is retrieved from
* the XY attribute, which is the sole store for the XY state.
*
* @method _getY
* @protected
* @return {Number} The Y page co-ordinate value
*/
_getY : function() {
return this.get(XY_COORD)[1];
},
/**
* Default attribute change listener for the xy attribute, responsible
* for updating the UI, in response to attribute changes.
*
* @method _afterXYChange
* @protected
* @param {EventFacade} e The event facade for the attribute change
*/
_afterXYChange : function(e) {
if (e.src != UI) {
this._uiSetXY(e.newVal);
}
},
/**
* Updates the UI to reflect the XY page co-ordinates passed in.
*
* @method _uiSetXY
* @protected
* @param {String} val The XY page co-ordinates value to be reflected in the UI
*/
_uiSetXY : function(val) {
this._posNode.setXY(val);
}
};
Y.WidgetPosition = Position;
}, '3.5.1' ,{requires:['base-build', 'node-screen', 'widget']});
|