5. EXTENDING
function Fooga() {
Y.log('Fooga constructor');
}
function Hooga() {
Y.log('Hooga constructor');
Hooga.superclass.constructor.apply(this, arguments);
}
Y.extend(Hooga, Fooga);
Wednesday, June 8, 2011
6. MIXING
function Hooga() {}
Hooga.prototype.fooga = 'wooga';
function Nooga() {}
Nooga.prototype.fooga = null;
Y.mix(Hooga, Nooga);
var h = new Hooga();
Y.log(h.fooga); // 'wooga'
Y.mix(Hooga, Nooga, true, null, 2); // allow override. set mode to
prototype (2)
var h2 = new Hooga();
Y.log(h2.fooga); // null
Wednesday, June 8, 2011
7. EXAMPLE
function Fooga() {
Fooga.superclass.constructor.apply(this, arguments);
}
Fooga.NAME = 'fooga';
Fooga.ATTRS = {
timer : {
value : 2000
}
};
Y.extend(Fooga, Y.Base);
Y.mix(Fooga, Y.io);
Wednesday, June 8, 2011
23. PLUGIN OR EXTENSION
• Plug when you: • Extend when you:
• Want to add or remove • Want to keep the
features during run time functionality across all
instances
• Want to mix features
per instance • Want to mix features
into a new object
Wednesday, June 8, 2011
24. QUESTIONS?
Anthony Pipkin
@apipkin
IRC: apipkin
meebo: a.pipkin
Links
http://developer.yahoo.com/yui/3/
http://developer.yahoo.com/yui/3/api/
http://developer.yahoo.com/yui/theater/
http://www.yuilibrary.com/
Wednesday, June 8, 2011