~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/widget-child/widget-child-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('widget-child', function(Y) {
8
 
 
9
 
/**
10
 
 * Extension enabling a Widget to be a child of another Widget.
11
 
 *
12
 
 * @module widget-child
13
 
 */
14
 
 
15
 
var Lang = Y.Lang;
16
 
 
17
 
/**
18
 
 * Widget extension providing functionality enabling a Widget to be a 
19
 
 * child of another Widget.
20
 
 *
21
 
 * @class WidgetChild
22
 
 * @param {Object} config User configuration object.
23
 
*/
24
 
function Child() {
25
 
 
26
 
    //  Widget method overlap
27
 
    Y.after(this._syncUIChild, this, "syncUI");
28
 
    Y.after(this._bindUIChild, this, "bindUI");
29
 
 
30
 
}
31
 
 
32
 
Child.ATTRS = {
33
 
 
34
 
    /**
35
 
     * @attribute selected
36
 
     * @type Number
37
 
     * @default 0
38
 
     *
39
 
     * @description Number indicating if the Widget is selected.  Possible 
40
 
     * values are:
41
 
     * <dl>
42
 
     * <dt>0</dt> <dd>(Default) Not selected</dd>
43
 
     * <dt>1</dt> <dd>Fully selected</dd>
44
 
     * <dt>2</dt> <dd>Partially selected</dd>
45
 
     * </dl>
46
 
    */
47
 
    selected: {   
48
 
        value: 0,
49
 
        validator: Lang.isNumber
50
 
    },
51
 
 
52
 
 
53
 
    /**
54
 
     * @attribute index
55
 
     * @type Number
56
 
     * @readOnly
57
 
     *
58
 
     * @description Number representing the Widget's ordinal position in its 
59
 
     * parent Widget.
60
 
     */
61
 
    index: {
62
 
        readOnly: true,
63
 
        getter: function () {
64
 
            
65
 
            var parent = this.get("parent"),
66
 
                index = -1;
67
 
            
68
 
            if (parent) {
69
 
                index = parent.indexOf(this);
70
 
            }
71
 
            
72
 
            return index;
73
 
            
74
 
        }
75
 
    },
76
 
 
77
 
 
78
 
    /**
79
 
     * @attribute parent
80
 
     * @type Widget
81
 
     * @readOnly
82
 
     *
83
 
     * @description Retrieves the parent of the Widget in the object hierarchy.
84
 
    */
85
 
    parent: {
86
 
        readOnly: true
87
 
    },
88
 
 
89
 
 
90
 
    /**
91
 
     * @attribute depth
92
 
     * @type Number
93
 
     * @default -1 
94
 
     * @readOnly         
95
 
     *
96
 
     * @description Number representing the depth of this Widget relative to 
97
 
     * the root Widget in the object heirarchy.
98
 
     */
99
 
    depth: {
100
 
        readOnly: true,
101
 
        getter: function () {
102
 
            
103
 
            var parent = this.get("parent"),
104
 
                root = this.get("root"),
105
 
                depth = -1;
106
 
            
107
 
            while (parent) {
108
 
 
109
 
                depth = (depth + 1);
110
 
 
111
 
                if (parent == root) {
112
 
                    break;
113
 
                }
114
 
 
115
 
                parent = parent.get("parent");
116
 
 
117
 
            }
118
 
            
119
 
            return depth;
120
 
            
121
 
        }
122
 
    },
123
 
 
124
 
    /**
125
 
     * @attribute root
126
 
     * @type Widget 
127
 
     * @readOnly         
128
 
     *
129
 
     * @description Returns the root Widget in the object hierarchy.  If the
130
 
     * ROOT_TYPE property is set, the search for the root Widget will be 
131
 
     * constrained to parent Widgets of the specified type.
132
 
     */
133
 
    root: {
134
 
        readOnly: true,
135
 
        getter: function () {
136
 
 
137
 
            var getParent = function (child) {
138
 
 
139
 
                var parent = child.get("parent"),
140
 
                    FnRootType = child.ROOT_TYPE,
141
 
                    criteria = parent;
142
 
 
143
 
                if (FnRootType) {
144
 
                    criteria = (parent && Y.instanceOf(parent, FnRootType));
145
 
                }
146
 
 
147
 
                return (criteria ? getParent(parent) : child);
148
 
                
149
 
            };
150
 
 
151
 
            return getParent(this);
152
 
            
153
 
        }
154
 
    }
155
 
 
156
 
};
157
 
 
158
 
Child.prototype = {
159
 
 
160
 
    /**
161
 
     * Constructor reference used to determine the root of a Widget-based 
162
 
     * object tree.
163
 
     * <p>
164
 
     * Currently used to control the behavior of the <code>root</code>  
165
 
     * attribute so that recursing up the object heirarchy can be constrained 
166
 
     * to a specific type of Widget.  Widget authors should set this property
167
 
     * to the constructor function for a given Widget implementation.
168
 
     * </p>
169
 
     *
170
 
     * @property ROOT_TYPE
171
 
     * @type Object
172
 
     */
173
 
    ROOT_TYPE: null,
174
 
 
175
 
    /**
176
 
     * Returns the node on which to bind delegate listeners.
177
 
     * 
178
 
     * Override of Widget's implementation of _getUIEventNode() to ensure that 
179
 
     * all event listeners are bound to the Widget's topmost DOM element.
180
 
     * This ensures that the firing of each type of Widget UI event (click,
181
 
     * mousedown, etc.) is facilitated by a single, top-level, delegated DOM
182
 
     * event listener.
183
 
     *
184
 
     * @method _getUIEventNode
185
 
     * @for Widget
186
 
     * @protected
187
 
     */
188
 
    _getUIEventNode: function () {
189
 
        var root = this.get("root"),
190
 
            returnVal;
191
 
        
192
 
        if (root) {
193
 
            returnVal = root.get("boundingBox");
194
 
        }
195
 
    
196
 
        return returnVal;
197
 
    },
198
 
 
199
 
    /**
200
 
    * @method next
201
 
    * @description Returns the Widget's next sibling.
202
 
    * @param {Boolean} circular Boolean indicating if the parent's first child 
203
 
    * should be returned if the child has no next sibling.  
204
 
    * @return {Widget} Widget instance. 
205
 
    */
206
 
    next: function (circular) {
207
 
 
208
 
        var parent = this.get("parent"),
209
 
            sibling;
210
 
 
211
 
        if (parent) {
212
 
            sibling = parent.item((this.get("index")+1));
213
 
        }
214
 
 
215
 
        if (!sibling && circular) {
216
 
            sibling = parent.item(0);
217
 
        }
218
 
 
219
 
        return sibling;
220
 
 
221
 
    },
222
 
 
223
 
 
224
 
    /**
225
 
    * @method previous
226
 
    * @description Returns the Widget's previous sibling.
227
 
    * @param {Boolean} circular Boolean indicating if the parent's last child 
228
 
    * should be returned if the child has no previous sibling.
229
 
    * @return {Widget} Widget instance. 
230
 
    */
231
 
    previous: function (circular) {
232
 
 
233
 
        var parent = this.get("parent"),
234
 
            index = this.get("index"),
235
 
            sibling;
236
 
        
237
 
        if (parent && index > 0) {
238
 
            sibling = parent.item([(index-1)]);
239
 
        }
240
 
 
241
 
        if (!sibling && circular) {
242
 
            sibling = parent.item((parent.size() - 1));
243
 
        }
244
 
 
245
 
        return sibling; 
246
 
        
247
 
    },
248
 
 
249
 
 
250
 
    //  Override of Y.WidgetParent.remove()
251
 
    //  Sugar implementation allowing a child to remove itself from its parent.
252
 
    remove: function (index) {
253
 
 
254
 
        var parent,
255
 
            removed;
256
 
 
257
 
        if (Lang.isNumber(index)) {
258
 
            removed = Y.WidgetParent.prototype.remove.apply(this, arguments);
259
 
        }
260
 
        else {
261
 
 
262
 
            parent = this.get("parent");
263
 
 
264
 
            if (parent) {
265
 
                removed = parent.remove(this.get("index"));
266
 
            }
267
 
                        
268
 
        }
269
 
        
270
 
        return removed;
271
 
        
272
 
    },
273
 
 
274
 
 
275
 
    /**
276
 
    * @method isRoot
277
 
    * @description Determines if the Widget is the root Widget in the 
278
 
    * object hierarchy.
279
 
    * @return {Boolean} Boolean indicating if Widget is the root Widget in the 
280
 
    * object hierarchy.
281
 
    */
282
 
    isRoot: function () {
283
 
        return (this == this.get("root"));
284
 
    },
285
 
 
286
 
 
287
 
    /**
288
 
    * @method ancestor
289
 
    * @description Returns the Widget instance at the specified depth.
290
 
    * @param {number} depth Number representing the depth of the ancestor.
291
 
    * @return {Widget} Widget instance.
292
 
    */
293
 
    ancestor: function (depth) {
294
 
 
295
 
        var root = this.get("root"),
296
 
            parent;
297
 
 
298
 
        if (this.get("depth") > depth)  {
299
 
 
300
 
            parent = this.get("parent");
301
 
 
302
 
            while (parent != root && parent.get("depth") > depth) {
303
 
                parent = parent.get("parent");
304
 
            }
305
 
 
306
 
        }
307
 
 
308
 
        return parent;
309
 
 
310
 
    },
311
 
 
312
 
 
313
 
    /**
314
 
     * Updates the UI to reflect the <code>selected</code> attribute value.
315
 
     *
316
 
     * @method _uiSetChildSelected
317
 
     * @protected
318
 
     * @param {number} selected The selected value to be reflected in the UI.
319
 
     */    
320
 
    _uiSetChildSelected: function (selected) {
321
 
 
322
 
        var box = this.get("boundingBox"),
323
 
            sClassName = this.getClassName("selected");
324
 
 
325
 
        if (selected === 0) {
326
 
            box.removeClass(sClassName);
327
 
        }
328
 
        else {
329
 
            box.addClass(sClassName);
330
 
        }
331
 
        
332
 
    },
333
 
 
334
 
 
335
 
    /**
336
 
     * Default attribute change listener for the <code>selected</code> 
337
 
     * attribute, responsible for updating the UI, in response to 
338
 
     * attribute changes.
339
 
     *
340
 
     * @method _afterChildSelectedChange
341
 
     * @protected
342
 
     * @param {EventFacade} event The event facade for the attribute change.
343
 
     */    
344
 
    _afterChildSelectedChange: function (event) {
345
 
        this._uiSetChildSelected(event.newVal);
346
 
    },
347
 
    
348
 
 
349
 
    /**
350
 
     * Synchronizes the UI to match the WidgetChild state.
351
 
     * <p>
352
 
     * This method is invoked after bindUI is invoked for the Widget class
353
 
     * using YUI's aop infrastructure.
354
 
     * </p>     
355
 
     *
356
 
     * @method _syncUIChild
357
 
     * @protected
358
 
     */    
359
 
    _syncUIChild: function () {
360
 
        this._uiSetChildSelected(this.get("selected"));
361
 
    },
362
 
 
363
 
 
364
 
    /**
365
 
     * Binds event listeners responsible for updating the UI state in response 
366
 
     * to WidgetChild related state changes.
367
 
     * <p>
368
 
     * This method is invoked after bindUI is invoked for the Widget class
369
 
     * using YUI's aop infrastructure.
370
 
     * </p>
371
 
     * @method _bindUIChild
372
 
     * @protected
373
 
     */    
374
 
    _bindUIChild: function () { 
375
 
        this.after("selectedChange", this._afterChildSelectedChange);
376
 
    }
377
 
    
378
 
};
379
 
 
380
 
Y.WidgetChild = Child;
381
 
 
382
 
 
383
 
}, '3.4.1' ,{requires:['base-build', 'widget']});