15. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
JSCONF 2010
16. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
‣ NAME property
JSCONF 2010
17. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
‣ NAME property
‣ Attrs property
JSCONF 2010
18. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
‣ NAME property
‣ Attrs property
‣ Custom events
JSCONF 2010
19. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
‣ NAME property
‣ Attrs property
‣ Custom events
‣ Initialization methods
JSCONF 2010
20. Augmenting your Module - YUI
Base
‣ Base provides a standard template for creating
modules with consistent API.
‣ NAME property
‣ Attrs property
‣ Custom events
‣ Initialization methods
‣ Destroy methods
JSCONF 2010
23. YUI Base: Attribute
‣ Consistent API and documentation - Blue prints
‣ Built in Setters and Getters
JSCONF 2010
24. YUI Base: Attribute
‣ Consistent API and documentation - Blue prints
‣ Built in Setters and Getters
‣ NameSpacing
JSCONF 2010
25. YUI Base: Attribute
‣ Consistent API and documentation - Blue prints
‣ Built in Setters and Getters
‣ NameSpacing
http://developer.yahoo.com/yui/3/attribute/
JSCONF 2010
26. YUI Base : Attribute
YUI.add('foo', function (Y) {
function MyClass(config) {
//Invoke Base constructor, passing through arguments
MyClass.superclass.constructor.apply(this, arguments);
}
MyClass.NAME = “myName”;
MyClass.ATTRS = {
someAttribute: {},
someOther : {}
}
Y.extend(MyClass, Y.Base, {
// Prototype methods for your new class
});
});
JSCONF 2010
40. Introducing YUI Gallery
‣ Instant access to hundreds of “first-class” modules.
‣ From developer to developer.
JSCONF 2010
41. Introducing YUI Gallery
‣ Instant access to hundreds of “first-class” modules.
‣ From developer to developer.
‣ Simply by add them into your YUI.use() statement.
JSCONF 2010
42. Introducing YUI Gallery
‣ Instant access to hundreds of “first-class” modules.
‣ From developer to developer.
‣ Simply by add them into your YUI.use() statement.
‣ Some examples: YQL module, Accordion, Twitter
status display, etc.
JSCONF 2010
48. Benefits
‣ Your code in our CDN!
‣ Your module live within one week
JSCONF 2010
49. Benefits
‣ Your code in our CDN!
‣ Your module live within one week
‣ Visibility
JSCONF 2010
50. Benefits
‣ Your code in our CDN!
‣ Your module live within one week
‣ Visibility
‣ Easy access within your YUI().use statament.
JSCONF 2010
51. Benefits
‣ Your code in our CDN!
‣ Your module live within one week
‣ Visibility
‣ Easy access within your YUI().use statament.
‣ Contributing and being part of the JS community.
JSCONF 2010
54. How to contribute
‣ 1 - Create your module
‣ 2 - Create a YUI Library account
JSCONF 2010
55. How to contribute
‣ 1 - Create your module
‣ 2 - Create a YUI Library account
‣ 3- Fork YUI3 on github
JSCONF 2010
56. How to contribute
‣ 1 - Create your module
‣ 2 - Create a YUI Library account
‣ 3- Fork YUI3 on github
‣ 4- Submit your module
JSCONF 2010
57. How to contribute
‣ 1 - Create your module
‣ 2 - Create a YUI Library account
‣ 3- Fork YUI3 on github
‣ 4- Submit your module
‣ 5- Get approved - Your code now live on Yahoo! CDN
servers.
JSCONF 2010
58. How to contribute
‣ 1 - Create your module
‣ 2 - Create a YUI Library account
‣ 3- Fork YUI3 on github
‣ 4- Submit your module
‣ 5- Get approved - Your code now live on Yahoo! CDN
servers.
http://yuilibrary.com/gallery/
JSCONF 2010
In YUI 3, the new global is YUI
YUI is a function, not just an object bag ala YAHOO. It returns an instance, your sandbox.
The library API is added to the YUI instance, not YUI.
Facilitates having multiple sandboxes on a page w/o collision.
- Custom modules are made available to YUI instances by registering themselves via YUI.add()
- As with Y.use(), YUI.add() provides an applied module pattern
- This gives you a truly private space to define vars and functions local to your module
- Code defined inside add() is held by the YUI infrastructure to execute at the proper time
- Module code is not executed until a YUI instance requests it via Y.use('my-module', function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
- Custom modules are made available to YUI instances by registering themselves via YUI.add()
- As with Y.use(), YUI.add() provides an applied module pattern
- This gives you a truly private space to define vars and functions local to your module
- Code defined inside add() is held by the YUI infrastructure to execute at the proper time
- Module code is not executed until a YUI instance requests it via Y.use('my-module', function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
- Custom modules are made available to YUI instances by registering themselves via YUI.add()
- As with Y.use(), YUI.add() provides an applied module pattern
- This gives you a truly private space to define vars and functions local to your module
- Code defined inside add() is held by the YUI infrastructure to execute at the proper time
- Module code is not executed until a YUI instance requests it via Y.use('my-module', function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
- Custom modules are made available to YUI instances by registering themselves via YUI.add()
- As with Y.use(), YUI.add() provides an applied module pattern
- This gives you a truly private space to define vars and functions local to your module
- Code defined inside add() is held by the YUI infrastructure to execute at the proper time
- Module code is not executed until a YUI instance requests it via Y.use('my-module', function (Y) {...}); but it is executed at some point after its required modules and before the use callback.
- 'version' has nothing to do with the YUI version you require
- 'version' allows you to define version information for your component
- 'requires' defines the dependancies for your component
- 'version' has nothing to do with the YUI version you require
- 'version' allows you to define version information for your component
- 'requires' defines the dependancies for your component
- 'version' has nothing to do with the YUI version you require
- 'version' allows you to define version information for your component
- 'requires' defines the dependancies for your component