SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
YUI3 : MODULES
                            Base - Plugin - Widget




Wednesday, June 8, 2011
CLASS CREATION

Wednesday, June 8, 2011
CLASS OBJECTS
    Constructor Functions
               function wooga() {}

               var wooga = function(){};




Wednesday, June 8, 2011
PROPERTIES
    function Fooga() {
        this.wooga = 'wooga';
    }

    Fooga.PI = Math.PI;

    Fooga.prototype.nooga = function(){
        return 42;
    };




Wednesday, June 8, 2011
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
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
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
BASE

Wednesday, June 8, 2011
UNDER THE HOOD

    • Event Target              - publish(), fire(), once(), before(), on(), after()

    • Attribute  - set(), get(), value, valueFn, setter, getter, validator,
       readOnly, writeOnce

    • Plugin              Host - plug(), unplug(), hasPlugin()




Wednesday, June 8, 2011
METHODS

    • Static          - create(), mix(), plug(), unplug()

    • Life        Cycle - init(), destroy()




Wednesday, June 8, 2011
EVENTS AND CONFIG

    • Configuration               - initialize, destroyed

    • Events              - init, initializedChange, destroy, destroyedChange




Wednesday, June 8, 2011
EXAMPLE
    YUI.add('calc', function(Y){

           Y.Calc = Y.Base.create('calc', Y.Base, [], {

                  add : function() {
                      var total = this.get('total'),
                          args = arguments;

                          Y.Array.each(args, function(val) {
                              total += parseFloat(val, 10);
                          });

                          this.set('total', total);
                          return total;
                  }

           }, {
                  ATTRS : {
                      total : {
                          value : 0
                      }
                  }
           });

    }, '1.0.0', { requires: ['base'] });

Wednesday, June 8, 2011
PLUGIN

Wednesday, June 8, 2011
LIFE CYCLE

    • initializer         - fired on plug()

    • destructor           - fired on unplug()




Wednesday, June 8, 2011
METHODS

    • Life        Cycle - initializer(), destructor()

    • Host           Method - beforeHostMethod(), afterHostMethod()

    • Host           Event - onHostEvent(), afterHostEvent()




Wednesday, June 8, 2011
EVENTS AND CONFIG

    • host          - object that gets plugged

    • hostChange           - fires when the host has changed




Wednesday, June 8, 2011
EXAMPLE
    YUI.add('my-plugin', function(Y){

          Y.Plugin.MyPlugin = Y.Base.create('my-plugin', Y.Plugin.Base, [], {

                 _clickHandle : null,
                 initializer : function() {
                     this._bindUI();
                 },
                 destructor : function() {
                     var handle = this._clickHandle;
                     if (handle) {
                         handle.detach();
                     }
                 },
                 _bindUI : function() {
                     this._clickHandle = this.get('host').on('click', this._preventClick, this);
                 },
                 _preventClick : function(e) {
                     e.preventDefault();
                     Y.log('click prevented');
                 }

          }, {
                 NS : 'my-plugin',
                 ATTRS : {}
          });

    }, '1.0.0', { requires: ['plugin', 'base-build'] });



Wednesday, June 8, 2011
WIDGET

Wednesday, June 8, 2011
LIFE CYCLE

    • initializer

    • render

             • renderUI

             • bindUI

             • syncUI

    • destructor

Wednesday, June 8, 2011
METHODS

    • focus           - blur(), focus()

    • enable              - enable(), disable()

    • show            - show(), hide()

    • getClassName()

    • getSkinName()




Wednesday, June 8, 2011
EVENTS AND CONFIG

    • boundingBox                  • boundingBoxChange

    • contentBox                   • contentBoxChange

    • srcNode                      • srcNodeChange

    • tabIndex                     • tabIndexChange

    • rendered                     • renderedChange

    • visible                      • visibleChange

Wednesday, June 8, 2011
EXAMPLE
    YUI.add('my-widget', function(Y){

          Y.MyWidget = Y.Base.create('my-widget', Y.Widget, [], {

                 renderUI : function() {
                     var cb = this.get('contentBox');
                     cb.append(Y.Node.create('<strong />'));
                     cb.one('strong').setContent(this.get('content'));
                 },
                 bindUI : function() {
                     var strongNode = this.get('contentBox').one('strong');
                     strongNode.on('click', function(e){
                         e.currentTarget.toggleClass('blue');
                     });
                 }

          }, {
                 ATTRS : {
                     content : {
                         value : 'Widget Content'
                     }
                 }
          });

    }, '1.0.0', { requires: ['widget', 'base-build'] });




Wednesday, June 8, 2011
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
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

Más contenido relacionado

La actualidad más candente

Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍louieuser
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UIRebecca Murphey
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performancejohndaviddalton
 
Idiots guide to jquery
Idiots guide to jqueryIdiots guide to jquery
Idiots guide to jqueryMark Casias
 
JQuery New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New EvolutionAllan Huang
 
The Ring programming language version 1.5.4 book - Part 60 of 185
The Ring programming language version 1.5.4 book - Part 60 of 185The Ring programming language version 1.5.4 book - Part 60 of 185
The Ring programming language version 1.5.4 book - Part 60 of 185Mahmoud Samir Fayed
 
Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019UA Mobile
 
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202Mahmoud Samir Fayed
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
Fabric.js @ Falsy Values
Fabric.js @ Falsy ValuesFabric.js @ Falsy Values
Fabric.js @ Falsy ValuesJuriy Zaytsev
 
Building a Pluggable Plugin
Building a Pluggable PluginBuilding a Pluggable Plugin
Building a Pluggable PluginBrandon Dove
 
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019Codemotion
 
The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184Mahmoud Samir Fayed
 
Creating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsCreating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsSencha
 

La actualidad más candente (20)

Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍
 
Xquery
XqueryXquery
Xquery
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UI
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
 
Idiots guide to jquery
Idiots guide to jqueryIdiots guide to jquery
Idiots guide to jquery
 
JQuery New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New Evolution
 
HTML,CSS Next
HTML,CSS NextHTML,CSS Next
HTML,CSS Next
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
The Ring programming language version 1.5.4 book - Part 60 of 185
The Ring programming language version 1.5.4 book - Part 60 of 185The Ring programming language version 1.5.4 book - Part 60 of 185
The Ring programming language version 1.5.4 book - Part 60 of 185
 
Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019
 
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
Fabric.js @ Falsy Values
Fabric.js @ Falsy ValuesFabric.js @ Falsy Values
Fabric.js @ Falsy Values
 
Building a Pluggable Plugin
Building a Pluggable PluginBuilding a Pluggable Plugin
Building a Pluggable Plugin
 
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
 
The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184
 
Phactory
PhactoryPhactory
Phactory
 
Creating Ext GWT Extensions and Components
Creating Ext GWT Extensions and ComponentsCreating Ext GWT Extensions and Components
Creating Ext GWT Extensions and Components
 
New text document
New text documentNew text document
New text document
 

Destacado

Exposicion sobre los Derechos Humanos UNEFA
Exposicion sobre los Derechos Humanos UNEFAExposicion sobre los Derechos Humanos UNEFA
Exposicion sobre los Derechos Humanos UNEFAJose Gil
 
Titulos propuestos del plan de la patria 2015
Titulos propuestos del plan de la patria 2015Titulos propuestos del plan de la patria 2015
Titulos propuestos del plan de la patria 2015UNEFA MARACAY
 
Defensas (derechos humanos en venezuela)
Defensas (derechos humanos en venezuela)Defensas (derechos humanos en venezuela)
Defensas (derechos humanos en venezuela)Jose Gil
 
Antecedentes de los derechos humanos
Antecedentes de los derechos humanosAntecedentes de los derechos humanos
Antecedentes de los derechos humanosCECILIA MOTTA ZARARTE
 
Tema 4. Sistemas de protección de los Derechos HUmanos
Tema 4. Sistemas de protección de los Derechos HUmanos Tema 4. Sistemas de protección de los Derechos HUmanos
Tema 4. Sistemas de protección de los Derechos HUmanos Fmorin84
 
Plan de gobierno 2013 2019
Plan de gobierno 2013 2019Plan de gobierno 2013 2019
Plan de gobierno 2013 20193230594
 
Derechos humanos en venezuela
Derechos humanos en venezuelaDerechos humanos en venezuela
Derechos humanos en venezuelaAngello Ferrari
 
Derechos humanos
Derechos humanosDerechos humanos
Derechos humanosKAtiRojChu
 

Destacado (8)

Exposicion sobre los Derechos Humanos UNEFA
Exposicion sobre los Derechos Humanos UNEFAExposicion sobre los Derechos Humanos UNEFA
Exposicion sobre los Derechos Humanos UNEFA
 
Titulos propuestos del plan de la patria 2015
Titulos propuestos del plan de la patria 2015Titulos propuestos del plan de la patria 2015
Titulos propuestos del plan de la patria 2015
 
Defensas (derechos humanos en venezuela)
Defensas (derechos humanos en venezuela)Defensas (derechos humanos en venezuela)
Defensas (derechos humanos en venezuela)
 
Antecedentes de los derechos humanos
Antecedentes de los derechos humanosAntecedentes de los derechos humanos
Antecedentes de los derechos humanos
 
Tema 4. Sistemas de protección de los Derechos HUmanos
Tema 4. Sistemas de protección de los Derechos HUmanos Tema 4. Sistemas de protección de los Derechos HUmanos
Tema 4. Sistemas de protección de los Derechos HUmanos
 
Plan de gobierno 2013 2019
Plan de gobierno 2013 2019Plan de gobierno 2013 2019
Plan de gobierno 2013 2019
 
Derechos humanos en venezuela
Derechos humanos en venezuelaDerechos humanos en venezuela
Derechos humanos en venezuela
 
Derechos humanos
Derechos humanosDerechos humanos
Derechos humanos
 

Similar a YUI3 Modules

Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webappsHenrik Joreteg
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfMorgan Cheng
 
Programação GUI com jRuby
Programação GUI com jRubyProgramação GUI com jRuby
Programação GUI com jRubyFrevo on Rails
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin developmentFaruk Hossen
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan YuiJH Lee
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern偉格 高
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture ComponentsBurhanuddinRashid
 
Super Awesome Interactions with jQuery
Super Awesome Interactions with jQuerySuper Awesome Interactions with jQuery
Super Awesome Interactions with jQueryZURB
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4jeresig
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
Backbone intro
Backbone introBackbone intro
Backbone introIan Yang
 
Android Opensources - ButterKnife, Lombok
Android Opensources - ButterKnife, LombokAndroid Opensources - ButterKnife, Lombok
Android Opensources - ButterKnife, LombokWooseong Kim
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testingjeresig
 
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with MagentoMagento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magentovarien
 
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagentoImagine
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-goikailan
 

Similar a YUI3 Modules (20)

Testable Javascript
Testable JavascriptTestable Javascript
Testable Javascript
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webapps
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend Perf
 
Programação GUI com jRuby
Programação GUI com jRubyProgramação GUI com jRuby
Programação GUI com jRuby
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin development
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture Components
 
Super Awesome Interactions with jQuery
Super Awesome Interactions with jQuerySuper Awesome Interactions with jQuery
Super Awesome Interactions with jQuery
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
Backbone intro
Backbone introBackbone intro
Backbone intro
 
Android Opensources - ButterKnife, Lombok
Android Opensources - ButterKnife, LombokAndroid Opensources - ButterKnife, Lombok
Android Opensources - ButterKnife, Lombok
 
Essential YUI
Essential YUIEssential YUI
Essential YUI
 
Slide
SlideSlide
Slide
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with MagentoMagento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
 
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-go
 

Último

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

YUI3 Modules

  • 1. YUI3 : MODULES Base - Plugin - Widget Wednesday, June 8, 2011
  • 3. CLASS OBJECTS Constructor Functions function wooga() {} var wooga = function(){}; Wednesday, June 8, 2011
  • 4. PROPERTIES function Fooga() { this.wooga = 'wooga'; } Fooga.PI = Math.PI; Fooga.prototype.nooga = function(){ return 42; }; Wednesday, June 8, 2011
  • 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
  • 9. UNDER THE HOOD • Event Target - publish(), fire(), once(), before(), on(), after() • Attribute - set(), get(), value, valueFn, setter, getter, validator, readOnly, writeOnce • Plugin Host - plug(), unplug(), hasPlugin() Wednesday, June 8, 2011
  • 10. METHODS • Static - create(), mix(), plug(), unplug() • Life Cycle - init(), destroy() Wednesday, June 8, 2011
  • 11. EVENTS AND CONFIG • Configuration - initialize, destroyed • Events - init, initializedChange, destroy, destroyedChange Wednesday, June 8, 2011
  • 12. EXAMPLE YUI.add('calc', function(Y){ Y.Calc = Y.Base.create('calc', Y.Base, [], { add : function() { var total = this.get('total'), args = arguments; Y.Array.each(args, function(val) { total += parseFloat(val, 10); }); this.set('total', total); return total; } }, { ATTRS : { total : { value : 0 } } }); }, '1.0.0', { requires: ['base'] }); Wednesday, June 8, 2011
  • 14. LIFE CYCLE • initializer - fired on plug() • destructor - fired on unplug() Wednesday, June 8, 2011
  • 15. METHODS • Life Cycle - initializer(), destructor() • Host Method - beforeHostMethod(), afterHostMethod() • Host Event - onHostEvent(), afterHostEvent() Wednesday, June 8, 2011
  • 16. EVENTS AND CONFIG • host - object that gets plugged • hostChange - fires when the host has changed Wednesday, June 8, 2011
  • 17. EXAMPLE YUI.add('my-plugin', function(Y){ Y.Plugin.MyPlugin = Y.Base.create('my-plugin', Y.Plugin.Base, [], { _clickHandle : null, initializer : function() { this._bindUI(); }, destructor : function() { var handle = this._clickHandle; if (handle) { handle.detach(); } }, _bindUI : function() { this._clickHandle = this.get('host').on('click', this._preventClick, this); }, _preventClick : function(e) { e.preventDefault(); Y.log('click prevented'); } }, { NS : 'my-plugin', ATTRS : {} }); }, '1.0.0', { requires: ['plugin', 'base-build'] }); Wednesday, June 8, 2011
  • 19. LIFE CYCLE • initializer • render • renderUI • bindUI • syncUI • destructor Wednesday, June 8, 2011
  • 20. METHODS • focus - blur(), focus() • enable - enable(), disable() • show - show(), hide() • getClassName() • getSkinName() Wednesday, June 8, 2011
  • 21. EVENTS AND CONFIG • boundingBox • boundingBoxChange • contentBox • contentBoxChange • srcNode • srcNodeChange • tabIndex • tabIndexChange • rendered • renderedChange • visible • visibleChange Wednesday, June 8, 2011
  • 22. EXAMPLE YUI.add('my-widget', function(Y){ Y.MyWidget = Y.Base.create('my-widget', Y.Widget, [], { renderUI : function() { var cb = this.get('contentBox'); cb.append(Y.Node.create('<strong />')); cb.one('strong').setContent(this.get('content')); }, bindUI : function() { var strongNode = this.get('contentBox').one('strong'); strongNode.on('click', function(e){ e.currentTarget.toggleClass('blue'); }); } }, { ATTRS : { content : { value : 'Widget Content' } } }); }, '1.0.0', { requires: ['widget', 'base-build'] }); 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