SlideShare a Scribd company logo
1 of 35
Download to read offline
KISSY




KISSY Component API Design
                    yiminghe@gmail.com

                       2012-06-05 draft
KISSY
                                                      2



             Outline
•   Why create component
•   Why API design
•   KISSY Component API Design
•   API Design principles

             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                               3



            Components




http://docs.kissyui.com/kissy-bootstrap/docs/

                      docs.kissyui.com | kissyteam@gmail.com
KISSY
                                           4



Components




  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                     5



Why create components

• Ease of development




            docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         6



Why create components

• Ease of development

• Reusability


                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         7



Why create components

• Ease of development

• Reusability

•Maintainability
                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                        8



       Why API Design

• Contract between user and developer




               docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         9



        Why API Design

• Contract between user and developer

• Stable platform to build on



                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                      1
                                                                      0



            Why API Design

• Contract between user and developer

• Stable platform to build on
• Minimize waste
  •   Code-reuse instead of re-writing
  •   Reduce code and complexity


                             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             1



  Component API Design
• Structure
• Subcomponent
• Subclass
• Plugin
• Events
    • Lifecycle event
• Skin
• Creation

                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                        1
                                                        2



              Structure

• Config

• Attribute

• Method

               docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             3



                    Config

• Config
new Overlay({
      width:100,
      height:100,
      content:'i am overlay'
})

                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                               1
                                                               4



                    Attribute

• Attribute
   • Talk to your component

var o=new Overlay({});
o.get("content");
o.set("content","xx");



                      docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                 1
                                                                 5



                     Method

• Method
   • Attribute first, method second

var o=new Tree({});
o.collapseAll();
o.set(“collapsed",true);



                        docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             6



          Subcomponent

•Config/Attribute
  • Children



•Method
  • addChild/removeChild/removeChildren


                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                       1
                                                                       7



              Subcomponent

•Config/Attribute
      • Children

var o=new Menu({
children:[{new Menu.Item(){}},{xclass:'menuitem‘, content:'menuitem-
content2'}]
});
o.get("children");



                          docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                              1
                                                              8



          Subcomponent

•Method
   • addChild/removeChild/removeChildren

var o=new Menu({});
o.addChild(new Menu.Item());




                     docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             9



              Subclass
                      var MyOverlay = Overlay.extend({
                                  initialize:function(){},
• Easy to extend                  createDom:function(){},
                                  renderUI:function(){},
                                  syncUI:function(){}
                      },{
                                  ATTRS:{
                                             myAttr:{}
                                  }
                      });
                   docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                   2
                                                                   0


                Plugin

• enhance ability            var editor = new Editor({
                                    plugins:[
dynamically at
                                       FontSize,
runtime                                new Image({
                                                url:’upload.htm’
                                       })]
                             });


                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                    2
                                                                    1



                           Events
• Event
    • Native lifecycle event / attrChange event / Custom event
    • Method: on / detach
    • Config : listeners
{
type:,
target:, // consider bubbling
yy:xx
}



                           docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           2



                  Events

• Custom Event
var o = new Overlay({
 listeners : { hide : { fn : function(){}}}
});
o.on("show",function(){
});

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                      2
                                                                      3



                           Events

• Lifecycle event
      • beforeCreateDom/afterCreateDom/beforeRenderUI/afterRenderUI
        /beforeBindUI/afterBindUI/..

var o=new Overlay();
o.on("afterCreateDom",function(){
  alert(o.get("el"));
});

                           docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                   2
                                                                   4



                          Events

• AttrChange event
      • beforeAttrChange/afterAttrChangeDom

var o=new Button.Toggle();
o.on("afterCheckedChange",function(){
 alert(o.get(“checked"));
});


                          docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             2
                                                             5



                          Skin

• Config
   • prefixCls

new Button({
      prefixCls:"xx-"
});



                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                      2
                                                      6



            Creation

• new

• srcNode

• xclass

             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           7



                Creation

• new

var m = new Menu();
m.addChild(new Menu.Item());
m.on("click",function(){})
m.render();


                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                           2
                                                                           8



                  Creation

• srcNode                                   new Menu({
                                                 srcNode:div,
<div class='ks-menu'>                            listeners:{
<div class='ks-                                        click:function(){
  menuitem'></div>                                     }
</div>                                           }
                                            });

                     docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           9



             Creation
           new Menu({
• xclass    children:[{
              xclass:'menuitem',
              content:'yy'
            }],
            render:container,
            listeners:{
              click:function(){}
           }});
                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           0



      API Design Principle

• Hide implementation

new Overlay({
// view: new OverlayRender()
});



                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           1



    API Design Principle

• Easy to learn
  • consistency
  • simple


• elCls/el/srcNode/get()/set()

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           2



    API Design Principle

• Easy to read and write
new Overlay({
  width:,
  height:'',
  children:[{
  xclass:'menu'
}]});

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                            3
                                                            3



    API Design Principle

• Easy to extend


var MyOverlay = Overlay.extend(…);


                   docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           4



     API Design Principle

• make api complete
• separate concern


• new/addChild/removeChild/destroy/on/detach


                  docs.kissyui.com | kissyteam@gmail.com
KISSY




THANKS FOR
  COMING
   SEE YOU SOON!

More Related Content

More from yiming he

KISSY 1.4.0 released
KISSY 1.4.0 releasedKISSY 1.4.0 released
KISSY 1.4.0 releasedyiming he
 
callSuper in kissy
callSuper in kissycallSuper in kissy
callSuper in kissyyiming he
 
KISSY XTemplate
KISSY XTemplateKISSY XTemplate
KISSY XTemplateyiming he
 
Introduction to kissy for adc 2013
Introduction to kissy for adc 2013Introduction to kissy for adc 2013
Introduction to kissy for adc 2013yiming he
 
Kissy component system
Kissy component systemKissy component system
Kissy component systemyiming he
 
KISSY@2013.05
KISSY@2013.05KISSY@2013.05
KISSY@2013.05yiming he
 
kissy@2013.03
kissy@2013.03 kissy@2013.03
kissy@2013.03 yiming he
 
KISSY 1.3-released
KISSY 1.3-releasedKISSY 1.3-released
KISSY 1.3-releasedyiming he
 
Simple kissy1.3
Simple kissy1.3Simple kissy1.3
Simple kissy1.3yiming he
 
Kissy in-progress
Kissy in-progressKissy in-progress
Kissy in-progressyiming he
 
Kissy dpl-practice
Kissy dpl-practiceKissy dpl-practice
Kissy dpl-practiceyiming he
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2yiming he
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2yiming he
 
Kissy autocomplete
Kissy autocompleteKissy autocomplete
Kissy autocompleteyiming he
 
KISSY_Component
KISSY_ComponentKISSY_Component
KISSY_Componentyiming he
 
How to reduce connections with kissy
How to reduce connections with kissyHow to reduce connections with kissy
How to reduce connections with kissyyiming he
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" IntroductionCaja "Ka-ha" Introduction
Caja "Ka-ha" Introductionyiming he
 

More from yiming he (20)

KISSY 1.4.0 released
KISSY 1.4.0 releasedKISSY 1.4.0 released
KISSY 1.4.0 released
 
callSuper in kissy
callSuper in kissycallSuper in kissy
callSuper in kissy
 
KISSY XTemplate
KISSY XTemplateKISSY XTemplate
KISSY XTemplate
 
Introduction to kissy for adc 2013
Introduction to kissy for adc 2013Introduction to kissy for adc 2013
Introduction to kissy for adc 2013
 
Kissy component system
Kissy component systemKissy component system
Kissy component system
 
KISSY@2013.05
KISSY@2013.05KISSY@2013.05
KISSY@2013.05
 
kissy@2013.03
kissy@2013.03 kissy@2013.03
kissy@2013.03
 
kissy@2013
kissy@2013kissy@2013
kissy@2013
 
KISSY 1.3-released
KISSY 1.3-releasedKISSY 1.3-released
KISSY 1.3-released
 
Simple kissy1.3
Simple kissy1.3Simple kissy1.3
Simple kissy1.3
 
Hujs 总结
Hujs 总结Hujs 总结
Hujs 总结
 
Kissy in-progress
Kissy in-progressKissy in-progress
Kissy in-progress
 
Kissy dpl-practice
Kissy dpl-practiceKissy dpl-practice
Kissy dpl-practice
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2
 
Kissy autocomplete
Kissy autocompleteKissy autocomplete
Kissy autocomplete
 
KISSY_Component
KISSY_ComponentKISSY_Component
KISSY_Component
 
How to reduce connections with kissy
How to reduce connections with kissyHow to reduce connections with kissy
How to reduce connections with kissy
 
Kissy mvc
Kissy mvcKissy mvc
Kissy mvc
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" IntroductionCaja "Ka-ha" Introduction
Caja "Ka-ha" Introduction
 

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
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

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
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

KISSY Component API Design

  • 1. KISSY KISSY Component API Design yiminghe@gmail.com 2012-06-05 draft
  • 2. KISSY 2 Outline • Why create component • Why API design • KISSY Component API Design • API Design principles docs.kissyui.com | kissyteam@gmail.com
  • 3. KISSY 3 Components http://docs.kissyui.com/kissy-bootstrap/docs/ docs.kissyui.com | kissyteam@gmail.com
  • 4. KISSY 4 Components docs.kissyui.com | kissyteam@gmail.com
  • 5. KISSY 5 Why create components • Ease of development docs.kissyui.com | kissyteam@gmail.com
  • 6. KISSY 6 Why create components • Ease of development • Reusability docs.kissyui.com | kissyteam@gmail.com
  • 7. KISSY 7 Why create components • Ease of development • Reusability •Maintainability docs.kissyui.com | kissyteam@gmail.com
  • 8. KISSY 8 Why API Design • Contract between user and developer docs.kissyui.com | kissyteam@gmail.com
  • 9. KISSY 9 Why API Design • Contract between user and developer • Stable platform to build on docs.kissyui.com | kissyteam@gmail.com
  • 10. KISSY 1 0 Why API Design • Contract between user and developer • Stable platform to build on • Minimize waste • Code-reuse instead of re-writing • Reduce code and complexity docs.kissyui.com | kissyteam@gmail.com
  • 11. KISSY 1 1 Component API Design • Structure • Subcomponent • Subclass • Plugin • Events • Lifecycle event • Skin • Creation docs.kissyui.com | kissyteam@gmail.com
  • 12. KISSY 1 2 Structure • Config • Attribute • Method docs.kissyui.com | kissyteam@gmail.com
  • 13. KISSY 1 3 Config • Config new Overlay({ width:100, height:100, content:'i am overlay' }) docs.kissyui.com | kissyteam@gmail.com
  • 14. KISSY 1 4 Attribute • Attribute • Talk to your component var o=new Overlay({}); o.get("content"); o.set("content","xx"); docs.kissyui.com | kissyteam@gmail.com
  • 15. KISSY 1 5 Method • Method • Attribute first, method second var o=new Tree({}); o.collapseAll(); o.set(“collapsed",true); docs.kissyui.com | kissyteam@gmail.com
  • 16. KISSY 1 6 Subcomponent •Config/Attribute • Children •Method • addChild/removeChild/removeChildren docs.kissyui.com | kissyteam@gmail.com
  • 17. KISSY 1 7 Subcomponent •Config/Attribute • Children var o=new Menu({ children:[{new Menu.Item(){}},{xclass:'menuitem‘, content:'menuitem- content2'}] }); o.get("children"); docs.kissyui.com | kissyteam@gmail.com
  • 18. KISSY 1 8 Subcomponent •Method • addChild/removeChild/removeChildren var o=new Menu({}); o.addChild(new Menu.Item()); docs.kissyui.com | kissyteam@gmail.com
  • 19. KISSY 1 9 Subclass var MyOverlay = Overlay.extend({ initialize:function(){}, • Easy to extend createDom:function(){}, renderUI:function(){}, syncUI:function(){} },{ ATTRS:{ myAttr:{} } }); docs.kissyui.com | kissyteam@gmail.com
  • 20. KISSY 2 0 Plugin • enhance ability var editor = new Editor({ plugins:[ dynamically at FontSize, runtime new Image({ url:’upload.htm’ })] }); docs.kissyui.com | kissyteam@gmail.com
  • 21. KISSY 2 1 Events • Event • Native lifecycle event / attrChange event / Custom event • Method: on / detach • Config : listeners { type:, target:, // consider bubbling yy:xx } docs.kissyui.com | kissyteam@gmail.com
  • 22. KISSY 2 2 Events • Custom Event var o = new Overlay({ listeners : { hide : { fn : function(){}}} }); o.on("show",function(){ }); docs.kissyui.com | kissyteam@gmail.com
  • 23. KISSY 2 3 Events • Lifecycle event • beforeCreateDom/afterCreateDom/beforeRenderUI/afterRenderUI /beforeBindUI/afterBindUI/.. var o=new Overlay(); o.on("afterCreateDom",function(){ alert(o.get("el")); }); docs.kissyui.com | kissyteam@gmail.com
  • 24. KISSY 2 4 Events • AttrChange event • beforeAttrChange/afterAttrChangeDom var o=new Button.Toggle(); o.on("afterCheckedChange",function(){ alert(o.get(“checked")); }); docs.kissyui.com | kissyteam@gmail.com
  • 25. KISSY 2 5 Skin • Config • prefixCls new Button({ prefixCls:"xx-" }); docs.kissyui.com | kissyteam@gmail.com
  • 26. KISSY 2 6 Creation • new • srcNode • xclass docs.kissyui.com | kissyteam@gmail.com
  • 27. KISSY 2 7 Creation • new var m = new Menu(); m.addChild(new Menu.Item()); m.on("click",function(){}) m.render(); docs.kissyui.com | kissyteam@gmail.com
  • 28. KISSY 2 8 Creation • srcNode new Menu({ srcNode:div, <div class='ks-menu'> listeners:{ <div class='ks- click:function(){ menuitem'></div> } </div> } }); docs.kissyui.com | kissyteam@gmail.com
  • 29. KISSY 2 9 Creation new Menu({ • xclass children:[{ xclass:'menuitem', content:'yy' }], render:container, listeners:{ click:function(){} }}); docs.kissyui.com | kissyteam@gmail.com
  • 30. KISSY 3 0 API Design Principle • Hide implementation new Overlay({ // view: new OverlayRender() }); docs.kissyui.com | kissyteam@gmail.com
  • 31. KISSY 3 1 API Design Principle • Easy to learn • consistency • simple • elCls/el/srcNode/get()/set() docs.kissyui.com | kissyteam@gmail.com
  • 32. KISSY 3 2 API Design Principle • Easy to read and write new Overlay({ width:, height:'', children:[{ xclass:'menu' }]}); docs.kissyui.com | kissyteam@gmail.com
  • 33. KISSY 3 3 API Design Principle • Easy to extend var MyOverlay = Overlay.extend(…); docs.kissyui.com | kissyteam@gmail.com
  • 34. KISSY 3 4 API Design Principle • make api complete • separate concern • new/addChild/removeChild/destroy/on/detach docs.kissyui.com | kissyteam@gmail.com
  • 35. KISSY THANKS FOR COMING SEE YOU SOON!