SlideShare uma empresa Scribd logo
1 de 28
3
           YUI
      http://developer.yahoo.com/yui/3
             http://github.com/yui/yui3


http://github.com/davglass/openhackday
               http://blog.davglass.com
                             @davglass
YUI.use('lighter', function(Y) {
	   Y.all('.faster li').each(function(v) {
	   	    v.set('innerHTML', 'easier');
	   });
});




                     2
Lighter


        Don't load what you don't need
    

        Don't write code more than once, use it again
    




    Easier


        Consistent API
    

            Base, Selector, Widget, IO/Get/DataSource
        Convenience
    

            each, bind, nodelist, queue, chainability, general sugar


    Faster


        Opportunity to re-factor core performance pain points
    




                                          3
Why the change?
What our users asked for:

    • Selectors
    • Chaining
    • Consistancy
    • Sandboxing
    • Better Dependency Handling
    • Versioning




                            4
Protected Code

<script src=quot;/3.4/build/yui/yui-min.jsquot;>
<script>
    YUI().use(quot;overlayquot;, function(Y) {
        Y.on(quot;clickquot;, function(){
            new Y.Overlay({...}).render();
        }, quot;#buttonquot;);
    });
</script>




                                5
Protected Code

<script src=quot;/3.2/build/overlay/overlay-min.jsquot;>
<script>
    YUI().use(quot;overlayquot;, function(Y) {
        Y.on(quot;clickquot;, function(){
            new Y.Overlay({...}).render();
        }, quot;#button2quot;);
    });
</script>




                                6
Self Populating


<script src=quot;yui-min.jsquot;>
<script>
    YUI().use(quot;animquot;, function(Y) {



    });
</script>




                                      7
Self Populating

<script    src=quot;yui-min.jsquot;>
<script    src=quot;oop-min.jsquot;>
<script    src=quot;event-min.jsquot;>
<script    src=quot;attribute-min.jsquot;>
<script    src=quot;base-min.jsquot;>
<script    src=quot;dom-min.jsquot;>
<script    src=quot;node-min.jsquot;>
<script    src=quot;anim-min.jsquot;>

<script>
    YUI().use(quot;animquot;, function(Y) {



    });
</script>




                                      8
Self Populating

<script src=quot;yui-min.jsquot;>
<script src=quot;http://yui.yahooapis.com/combo?oop-min.js&event-min.js..quot;>
<script>
    YUI().use(quot;animquot;, function(Y) {



    });
</script>




                                      9
Event
The Enhanced Custom Event System Is An
Integral Part of YUI 3’s Goal To Be Lighter,
Allowing For Highly Decoupled Code

         Event Facades
     
         Built-in on and after moments
     
         Default Behavior (preventDefault)
     
         Event Bubbling (stopPropagation)
     
         Detach Handles
     




                          10
Event
// Dom Event
YAHOO.util.Event.on(quot;clickquot;, function(e) {
     YAHOO.util.Event.preventDefault(e);
});

// Dom Event
YAHOO.util.Event.on(quot;mousemovequot;, function(e) {
     YAHOO.util.Event.getPageX(e);
});

// Custom Event
slider.on(quot;valueChangequot;, function(e) {
     if (someVal < 200) {
           return false;
     }
});

                     11
Event Facade
// Dom Event
linkNode.on(quot;clickquot;, function(e) {
  if (!e.target.hasClass(quot;selectorquot;)) {
    e.preventDefault();
  }
  var x = e.pageX;
});

// Custom Event
slider.on(quot;valueChangequot;, function(e) {
     if (e.newVal < 200) {
           e.preventDefault();
     }
});



                      12
Event Bubbling
var dd = new Y.DD.Drag({ node: '#drag' });

//Listen at a higher level
Y.DD.DDM.on('drag:drag', function(e) {
  if (tooFar) {
    e.preventDefault();
  }
});

//Set opacity on all drag objects
Y.DD.DDM.on('drag:start', function(e) {
  var dds = Y.all('.yui-dd-draggable').
    setStyle('opacity', '.5');
});



                     13
Event
// Publisher
show : function() {
   this.fire(quot;showquot;);
},

_defShowFn : function(e) {
   node.removeClass(quot;hiddenquot;);
   ...
}
// Subscriber
overlay.on(quot;showquot;, function(e) {
   if (!taskSelected) { e.preventDefault(); }
}
overlay.after(quot;showquot;, function(e) {...});




                         14
Node

A single convenient location for working with
HTML Elements
     SelectorBased
     Supports
     Normalizes
     Enhances


     Extendable
     Constrainable



                       15
Node

Working with Node:
Y.get('#foo').addClass('selected').
   set('innerHTML', 'Here');
var foo = Y.get('#foo');
foo.on('click', function() { ... });
foo.addClass('selected');
foo.getXY();
foo.setStyle('backgroundColor', 'red');



                      16
Node

Supports the HTMLElement API
 node.appendChild(aNode)
 node.cloneNode(aNode)
 node.scrollIntoView()
 node.get(quot;parentNodequot;)
 node.set(quot;innerHTMLquot;,quot;Fooquot;)



               17
Node

Normalizes the HTMLElement API
 node.getAttribute(quot;hrefquot;)
 node.contains(aNode)
 node.getText()
 node.getStyle(quot;paddingTopquot;)
 node.previous()



               18
Node

Enhances The HTMLElement API
 node.addClass(quot;selectablequot;)
 node.toggleClass(quot;enabledquot;)
 node.getXY()
 node.get(quot;regionquot;)




               19
Node

Extendable
Plugins can provide app specific features…

  node.plug(IOPlugin);
  node.io.getContent(quot;http://foo/barquot;);

  node.plug(DragPlugin);
  node.dd.set(quot;handlequot;, quot;.titlequot;);



                          20
Node

Constrainable
 Node is the single point for DOM access,
 throughout YUI 3
Makes YUI 3 ideal as a trusted source in
quot;constrainedquot; environments such as
Caja and Ad-Safe




                     21
NodeList

Used to Batch Node operations
 var items = Y.Node.all(quot;.actions liquot;);
 items.addClass(quot;disabledquot;);
 items.set(quot;titlequot;, quot;Item Disabledquot;);

 items.each(function(node) {
      node.addClass(quot;disabledquot;);
      node.set(quot;titlequot;, quot;Item Disabledquot;);
 });




                      22
Core Language Addons

    Array Extras

    isString, isNumber …

    Bind

    Each

    Later

    OOP

        Augment, Extend, Aggregate, Merge, Clone
    

    AOP

        Before/After For Methods
    




                             23
A Common Foundation

Y.Attribute
    Configurable Attributes

         readOnly, writeOnce
     

         validators, getters and setters
     

    Attribute Value Change Events

         on/after
     

    Complex Attribute Support

         set(quot;strings.label_enabledquot;, quot;Enabledquot;);
     




                                      24
A Common Foundation

Y.Base
    The Class From Which YUI 3 Classes Will Be Derived


    Combines Custom Event And Attribute Support


    Manages the quot;initquot; and quot;destroyquot; Lifecycle Moments


    Provides Plugin/Extension Management





                             25
A Common Foundation

Y.Widget
    The Base Implementation For All Widgets


    Introduces Common Attributes, Methods

        boundingBox, contentBox
    

        width, height
    

        visible, disabled, hasFocus
    

        strings
    

        show(), hide(), focus(), blur(), enable(), disable()
    

    Manages The quot;renderquot; Lifecycle Moment


    Establishes A Common Pattern For Widget Development





                               26
Code...




 Finally, let's see some code..




              27
3
           YUI
      http://developer.yahoo.com/yui/3
             http://github.com/yui/yui3


http://github.com/davglass/openhackday
               http://blog.davglass.com
                             @davglass

Mais conteúdo relacionado

Mais procurados

IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)jeresig
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)jeresig
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloRobert Nyman
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Eventsdmethvin
 
Standford 2015 week6
Standford 2015 week6Standford 2015 week6
Standford 2015 week6彼得潘 Pan
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.jsTechExeter
 
AngularJS Animations
AngularJS AnimationsAngularJS Animations
AngularJS AnimationsEyal Vardi
 
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Patrick Lauke
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascriptaglemann
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoJavier Abadía
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widgetTudor Barbu
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007Netvibes
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonKris Wallsmith
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explainedRamesh BN
 

Mais procurados (20)

IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
 
Standford 2015 week6
Standford 2015 week6Standford 2015 week6
Standford 2015 week6
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
AngularJS Animations
AngularJS AnimationsAngularJS Animations
AngularJS Animations
 
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar Django
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007Netvibes UWA workshop at ParisWeb 2007
Netvibes UWA workshop at ParisWeb 2007
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explained
 

Destaque

Creating Animated PPT presentations
Creating Animated PPT presentationsCreating Animated PPT presentations
Creating Animated PPT presentationsSOAP Presentations
 
Animation Techniques
Animation TechniquesAnimation Techniques
Animation TechniquesMedia Studies
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Destaque (6)

Slideshare with animations
Slideshare with animationsSlideshare with animations
Slideshare with animations
 
Creating Animated PPT presentations
Creating Animated PPT presentationsCreating Animated PPT presentations
Creating Animated PPT presentations
 
Animation Techniques
Animation TechniquesAnimation Techniques
Animation Techniques
 
Animation
AnimationAnimation
Animation
 
ANIMATION PPT
ANIMATION PPTANIMATION PPT
ANIMATION PPT
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Semelhante a YUI 3

2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan YuiJH Lee
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuffjeresig
 
Security testing of YUI powered applications
Security testing of YUI powered applicationsSecurity testing of YUI powered applications
Security testing of YUI powered applicationsdimisec
 
Server Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetServer Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetTom Croucher
 
Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Matt Raible
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build Systemklipstein
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)Carles Farré
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 
jQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UIjQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UIjeresig
 
Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Adam Moore
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern偉格 高
 
Hack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurHack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurSumana Hariharan
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfMorgan Cheng
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 

Semelhante a YUI 3 (20)

2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuff
 
Security testing of YUI powered applications
Security testing of YUI powered applicationsSecurity testing of YUI powered applications
Security testing of YUI powered applications
 
Server Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetServer Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yet
 
Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build System
 
Dojo and Adobe AIR
Dojo and Adobe AIRDojo and Adobe AIR
Dojo and Adobe AIR
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
jQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UIjQuery 1.3 and jQuery UI
jQuery 1.3 and jQuery UI
 
Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
 
Hack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurHack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT Kharagpur
 
Spine.js
Spine.jsSpine.js
Spine.js
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend Perf
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 

Mais de Dav Glass

YUI and the History of OSS at Yahoo
YUI and the History of OSS at YahooYUI and the History of OSS at Yahoo
YUI and the History of OSS at YahooDav Glass
 
Intro to Yahoo Tech
Intro to Yahoo TechIntro to Yahoo Tech
Intro to Yahoo TechDav Glass
 
Yahoo Cocktails - NodeConfEU
Yahoo Cocktails - NodeConfEUYahoo Cocktails - NodeConfEU
Yahoo Cocktails - NodeConfEUDav Glass
 
YUIConf 2012 Keynote Address
YUIConf 2012 Keynote AddressYUIConf 2012 Keynote Address
YUIConf 2012 Keynote AddressDav Glass
 
YUIConf 2011 keynote
YUIConf 2011 keynoteYUIConf 2011 keynote
YUIConf 2011 keynoteDav Glass
 
Contributing to YUI
Contributing to YUIContributing to YUI
Contributing to YUIDav Glass
 

Mais de Dav Glass (7)

YUI and the History of OSS at Yahoo
YUI and the History of OSS at YahooYUI and the History of OSS at Yahoo
YUI and the History of OSS at Yahoo
 
Intro to Yahoo Tech
Intro to Yahoo TechIntro to Yahoo Tech
Intro to Yahoo Tech
 
Yahoo Cocktails - NodeConfEU
Yahoo Cocktails - NodeConfEUYahoo Cocktails - NodeConfEU
Yahoo Cocktails - NodeConfEU
 
YUIConf 2012 Keynote Address
YUIConf 2012 Keynote AddressYUIConf 2012 Keynote Address
YUIConf 2012 Keynote Address
 
YUIConf 2011 keynote
YUIConf 2011 keynoteYUIConf 2011 keynote
YUIConf 2011 keynote
 
Node yui3
Node yui3Node yui3
Node yui3
 
Contributing to YUI
Contributing to YUIContributing to YUI
Contributing to YUI
 

Último

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

YUI 3

  • 1. 3 YUI http://developer.yahoo.com/yui/3 http://github.com/yui/yui3 http://github.com/davglass/openhackday http://blog.davglass.com @davglass
  • 2. YUI.use('lighter', function(Y) { Y.all('.faster li').each(function(v) { v.set('innerHTML', 'easier'); }); }); 2
  • 3. Lighter  Don't load what you don't need  Don't write code more than once, use it again  Easier  Consistent API  Base, Selector, Widget, IO/Get/DataSource Convenience  each, bind, nodelist, queue, chainability, general sugar Faster  Opportunity to re-factor core performance pain points  3
  • 4. Why the change? What our users asked for: • Selectors • Chaining • Consistancy • Sandboxing • Better Dependency Handling • Versioning 4
  • 5. Protected Code <script src=quot;/3.4/build/yui/yui-min.jsquot;> <script> YUI().use(quot;overlayquot;, function(Y) { Y.on(quot;clickquot;, function(){ new Y.Overlay({...}).render(); }, quot;#buttonquot;); }); </script> 5
  • 6. Protected Code <script src=quot;/3.2/build/overlay/overlay-min.jsquot;> <script> YUI().use(quot;overlayquot;, function(Y) { Y.on(quot;clickquot;, function(){ new Y.Overlay({...}).render(); }, quot;#button2quot;); }); </script> 6
  • 7. Self Populating <script src=quot;yui-min.jsquot;> <script> YUI().use(quot;animquot;, function(Y) { }); </script> 7
  • 8. Self Populating <script src=quot;yui-min.jsquot;> <script src=quot;oop-min.jsquot;> <script src=quot;event-min.jsquot;> <script src=quot;attribute-min.jsquot;> <script src=quot;base-min.jsquot;> <script src=quot;dom-min.jsquot;> <script src=quot;node-min.jsquot;> <script src=quot;anim-min.jsquot;> <script> YUI().use(quot;animquot;, function(Y) { }); </script> 8
  • 9. Self Populating <script src=quot;yui-min.jsquot;> <script src=quot;http://yui.yahooapis.com/combo?oop-min.js&event-min.js..quot;> <script> YUI().use(quot;animquot;, function(Y) { }); </script> 9
  • 10. Event The Enhanced Custom Event System Is An Integral Part of YUI 3’s Goal To Be Lighter, Allowing For Highly Decoupled Code Event Facades  Built-in on and after moments  Default Behavior (preventDefault)  Event Bubbling (stopPropagation)  Detach Handles  10
  • 11. Event // Dom Event YAHOO.util.Event.on(quot;clickquot;, function(e) { YAHOO.util.Event.preventDefault(e); }); // Dom Event YAHOO.util.Event.on(quot;mousemovequot;, function(e) { YAHOO.util.Event.getPageX(e); }); // Custom Event slider.on(quot;valueChangequot;, function(e) { if (someVal < 200) { return false; } }); 11
  • 12. Event Facade // Dom Event linkNode.on(quot;clickquot;, function(e) { if (!e.target.hasClass(quot;selectorquot;)) { e.preventDefault(); } var x = e.pageX; }); // Custom Event slider.on(quot;valueChangequot;, function(e) { if (e.newVal < 200) { e.preventDefault(); } }); 12
  • 13. Event Bubbling var dd = new Y.DD.Drag({ node: '#drag' }); //Listen at a higher level Y.DD.DDM.on('drag:drag', function(e) { if (tooFar) { e.preventDefault(); } }); //Set opacity on all drag objects Y.DD.DDM.on('drag:start', function(e) { var dds = Y.all('.yui-dd-draggable'). setStyle('opacity', '.5'); }); 13
  • 14. Event // Publisher show : function() { this.fire(quot;showquot;); }, _defShowFn : function(e) { node.removeClass(quot;hiddenquot;); ... } // Subscriber overlay.on(quot;showquot;, function(e) { if (!taskSelected) { e.preventDefault(); } } overlay.after(quot;showquot;, function(e) {...}); 14
  • 15. Node A single convenient location for working with HTML Elements  SelectorBased  Supports  Normalizes  Enhances  Extendable  Constrainable 15
  • 16. Node Working with Node: Y.get('#foo').addClass('selected'). set('innerHTML', 'Here'); var foo = Y.get('#foo'); foo.on('click', function() { ... }); foo.addClass('selected'); foo.getXY(); foo.setStyle('backgroundColor', 'red'); 16
  • 17. Node Supports the HTMLElement API node.appendChild(aNode) node.cloneNode(aNode) node.scrollIntoView() node.get(quot;parentNodequot;) node.set(quot;innerHTMLquot;,quot;Fooquot;) 17
  • 18. Node Normalizes the HTMLElement API node.getAttribute(quot;hrefquot;) node.contains(aNode) node.getText() node.getStyle(quot;paddingTopquot;) node.previous() 18
  • 19. Node Enhances The HTMLElement API node.addClass(quot;selectablequot;) node.toggleClass(quot;enabledquot;) node.getXY() node.get(quot;regionquot;) 19
  • 20. Node Extendable Plugins can provide app specific features… node.plug(IOPlugin); node.io.getContent(quot;http://foo/barquot;); node.plug(DragPlugin); node.dd.set(quot;handlequot;, quot;.titlequot;); 20
  • 21. Node Constrainable Node is the single point for DOM access, throughout YUI 3 Makes YUI 3 ideal as a trusted source in quot;constrainedquot; environments such as Caja and Ad-Safe 21
  • 22. NodeList Used to Batch Node operations var items = Y.Node.all(quot;.actions liquot;); items.addClass(quot;disabledquot;); items.set(quot;titlequot;, quot;Item Disabledquot;); items.each(function(node) { node.addClass(quot;disabledquot;); node.set(quot;titlequot;, quot;Item Disabledquot;); }); 22
  • 23. Core Language Addons Array Extras  isString, isNumber …  Bind  Each  Later  OOP  Augment, Extend, Aggregate, Merge, Clone  AOP  Before/After For Methods  23
  • 24. A Common Foundation Y.Attribute Configurable Attributes  readOnly, writeOnce  validators, getters and setters  Attribute Value Change Events  on/after  Complex Attribute Support  set(quot;strings.label_enabledquot;, quot;Enabledquot;);  24
  • 25. A Common Foundation Y.Base The Class From Which YUI 3 Classes Will Be Derived  Combines Custom Event And Attribute Support  Manages the quot;initquot; and quot;destroyquot; Lifecycle Moments  Provides Plugin/Extension Management  25
  • 26. A Common Foundation Y.Widget The Base Implementation For All Widgets  Introduces Common Attributes, Methods  boundingBox, contentBox  width, height  visible, disabled, hasFocus  strings  show(), hide(), focus(), blur(), enable(), disable()  Manages The quot;renderquot; Lifecycle Moment  Establishes A Common Pattern For Widget Development  26
  • 27. Code... Finally, let's see some code.. 27
  • 28. 3 YUI http://developer.yahoo.com/yui/3 http://github.com/yui/yui3 http://github.com/davglass/openhackday http://blog.davglass.com @davglass

Notas do Editor