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

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/widget-position/widget-position-debug.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('widget-position', function(Y) {
 
8
 
 
9
/**
 
10
 * Provides basic XY positioning support for Widgets, though an extension
 
11
 *
 
12
 * @module widget-position
 
13
 */
 
14
    var Lang = Y.Lang,
 
15
        Widget = Y.Widget,
 
16
 
 
17
        XY_COORD = "xy",
 
18
 
 
19
        POSITION = "position",
 
20
        POSITIONED = "positioned",
 
21
        BOUNDING_BOX = "boundingBox",
 
22
        RELATIVE = "relative",
 
23
 
 
24
        RENDERUI = "renderUI",
 
25
        BINDUI = "bindUI",
 
26
        SYNCUI = "syncUI",
 
27
 
 
28
        UI = Widget.UI_SRC,
 
29
 
 
30
        XYChange = "xyChange";
 
31
 
 
32
    /**
 
33
     * Widget extension, which can be used to add positioning support to the base Widget class, 
 
34
     * through the <a href="Base.html#method_build">Base.build</a> method.
 
35
     *
 
36
     * @class WidgetPosition
 
37
     * @param {Object} config User configuration object
 
38
     */
 
39
    function Position(config) {
 
40
        this._posNode = this.get(BOUNDING_BOX);
 
41
 
 
42
        // WIDGET METHOD OVERLAP
 
43
        Y.after(this._renderUIPosition, this, RENDERUI);
 
44
        Y.after(this._syncUIPosition, this, SYNCUI);
 
45
        Y.after(this._bindUIPosition, this, BINDUI);
 
46
    }
 
47
 
 
48
    /**
 
49
     * Static property used to define the default attribute 
 
50
     * configuration introduced by WidgetPosition.
 
51
     *
 
52
     * @property ATTRS
 
53
     * @static
 
54
     * @type Object
 
55
     */
 
56
    Position.ATTRS = {
 
57
 
 
58
        /**
 
59
         * @attribute x
 
60
         * @type number
 
61
         * @default 0
 
62
         *
 
63
         * @description Page X co-ordinate for the widget. This attribute acts as a facade for the 
 
64
         * xy attribute. Changes in position can be monitored by listening for xyChange events.
 
65
         */
 
66
        x: {
 
67
            setter: function(val) {
 
68
                this._setX(val);
 
69
            },
 
70
            getter: function() {
 
71
                return this._getX();
 
72
            },
 
73
            lazyAdd:false
 
74
        },
 
75
 
 
76
        /**
 
77
         * @attribute y
 
78
         * @type number
 
79
         * @default 0
 
80
         *
 
81
         * @description Page Y co-ordinate for the widget. This attribute acts as a facade for the 
 
82
         * xy attribute. Changes in position can be monitored by listening for xyChange events.
 
83
         */
 
84
        y: {
 
85
            setter: function(val) {
 
86
                this._setY(val);
 
87
            },
 
88
            getter: function() {
 
89
                return this._getY();
 
90
            },
 
91
            lazyAdd: false
 
92
        },
 
93
 
 
94
        /**
 
95
         * @attribute xy
 
96
         * @type Array
 
97
         * @default [0,0]
 
98
         *
 
99
         * @description Page XY co-ordinate pair for the widget.
 
100
         */
 
101
        xy: {
 
102
            value:[0,0],
 
103
            validator: function(val) {
 
104
                return this._validateXY(val);
 
105
            }
 
106
        }
 
107
    };
 
108
 
 
109
    /**
 
110
     * Default class used to mark the boundingBox of a positioned widget.
 
111
     *
 
112
     * @property POSITIONED_CLASS_NAME
 
113
     * @type String
 
114
     * @default "yui-widget-positioned"
 
115
     * @static
 
116
     */
 
117
    Position.POSITIONED_CLASS_NAME = Widget.getClassName(POSITIONED);
 
118
 
 
119
    Position.prototype = {
 
120
 
 
121
        /**
 
122
         * Creates/Initializes the DOM to support xy page positioning.
 
123
         * <p>
 
124
         * This method in invoked after renderUI is invoked for the Widget class
 
125
         * using YUI's aop infrastructure.
 
126
         * </p>
 
127
         * @method _renderUIPosition
 
128
         * @protected
 
129
         */
 
130
        _renderUIPosition : function() {
 
131
            this._posNode.addClass(Position.POSITIONED_CLASS_NAME);
 
132
        },
 
133
 
 
134
        /**
 
135
         * Synchronizes the UI to match the Widgets xy page position state.
 
136
         * <p>
 
137
         * This method in invoked after syncUI is invoked for the Widget class
 
138
         * using YUI's aop infrastructure.
 
139
         * </p>
 
140
         * @method _syncUIPosition
 
141
         * @protected
 
142
         */
 
143
        _syncUIPosition : function() {
 
144
            var posNode = this._posNode;
 
145
            if (posNode.getStyle(POSITION) === RELATIVE) {
 
146
                this.syncXY();
 
147
            }
 
148
            this._uiSetXY(this.get(XY_COORD));
 
149
        },
 
150
 
 
151
        /**
 
152
         * Binds event listeners responsible for updating the UI state in response to 
 
153
         * Widget position related state changes.
 
154
         * <p>
 
155
         * This method in invoked after bindUI is invoked for the Widget class
 
156
         * using YUI's aop infrastructure.
 
157
         * </p>
 
158
         * @method _bindUIPosition
 
159
         * @protected
 
160
         */
 
161
        _bindUIPosition :function() {
 
162
            this.after(XYChange, this._afterXYChange);
 
163
        },
 
164
 
 
165
        /**
 
166
         * Moves the Widget to the specified page xy co-ordinate position.
 
167
         *
 
168
         * @method move
 
169
         *
 
170
         * @param {Number} x The new x position
 
171
         * @param {Number} y The new y position
 
172
         * <p>Or</p>
 
173
         * @param {Array} x, y values passed as an array ([x, y]), to support
 
174
         * simple pass through of Node.getXY results
 
175
         */
 
176
        move: function () {
 
177
            var args = arguments,
 
178
                coord = (Lang.isArray(args[0])) ? args[0] : [args[0], args[1]];
 
179
                this.set(XY_COORD, coord);
 
180
        },
 
181
 
 
182
        /**
 
183
         * Synchronizes the Panel's "xy", "x", and "y" properties with the 
 
184
         * Widget's position in the DOM.
 
185
         *
 
186
         * @method syncXY
 
187
         */
 
188
        syncXY : function () {
 
189
            this.set(XY_COORD, this._posNode.getXY(), {src: UI});
 
190
        },
 
191
 
 
192
        /**
 
193
         * Default validator for the XY attribute
 
194
         *
 
195
         * @method _validateXY
 
196
         * @protected
 
197
         * @param {Array} val The XY page co-ordinate value which is being set.
 
198
         * @return {boolean} true if valid, false if not.
 
199
         */
 
200
        _validateXY : function(val) {
 
201
            return (Lang.isArray(val) && Lang.isNumber(val[0]) && Lang.isNumber(val[1]));
 
202
        },
 
203
 
 
204
        /**
 
205
         * Default setter for the X attribute. The setter passes the X value through
 
206
         * to the XY attribute, which is the sole store for the XY state.
 
207
         *
 
208
         * @method _setX
 
209
         * @protected
 
210
         * @param {Number} val The X page co-ordinate value
 
211
         */
 
212
        _setX : function(val) {
 
213
            this.set(XY_COORD, [val, this.get(XY_COORD)[1]]);
 
214
        },
 
215
 
 
216
        /**
 
217
         * Default setter for the Y attribute. The setter passes the Y value through
 
218
         * to the XY attribute, which is the sole store for the XY state.
 
219
         *
 
220
         * @method _setY
 
221
         * @protected
 
222
         * @param {Number} val The Y page co-ordinate value
 
223
         */
 
224
        _setY : function(val) {
 
225
            this.set(XY_COORD, [this.get(XY_COORD)[0], val]);
 
226
        },
 
227
 
 
228
        /**
 
229
         * Default getter for the X attribute. The value is retrieved from 
 
230
         * the XY attribute, which is the sole store for the XY state.
 
231
         *
 
232
         * @method _getX
 
233
         * @protected 
 
234
         * @return {Number} The X page co-ordinate value
 
235
         */
 
236
        _getX : function() {
 
237
            return this.get(XY_COORD)[0];
 
238
        },
 
239
 
 
240
        /**
 
241
         * Default getter for the Y attribute. The value is retrieved from 
 
242
         * the XY attribute, which is the sole store for the XY state.
 
243
         *
 
244
         * @method _getY
 
245
         * @protected 
 
246
         * @return {Number} The Y page co-ordinate value
 
247
         */
 
248
        _getY : function() {
 
249
            return this.get(XY_COORD)[1];
 
250
        },
 
251
 
 
252
        /**
 
253
         * Default attribute change listener for the xy attribute, responsible
 
254
         * for updating the UI, in response to attribute changes.
 
255
         * 
 
256
         * @method _afterXYChange
 
257
         * @protected
 
258
         * @param {EventFacade} e The event facade for the attribute change
 
259
         */
 
260
        _afterXYChange : function(e) {
 
261
            if (e.src != UI) {
 
262
                this._uiSetXY(e.newVal);
 
263
            }
 
264
        },
 
265
 
 
266
        /**
 
267
         * Updates the UI to reflect the XY page co-ordinates passed in.
 
268
         * 
 
269
         * @method _uiSetXY
 
270
         * @protected
 
271
         * @param {String} val The XY page co-ordinates value to be reflected in the UI
 
272
         */
 
273
        _uiSetXY : function(val) {
 
274
            this._posNode.setXY(val);
 
275
        }
 
276
    };
 
277
 
 
278
    Y.WidgetPosition = Position;
 
279
 
 
280
 
 
281
}, '3.5.1' ,{requires:['base-build', 'node-screen', 'widget']});