SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Kürzlich hochgeladen (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

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