/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

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

  • Committer: Martin Albisetti
  • Date: 2008-10-22 11:05:23 UTC
  • mfrom: (230 trunk)
  • mto: This revision was merged to the branch mainline in revision 233.
  • Revision ID: martin.albisetti@canonical.com-20081022110523-sb3mjicez8ktsc3x
MergeĀ fromĀ trunk

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.0pr1
 
6
*/
 
7
YUI.add('base', function(Y) {
 
8
 
 
9
    /**
 
10
     * Base class support for objects requiring
 
11
     * managed attributes and acting as event targets
 
12
     *
 
13
     * @module base
 
14
     */
 
15
 
 
16
    var L = Y.Lang,
 
17
        O = Y.Object,
 
18
        SEP = ":",
 
19
        DESTROY = "destroy",
 
20
        INIT = "init",
 
21
        VALUE = "value",
 
22
        INITIALIZED = "initialized",
 
23
        DESTROYED = "destroyed",
 
24
        INITIALIZER = "initializer",
 
25
        DESTRUCTOR = "destructor";
 
26
 
 
27
    var ETP = Y.Event.Target.prototype;
 
28
 
 
29
    /**
 
30
     * <p>
 
31
     * Provides a base class for managed attribute based
 
32
     * objects, which handles the chaining of initializer and destructor methods
 
33
     * across the hierarchy during init and destroy lifecycle methods and 
 
34
     * handles automatic configuration of registered Attributes, through 
 
35
     * the static <a href="#property_ATTRS">ATTRS</a> property.
 
36
     * </p>
 
37
     *
 
38
     * <p>The Base class also handles prefixing of event types with the static <a href="#property_NAME">NAME</a> 
 
39
     * property for all events fired from instances of classes derived from Base.</p>
 
40
     *
 
41
     * @constructor
 
42
     * @class Base
 
43
     * @uses Attribute
 
44
     *
 
45
     * @param {Object} config Object literal of configuration property name/value pairs
 
46
     */
 
47
    var Base = function() {
 
48
        Y.log('constructor called', 'life', 'base');
 
49
        Y.Attribute.call(this);
 
50
        this.init.apply(this, arguments);
 
51
    };
 
52
 
 
53
    /**
 
54
     * <p>
 
55
     * Name string to be used to identify instances of 
 
56
     * this class, for example in prefixing events.
 
57
     * </p>
 
58
     * <p>
 
59
     * Classes extending Base, should define their own
 
60
     * static NAME property.
 
61
     * </p>
 
62
     * @property NAME
 
63
     * @type String
 
64
     * @static
 
65
     */
 
66
    Base.NAME = 'base';
 
67
 
 
68
    /**
 
69
     * Object literal defining the set of attributes which
 
70
     * will be available for instances of this class, and 
 
71
     * how they are configured. See Attributes addAtt method
 
72
     * for a description of configuration options available 
 
73
     * for each attribute.
 
74
     *
 
75
     * @property ATTRS
 
76
     * @type Object
 
77
     * @static
 
78
     */
 
79
    Base.ATTRS = {
 
80
        /**
 
81
         * Flag indicating whether or not this object
 
82
         * has been through the init lifecycle phase.
 
83
         *
 
84
         * @attribute initialized
 
85
         * @readOnly
 
86
         * @default false
 
87
         * @type boolean
 
88
         */
 
89
        intialized: {
 
90
            readOnly:true,
 
91
            value:false
 
92
        },
 
93
 
 
94
        /**
 
95
         * Flag indicating whether or not this object
 
96
         * has been through the destroy lifecycle phase.
 
97
         *
 
98
         * @attribute destroyed
 
99
         * @readOnly
 
100
         * @default false
 
101
         * @type boolean
 
102
         */
 
103
        destroyed: {
 
104
            readOnly:true,
 
105
            value:false
 
106
        }
 
107
    };
 
108
 
 
109
    var _instances = {};
 
110
 
 
111
    /**
 
112
     * <p>
 
113
     * Builds a constructor function (class) from the
 
114
     * main function, and array of extension functions (classes)
 
115
     * provided.
 
116
     * </p>
 
117
     * <p>
 
118
     * The cfg object literal supports the following properties
 
119
     * </p>
 
120
     * <dl>
 
121
     *    <dt>dynamic &#60;boolean&#62;</dt>
 
122
     *    <dd>
 
123
     *    <p>If true, a completely new class
 
124
     *    is created which extends the main class, and acts as the 
 
125
     *    host on which the extension classes are augmented.</p>
 
126
     *    <p>If false, the extensions classes are augmented directly to
 
127
     *    the main class, modifying the main classes prototype.</p>
 
128
     *    </dd>
 
129
     *    <dt>aggregates &#60;String[]&#62;</dt>
 
130
     *    <dd>An array of static property names, which will get aggregated
 
131
     *    on to the built class in addition to the default properties build 
 
132
     *    will always aggregate - "ATTRS" and "PLUGINS", as defined by 
 
133
     *    Base.build.AGGREGATES</dd>
 
134
     * </dl>
 
135
     *
 
136
     * @method build
 
137
     * @static
 
138
     * @param {Function} main The main class on which to base the built class
 
139
     * @param {Function[]} extensions The set of extension classes which will be
 
140
     * augmented/aggregated to the built class.
 
141
     * @param {Object} cfg
 
142
     * @return {Function} A custom class, created from the provided main and extension classes
 
143
     */
 
144
    Base.build = function(main, extensions, cfg) {
 
145
 
 
146
        var build = Base.build,
 
147
            builtClass,
 
148
            extClass,
 
149
            aggregates,
 
150
            dynamic,
 
151
            key = main.NAME;
 
152
 
 
153
        if (cfg) {
 
154
            aggregates = cfg.aggregates;
 
155
            dynamic = cfg.dynamic;
 
156
        }
 
157
 
 
158
        // Create dynamic class or just modify main class
 
159
        builtClass = (dynamic) ? build._template(main) : main;
 
160
 
 
161
        builtClass._yuibuild = {
 
162
            id: null,
 
163
            exts : [],
 
164
            dynamic : dynamic
 
165
        };
 
166
 
 
167
        aggregates = (aggregates) ? build.AGGREGATES.concat(aggregates) : build.AGGREGATES;
 
168
 
 
169
        var el = extensions.length,
 
170
            al = aggregates.length,
 
171
            i;
 
172
 
 
173
        // Shallow isolate aggregates
 
174
        if (dynamic && aggregates) {
 
175
            for (i = 0; i < al; i++) {
 
176
                var val = aggregates[i];
 
177
                if (O.owns(main, val)) {
 
178
                    builtClass[val] = L.isArray(main[val]) ? [] : {};
 
179
                }
 
180
            }
 
181
            Y.aggregate(builtClass, main, true, aggregates);
 
182
        }
 
183
 
 
184
        // Augment/Aggregate
 
185
        for (i = 0; i < el; i++) {
 
186
            extClass = extensions[i];
 
187
 
 
188
            if (aggregates) {
 
189
                Y.aggregate(builtClass, extClass, true, aggregates);
 
190
            }
 
191
 
 
192
            // Old augment
 
193
            Y.mix(builtClass, extClass, true, null, 1);
 
194
 
 
195
            builtClass._yuibuild.exts.push(extClass);
 
196
            key = key + ":" + Y.stamp(extClass);
 
197
        }
 
198
 
 
199
        builtClass._yuibuild.id = key;
 
200
        builtClass.prototype.hasImpl = build._hasImpl;
 
201
 
 
202
        if (dynamic) {
 
203
            builtClass.NAME = main.NAME;
 
204
            builtClass.prototype.constructor = builtClass;
 
205
        }
 
206
 
 
207
        return builtClass;
 
208
    };
 
209
 
 
210
    Y.mix(Base.build, {
 
211
 
 
212
        AGGREGATES : ["ATTRS", "PLUGINS"],
 
213
 
 
214
        _template: function(main) {
 
215
 
 
216
            function BuiltClass() {
 
217
                BuiltClass.superclass.constructor.apply(this, arguments);
 
218
 
 
219
                var f = BuiltClass._yuibuild.exts, 
 
220
                    l = f.length;
 
221
 
 
222
                for (var i = 0; i < l; i++) {
 
223
                    f[i].apply(this, arguments);
 
224
                }
 
225
                return this;
 
226
            }
 
227
 
 
228
            Y.extend(BuiltClass, main);
 
229
 
 
230
            return BuiltClass;
 
231
        },
 
232
 
 
233
        _hasImpl : function(extClass) {
 
234
            if (this.constructor._yuibuild) {
 
235
                var f = this.constructor._yuibuild.exts,
 
236
                    l = f.length,
 
237
                    i;
 
238
 
 
239
                for (i = 0; i < l; i++) {
 
240
                    if (f[i] === extClass) {
 
241
                        return true;
 
242
                    }
 
243
                }
 
244
            }
 
245
 
 
246
            return false;
 
247
        }
 
248
    });
 
249
 
 
250
    /**
 
251
     * <p>
 
252
     * Creates a new object instance, based on a dynamically created custom class.
 
253
     * The custom class is created from the main class passed in as the first parameter 
 
254
     * along with the list of extension classes passed in
 
255
     * as the second parameter using <a href="#method_build">Base.build</a> 
 
256
     * with "dynamic" set to true. See the documentation for this method 
 
257
     * to see how the main class and extension classes are used.
 
258
     * </p>
 
259
     * 
 
260
     * <p>Any arguments following the 2nd argument are passed as arguments to the 
 
261
     * constructor of the newly created class used to create the instance.</p>
 
262
     * 
 
263
     * @method create
 
264
     * @static
 
265
     *
 
266
     * @param {Function} main The main class on which the instance it to be 
 
267
     * based. This class will be extended to create the class for the custom instance
 
268
     * @param {Array} extensions The list of extension classes used to augment the
 
269
     * main class with.
 
270
     * @param {Any*} args* 0..n arguments to pass to the constructor of the 
 
271
     * newly created class, when creating the instance.
 
272
     * @return {Object} An instance of the custom class
 
273
     */
 
274
    Base.create = function(main, extensions, args) {
 
275
        var c = Base.build(main, extensions, {dynamic:true}),
 
276
            cArgs = Y.Array(arguments, 2, true);
 
277
 
 
278
        function F(){}
 
279
        F.prototype = c.prototype;
 
280
 
 
281
        return c.apply(new F(), cArgs);
 
282
    };
 
283
 
 
284
    Base.prototype = {
 
285
 
 
286
        /**
 
287
         * Init lifecycle method, invoked during construction.
 
288
         * Fires the init event prior to invoking initializers on
 
289
         * the class hierarchy.
 
290
         * 
 
291
         * @method init
 
292
         * @final
 
293
         * @chainable
 
294
         * @param {Object} config Object literal of configuration property name/value pairs
 
295
         * @return {Base} A reference to this object
 
296
         */
 
297
        init: function(config) {
 
298
            Y.log('init called', 'life', 'base');
 
299
 
 
300
            /**
 
301
             * The name string to be used to identify 
 
302
             * this instance of object. 
 
303
             * @property name
 
304
             * @type String
 
305
             */
 
306
            this.name = this.constructor.NAME;
 
307
 
 
308
            /**
 
309
             * <p>
 
310
             * Init event, fired prior to initialization. Invoking
 
311
             * the preventDefault method on the event object provided 
 
312
             * to subscribers will prevent initialization from occuring.
 
313
             * </p>
 
314
             * <p>
 
315
             * Subscribers to the "after" momemt of this event, will be notified
 
316
             * after initialization of the object is complete (and therefore
 
317
             * cannot prevent initialization).
 
318
             * </p>
 
319
             *
 
320
             * @event init
 
321
             * @preventable _defInitFn
 
322
             * @param {Event.Facade} e Event object
 
323
             * @param config Object literal of configuration name/value pairs
 
324
             */
 
325
            this.publish(INIT, {
 
326
                queuable:false,
 
327
                defaultFn:this._defInitFn
 
328
            });
 
329
            this.fire(INIT, config);
 
330
 
 
331
            return this;
 
332
        },
 
333
 
 
334
        /**
 
335
         * <p>
 
336
         * Destroy lifecycle method. Fires the destroy
 
337
         * event, prior to invoking destructors for the
 
338
         * class hierarchy.
 
339
         * </p>
 
340
         * <p>
 
341
         * Subscribers to the destroy
 
342
         * event can invoke preventDefault on the event object, to prevent destruction
 
343
         * from proceeding.
 
344
         * </p>
 
345
         * @method destroy
 
346
         * @return {Base} A reference to this object
 
347
         * @final
 
348
         * @chainable
 
349
         */
 
350
        destroy: function() {
 
351
            Y.log('destroy called', 'life', 'base');
 
352
 
 
353
            /**
 
354
             * <p>
 
355
             * Destroy event, fired prior to destruction. Invoking
 
356
             * the preventDefault method on the event object provided 
 
357
             * to subscribers will prevent destruction from proceeding.
 
358
             * </p>
 
359
             * <p>
 
360
             * Subscribers to the "after" moment of this event, will be notified
 
361
             * after destruction is complete (and as a result cannot prevent
 
362
             * destruction).
 
363
             * </p>
 
364
             * @event destroy
 
365
             * @preventable _defDestroyFn
 
366
             * @param {Event.Facade} e Event object
 
367
             */
 
368
            this.publish(DESTROY, {
 
369
                queuable:false,
 
370
                defaultFn: this._defDestroyFn
 
371
            });
 
372
            this.fire(DESTROY);
 
373
            return this;
 
374
        },
 
375
 
 
376
        /**
 
377
         * Default init event handler
 
378
         *
 
379
         * @method _defInitFn
 
380
         * @param {Object} config Object literal of configuration property name/value pairs
 
381
         * @protected
 
382
         */
 
383
        _defInitFn : function(config) {
 
384
            _instances[Y.stamp(this)] = this;
 
385
            this._initHierarchy(config);
 
386
 
 
387
            this._conf.remove(INITIALIZED, VALUE);
 
388
            this.set(INITIALIZED, true);
 
389
        },
 
390
 
 
391
        /**
 
392
         * Default destroy event handler
 
393
         *
 
394
         * @method _defDestroyFn
 
395
         * @protected
 
396
         */
 
397
        _defDestroyFn : function() {
 
398
            this._destroyHierarchy();
 
399
            delete _instances[this._yuid];
 
400
 
 
401
            this._conf.remove(DESTROYED, VALUE);
 
402
            this.set(DESTROYED, true);
 
403
        },
 
404
 
 
405
        /**
 
406
         * Returns the top down class hierarchy for this object,
 
407
         * with Base being the first class in the array.
 
408
         *
 
409
         * @protected
 
410
         * @return {Function[]} An Array of classes (constructor functions), making up the class heirarchy for this object
 
411
         */
 
412
        _getClasses : function() {
 
413
            if (!this._classes) {
 
414
                var c = this.constructor, 
 
415
                    classes = [];
 
416
 
 
417
                while (c && c.prototype) {
 
418
                    classes.unshift(c);
 
419
                    c = c.superclass ? c.superclass.constructor : null;
 
420
                }
 
421
                this._classes = classes;
 
422
            }
 
423
            return this._classes.concat();
 
424
        },
 
425
 
 
426
        /**
 
427
         * Initializes the class hierarchy rooted at this base class,
 
428
         * which includes initializing attributes for each class defined 
 
429
         * in the class's static <a href="#property_ATTRS">ATTRS</a> property and invoking the initializer 
 
430
         * method on the prototype of each class in the hierarchy.
 
431
         * 
 
432
         * @method _initHierarchy
 
433
         * @param {Object} userConf Object literal containing attribute name/value pairs
 
434
         * @private
 
435
         */
 
436
        _initHierarchy : function(userConf) {
 
437
            var constr,
 
438
                classes = this._getClasses();
 
439
 
 
440
            for (var ci = 0, cl = classes.length; ci < cl; ci++) {
 
441
                constr = classes[ci];
 
442
 
 
443
                if (constr._yuibuild && constr._yuibuild.exts && !constr._yuibuild.dynamic) {
 
444
                    for (var ei = 0, el = constr._yuibuild.exts.length; ei < el; ei++) {
 
445
                        constr._yuibuild.exts[ei].apply(this, arguments);
 
446
                    }
 
447
                }
 
448
 
 
449
                this._initAtts(constr.ATTRS, userConf);
 
450
 
 
451
                if (O.owns(constr.prototype, INITIALIZER)) {
 
452
                    constr.prototype[INITIALIZER].apply(this, arguments);
 
453
                }
 
454
            }
 
455
        },
 
456
 
 
457
        /**
 
458
         * Destroys the class hierarchy rooted at this base class by invoking
 
459
         * the descructor method on the prototype of each class in the hierarchy.
 
460
         *
 
461
         * @method _destroyHierarchy
 
462
         * @private
 
463
         */
 
464
        _destroyHierarchy : function() {
 
465
            var constr,
 
466
                classes = this._getClasses();
 
467
 
 
468
            for (var ci = classes.length-1; ci >= 0; ci--) {
 
469
                constr = classes[ci];
 
470
                if (O.owns(constr.prototype, DESTRUCTOR)) {
 
471
                    constr.prototype[DESTRUCTOR].apply(this, arguments);
 
472
                }
 
473
            }
 
474
        },
 
475
 
 
476
        /**
 
477
         * Default toString implementation. Provides the constructor NAME
 
478
         * and the instance ID.
 
479
         * 
 
480
         * @method toString
 
481
         * @return {String} String representation for this object
 
482
         */
 
483
        toString: function() {
 
484
            return this.constructor.NAME + "[" + Y.stamp(this) + "]";
 
485
        },
 
486
 
 
487
        /**
 
488
         * <p>
 
489
         * Subscribe to a custom event hosted by this object.
 
490
         * </p>
 
491
         * <p>
 
492
         * Overrides Event.Target's <a href="Event.Target.html#method_subscribe">subscribe</a> method, to add the name prefix 
 
493
         * of the instance to the event type, if absent.
 
494
         * </p>
 
495
         * 
 
496
         * @method subscribe
 
497
         * @param {String} type The type of event to subscribe to. If 
 
498
         * the type string does not contain a prefix ("prefix:eventType"), 
 
499
         * the name property of the instance will be used as the default prefix.
 
500
         * @param {Function} fn The subscribed callback function, invoked when the event is fired.
 
501
         * @param {Object} context Optional execution context for the callback.
 
502
         * @param {Any*} args* 0..n params to supply to the callback
 
503
         * 
 
504
         * @return {Event.Handle} An event handle which can be used to unsubscribe the subscribed callback.
 
505
         */
 
506
        subscribe : function() {
 
507
            var a = arguments;
 
508
            a[0] = this._prefixEvtType(a[0]);
 
509
            return ETP.subscribe.apply(this, a);
 
510
        },
 
511
 
 
512
        /**
 
513
         * <p>
 
514
         * Fire a custom event by name.  The callback functions will be executed
 
515
         * from the context specified when the event was created, and with the 
 
516
         * following parameters.
 
517
         * </p>
 
518
         * <p>
 
519
         * Overrides Event.Target's <a href="Event.Target.html#method_fire">fire</a> method, to add the name prefix 
 
520
         * of the instance to the event type, if absent.
 
521
         * </p>
 
522
         * 
 
523
         * @method fire
 
524
         * @param {String|Object} type The type of the event, or an object that contains
 
525
         * a 'type' property. If the type does not contain a prefix ("prefix:eventType"),
 
526
         * the name property of the instance will be used as the default prefix.
 
527
         * @param {Any*} args* 0..n Additional arguments to pass to subscribers.
 
528
         * @return {boolean} The return value from Event Target's <a href="Event.Target.html#method_fire">fire</a> method.
 
529
         *
 
530
         */
 
531
        fire : function() {
 
532
            var a = arguments;
 
533
            if (L.isString(a[0])) {
 
534
                a[0] = this._prefixEvtType(a[0]);
 
535
            } else if (a[0].type){
 
536
                a[0].type = this._prefixEvtType(a[0].type);
 
537
            }
 
538
            return ETP.fire.apply(this, a);
 
539
        },
 
540
 
 
541
        /**
 
542
         * <p>
 
543
         * Creates a new custom event of the specified type.  If a custom event
 
544
         * by that name already exists, it will not be re-created.  In either
 
545
         * case the custom event is returned. 
 
546
         * </p>
 
547
         * <p>
 
548
         * Overrides Event.Target's <a href="Event.Target.html#method_publish">publish</a> method, to add the name prefix 
 
549
         * of the instance to the event type, if absent.
 
550
         * </p>
 
551
         *
 
552
         * @method publish
 
553
         * @param {String} type  The type, or name of the event. If the type does not 
 
554
         * contain a prefix ("prefix:eventType"), the name property of the instance will 
 
555
         * be used as the default prefix.
 
556
         * @param {Object} opts Optional config params (see Event.Target <a href="Event.Target.html#method_publish">publish</a> for details)
 
557
         * @return {Event.Custom} The published custom event object
 
558
         */
 
559
        publish : function() {
 
560
            var a = arguments;
 
561
            a[0] = this._prefixEvtType(a[0]);
 
562
            return ETP.publish.apply(this, a);
 
563
        },
 
564
 
 
565
        /**
 
566
         * <p>
 
567
         * Subscribe to a custom event hosted by this object.  The
 
568
         * supplied callback will execute <em>after</em> any listeners added
 
569
         * via the subscribe method, and after the default function,
 
570
         * if configured for the event, has executed.
 
571
         * </p>
 
572
         * <p>
 
573
         * Overrides Event.Target's <a href="Event.Target.html#method_after">after</a> method, to add the name prefix 
 
574
         * of the instance to the event type, if absent.
 
575
         * </p>
 
576
         * @method after
 
577
         * @param {String} type The type of event to subscribe to. If 
 
578
         * the type string does not contain a prefix ("prefix:eventType"), 
 
579
         * the name property of the instance will be used as the default prefix.
 
580
         * @param {Function} fn  The subscribed callback function
 
581
         * @param {Object} context Optional execution context for the callback
 
582
         * @param {Any*} args* 0..n params to supply to the callback
 
583
         * @return {Event.Handle} Event handle which can be used to unsubscribe the subscribed callback.
 
584
         */
 
585
        after : function() {
 
586
            var a = arguments;
 
587
            a[0] = this._prefixEvtType(a[0]);
 
588
            return ETP.after.apply(this, a);
 
589
        },
 
590
 
 
591
        /**
 
592
         * <p>
 
593
         * Unsubscribes one or more listeners the from the specified event.
 
594
         * </p>
 
595
         * <p>
 
596
         * Overrides Event.Target's <a href="Event.Target.html#method_unsubscribe">unsubscribe</a> method, to add the name prefix 
 
597
         * of the instance to the event type, if absent.
 
598
         * </p>
 
599
         * @method unsubscribe
 
600
         * @param {String|Object} type Either the handle to the subscriber or the 
 
601
         *                        type of event.  If the type
 
602
         *                        is not specified, it will attempt to remove
 
603
         *                        the listener from all hosted events. If 
 
604
         *                        the type string does not contain a prefix 
 
605
         *                        ("prefix:eventType"), the name property of the 
 
606
         *                        instance will be used as the default prefix.
 
607
         * @param {Function} fn The subscribed function to unsubscribe, if not
 
608
         *                          supplied, all subscribers will be removed.
 
609
         * @param {Object} context The custom object passed to subscribe.  This is
 
610
         *                        optional, but if supplied will be used to
 
611
         *                        disambiguate multiple listeners that are the same
 
612
         *                        (e.g., you subscribe many object using a function
 
613
         *                        that lives on the prototype)
 
614
         * @return {boolean} true if the subscriber was found and detached.
 
615
         */
 
616
        unsubscribe: function(type, fn, context) {
 
617
            var a = arguments;
 
618
            if (L.isString(a[0])) {
 
619
                a[0] = this._prefixEvtType(a[0]);
 
620
            }
 
621
            return ETP.unsubscribe.apply(this, a);
 
622
        },
 
623
 
 
624
        /**
 
625
         * <p>
 
626
         * Removes all listeners from the specified event.  If the event type
 
627
         * is not specified, all listeners from all hosted custom events will
 
628
         * be removed.
 
629
         * </p>
 
630
         * <p>
 
631
         * Overrides Event.Target's <a href="Event.Target.html#method_unsubscribeAll">unsubscribeAll</a> method, to add the name prefix 
 
632
         * of the instance to the event type, if absent.
 
633
         * </p>
 
634
         * @method unsubscribeAll
 
635
         * @param {String} type The type, or name of the event. If 
 
636
         * the type string does not contain a prefix ("prefix:eventType"), 
 
637
         * the name property of the instance will be used as the default prefix
 
638
         * @return {int} The number of listeners unsubscribed
 
639
         */
 
640
        unsubscribeAll: function(type) {
 
641
            var a = arguments;
 
642
            a[0] = this._prefixEvtType(a[0]);
 
643
            return ETP.unsubscribeAll.apply(this, a);
 
644
        },
 
645
 
 
646
        /**
 
647
         * Utility method to prefix the event name with the
 
648
         * name property of the instance, if absent
 
649
         *
 
650
         * @method _prefixEvtType
 
651
         * @private
 
652
         * @param {String} type The event name
 
653
         * @return {String} The prefixed event name
 
654
         */
 
655
        _prefixEvtType: function(type) {
 
656
            if (type.indexOf(SEP) === -1 && this.name) {
 
657
               type = this.name + ":" + type;
 
658
            }
 
659
            return type;
 
660
        }
 
661
    };
 
662
 
 
663
    Y.mix(Base, Y.Attribute, false, null, 1);
 
664
 
 
665
    Y.Base = Base;
 
666
 
 
667
 
 
668
 
 
669
}, '3.0.0pr1' ,{requires:['attribute']});