SlideShare une entreprise Scribd logo
1  sur  22
Essential YUI
  {   An introduction to Yahoo!’s JavaScript library
      Derrick McMillen, March 2012
Why do we need libraries?
• The DOM is difficult to use, verbose,
  and inconsistent (see DOM levels).
• We must always respect the global
  namespace !
• Building advanced web applications
  requires abstraction.
• Leveraging other developer’s code
  makes our lives easier.
The Yahoo! User Interface
library is a tool to help you
avoid these pitfalls!
The YUI Seed
<html>
<body>
    <!-- your page content -->
    <!-- YUI seed-->
    <script src=‚…"></script>
    <script src=‚…">
        // your JavaScript
    </script>
</body>
</html>
Quiz
// finds the greatest common divisor
function gcd(a, b) {
     if(b === 0)
          return a;
     else {
          x = a % b;
          return gcd(b, x);
     }
}

x = 5;
y = gcd(12, 4) + x; // what is y?
The YUI Loader
YUI().use(‘node’, function(Y) {

      Y.log(‚Hello world!‛);
});
DOM nodes

var d = document;

var body = d.getElementsByTagName(‘body’)[0],
p = d.createElement(‘p’),
txt = d.createTextNode(‘Hello world!’);

body.appendChild(p.appendChild(txt));
DOM nodes

YUI().use(‘node’, function(Y) {

  var body = Y.one(‘body’);
  body.append(Y.Node.create(
              ‘<p>Hello world!</p>’);

});
DOM Events

YUI().use(‘event’, function(Y) {

  var button = Y.one(‘#button’);

  Y.on(‘click’, function(e) {
     alert(‘hello’);
  });
});
DOM Events
YUI().use(‘event’, function(Y) {

  var mask = Y.one(‘#mask’);

  Y.on(‘click’, function(e) {

     e.preventDefault();
     mask.show();
  }, ‘a#button’);
});
Ajax
YUI().use(‘io’, function(Y) {

 var handler = function(id, o, args) {
    Y.one(‘body’).append(o.responseText);
 });

 Y.on(‘io:complete’, handler);

  Y.io(‘/users/profile?user_name=derrick’);
});
Objected Oriented
JavaScript without YUI
Pseudo-classical
Inheritance
var Animal = function(n) {
     var noise = n;
     this.makeNoise = function() {
          alert(noise);
     }
};

var Dog = function () {
     this.bark = function() {
          this.makeNoise();
     }
};

Dog.prototype = new Animal(‘woof!’);
var Mammal = function() {
     this.baby = function() {
          return new Mammal();
     }
};

Mammal.prototype = new Animal(); // uh oh…
Dog.prototype = new Mammal(‘woof!’);
fido = new Dog();
fido.bark(); // undefined

fido instanceof Dog    //true
fido instanceof Mammal // true
fido instanceof Animal //true
The Prototype Chain
      Animal
                   What happened when fido.bark() ?
      noise
      makeNoise
      __proto__      We were unable to { }
                                        provide the
                     instance of Animal the correct
      Mammal         argument when instanciated.

      baby
      __proto__      The noise private field was
                     never set.

      Dog (fido)

      bark
      __proto__
Objected Oriented
JavaScript with YUI
YUI OO Utilities
• Native JavaScript OO
   • Y.extend (pseudo-classical)
   • Y.Object (prototypal)

• Synthetic OO
   • Y.augment (multiple inheritance)
   • Y.Plugin (expressive, flexible)
   • Y.Base (feature rich out-of-the-box)
var Animal = function(n) {
     var noise = n;
     this.makeNoise = function() {
          alert(noise);
     }
};
var Dog = function () {
     Dog.superclass.constructor.apply(this,
                            arguments);
     this.bark = function() {
          this.makeNoise();
     }
};

Y.extend(Dog, Animal);
YUI Widgets from
Yahoo!’s CDN
You may retrieve any modules available
on the Yahoo! CDN using the YUI loader.



YUI().use(‘datatable’, …);

YUI().use(‘panel’, …);
Check it out!

    yuilibrary.com

Hundreds of fantastic
 video presentations!

yuilibrary.com/theater

Contenu connexe

Tendances

Steam Learn: Javascript and OOP
Steam Learn: Javascript and OOPSteam Learn: Javascript and OOP
Steam Learn: Javascript and OOPinovia
 
Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Gesh Markov
 
Introduction To Moose
Introduction To MooseIntroduction To Moose
Introduction To MooseMike Whitaker
 
You are in a maze of deeply nested maps, all alike
You are in a maze of deeply nested maps, all alikeYou are in a maze of deeply nested maps, all alike
You are in a maze of deeply nested maps, all alikeEric Normand
 
201705 metaprogramming in julia
201705 metaprogramming in julia201705 metaprogramming in julia
201705 metaprogramming in julia岳華 杜
 
Minimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityMinimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityDerek Lee Boire
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in SwiftDerek Lee Boire
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzenAndreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzenDevDay Dresden
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQueryRemy Sharp
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tipsanubavam-techkt
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽taobao.com
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発swdyh
 
History of jQuery
History of jQueryHistory of jQuery
History of jQueryjeresig
 
Advanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDBAdvanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDBAijaz Ansari
 

Tendances (20)

Steam Learn: Javascript and OOP
Steam Learn: Javascript and OOPSteam Learn: Javascript and OOP
Steam Learn: Javascript and OOP
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)
 
Introduction To Moose
Introduction To MooseIntroduction To Moose
Introduction To Moose
 
You are in a maze of deeply nested maps, all alike
You are in a maze of deeply nested maps, all alikeYou are in a maze of deeply nested maps, all alike
You are in a maze of deeply nested maps, all alike
 
201705 metaprogramming in julia
201705 metaprogramming in julia201705 metaprogramming in julia
201705 metaprogramming in julia
 
Minimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityMinimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team Productivity
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in Swift
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
Voyage by example
Voyage by exampleVoyage by example
Voyage by example
 
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzenAndreas Roth - GraphQL erfolgreich im Backend einsetzen
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
 
dojo.things()
dojo.things()dojo.things()
dojo.things()
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽
 
Learning How To Use Jquery #5
Learning How To Use Jquery #5Learning How To Use Jquery #5
Learning How To Use Jquery #5
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 
Advanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDBAdvanced Debugging with Xcode - Extending LLDB
Advanced Debugging with Xcode - Extending LLDB
 

En vedette

Presentatie1 voor slideshare
Presentatie1 voor slidesharePresentatie1 voor slideshare
Presentatie1 voor slideshareStijn Willems
 
Industry
IndustryIndustry
Industrypriyase
 
Yovita kristin (090210302079)
Yovita kristin (090210302079)Yovita kristin (090210302079)
Yovita kristin (090210302079)Vichrista Arista
 
Regresiones, de Vicente Muñoz Ávarez
Regresiones, de Vicente Muñoz ÁvarezRegresiones, de Vicente Muñoz Ávarez
Regresiones, de Vicente Muñoz ÁvarezAna R. Otero
 
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전세바기(세상을 바꾸는 기술)_변화를 위한 무한도전
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전S.K. Cha of ACS in Korea
 
Designing a "nutrition facts" label for disclosing prepaid card fees
Designing a "nutrition facts" label for disclosing prepaid card feesDesigning a "nutrition facts" label for disclosing prepaid card fees
Designing a "nutrition facts" label for disclosing prepaid card feesDesiree Zamora Garcia
 
Industry
IndustryIndustry
Industrypriyase
 
S ilabus tik smp berkarakter kelas 7 sd 9
S ilabus tik smp berkarakter kelas 7 sd 9S ilabus tik smp berkarakter kelas 7 sd 9
S ilabus tik smp berkarakter kelas 7 sd 9suryo purnomo
 
mes와 fems을 활용한 생산공장 에너지효율화
 mes와 fems을 활용한 생산공장 에너지효율화 mes와 fems을 활용한 생산공장 에너지효율화
mes와 fems을 활용한 생산공장 에너지효율화S.K. Cha of ACS in Korea
 

En vedette (17)

Ciparay
CiparayCiparay
Ciparay
 
Yui css
Yui cssYui css
Yui css
 
Budgeting
BudgetingBudgeting
Budgeting
 
Presentatie1 voor slideshare
Presentatie1 voor slidesharePresentatie1 voor slideshare
Presentatie1 voor slideshare
 
Industry
IndustryIndustry
Industry
 
111
111111
111
 
Making API documentation work
Making API documentation workMaking API documentation work
Making API documentation work
 
Yovita kristin (090210302079)
Yovita kristin (090210302079)Yovita kristin (090210302079)
Yovita kristin (090210302079)
 
Media evaluation
Media evaluationMedia evaluation
Media evaluation
 
Regresiones, de Vicente Muñoz Ávarez
Regresiones, de Vicente Muñoz ÁvarezRegresiones, de Vicente Muñoz Ávarez
Regresiones, de Vicente Muñoz Ávarez
 
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전세바기(세상을 바꾸는 기술)_변화를 위한 무한도전
세바기(세상을 바꾸는 기술)_변화를 위한 무한도전
 
Designing a "nutrition facts" label for disclosing prepaid card fees
Designing a "nutrition facts" label for disclosing prepaid card feesDesigning a "nutrition facts" label for disclosing prepaid card fees
Designing a "nutrition facts" label for disclosing prepaid card fees
 
Industry
IndustryIndustry
Industry
 
Analsisis pisa
Analsisis pisaAnalsisis pisa
Analsisis pisa
 
S ilabus tik smp berkarakter kelas 7 sd 9
S ilabus tik smp berkarakter kelas 7 sd 9S ilabus tik smp berkarakter kelas 7 sd 9
S ilabus tik smp berkarakter kelas 7 sd 9
 
e-Manufacturing; before and after
e-Manufacturing; before and aftere-Manufacturing; before and after
e-Manufacturing; before and after
 
mes와 fems을 활용한 생산공장 에너지효율화
 mes와 fems을 활용한 생산공장 에너지효율화 mes와 fems을 활용한 생산공장 에너지효율화
mes와 fems을 활용한 생산공장 에너지효율화
 

Similaire à Essential YUI

Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceChristian Heilmann
 
Objective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET DevelopersObjective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET DevelopersBen Scheirman
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIsDmitry Buzdin
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfMorgan Cheng
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan YuiJH Lee
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Peter Higgins
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming languagePivorak MeetUp
 
Server Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetServer Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetTom Croucher
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012Nicholas Zakas
 
Jeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumJeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumAxway Appcelerator
 
Solving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoCompleteSolving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoCompleteIsaacSchlueter
 

Similaire à Essential YUI (20)

Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
YUI Hidden Gems
YUI Hidden GemsYUI Hidden Gems
YUI Hidden Gems
 
Geekup Leeds - Why the YUI?
Geekup Leeds - Why the YUI?Geekup Leeds - Why the YUI?
Geekup Leeds - Why the YUI?
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax Experience
 
Objective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET DevelopersObjective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET Developers
 
YUI (Advanced)
YUI (Advanced)YUI (Advanced)
YUI (Advanced)
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend Perf
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
YUI for your Hacks
YUI for your Hacks YUI for your Hacks
YUI for your Hacks
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming language
 
Server Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yetServer Side JavaScript - You ain't seen nothing yet
Server Side JavaScript - You ain't seen nothing yet
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012
 
Jeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumJeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend Titanium
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
Solving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoCompleteSolving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoComplete
 
YUI on the go
YUI on the goYUI on the go
YUI on the go
 

Dernier

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 productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 Scriptwesley chun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 interpreternaman860154
 
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 AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Dernier (20)

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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Essential YUI

  • 1. Essential YUI { An introduction to Yahoo!’s JavaScript library Derrick McMillen, March 2012
  • 2. Why do we need libraries? • The DOM is difficult to use, verbose, and inconsistent (see DOM levels). • We must always respect the global namespace ! • Building advanced web applications requires abstraction. • Leveraging other developer’s code makes our lives easier.
  • 3. The Yahoo! User Interface library is a tool to help you avoid these pitfalls!
  • 4. The YUI Seed <html> <body> <!-- your page content --> <!-- YUI seed--> <script src=‚…"></script> <script src=‚…"> // your JavaScript </script> </body> </html>
  • 5. Quiz // finds the greatest common divisor function gcd(a, b) { if(b === 0) return a; else { x = a % b; return gcd(b, x); } } x = 5; y = gcd(12, 4) + x; // what is y?
  • 6. The YUI Loader YUI().use(‘node’, function(Y) { Y.log(‚Hello world!‛); });
  • 7. DOM nodes var d = document; var body = d.getElementsByTagName(‘body’)[0], p = d.createElement(‘p’), txt = d.createTextNode(‘Hello world!’); body.appendChild(p.appendChild(txt));
  • 8. DOM nodes YUI().use(‘node’, function(Y) { var body = Y.one(‘body’); body.append(Y.Node.create( ‘<p>Hello world!</p>’); });
  • 9. DOM Events YUI().use(‘event’, function(Y) { var button = Y.one(‘#button’); Y.on(‘click’, function(e) { alert(‘hello’); }); });
  • 10. DOM Events YUI().use(‘event’, function(Y) { var mask = Y.one(‘#mask’); Y.on(‘click’, function(e) { e.preventDefault(); mask.show(); }, ‘a#button’); });
  • 11. Ajax YUI().use(‘io’, function(Y) { var handler = function(id, o, args) { Y.one(‘body’).append(o.responseText); }); Y.on(‘io:complete’, handler); Y.io(‘/users/profile?user_name=derrick’); });
  • 14. var Animal = function(n) { var noise = n; this.makeNoise = function() { alert(noise); } }; var Dog = function () { this.bark = function() { this.makeNoise(); } }; Dog.prototype = new Animal(‘woof!’);
  • 15. var Mammal = function() { this.baby = function() { return new Mammal(); } }; Mammal.prototype = new Animal(); // uh oh… Dog.prototype = new Mammal(‘woof!’); fido = new Dog(); fido.bark(); // undefined fido instanceof Dog //true fido instanceof Mammal // true fido instanceof Animal //true
  • 16. The Prototype Chain Animal What happened when fido.bark() ? noise makeNoise __proto__ We were unable to { } provide the instance of Animal the correct Mammal argument when instanciated. baby __proto__ The noise private field was never set. Dog (fido) bark __proto__
  • 18. YUI OO Utilities • Native JavaScript OO • Y.extend (pseudo-classical) • Y.Object (prototypal) • Synthetic OO • Y.augment (multiple inheritance) • Y.Plugin (expressive, flexible) • Y.Base (feature rich out-of-the-box)
  • 19. var Animal = function(n) { var noise = n; this.makeNoise = function() { alert(noise); } }; var Dog = function () { Dog.superclass.constructor.apply(this, arguments); this.bark = function() { this.makeNoise(); } }; Y.extend(Dog, Animal);
  • 21. You may retrieve any modules available on the Yahoo! CDN using the YUI loader. YUI().use(‘datatable’, …); YUI().use(‘panel’, …);
  • 22. Check it out! yuilibrary.com Hundreds of fantastic video presentations! yuilibrary.com/theater