SlideShare a Scribd company logo
1 of 59
YUI3 - Creating Custom Modules
                Gonzalo Cordero
              Yahoo! Front End Engineer
JSCONF 2010
YUI()



JSCONF 2010
<script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js">
</script>




JSCONF 2010
YUI Add




JSCONF 2010
YUI Add


  YUI.add('foo', function (Y) {




JSCONF 2010
YUI Add


  YUI.add('foo', function (Y) {
      //All your properties go in here




JSCONF 2010
YUI Add


  YUI.add('foo', function (Y) {
      //All your properties go in here
      Y.foo = "foo";




JSCONF 2010
YUI Add


  YUI.add('foo', function (Y) {
      //All your properties go in here
      Y.foo = "foo";
  });




JSCONF 2010
Namespacing


  YUI.add('foo', function (Y) {

         Y.namespace("foo.bar");
         Y.foo.bar= {
             init : function () {
                 //init code
             }
         };
  });



JSCONF 2010
YUI.add() - Version and
requirements




JSCONF 2010
YUI.add() - Version and
requirements

  YUI.add('foo', function (Y) {




JSCONF 2010
YUI.add() - Version and
requirements

  YUI.add('foo', function (Y) {

         Y.foo = "foo";




JSCONF 2010
YUI.add() - Version and
requirements

  YUI.add('foo', function (Y) {

         Y.foo = "foo";

  },'0.0.1’, { requires: ['node'] });




JSCONF 2010
Augmenting your Module - YUI
Base




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.
‣   NAME property




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.
‣   NAME property
‣   Attrs property




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.
‣   NAME property
‣   Attrs property
‣   Custom events




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.
‣   NAME property
‣   Attrs property
‣   Custom events
‣   Initialization methods




JSCONF 2010
Augmenting your Module - YUI
Base
‣   Base provides a standard template for creating
    modules with consistent API.
‣   NAME property
‣   Attrs property
‣   Custom events
‣   Initialization methods
‣   Destroy methods




JSCONF 2010
YUI Base: Attribute




JSCONF 2010
YUI Base: Attribute


‣   Consistent API and documentation - Blue prints




JSCONF 2010
YUI Base: Attribute


‣   Consistent API and documentation - Blue prints
‣   Built in Setters and Getters




JSCONF 2010
YUI Base: Attribute


‣   Consistent API and documentation - Blue prints
‣   Built in Setters and Getters
‣   NameSpacing




JSCONF 2010
YUI Base: Attribute


‣   Consistent API and documentation - Blue prints
‣   Built in Setters and Getters
‣   NameSpacing

       http://developer.yahoo.com/yui/3/attribute/




JSCONF 2010
YUI Base : Attribute
  YUI.add('foo', function (Y) {
    function MyClass(config) {
        //Invoke Base constructor, passing through arguments
        MyClass.superclass.constructor.apply(this, arguments);
    }

    MyClass.NAME = “myName”;
    MyClass.ATTRS = {
        someAttribute: {},
        someOther : {}
    }
    Y.extend(MyClass, Y.Base, {
      // Prototype methods for your new class
    });
  });


JSCONF 2010
YUI Base - Events




JSCONF 2010
YUI Base - Events


‣   Custom events




JSCONF 2010
YUI Base - Events


‣   Custom events
‣   Bubbling




JSCONF 2010
YUI Base - Events


‣   Custom events
‣   Bubbling
‣   Event Broadcasting




JSCONF 2010
YUI Base - Events


‣   Custom events
‣   Bubbling
‣   Event Broadcasting

        http://developer.yahoo.com/yui/3/base/




JSCONF 2010
YUI Base
  YUI.add('foo', function (Y) {
    Goonie.prototype.neverSayDie = {
       this.fire(“neverSayDie”);
    }

    var myGoonie = new Goonie();
    myGoonie.on(“neverSayDie”, function(e) {
        //Actually listening for (“Goonie:neverSayDie”);
        alert(“Hey you guys!!”);
    });

  });




JSCONF 2010
Loading Strategies - By Inclusion

    YUI.add('today', function (Y) {
        Y.today = new Date();

    },0.0.1,{requires[‘node’]});


    YUI.use('today', function (Y) {
        Y.one('#when').setContent( Y.today );

    });


JSCONF 2010
Loading Strategies - By
Configuration

  YUI({
  modules: {
          'foo': {
              fullpath: 'foo.js',
              requires: ['node']
          }
  }).use('foo', function (Y) {
   //foo ready to use
  });



JSCONF 2010
Loading strategies




               Or...




JSCONF 2010
Introducing The YUI Gallery




YUICONF 2009
I can haz YUI Gallery




              Image Title
JSCONF 2010
Introducing YUI Gallery




JSCONF 2010
Introducing YUI Gallery


‣   Instant access to hundreds of “first-class” modules.




JSCONF 2010
Introducing YUI Gallery


‣   Instant access to hundreds of “first-class” modules.
‣   From developer to developer.




JSCONF 2010
Introducing YUI Gallery


‣   Instant access to hundreds of “first-class” modules.
‣   From developer to developer.
‣   Simply by add them into your YUI.use() statement.




JSCONF 2010
Introducing YUI Gallery


‣   Instant access to hundreds of “first-class” modules.
‣   From developer to developer.
‣   Simply by add them into your YUI.use() statement.
‣   Some examples: YQL module, Accordion, Twitter
    status display, etc.




JSCONF 2010
JSCONF 2010
Demo: YQL + DD + Flickr
  YUI({gallery:
  'gallery-2010.01.27-20'}).use("anim",
  "dd","gallery-yql", function (Y) {

  //On DropHit
  var flickrq = new Y.yql('select * from
  flickr.photos.search where (text =
  "'+tags+'")');

  flickrq.on(‘query’,function(response) {
      //Load Photos
      });
  });
JSCONF 2010
Contributing to the YUI Gallery




JSCONF 2010
Benefits




JSCONF 2010
Benefits


‣   Your code in our CDN!




JSCONF 2010
Benefits


‣   Your code in our CDN!
‣   Your module live within one week




JSCONF 2010
Benefits


‣   Your code in our CDN!
‣   Your module live within one week
‣   Visibility




JSCONF 2010
Benefits


‣   Your code in our CDN!
‣   Your module live within one week
‣   Visibility
‣   Easy access within your YUI().use statament.




JSCONF 2010
Benefits


‣   Your code in our CDN!
‣   Your module live within one week
‣   Visibility
‣   Easy access within your YUI().use statament.
‣   Contributing and being part of the JS community.




JSCONF 2010
How to contribute




JSCONF 2010
How to contribute
‣   1 - Create your module




JSCONF 2010
How to contribute
‣   1 - Create your module
‣   2 - Create a YUI Library account




JSCONF 2010
How to contribute
‣   1 - Create your module
‣   2 - Create a YUI Library account
‣   3- Fork YUI3 on github




JSCONF 2010
How to contribute
‣   1 - Create your module
‣   2 - Create a YUI Library account
‣   3- Fork YUI3 on github
‣   4- Submit your module




JSCONF 2010
How to contribute
‣   1 - Create your module
‣   2 - Create a YUI Library account
‣   3- Fork YUI3 on github
‣   4- Submit your module
‣   5- Get approved - Your code now live on Yahoo! CDN
    servers.




JSCONF 2010
How to contribute
‣   1 - Create your module
‣   2 - Create a YUI Library account
‣   3- Fork YUI3 on github
‣   4- Submit your module
‣   5- Get approved - Your code now live on Yahoo! CDN
    servers.

              http://yuilibrary.com/gallery/




JSCONF 2010
YUI3 - Custom Modules

                           Gonzalo
                           Cordero
                 yuilibrary: gonzalocordero
                          github: goonieiam
                        twitter: @goonieiam




JSCONF 2009

More Related Content

Similar to Creating custom modules using YUI3

YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010Caridy Patino
 
Introduction to YUI3 - Palouse Code Camp 2010
Introduction to YUI3 - Palouse Code Camp 2010Introduction to YUI3 - Palouse Code Camp 2010
Introduction to YUI3 - Palouse Code Camp 2010Jeff Craig
 
jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');mikehostetler
 
Advanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component InfrastructureAdvanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component InfrastructureJeff Craig
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan YuiJH Lee
 
Liferay UI (R)evolution
Liferay UI (R)evolutionLiferay UI (R)evolution
Liferay UI (R)evolutionZeno Rocha
 
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
 
Y hack-china-2013
Y hack-china-2013Y hack-china-2013
Y hack-china-2013Syu-jhih Wu
 
Yui- Yahoo! User Interface Library
Yui- Yahoo! User Interface LibraryYui- Yahoo! User Interface Library
Yui- Yahoo! User Interface LibraryMomentum Design Lab
 
Y!OS Overview and Deep Code Dive
Y!OS Overview and Deep Code DiveY!OS Overview and Deep Code Dive
Y!OS Overview and Deep Code DiveJonathan LeBlanc
 
YUI introduction to build hack interfaces
YUI introduction to build hack interfacesYUI introduction to build hack interfaces
YUI introduction to build hack interfacesChristian Heilmann
 
Building Video Applications with YouTube APIs
Building Video Applications with YouTube APIsBuilding Video Applications with YouTube APIs
Building Video Applications with YouTube APIsJarek Wilkiewicz
 
Running YUI 3 on Node.js - BayJax
Running YUI 3 on Node.js - BayJaxRunning YUI 3 on Node.js - BayJax
Running YUI 3 on Node.js - BayJaxAdam Moore
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yuiISOCHK
 

Similar to Creating custom modules using YUI3 (20)

YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010
 
Hack with YUI
Hack with YUIHack with YUI
Hack with YUI
 
YUI open for all !
YUI open for all !YUI open for all !
YUI open for all !
 
Introduction to YUI3 - Palouse Code Camp 2010
Introduction to YUI3 - Palouse Code Camp 2010Introduction to YUI3 - Palouse Code Camp 2010
Introduction to YUI3 - Palouse Code Camp 2010
 
jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');
 
Advanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component InfrastructureAdvanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component Infrastructure
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui
 
Liferay UI (R)evolution
Liferay UI (R)evolutionLiferay UI (R)evolution
Liferay UI (R)evolution
 
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
 
Y hack-china-2013
Y hack-china-2013Y hack-china-2013
Y hack-china-2013
 
YUI for your Hacks
YUI for your Hacks YUI for your Hacks
YUI for your Hacks
 
Yui- Yahoo! User Interface Library
Yui- Yahoo! User Interface LibraryYui- Yahoo! User Interface Library
Yui- Yahoo! User Interface Library
 
UWash Hack U - Y!OS
UWash Hack U - Y!OSUWash Hack U - Y!OS
UWash Hack U - Y!OS
 
Y!OS Overview and Deep Code Dive
Y!OS Overview and Deep Code DiveY!OS Overview and Deep Code Dive
Y!OS Overview and Deep Code Dive
 
Technical Introduction to YDN
Technical Introduction to YDNTechnical Introduction to YDN
Technical Introduction to YDN
 
YUI introduction to build hack interfaces
YUI introduction to build hack interfacesYUI introduction to build hack interfaces
YUI introduction to build hack interfaces
 
YUI (Advanced)
YUI (Advanced)YUI (Advanced)
YUI (Advanced)
 
Building Video Applications with YouTube APIs
Building Video Applications with YouTube APIsBuilding Video Applications with YouTube APIs
Building Video Applications with YouTube APIs
 
Running YUI 3 on Node.js - BayJax
Running YUI 3 on Node.js - BayJaxRunning YUI 3 on Node.js - BayJax
Running YUI 3 on Node.js - BayJax
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yui
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Creating custom modules using YUI3

  • 1. YUI3 - Creating Custom Modules Gonzalo Cordero Yahoo! Front End Engineer JSCONF 2010
  • 5. YUI Add YUI.add('foo', function (Y) { JSCONF 2010
  • 6. YUI Add YUI.add('foo', function (Y) { //All your properties go in here JSCONF 2010
  • 7. YUI Add YUI.add('foo', function (Y) { //All your properties go in here Y.foo = "foo"; JSCONF 2010
  • 8. YUI Add YUI.add('foo', function (Y) { //All your properties go in here Y.foo = "foo"; }); JSCONF 2010
  • 9. Namespacing YUI.add('foo', function (Y) { Y.namespace("foo.bar"); Y.foo.bar= { init : function () { //init code } }; }); JSCONF 2010
  • 10. YUI.add() - Version and requirements JSCONF 2010
  • 11. YUI.add() - Version and requirements YUI.add('foo', function (Y) { JSCONF 2010
  • 12. YUI.add() - Version and requirements YUI.add('foo', function (Y) { Y.foo = "foo"; JSCONF 2010
  • 13. YUI.add() - Version and requirements YUI.add('foo', function (Y) { Y.foo = "foo"; },'0.0.1’, { requires: ['node'] }); JSCONF 2010
  • 14. Augmenting your Module - YUI Base JSCONF 2010
  • 15. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. JSCONF 2010
  • 16. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. ‣ NAME property JSCONF 2010
  • 17. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. ‣ NAME property ‣ Attrs property JSCONF 2010
  • 18. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. ‣ NAME property ‣ Attrs property ‣ Custom events JSCONF 2010
  • 19. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. ‣ NAME property ‣ Attrs property ‣ Custom events ‣ Initialization methods JSCONF 2010
  • 20. Augmenting your Module - YUI Base ‣ Base provides a standard template for creating modules with consistent API. ‣ NAME property ‣ Attrs property ‣ Custom events ‣ Initialization methods ‣ Destroy methods JSCONF 2010
  • 22. YUI Base: Attribute ‣ Consistent API and documentation - Blue prints JSCONF 2010
  • 23. YUI Base: Attribute ‣ Consistent API and documentation - Blue prints ‣ Built in Setters and Getters JSCONF 2010
  • 24. YUI Base: Attribute ‣ Consistent API and documentation - Blue prints ‣ Built in Setters and Getters ‣ NameSpacing JSCONF 2010
  • 25. YUI Base: Attribute ‣ Consistent API and documentation - Blue prints ‣ Built in Setters and Getters ‣ NameSpacing http://developer.yahoo.com/yui/3/attribute/ JSCONF 2010
  • 26. YUI Base : Attribute YUI.add('foo', function (Y) { function MyClass(config) { //Invoke Base constructor, passing through arguments MyClass.superclass.constructor.apply(this, arguments); } MyClass.NAME = “myName”; MyClass.ATTRS = { someAttribute: {}, someOther : {} } Y.extend(MyClass, Y.Base, { // Prototype methods for your new class }); }); JSCONF 2010
  • 27. YUI Base - Events JSCONF 2010
  • 28. YUI Base - Events ‣ Custom events JSCONF 2010
  • 29. YUI Base - Events ‣ Custom events ‣ Bubbling JSCONF 2010
  • 30. YUI Base - Events ‣ Custom events ‣ Bubbling ‣ Event Broadcasting JSCONF 2010
  • 31. YUI Base - Events ‣ Custom events ‣ Bubbling ‣ Event Broadcasting http://developer.yahoo.com/yui/3/base/ JSCONF 2010
  • 32. YUI Base YUI.add('foo', function (Y) { Goonie.prototype.neverSayDie = { this.fire(“neverSayDie”); } var myGoonie = new Goonie(); myGoonie.on(“neverSayDie”, function(e) { //Actually listening for (“Goonie:neverSayDie”); alert(“Hey you guys!!”); }); }); JSCONF 2010
  • 33. Loading Strategies - By Inclusion YUI.add('today', function (Y) { Y.today = new Date(); },0.0.1,{requires[‘node’]}); YUI.use('today', function (Y) { Y.one('#when').setContent( Y.today ); }); JSCONF 2010
  • 34. Loading Strategies - By Configuration YUI({ modules: { 'foo': { fullpath: 'foo.js', requires: ['node'] } }).use('foo', function (Y) { //foo ready to use }); JSCONF 2010
  • 35. Loading strategies Or... JSCONF 2010
  • 36. Introducing The YUI Gallery YUICONF 2009
  • 37. I can haz YUI Gallery Image Title JSCONF 2010
  • 39. Introducing YUI Gallery ‣ Instant access to hundreds of “first-class” modules. JSCONF 2010
  • 40. Introducing YUI Gallery ‣ Instant access to hundreds of “first-class” modules. ‣ From developer to developer. JSCONF 2010
  • 41. Introducing YUI Gallery ‣ Instant access to hundreds of “first-class” modules. ‣ From developer to developer. ‣ Simply by add them into your YUI.use() statement. JSCONF 2010
  • 42. Introducing YUI Gallery ‣ Instant access to hundreds of “first-class” modules. ‣ From developer to developer. ‣ Simply by add them into your YUI.use() statement. ‣ Some examples: YQL module, Accordion, Twitter status display, etc. JSCONF 2010
  • 44. Demo: YQL + DD + Flickr YUI({gallery: 'gallery-2010.01.27-20'}).use("anim", "dd","gallery-yql", function (Y) { //On DropHit var flickrq = new Y.yql('select * from flickr.photos.search where (text = "'+tags+'")'); flickrq.on(‘query’,function(response) { //Load Photos }); }); JSCONF 2010
  • 45. Contributing to the YUI Gallery JSCONF 2010
  • 47. Benefits ‣ Your code in our CDN! JSCONF 2010
  • 48. Benefits ‣ Your code in our CDN! ‣ Your module live within one week JSCONF 2010
  • 49. Benefits ‣ Your code in our CDN! ‣ Your module live within one week ‣ Visibility JSCONF 2010
  • 50. Benefits ‣ Your code in our CDN! ‣ Your module live within one week ‣ Visibility ‣ Easy access within your YUI().use statament. JSCONF 2010
  • 51. Benefits ‣ Your code in our CDN! ‣ Your module live within one week ‣ Visibility ‣ Easy access within your YUI().use statament. ‣ Contributing and being part of the JS community. JSCONF 2010
  • 53. How to contribute ‣ 1 - Create your module JSCONF 2010
  • 54. How to contribute ‣ 1 - Create your module ‣ 2 - Create a YUI Library account JSCONF 2010
  • 55. How to contribute ‣ 1 - Create your module ‣ 2 - Create a YUI Library account ‣ 3- Fork YUI3 on github JSCONF 2010
  • 56. How to contribute ‣ 1 - Create your module ‣ 2 - Create a YUI Library account ‣ 3- Fork YUI3 on github ‣ 4- Submit your module JSCONF 2010
  • 57. How to contribute ‣ 1 - Create your module ‣ 2 - Create a YUI Library account ‣ 3- Fork YUI3 on github ‣ 4- Submit your module ‣ 5- Get approved - Your code now live on Yahoo! CDN servers. JSCONF 2010
  • 58. How to contribute ‣ 1 - Create your module ‣ 2 - Create a YUI Library account ‣ 3- Fork YUI3 on github ‣ 4- Submit your module ‣ 5- Get approved - Your code now live on Yahoo! CDN servers. http://yuilibrary.com/gallery/ JSCONF 2010
  • 59. YUI3 - Custom Modules Gonzalo Cordero yuilibrary: gonzalocordero github: goonieiam twitter: @goonieiam JSCONF 2009

Editor's Notes

  1. In YUI 3, the new global is YUI YUI is a function, not just an object bag ala YAHOO. It returns an instance, your sandbox. The library API is added to the YUI instance, not YUI. Facilitates having multiple sandboxes on a page w/o collision.
  2. - Custom modules are made available to YUI instances by registering themselves via YUI.add() - As with Y.use(), YUI.add() provides an applied module pattern - This gives you a truly private space to define vars and functions local to your module - Code defined inside add() is held by the YUI infrastructure to execute at the proper time - Module code is not executed until a YUI instance requests it via Y.use(&apos;my-module&apos;, function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
  3. - Custom modules are made available to YUI instances by registering themselves via YUI.add() - As with Y.use(), YUI.add() provides an applied module pattern - This gives you a truly private space to define vars and functions local to your module - Code defined inside add() is held by the YUI infrastructure to execute at the proper time - Module code is not executed until a YUI instance requests it via Y.use(&apos;my-module&apos;, function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
  4. - Custom modules are made available to YUI instances by registering themselves via YUI.add() - As with Y.use(), YUI.add() provides an applied module pattern - This gives you a truly private space to define vars and functions local to your module - Code defined inside add() is held by the YUI infrastructure to execute at the proper time - Module code is not executed until a YUI instance requests it via Y.use(&apos;my-module&apos;, function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
  5. - Custom modules are made available to YUI instances by registering themselves via YUI.add() - As with Y.use(), YUI.add() provides an applied module pattern - This gives you a truly private space to define vars and functions local to your module - Code defined inside add() is held by the YUI infrastructure to execute at the proper time - Module code is not executed until a YUI instance requests it via Y.use(&apos;my-module&apos;, function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
  6. - &apos;version&apos; has nothing to do with the YUI version you require - &apos;version&apos; allows you to define version information for your component - &apos;requires&apos; defines the dependancies for your component
  7. - &apos;version&apos; has nothing to do with the YUI version you require - &apos;version&apos; allows you to define version information for your component - &apos;requires&apos; defines the dependancies for your component
  8. - &apos;version&apos; has nothing to do with the YUI version you require - &apos;version&apos; allows you to define version information for your component - &apos;requires&apos; defines the dependancies for your component