39
Y the YUI? Christian Heilmann, GeekUp Leeds, February 2008

Geekup Leeds - Why the YUI?

Embed Size (px)

DESCRIPTION

My presentation at GeekUp in Leeds, UK about the ins and outs why libraries in general and the YUI is a good idea.

Citation preview

Page 1: Geekup Leeds - Why the YUI?

Y the YUI?Christian Heilmann,

GeekUp Leeds, February 2008

Page 2: Geekup Leeds - Why the YUI?

Why any library?

Page 3: Geekup Leeds - Why the YUI?

Because not everybody likes pain.

Page 4: Geekup Leeds - Why the YUI?

Browsers have shifty eyes and will steal your lunch money!

Page 5: Geekup Leeds - Why the YUI?

Memory leaks,creative standards support and syntax

oddities make your life less fun

Page 6: Geekup Leeds - Why the YUI?

So why the YUI?

Page 7: Geekup Leeds - Why the YUI?

First of all, please stop the fanboy fights.

Page 8: Geekup Leeds - Why the YUI?

All good libraries want to do the same thing:make your life easier.

Page 9: Geekup Leeds - Why the YUI?

YUI has one big benefit though:

Page 10: Geekup Leeds - Why the YUI?

It is Dr.Martensfor the web:

Industrial strength for your solutions.

Page 11: Geekup Leeds - Why the YUI?

Safety and Maintainability.

Page 12: Geekup Leeds - Why the YUI?

Namespacing included.

Page 13: Geekup Leeds - Why the YUI?

Let’s guess what the following things are...

Page 14: Geekup Leeds - Why the YUI?

YAHOO.util.DomYAHOO.util.Event

YAHOO.widget.ColorPicker

Page 15: Geekup Leeds - Why the YUI?

Roll your own:

YAHOO.namespace(‘GeekUp’);YAHOO.GeekUp.getRoundIn = function(){...}

Page 16: Geekup Leeds - Why the YUI?

Mess around with JavaScript:

YAHOO.lang. ...

Page 17: Geekup Leeds - Why the YUI?

OO-goodness for JS,Testing for types:

isArray, isBoolean, isFunction, isNull, isNumberisObject, isString, isUndefined, isValue

Page 18: Geekup Leeds - Why the YUI?

React to User Agents: YAHOO.env.uaif(YAHOO.env.ua.ie === 5){ alert(“you hate developers,right?”);}

Page 19: Geekup Leeds - Why the YUI?

OMG! It is so HUGE!

Page 20: Geekup Leeds - Why the YUI?

Hosting by YAHOO (CDN, gzipped, minified)

Page 21: Geekup Leeds - Why the YUI?

Include on-demand, either with YAHOO loader, get or

YAHOO_config.

Page 22: Geekup Leeds - Why the YUI?

Take control with Custom Events.

Page 23: Geekup Leeds - Why the YUI?

You do know what happens when and how and you can react to it.

Page 24: Geekup Leeds - Why the YUI?

Yes, you can use CSS selectors!

(as a query and as a filter)

Page 25: Geekup Leeds - Why the YUI?

You have full API documentation, examples and

cheatsheets - even offline!

(Elephants, Tigers and Bears are extra.)

Page 26: Geekup Leeds - Why the YUI?

Oh, and the YUI is *not* a JavaScript library!

Page 27: Geekup Leeds - Why the YUI?

It is a framework of JS, CSS, Design Patterns

and Widgets.

Page 28: Geekup Leeds - Why the YUI?

Developed and tested for use in Yahoo! properties, and handed over to you

for free!(BSD license FTW)

Page 29: Geekup Leeds - Why the YUI?

Go, fetch!http://developer.yahoo.com/yui

Page 30: Geekup Leeds - Why the YUI?

Tips for quick YUI development:

Page 31: Geekup Leeds - Why the YUI?

Get an IDE that supports it (Aptana, Eclipse, TextMate Bundle)

Page 32: Geekup Leeds - Why the YUI?

Make your own shortcuts and nest them in a

module pattern.

Page 33: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ function handler(){ if(YAHOO.util.Dom.hasClass(this, 'hl')){ YAHOO.util.Dom.removeClass(this, 'hl'); } else { YAHOO.util.Dom.addClass(this, 'hl'); } } var nav = YAHOO.util.Dom.get('nav'); var lis = YAHOO.util.Selector.query('#nav li') for(var i=0;lis[i];i++){ YAHOO.util.Event.addListener(lis[i], 'click', handler); }}();

Page 34: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ var YD = YAHOO.util.Dom, var YE = YAHOO.util.Event; var $ = YAHOO.util.Selector.query; function handler(){ if(YD.hasClass(this, 'hl')){ YD.removeClass(this, 'hl'); } else { YD.addClass(this, 'hl'); } } var lis = $('#nav li') for(var i=0;lis[i];i++){ YE.on(lis[i], 'click', handler); }}();

Page 35: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ var YD = YAHOO.util.Dom, var YE = YAHOO.util.Event; var $ = YAHOO.util.Selector.query; function handler(){ if(YD.hasClass(this, 'hl')){ YD.removeClass(this, 'hl'); } else { YD.addClass(this, 'hl'); } } var lis = $('#nav li') for(var i=0;lis[i];i++){ YE.on(lis[i], 'click', handler); }}();

Page 36: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ var YD = YAHOO.util.Dom; var YE = YAHOO.util.Event; var $ = YAHOO.util.Selector.query; YE.on($('#nav li'),'click',function(){ if(YD.hasClass(this, 'hl')){ YD.removeClass(this, 'hl'); } else { YD.addClass(this, 'hl'); } });}();

Page 37: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ var YD = YAHOO.util.Dom; var YE = YAHOO.util.Event; var $ = YAHOO.util.Selector.query; YE.on($('#nav li'),'click',function(){ if(YD.hasClass(this, 'hl')){ YD.removeClass(this, 'hl'); } else { YD.addClass(this, 'hl'); } });}();

Page 38: Geekup Leeds - Why the YUI?

YAHOO.namespace('geekup');YAHOO.geekup.doStuff = function(){ var YD = YAHOO.util.Dom; var YE = YAHOO.util.Event; YE.on(YD.get('nav'),'click',function(e){ var t = YE.getTarget(e); if(t.nodeName.toLowerCase()==='li'){ if(YD.hasClass(t, 'hl')){ YD.removeClass(t, 'hl'); } else { YD.addClass(t, 'hl'); } } });}();

Page 39: Geekup Leeds - Why the YUI?

Thanks, now tell me what you’d like to know.