SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Getting started with
      Dojo Toolkit
             Cologne.js
User Group Meeting, Cologne (@cowoco)

            Thomas Koch
            (@tomy_koch)

           10. August 2010
Dojo Toolkit: About
• Dojo is JS Framework
      – Pure client-side JS (in contrast to GWT etc.)
      – Includes Dev.Tools: build, test
      – Open source, active community
        http://www.dojotoolkit.org/
• Dojo features
      –      OO-style class based development
      –      Modularisation (via concept of packages)
      –      Support for data and GUI  MVC
      –      Wide range of builtin widgets

10.08.2010                       Thomas Koch            2
Dojo Toolkit: Features
• Development: APIs for robust Web Applications
      – Event handling, DOM manipulation
      – CSS Querying, Animations, …
• Communication: Ajax and even more
      – Data abstraction layer, JSON-RPC, Comet, XMPP etc.
• Integration: with many server-side developments
      – including DWR, Django, TurboGears, Google, Jaxer …
• User interface: re-usable gui components
      –      Standard gui widgets (button, slider, table, tree, menu …)
      –      vector graphics, charting, …
      –      theming, drag’n drop, …
      –      i18N, a11y

• Widely used: Dojo Widgets (aka Dijits)


10.08.2010                                  Thomas Koch                   3
Dojo Sneak Preview: Theme Tester




10.08.2010     Thomas Koch          4
Dojo quick-start

   GETTING STARTED


10.08.2010            Thomas Koch   5
Basic Dojo Page
• minimal Dojo
    – load the dojo base stuff: dojo.js
    – define a config (optional!)
             • djConfig : dictionary used by dojo bootstrap process
                – Locale, debug, baseURL, parseOnLoad, …

• Example
         <html><head><title>Dojo Demo</title>
         <script type="text/javascript" src="dojo/dojo.js"
                djConfig="isDebug:true">
         </script></head>
         <body><p>Hello Dojo</p></body>
         </html>
10.08.2010                           Thomas Koch                      6
Document Life-Cycle
• OnLoad/unLoad Handler
    – dojo.addOnLoad(<functionname>)
             • defers script execution until all HTML is loaded
    – vice versa: addOnUnload()
• Example
        <script type="text/javascript">
          function showVersion() {
            var node = dojo.byId("demo");
            node.innerHTML = "Dojo"+dojo.version;
          }
          dojo.addOnLoad(showVersion);
        </script>
        <body>
        <div id="demo"></div>
10.08.2010                           Thomas Koch                  7
Dojo Base
• Foundation of Dojo Framework: dojo.js
    – Implements Browser detection & Package loading
          • import/packaging-concept via dojo.declare / dojo.require
    – Provides DOM Manipulation and CSS query engine
• Browser sniffing
    – dojo.isFF, dojo.isIE
    – dojo.isOpera, dojo.isSafari
    – dojo.isAir
• Dojo.is<Browser> (global variable!)
    – IS version of browser
    – OR undefined
          >>> dojo.isFF
          3.5
  10.08.2010                             Thomas Koch                   8
DOM Manipulation
• DOM Lookup
     – node = dojo.byId("id")  returns a DOM node
             • Similar to document.getElementById("id")
     – Watch out: dijit.byId("id")  returns a Dijit widget instance!
• DOM Insert/Edit
     – dojo.create() & dojo.place()
             var img = dojo.create("img"‚ ,src:"a.gif", alt:"demo" });
             dojo.place(img, node, "after");
             OR: dojo.create("img"‚ ,src:"a.gif", alt:"demo" }, node, "after");
• Dom Manipulation: cleanup
     – dojo.destroy(node)
     – dojo.empty(node)
10.08.2010                               Thomas Koch                              9
Dojo Base : Querying
• CSS query engine
    – dojo.query("img")  returns NodeList
             • Similar to document.getElementsByTagName("IMG");
    – nodelist = dojo.query(String query, String?|Node? root)
             • Query: CSS3-Selektor http://www.w3.org/TR/css3-selectors
    – Examples
             • dojo.query(".progressIndicator"); // Query by css class.
             • dojo.query(„div#demo"); // Query by node type and id
             • dojo.query(„a*href*=‚www.bscw.de‘+"); // Query attributes
• NodeList
    – Subclass of Array with special extensions:
             • every, forEach ,filter, concat, splice, addClass,removeClass…
10.08.2010                            Thomas Koch                              10
Dojo Base : CSS
• CSS styling
     – Assign CSS classes
              • dojo.addClass(node,clsStr) , removeClass, toggleClass, hasClass
     – Assign CSS styles
              • dojo.style(DOMnode|String node, String|Object style, String val)
              • Example
                  var box = dojo.byId(„bannerTop“);
                  dojo.style(box, {height : „100px“, width: „200px“-);
                  <= => dojo.style(„bannerTop“, …);
              • dojo.attr(DOMnode|String node, String name, String value)
              • Example
                  var img = dojo.byId(„logo1“);
                  dojo.attr(img, „alt“, „OrbiTeam“);


 10.08.2010                                   Thomas Koch                          11
Dojo hands-on

   PRACTICAL EXAMPLE


10.08.2010         Thomas Koch   12
Examples - code available at
 http://code.google.com/p/dojodemo/
• 1. Simple dojo page
      –      Browser sniffing
      –      DOM Manipulation
      –      CSS Querying
      –      onLoad-Handler
• 2. Use of dijits
      –      dojo.require
      –      dojoType magic
      –      Dijit properties
      –      Data layer
• 3. Define your own dijit
      – dojo.provide / dojo.declare
      – dijit.Widget / dijit.Templated

10.08.2010                        Thomas Koch   13
The big picture

   DOJO BUILDING BLOCKS


10.08.2010           Thomas Koch   14
Dojo Architecture
• Dojo consists of …
      – Base
             • Foundation of everything else: packaging,
               loading, DOM manipulation
      – Core
             • Widget parser, animations,
               drag‘n drop, i18n …
      – Dijit
             • Dijits = Dojo Widgets:
                portable widgets
               (progress bar, menu, editor, …)
      – DojoX
             • Dojo eXtensions: stable and
                experimental widgets
               (like Charting, Grid, FishEye)
      – Util
             • Dojo Build System, ShrinkSafe,
               Checkstyle, API Doc System
10.08.2010                                      Thomas Koch   15
Dojo Base
• Basic Toolset
    –   Array Utilities                    (dojo.filter, dojo.forEach …)
    –   Language Utilities                 (dojo.hitch, dojo.isString …)
    –   OO Utilities                       (declare, mixin, extend ...)
    –   Event-System                       (publish, subscribe)
    –   Ajax / IO                          (dojo.xhr)
• Furthermore …
    – Animations
    – String Utilities, JSON Tools                 (fromJSON, toJSON, …)
    – Misc: Colors,Keys, global, eval



  10.08.2010                       Thomas Koch                             16
Dojo Core
• Extends Dojo Base Framework
   – Contains everything from dojo-Namespace
     that needs import, e.g. dojo.require(„dojo.date“)
• Important Components
   –   dojo.dnd:       Drag and Drop
   –   dojo.i18n:      Internationalization Utility
   –   dojo.rpc: Remote Procedure Calls with Backend Servers
   –   dojo.data:      a uniform data access layer
• Furthermore contains…
   –   dojo.fx:         Effects library on top of Base animations
   –   dojo.gears:      Google Gears
   –   dojo.io:         Additional AJAX I/O transports
   –   dojo.html:       Inserting contents in HTML nodes
   –   Misc: dojo.currency, dojo.date, dojo.number, dojo.regexp etc.

                                 Thomas Koch      10.08.2010           17
Dojo Unified Events
• Publish/Subscribe communication
• connect a function of your own to:
    –   a DOM event, such as when a link is clicked
    –   an event of an object, such as an animation starting
    –   a topic, which other objects can publish objects to
    –   function call of your own, such as bar();
• Methods
    – dojo.[dis]connect(), dojo.publish, dojo.subscribe()
• Example        var foo = dojo.byId("foo"); // anchor element
                 dojo.connect(foo, "onclick", function(evt) {
                     console.log("anchor clicked");
                     dojo.stopEvent(evt); //suppress navigation
 10.08.2010                   Thomas Koch                     18
                 });
Further Information on Dojo

   DOJO RELATED


10.08.2010                       Thomas Koch   19
Dojo Documentation
• API Docs
      – Online Documentation : http://dojotoolkit.org/api/
• Dojo Campus
      – Articles, Tutorials, Feature Explorer … http://dojocampus.org
• Blogs
      – Dojo Project Blog
             • http://dojotoolkit.org/blog/
      – SitePen Blog
             • http://www.sitepen.com/blog
      – Shane O’Sullivan’s technical blog
             • http://shaneosullivan.wordpress.com/
• Books
      – Russell, Matthew A.
             • Dojo: The Definitive Guide
      – Riecke, C.; Gill, R.; Russell, A.
             • Mastering Dojo:
      – Zammetti, Frank
10.08.2010
             •   Practical Dojo Projects      Thomas Koch               20
Dojo Performance
• Dojo Performs Better (DOM Manipulation!)
      – Dojo is 1.5-2x faster than jQuery, and the difference is
        biggest on the slowest browsers — where it counts most.




    siehe TaskSpeed
      – http://dante.dojotoolkit.org/taskspeed/

10.08.2010                     Thomas Koch                         21
Dojo Foundation
 – http://www.dojofoundation.org/
 – home of great open-source projects
 – started as the home of
   the Dojo Toolkit
 – today the Dojo Foundation
   is also home of other open
   web projects including
   cometD, DWR, OpenRecord,
   Persevere, and Sizzle.
 – Dojo Foundation Board
 – vote per committer

10.08.2010               Thomas Koch    22
Dojo Demos
• Demo #1
      – Dojo Image Demo: Zoomer
      – http://demos.dojotoolkit.org/demos/cropper/
• Demo #2
      – Dojo Feature Explorer
      – http://dojocampus.org/explorer
• Demo #3
      – Sitepen Persevere Demo: Stocker
      – http://persevere.sitepen.com/stocker.html

10.08.2010                 Thomas Koch                23

Mais conteúdo relacionado

Mais procurados (7)

03 Custom Classes
03 Custom Classes03 Custom Classes
03 Custom Classes
 
09 Data
09 Data09 Data
09 Data
 
Presentation to wdim_students
Presentation to wdim_studentsPresentation to wdim_students
Presentation to wdim_students
 
Html5: something wicked this way comes
Html5: something wicked this way comesHtml5: something wicked this way comes
Html5: something wicked this way comes
 
Devdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for DevelopersDevdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for Developers
 
Building Your First MongoDB Application
Building Your First MongoDB ApplicationBuilding Your First MongoDB Application
Building Your First MongoDB Application
 
Mobile, Media & Touch
Mobile, Media & TouchMobile, Media & Touch
Mobile, Media & Touch
 

Destaque (6)

EnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes ForschungsinformationssystemEnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes Forschungsinformationssystem
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)
 
Automated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and ValidationAutomated Python Test Frameworks for Hardware Verification and Validation
Automated Python Test Frameworks for Hardware Verification and Validation
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
Automated hardware testing using python
Automated hardware testing using pythonAutomated hardware testing using python
Automated hardware testing using python
 

Semelhante a Getting Started with Dojo Toolkit

Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
helenmga
 
Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojo
yoavrubin
 
JavaScript DOM & event
JavaScript DOM & eventJavaScript DOM & event
JavaScript DOM & event
Borey Lim
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
jeresig
 
jQuery Learning
jQuery LearningjQuery Learning
jQuery Learning
Uzair Ali
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden
 

Semelhante a Getting Started with Dojo Toolkit (20)

The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An Introduction
 
How dojo works
How dojo worksHow dojo works
How dojo works
 
Building Dojo in the Cloud
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
 
Dojo javascript toolkit
Dojo javascript toolkit Dojo javascript toolkit
Dojo javascript toolkit
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
 
Dojo training
Dojo trainingDojo training
Dojo training
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Test02
Test02Test02
Test02
 
Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojo
 
Dojo, from scratch to result
Dojo, from scratch to resultDojo, from scratch to result
Dojo, from scratch to result
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
JavaScript DOM & event
JavaScript DOM & eventJavaScript DOM & event
JavaScript DOM & event
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started Today
 
dojo.things()
dojo.things()dojo.things()
dojo.things()
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
 
jQuery Learning
jQuery LearningjQuery Learning
jQuery Learning
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
DOJO
DOJO DOJO
DOJO
 
Complete Dojo
Complete DojoComplete Dojo
Complete Dojo
 
Rich internet application development using the dojo toolkit
Rich internet application development using the dojo toolkitRich internet application development using the dojo toolkit
Rich internet application development using the dojo toolkit
 

Mais de Thomas Koch

Mais de Thomas Koch (14)

Einfache Heimautomatisierung auf dem Raspberry Pi mit Python
Einfache Heimautomatisierung auf dem Raspberry Pi mit PythonEinfache Heimautomatisierung auf dem Raspberry Pi mit Python
Einfache Heimautomatisierung auf dem Raspberry Pi mit Python
 
CI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python CodeCI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python Code
 
CI-Ampel für Jenkins mit RaspberryPi und Python
CI-Ampel für Jenkins mit RaspberryPi und PythonCI-Ampel für Jenkins mit RaspberryPi und Python
CI-Ampel für Jenkins mit RaspberryPi und Python
 
Facettensuche mit Lucene und Solr
Facettensuche mit Lucene und SolrFacettensuche mit Lucene und Solr
Facettensuche mit Lucene und Solr
 
BSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemachtBSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemacht
 
Raspberry Pi und Python
Raspberry Pi und PythonRaspberry Pi und Python
Raspberry Pi und Python
 
Einführung in Raspberry Pi und GPIO
Einführung in Raspberry Pi und GPIOEinführung in Raspberry Pi und GPIO
Einführung in Raspberry Pi und GPIO
 
Python-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und EclipsePython-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und Eclipse
 
Pandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen EinsatzPandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen Einsatz
 
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
 
Volltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und SolrVolltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und Solr
 
PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011
 
Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008) Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008)
 
Suche und PyLucene
Suche und PyLuceneSuche und PyLucene
Suche und PyLucene
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Getting Started with Dojo Toolkit

  • 1. Getting started with Dojo Toolkit Cologne.js User Group Meeting, Cologne (@cowoco) Thomas Koch (@tomy_koch) 10. August 2010
  • 2. Dojo Toolkit: About • Dojo is JS Framework – Pure client-side JS (in contrast to GWT etc.) – Includes Dev.Tools: build, test – Open source, active community http://www.dojotoolkit.org/ • Dojo features – OO-style class based development – Modularisation (via concept of packages) – Support for data and GUI  MVC – Wide range of builtin widgets 10.08.2010 Thomas Koch 2
  • 3. Dojo Toolkit: Features • Development: APIs for robust Web Applications – Event handling, DOM manipulation – CSS Querying, Animations, … • Communication: Ajax and even more – Data abstraction layer, JSON-RPC, Comet, XMPP etc. • Integration: with many server-side developments – including DWR, Django, TurboGears, Google, Jaxer … • User interface: re-usable gui components – Standard gui widgets (button, slider, table, tree, menu …) – vector graphics, charting, … – theming, drag’n drop, … – i18N, a11y • Widely used: Dojo Widgets (aka Dijits) 10.08.2010 Thomas Koch 3
  • 4. Dojo Sneak Preview: Theme Tester 10.08.2010 Thomas Koch 4
  • 5. Dojo quick-start GETTING STARTED 10.08.2010 Thomas Koch 5
  • 6. Basic Dojo Page • minimal Dojo – load the dojo base stuff: dojo.js – define a config (optional!) • djConfig : dictionary used by dojo bootstrap process – Locale, debug, baseURL, parseOnLoad, … • Example <html><head><title>Dojo Demo</title> <script type="text/javascript" src="dojo/dojo.js" djConfig="isDebug:true"> </script></head> <body><p>Hello Dojo</p></body> </html> 10.08.2010 Thomas Koch 6
  • 7. Document Life-Cycle • OnLoad/unLoad Handler – dojo.addOnLoad(<functionname>) • defers script execution until all HTML is loaded – vice versa: addOnUnload() • Example <script type="text/javascript"> function showVersion() { var node = dojo.byId("demo"); node.innerHTML = "Dojo"+dojo.version; } dojo.addOnLoad(showVersion); </script> <body> <div id="demo"></div> 10.08.2010 Thomas Koch 7
  • 8. Dojo Base • Foundation of Dojo Framework: dojo.js – Implements Browser detection & Package loading • import/packaging-concept via dojo.declare / dojo.require – Provides DOM Manipulation and CSS query engine • Browser sniffing – dojo.isFF, dojo.isIE – dojo.isOpera, dojo.isSafari – dojo.isAir • Dojo.is<Browser> (global variable!) – IS version of browser – OR undefined >>> dojo.isFF 3.5 10.08.2010 Thomas Koch 8
  • 9. DOM Manipulation • DOM Lookup – node = dojo.byId("id")  returns a DOM node • Similar to document.getElementById("id") – Watch out: dijit.byId("id")  returns a Dijit widget instance! • DOM Insert/Edit – dojo.create() & dojo.place() var img = dojo.create("img"‚ ,src:"a.gif", alt:"demo" }); dojo.place(img, node, "after"); OR: dojo.create("img"‚ ,src:"a.gif", alt:"demo" }, node, "after"); • Dom Manipulation: cleanup – dojo.destroy(node) – dojo.empty(node) 10.08.2010 Thomas Koch 9
  • 10. Dojo Base : Querying • CSS query engine – dojo.query("img")  returns NodeList • Similar to document.getElementsByTagName("IMG"); – nodelist = dojo.query(String query, String?|Node? root) • Query: CSS3-Selektor http://www.w3.org/TR/css3-selectors – Examples • dojo.query(".progressIndicator"); // Query by css class. • dojo.query(„div#demo"); // Query by node type and id • dojo.query(„a*href*=‚www.bscw.de‘+"); // Query attributes • NodeList – Subclass of Array with special extensions: • every, forEach ,filter, concat, splice, addClass,removeClass… 10.08.2010 Thomas Koch 10
  • 11. Dojo Base : CSS • CSS styling – Assign CSS classes • dojo.addClass(node,clsStr) , removeClass, toggleClass, hasClass – Assign CSS styles • dojo.style(DOMnode|String node, String|Object style, String val) • Example var box = dojo.byId(„bannerTop“); dojo.style(box, {height : „100px“, width: „200px“-); <= => dojo.style(„bannerTop“, …); • dojo.attr(DOMnode|String node, String name, String value) • Example var img = dojo.byId(„logo1“); dojo.attr(img, „alt“, „OrbiTeam“); 10.08.2010 Thomas Koch 11
  • 12. Dojo hands-on PRACTICAL EXAMPLE 10.08.2010 Thomas Koch 12
  • 13. Examples - code available at http://code.google.com/p/dojodemo/ • 1. Simple dojo page – Browser sniffing – DOM Manipulation – CSS Querying – onLoad-Handler • 2. Use of dijits – dojo.require – dojoType magic – Dijit properties – Data layer • 3. Define your own dijit – dojo.provide / dojo.declare – dijit.Widget / dijit.Templated 10.08.2010 Thomas Koch 13
  • 14. The big picture DOJO BUILDING BLOCKS 10.08.2010 Thomas Koch 14
  • 15. Dojo Architecture • Dojo consists of … – Base • Foundation of everything else: packaging, loading, DOM manipulation – Core • Widget parser, animations, drag‘n drop, i18n … – Dijit • Dijits = Dojo Widgets: portable widgets (progress bar, menu, editor, …) – DojoX • Dojo eXtensions: stable and experimental widgets (like Charting, Grid, FishEye) – Util • Dojo Build System, ShrinkSafe, Checkstyle, API Doc System 10.08.2010 Thomas Koch 15
  • 16. Dojo Base • Basic Toolset – Array Utilities (dojo.filter, dojo.forEach …) – Language Utilities (dojo.hitch, dojo.isString …) – OO Utilities (declare, mixin, extend ...) – Event-System (publish, subscribe) – Ajax / IO (dojo.xhr) • Furthermore … – Animations – String Utilities, JSON Tools (fromJSON, toJSON, …) – Misc: Colors,Keys, global, eval 10.08.2010 Thomas Koch 16
  • 17. Dojo Core • Extends Dojo Base Framework – Contains everything from dojo-Namespace that needs import, e.g. dojo.require(„dojo.date“) • Important Components – dojo.dnd: Drag and Drop – dojo.i18n: Internationalization Utility – dojo.rpc: Remote Procedure Calls with Backend Servers – dojo.data: a uniform data access layer • Furthermore contains… – dojo.fx: Effects library on top of Base animations – dojo.gears: Google Gears – dojo.io: Additional AJAX I/O transports – dojo.html: Inserting contents in HTML nodes – Misc: dojo.currency, dojo.date, dojo.number, dojo.regexp etc. Thomas Koch 10.08.2010 17
  • 18. Dojo Unified Events • Publish/Subscribe communication • connect a function of your own to: – a DOM event, such as when a link is clicked – an event of an object, such as an animation starting – a topic, which other objects can publish objects to – function call of your own, such as bar(); • Methods – dojo.[dis]connect(), dojo.publish, dojo.subscribe() • Example var foo = dojo.byId("foo"); // anchor element dojo.connect(foo, "onclick", function(evt) { console.log("anchor clicked"); dojo.stopEvent(evt); //suppress navigation 10.08.2010 Thomas Koch 18 });
  • 19. Further Information on Dojo DOJO RELATED 10.08.2010 Thomas Koch 19
  • 20. Dojo Documentation • API Docs – Online Documentation : http://dojotoolkit.org/api/ • Dojo Campus – Articles, Tutorials, Feature Explorer … http://dojocampus.org • Blogs – Dojo Project Blog • http://dojotoolkit.org/blog/ – SitePen Blog • http://www.sitepen.com/blog – Shane O’Sullivan’s technical blog • http://shaneosullivan.wordpress.com/ • Books – Russell, Matthew A. • Dojo: The Definitive Guide – Riecke, C.; Gill, R.; Russell, A. • Mastering Dojo: – Zammetti, Frank 10.08.2010 • Practical Dojo Projects Thomas Koch 20
  • 21. Dojo Performance • Dojo Performs Better (DOM Manipulation!) – Dojo is 1.5-2x faster than jQuery, and the difference is biggest on the slowest browsers — where it counts most. siehe TaskSpeed – http://dante.dojotoolkit.org/taskspeed/ 10.08.2010 Thomas Koch 21
  • 22. Dojo Foundation – http://www.dojofoundation.org/ – home of great open-source projects – started as the home of the Dojo Toolkit – today the Dojo Foundation is also home of other open web projects including cometD, DWR, OpenRecord, Persevere, and Sizzle. – Dojo Foundation Board – vote per committer 10.08.2010 Thomas Koch 22
  • 23. Dojo Demos • Demo #1 – Dojo Image Demo: Zoomer – http://demos.dojotoolkit.org/demos/cropper/ • Demo #2 – Dojo Feature Explorer – http://dojocampus.org/explorer • Demo #3 – Sitepen Persevere Demo: Stocker – http://persevere.sitepen.com/stocker.html 10.08.2010 Thomas Koch 23