SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Introduction to YUI 3
Jeff Craig
May 13, 2010
Jeff Craig () Introduction to YUI 3 May 13, 2010 1 / 21
About Me
Who am I?
Software Developer at Washington State University
Contact:
foxxtrot@foxxtrot.net
http://blog.foxxtrot.net/
twitter.com/foxxtrot
github.com/foxxtrot
Jeff Craig () Introduction to YUI 3 May 13, 2010 2 / 21
YUI What
What is YUI?
Housed and Developed at Yahoo!
YUI2 Released in 2006, still actively supported
YUI3 launched late 2009
Used across most Yahoo! properties, new development is in YUI3
Designed to be scalable, fast, secure, and modular
Jeff Craig () Introduction to YUI 3 May 13, 2010 3 / 21
YUI What
YUI3 Structure
Core
Component Infrastructure
Utilities
Widgets
Developer Tools
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI What
YUI3 Structure
Core
Lang, UA, Queue, Object, Get, Array, Node, Event
Component Infrastructure
Utilities
Widgets
Developer Tools
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI What
YUI3 Structure
Core
Component Infrastructure
Base, Attribute, Plugin, Widget
Utilities
Widgets
Developer Tools
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI What
YUI3 Structure
Core
Component Infrastructure
Utilities
Animation, Cache, Cookie, DataSchema, IO, JSON, ImageLoader,
Internationalization, etc.
Widgets
Developer Tools
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI What
YUI3 Structure
Core
Component Infrastructure
Utilities
Widgets
Overlay, Slider, TabView, GridView
Developer Tools
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI What
YUI3 Structure
Core
Component Infrastructure
Utilities
Widgets
Developer Tools
Console, Profiler, Test
Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
YUI Why?
Why YUI3?
Modular: Load only the code you need.
Flexible: Base functionality provides flexible Attribute and Plugin
systems
Complete: Tons of utilities available now, and widgets are coming
Fast: Demonstrable faster at common tasks, and fast enough for one
of the worlds largest websites.
Jeff Craig () Introduction to YUI 3 May 13, 2010 5 / 21
YUI Why Not?
Why not YUI3?
Your existing codebase works
Many widgets haven’t been ported yet.
Jeff Craig () Introduction to YUI 3 May 13, 2010 6 / 21
YUI Why Not?
Why not YUI3?
Your existing codebase works
Many widgets haven’t been ported yet.
Some will not be.
Jeff Craig () Introduction to YUI 3 May 13, 2010 6 / 21
YUI SimpleYUI
SimpleYUI
Introduced with YUI 3.2
Eliminates the Sandbox
Fastest way to get started with YUI3
Provides Node/Events, Transitions, IO
Jeff Craig () Introduction to YUI 3 May 13, 2010 7 / 21
YUI SimpleYUI
Why not use SimpleYUI?
There are performance benefits to using the module pattern
There is safety in the sandbox
You have more control in standard YUI
Jeff Craig () Introduction to YUI 3 May 13, 2010 8 / 21
YUI Community
YUI3 and the Community
With YUI3, the team refocused on open-source. They launched YUI3 with
a public bug tracker and forums, and put the source up on GitHub.
In October 2009, the Gallery launched, providing a mechanism for modules
to be shared easily outside of the core of YUI, including offering hosting on
the Yahoo! CDN for modules, and easy inclusion within YUI3 projects.
In early 2010, the YUI Team began hosting ”YUI Open Hours” a periodic
conference call.
Jeff Craig () Introduction to YUI 3 May 13, 2010 9 / 21
YUI Resources
YUI Resources
http://yuilibrary.com/
http://developer.yahoo.com/yui/3/
http://github.com/yui/
http://yuiblog.com/
http://twitter.com/miraglia/yui/members
Jeff Craig () Introduction to YUI 3 May 13, 2010 10 / 21
YUI Standard Utilities
Node
Y.one(’#nav’);
Y.all(’#nav li’);
Y.one returns a ’Node’
Y.all returns a ’NodeList’
Jeff Craig () Introduction to YUI 3 May 13, 2010 11 / 21
YUI Standard Utilities
Node Methods
var input = Y.one(’input[type=text]’);
input.addClass(’hide’); // Add the ’hide’ class to the node
input.removeClass(’hide’);
input.toggleClass(’hide’);
input.get(’value’);
input.getStyle(’display’);
input.test(’.hide’); // Tests if the node matches a selctor
Jeff Craig () Introduction to YUI 3 May 13, 2010 12 / 21
YUI Standard Utilities
NodeList Methods
var items = Y.one(’li’);
items.filter(’.hidden’);
items.even().addClass(’even’);
items.odd().addClass(’odd’);
items.item(4); // NOT an array-like object
items.size();
items.each(function(item, index, list) {
// Treat this kind of like a for loop.
});
Jeff Craig () Introduction to YUI 3 May 13, 2010 13 / 21
YUI Standard Utilities
Events
Y.on(’click’, handler, ’#actionButton’);
handler = function(e) {
// e is a DOM Event Facade
// Same betwen all browsers
e.halt(); // Stop propogation and default action
e.preventDefault();
e.stopPropogation();
}
Same syntax as custom events
Support for touch events
Jeff Craig () Introduction to YUI 3 May 13, 2010 14 / 21
YUI Standard Utilities
Event Delegation
Y.delegate(’click’, handler, ’#container’, selector);
Assign one event, on the container, but only call the handler on
children that match the selector.
Jeff Craig () Introduction to YUI 3 May 13, 2010 15 / 21
YUI Standard Utilities
Event Delegation
Y.delegate(’click’, handler, ’#container’, selector);
Assign one event, on the container, but only call the handler on
children that match the selector.
Doesn’t fix non-bubbling events, like change-events in Internet
Explorer
Jeff Craig () Introduction to YUI 3 May 13, 2010 15 / 21
YUI Standard Utilities
YUI3 Templating
TEMPLATE = "<li><a href=’{link}’>{label}</a></li>";
data = {
link: "http://blog.foxxtrot.net/",
label: "My Blog"
};
Y.Lang.sub(TEMPLATE, data);
Jeff Craig () Introduction to YUI 3 May 13, 2010 16 / 21
YUI Standard Utilities
Advanced YUI3 Templating
TEMPLATE = "<li class=’{selected}’><a href=’{link}’>{label}</a
data = {
link: "http://blog.foxxtrot.net/",
label: "My Blog",
selected: true
};
Y.use(’substitutue’, function(Y) {
Y.substitute(TEMPLATE, data,
function(key, value) {
if(key === "selected") {
return value ? "selected" : "";
}
return value;
});
});
Jeff Craig () Introduction to YUI 3 May 13, 2010 17 / 21
YUI AJAX
Server Calls
Y.io("/path/to/request", {
method: ’GET’,
data: ’field1=value&field2=3’,
on: {
start: handler,
complete: handler,
success: handler,
failure: handler,
end: handler
}
sync: false,
timeout: 2000
});
Jeff Craig () Introduction to YUI 3 May 13, 2010 18 / 21
YUI AJAX
JSON
Y.JSON.stringify({
name: "Jeff Craig",
nick: "foxxtrot",
session: "Intro to YUI3"
});
Y.JSON.parse("{’event’: ’Palouse Code Camp’,
’date’: ’2010.10.30’}");
Jeff Craig () Introduction to YUI 3 May 13, 2010 19 / 21
YUI AJAX
Transistions
Y.one(’#demo’).transition({
duration: 1, // seconds
easing: ’ease-out’,
height: 0,
width: 0,
left: ’150px’,
top: ’100px’,
opacity: 0
}, function() { Y.one(’#demo’).destroy(true); } );
Jeff Craig () Introduction to YUI 3 May 13, 2010 20 / 21
YUI End Notes
Links
YUI:
http://yuilibrary.com/
http://developer.yahoo.com/yui/3/
http://github.com/yui/
http://yuiblog.com/
http://twitter.com/miraglia/yui/members
Me:
foxxtrot@foxxtrot.net
http://blog.foxxtrot.net/
twitter.com/foxxtrot
github.com/foxxtrot
Jeff Craig () Introduction to YUI 3 May 13, 2010 21 / 21

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (7)

Adverbs of frequency
Adverbs of frequencyAdverbs of frequency
Adverbs of frequency
 
Asesoría en creación e implementación de Franquicias por ELG ASESORES PERÚ.
Asesoría en creación e implementación de Franquicias por ELG ASESORES PERÚ.Asesoría en creación e implementación de Franquicias por ELG ASESORES PERÚ.
Asesoría en creación e implementación de Franquicias por ELG ASESORES PERÚ.
 
Chrysler 300
Chrysler 300Chrysler 300
Chrysler 300
 
Produttività in Italia: una chimera?
Produttività in Italia: una chimera?Produttività in Italia: una chimera?
Produttività in Italia: una chimera?
 
Dyes classification
Dyes   classificationDyes   classification
Dyes classification
 
Università e mercato del lavoro
Università e mercato del lavoro Università e mercato del lavoro
Università e mercato del lavoro
 
Sky gate presentation
Sky gate presentationSky gate presentation
Sky gate presentation
 

Ähnlich wie Introduction to YUI3 - Palouse Code Camp 2010

Y hack-china-2013
Y hack-china-2013Y hack-china-2013
Y hack-china-2013
Syu-jhih Wu
 

Ähnlich wie Introduction to YUI3 - Palouse Code Camp 2010 (20)

Advanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component InfrastructureAdvanced YUI3: Module Creation and the Component Infrastructure
Advanced YUI3: Module Creation and the Component Infrastructure
 
YUI open for all !
YUI open for all !YUI open for all !
YUI open for all !
 
YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010
 
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
 
Creating custom modules using YUI3
Creating custom modules using YUI3Creating custom modules using YUI3
Creating custom modules using YUI3
 
Yui intro
Yui introYui intro
Yui intro
 
yui3 is Sexy - 使用 YUI 3 的 Sexy Part !
yui3 is Sexy - 使用 YUI 3 的 Sexy Part !yui3 is Sexy - 使用 YUI 3 的 Sexy Part !
yui3 is Sexy - 使用 YUI 3 的 Sexy Part !
 
YUI Test The Next Generation (YUIConf 2010)
YUI Test The Next Generation (YUIConf 2010)YUI Test The Next Generation (YUIConf 2010)
YUI Test The Next Generation (YUIConf 2010)
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yui
 
Hack with YUI
Hack with YUIHack with YUI
Hack with YUI
 
Making Rich Internet Applications Accessible Through jQuery
Making Rich Internet Applications Accessible Through jQueryMaking Rich Internet Applications Accessible Through jQuery
Making Rich Internet Applications Accessible Through jQuery
 
Introduction to YUI
Introduction to YUIIntroduction to YUI
Introduction to YUI
 
Sakai uPortal Integration Options
Sakai uPortal Integration OptionsSakai uPortal Integration Options
Sakai uPortal Integration Options
 
Y hack-china-2013
Y hack-china-2013Y hack-china-2013
Y hack-china-2013
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
 
Yui mixer
Yui mixerYui mixer
Yui mixer
 
Introduction to YUI - IIT Kharagpur
Introduction to YUI - IIT KharagpurIntroduction to YUI - IIT Kharagpur
Introduction to YUI - IIT Kharagpur
 
Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010
 
YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU
 
Feature Bits at DevOpsDays 2010 US
Feature Bits at DevOpsDays 2010 USFeature Bits at DevOpsDays 2010 US
Feature Bits at DevOpsDays 2010 US
 

Kürzlich hochgeladen

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
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 

Introduction to YUI3 - Palouse Code Camp 2010

  • 1. Introduction to YUI 3 Jeff Craig May 13, 2010 Jeff Craig () Introduction to YUI 3 May 13, 2010 1 / 21
  • 2. About Me Who am I? Software Developer at Washington State University Contact: foxxtrot@foxxtrot.net http://blog.foxxtrot.net/ twitter.com/foxxtrot github.com/foxxtrot Jeff Craig () Introduction to YUI 3 May 13, 2010 2 / 21
  • 3. YUI What What is YUI? Housed and Developed at Yahoo! YUI2 Released in 2006, still actively supported YUI3 launched late 2009 Used across most Yahoo! properties, new development is in YUI3 Designed to be scalable, fast, secure, and modular Jeff Craig () Introduction to YUI 3 May 13, 2010 3 / 21
  • 4. YUI What YUI3 Structure Core Component Infrastructure Utilities Widgets Developer Tools Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 5. YUI What YUI3 Structure Core Lang, UA, Queue, Object, Get, Array, Node, Event Component Infrastructure Utilities Widgets Developer Tools Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 6. YUI What YUI3 Structure Core Component Infrastructure Base, Attribute, Plugin, Widget Utilities Widgets Developer Tools Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 7. YUI What YUI3 Structure Core Component Infrastructure Utilities Animation, Cache, Cookie, DataSchema, IO, JSON, ImageLoader, Internationalization, etc. Widgets Developer Tools Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 8. YUI What YUI3 Structure Core Component Infrastructure Utilities Widgets Overlay, Slider, TabView, GridView Developer Tools Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 9. YUI What YUI3 Structure Core Component Infrastructure Utilities Widgets Developer Tools Console, Profiler, Test Jeff Craig () Introduction to YUI 3 May 13, 2010 4 / 21
  • 10. YUI Why? Why YUI3? Modular: Load only the code you need. Flexible: Base functionality provides flexible Attribute and Plugin systems Complete: Tons of utilities available now, and widgets are coming Fast: Demonstrable faster at common tasks, and fast enough for one of the worlds largest websites. Jeff Craig () Introduction to YUI 3 May 13, 2010 5 / 21
  • 11. YUI Why Not? Why not YUI3? Your existing codebase works Many widgets haven’t been ported yet. Jeff Craig () Introduction to YUI 3 May 13, 2010 6 / 21
  • 12. YUI Why Not? Why not YUI3? Your existing codebase works Many widgets haven’t been ported yet. Some will not be. Jeff Craig () Introduction to YUI 3 May 13, 2010 6 / 21
  • 13. YUI SimpleYUI SimpleYUI Introduced with YUI 3.2 Eliminates the Sandbox Fastest way to get started with YUI3 Provides Node/Events, Transitions, IO Jeff Craig () Introduction to YUI 3 May 13, 2010 7 / 21
  • 14. YUI SimpleYUI Why not use SimpleYUI? There are performance benefits to using the module pattern There is safety in the sandbox You have more control in standard YUI Jeff Craig () Introduction to YUI 3 May 13, 2010 8 / 21
  • 15. YUI Community YUI3 and the Community With YUI3, the team refocused on open-source. They launched YUI3 with a public bug tracker and forums, and put the source up on GitHub. In October 2009, the Gallery launched, providing a mechanism for modules to be shared easily outside of the core of YUI, including offering hosting on the Yahoo! CDN for modules, and easy inclusion within YUI3 projects. In early 2010, the YUI Team began hosting ”YUI Open Hours” a periodic conference call. Jeff Craig () Introduction to YUI 3 May 13, 2010 9 / 21
  • 17. YUI Standard Utilities Node Y.one(’#nav’); Y.all(’#nav li’); Y.one returns a ’Node’ Y.all returns a ’NodeList’ Jeff Craig () Introduction to YUI 3 May 13, 2010 11 / 21
  • 18. YUI Standard Utilities Node Methods var input = Y.one(’input[type=text]’); input.addClass(’hide’); // Add the ’hide’ class to the node input.removeClass(’hide’); input.toggleClass(’hide’); input.get(’value’); input.getStyle(’display’); input.test(’.hide’); // Tests if the node matches a selctor Jeff Craig () Introduction to YUI 3 May 13, 2010 12 / 21
  • 19. YUI Standard Utilities NodeList Methods var items = Y.one(’li’); items.filter(’.hidden’); items.even().addClass(’even’); items.odd().addClass(’odd’); items.item(4); // NOT an array-like object items.size(); items.each(function(item, index, list) { // Treat this kind of like a for loop. }); Jeff Craig () Introduction to YUI 3 May 13, 2010 13 / 21
  • 20. YUI Standard Utilities Events Y.on(’click’, handler, ’#actionButton’); handler = function(e) { // e is a DOM Event Facade // Same betwen all browsers e.halt(); // Stop propogation and default action e.preventDefault(); e.stopPropogation(); } Same syntax as custom events Support for touch events Jeff Craig () Introduction to YUI 3 May 13, 2010 14 / 21
  • 21. YUI Standard Utilities Event Delegation Y.delegate(’click’, handler, ’#container’, selector); Assign one event, on the container, but only call the handler on children that match the selector. Jeff Craig () Introduction to YUI 3 May 13, 2010 15 / 21
  • 22. YUI Standard Utilities Event Delegation Y.delegate(’click’, handler, ’#container’, selector); Assign one event, on the container, but only call the handler on children that match the selector. Doesn’t fix non-bubbling events, like change-events in Internet Explorer Jeff Craig () Introduction to YUI 3 May 13, 2010 15 / 21
  • 23. YUI Standard Utilities YUI3 Templating TEMPLATE = "<li><a href=’{link}’>{label}</a></li>"; data = { link: "http://blog.foxxtrot.net/", label: "My Blog" }; Y.Lang.sub(TEMPLATE, data); Jeff Craig () Introduction to YUI 3 May 13, 2010 16 / 21
  • 24. YUI Standard Utilities Advanced YUI3 Templating TEMPLATE = "<li class=’{selected}’><a href=’{link}’>{label}</a data = { link: "http://blog.foxxtrot.net/", label: "My Blog", selected: true }; Y.use(’substitutue’, function(Y) { Y.substitute(TEMPLATE, data, function(key, value) { if(key === "selected") { return value ? "selected" : ""; } return value; }); }); Jeff Craig () Introduction to YUI 3 May 13, 2010 17 / 21
  • 25. YUI AJAX Server Calls Y.io("/path/to/request", { method: ’GET’, data: ’field1=value&field2=3’, on: { start: handler, complete: handler, success: handler, failure: handler, end: handler } sync: false, timeout: 2000 }); Jeff Craig () Introduction to YUI 3 May 13, 2010 18 / 21
  • 26. YUI AJAX JSON Y.JSON.stringify({ name: "Jeff Craig", nick: "foxxtrot", session: "Intro to YUI3" }); Y.JSON.parse("{’event’: ’Palouse Code Camp’, ’date’: ’2010.10.30’}"); Jeff Craig () Introduction to YUI 3 May 13, 2010 19 / 21
  • 27. YUI AJAX Transistions Y.one(’#demo’).transition({ duration: 1, // seconds easing: ’ease-out’, height: 0, width: 0, left: ’150px’, top: ’100px’, opacity: 0 }, function() { Y.one(’#demo’).destroy(true); } ); Jeff Craig () Introduction to YUI 3 May 13, 2010 20 / 21