This document discusses the transition from YUI3 to K2. It provides a brief history of YUI, describing its goals of code reuse through modular components and submodules. It highlights aspects of YUI3 that make it lighter, easier and faster to use than previous versions, including a more consistent API through the Node utility, language enhancements, dynamic loading, and combo handling for faster loading. The document suggests K2 builds upon these strengths.
10. Lighter
• Emphasis on Code Reuse
Don’t write code more than once, use it again.
Y.aggregate()
Y.agument()
Y.bind()
Y.clone()
Y.extend()
Y.rbind()
http://developer.yahoo.com/yui/3/api/module_oop.html
11. Lighter
• Emphasis on Code Reuse
Don’t write code more than once, use it again.
Attribute
Base EventTarget
Plugin.Host
Widget
MyWidget
Widget Hierarchy
http://josephjiang.com/entry.php?id=257
http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets
12. Lighter
• Emphasis on Code Reuse
Don’t write code more than once, use it again.
Component
Core Utilities Widgets Plugins CSS
Infrastructure
YUI (seed) Attribute Animation Autocomplete Console Filters Plugin Reset
Event Base AsyncQueue Charts FocusManager Node Base
Loader Plugin Cache Console Plugin Fonts
DOM Widget Cookie DataTable MenuNav Node Plugin Grids
OOP DataSchema Dial
Node DataSource Overlay
DataType RTE
DD ScrollView
History Slider
ImageLoader TabView
Internationalization
IO
JSON
JSONP
Profiler
Recoredset
Resize
Sortable
StyleSheet
SWF
Test
Transition
Uploader
YQL Query
13. Lighter
• Emphasis on Code Reuse
Don’t write code more than once, use it again.
• Finer Grainded, Modules & Sub-Modules
Don’t load what you don’t need
"io":
{
"submodules":
{
"io-‐base":
{
"optional":
["querystring-‐stringify-‐simple"],
"requires":
["event-‐custom-‐base"]
},
"io-‐form":
{
"requires":
["io-‐base",
"node-‐base",
"node-‐style"]
},
"io-‐queue":
{
"requires":
["io-‐base",
"queue-‐promote"]
},
"io-‐upload-‐iframe":
{
"requires":
["io-‐base",
"node-‐base"]
},
"io-‐xdr":
{
"requires":
["io-‐base",
"datatype-‐xml"]
}
}
},
http://developer.yahoo.com/yui/3/io/
15. Easier
• More Consistent
Node supports the HTMLElements API
Node normalizes the HTMLElements API
node.getAttribute("href")
node.contains(aNode)
node.getStyle("paddingTop")
node.previous()
16. Easier
• More Consistent
Node supports the HTMLElements API
Node normalizes the HTMLElements API
Array supports some Array methods of JavaScript 1.6
Y.Array.each()
(forEach)
Y.Array.indexOf()
Y.Array.some()
https://developer.mozilla.org/en/javascript
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array
17. Easier
• More Consistent
Node supports the HTMLElements API
Node normalizes the HTMLElements API
Array supports some Array methods of JavaScript 1.6
All events are custom events
//DOM
events
button.on("click",
doSomething);
//Custom
events
instance.on("myEvent",
doSomething);
http://developer.yahoo.com/yui/3/event/
18. Easier
• More Consistent
• More Convenient
Flatter namespace & chainability
YUI().use(‘node-‐base’,function(Y){
Y.one(‘body’).addClass(‘yui-‐skin-‐sam’);
});
19. Easier
• More Consistent
• More Convenient
Flatter namespace & chainability
Language enhancements & batch operations
Y.Array.test()
Y.Array.hash()
Y.Array.numericSort()
Y.all(‘li’).each(function(){
});
21. Easier
• More Consistent
• More Convenient
• More Powerful
Sandbox
YUI().use(‘node’,function({
Y.all(‘.k2’).addClass(‘k3’);
});
YUI({
root:‘yui/3.1.0/’
}).use(‘node’,function(){
Y.all(‘.k2’).addClass(‘k3’);
});
http://www.infoq.com/cn/articles/sandboxOnB
22. Easier
• More Consistent
• More Convenient
• More Powerful
Sandbox
Plugin
node.plug(IOPlugin);
node.io.getContent("http://foo/bar");
node.plug(DragDropPlugin);
node.dd.set("handle",
".title");
23. Easier
• More Consistent
• More Convenient
• More Powerful
Sandbox
Plugin
Selector
YUI().use('node',
function(Y)
{
var
node
=
Y.one('#demo'),
node2
=
node.one('p');
if
(node2)
{
node2.addClass('bar');
}
});
YUI().use(‘node’,‘selector-‐css3’,function(Y){
var
one
=
Y.one(‘li[foo=”en”]’);
});
24. Easier
• More Consistent
• More Convenient
• More Powerful
Sandbox
Plugin
Selector
AOP
Do.before()
Do.after()
Do.detach()
AOP
http://developer.yahoo.com/yui/3/api/Do.html
http://uedmagazine.com/ued/comments.php?y=09&m=09&entry=entry090923-120216
25. Easier
• More Consistent
• More Convenient
• More Powerful
• More Securable
Node is the single point of access to the DOM.
Makes YUI 3 ideal as a trusted source for"constrained"
environments like Caja and Ad-safe.
http://adsafe.org
https://github.com/yui/yui-caja
http://code.google.com/p/google-caja/
30. Trade-off
Usable vs. Professional
http://ued.taobao.com/blog/2010/01/11/yui3%E8%AE%BE%E8%AE%A1%E4%B8%AD%E7%9A%84%E6%BF%80%E8%BF%9B%E5%92%8C%E5%A6%A5%E5%8D%8F/
37. What is K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
Core Utilities Widgets Components CSS & Skin
seed datalazyload editor ww reset
validator switch color
uploader shutter common
swf calendar corner
scroll-follow image-cropper grids
popup pagination icon
resize bookmark button
cdselector
form
http://kxt.koubei.com/k2
38. What is K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• k.kbcdn.com
• Minify
• CMS & CMS
39. What is K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• Development Runtime
• ATT2, Pea
• http://kxt.koubei.com/k2
• K2 Runtime
• console, noCache, noVersion, syntaxHighlight, noCombo, local
• TDD
• Yeti @ koubei.com
• grape
• hive, queen
40. What is K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• Development Runtime
• Tools
• F2E Validator
• KFC
• Cod
• CodeCola
• FoTiaoQiang
41. What is next about K2?
• Web Structure
Web Module Template Engine (Web Server & JS Engine Assembling)
{
‘module’:‘tuan-‐list’,
‘path’:’...’,
‘data’:{
‘path’:’...’,
‘require’:[‘...’]
},
‘js’:{
‘path’:’...’,
‘require’:[‘...’]
},
‘css’:{
‘path’:’...’,
‘require’:[‘...’],
},
‘callback’:’...’,
‘require’:[‘...’]
}
http://mustache.github.com/
42. What is next about K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
Core Utilities Widgets Components CSS & Skin
(for mobile) (for mobile) (for mobile) (for mobile) (for mobile)
shareTo Koubei Design Pattern
Favorite
subscribe
login & singup
feedback
43. What is next about K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• Java Loader
• Koubei Server Loader @ Node.js
• F2E Minify
• Front-end Management System 1.0
44. What is next about K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• Development Runtime
• ATT3 @ Node.js
• Debug anywhere & anytime @ seed 2.0
45. What is next about K2?
• Web Structure
• Core Engine & Components (Powered by YUI3)
• Front-end Runtime
• Development Runtime
• Tools
• SlowSlow
• input.koubei.com
• performance.koubei.com