~ubuntu-branches/ubuntu/lucid/loggerhead/lucid-security

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/widget/widget-position-debug.js

  • Committer: Bazaar Package Importer
  • Author(s): James Westby, Roland Mas, Jelmer Vernooij, James Westby
  • Date: 2009-08-26 13:18:03 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090826131803-0ce1fhaetci8b0c5
Tags: 1.17-0ubuntu1
[ Roland Mas ]
* Use the YUI library provided by libjs-yui. (Closes: #511286)

[ Jelmer Vernooij ]
* Use my debian.org address in Uploaders field.
* Add ${misc:Depends} to please lintian.
* Suggest recent version of paste, which doesn't expose internal port
  numbers in links. (Closes: #507000)
* Bump standards version to 3.8.1.

[ James Westby ]
* New upstream release.
* Drop get-orig-source rule in favour of debian/watch.
* Add python-pkg-resources and python-paste to Build-Depends,
  python-pkg-resources to Depends and python-simplejson to
  Recommends due to dependency changes.

Show diffs side-by-side

added added

removed removed

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