Dojo: The Definitive Guide

Book description

Of all the Ajax-specific frameworks that have popped up in recent years, one clearly stands out as the industrial strength solution. Dojo is not just another JavaScript toolkit—it's the JavaScript toolkit—and Dojo: The Definitive Guide demonstrates how to tame Dojo's extensive library of utilities so that you can build rich and responsive web applications like never before. Dojo founder Alex Russell gives a foreword that explains the "why" of Dojo and of this book.

Dojo provides an end-to-end solution for development in the browser, including everything from the core JavaScript library and turnkey widgets to build tools and a testing framework. Its vibrant open source community keeps adding to Dojo's arsenal, and this book provides an ideal companion to Dojo's official documentation.

Dojo: the Definitive Guide gives you the most thorough overview of this toolkit available, showing you everything from how to create complex layouts and form controls closely resembling those found in the most advanced desktop applications with stock widgets, to advanced JavaScript idioms to AJAX and advanced communication transports. With this definitive reference you get:

  • Get a concise introduction to Dojo that's good for all 1.x versions
  • Well-explained examples, with scores of tested code samples, that let you see Dojo in action
  • A comprehensive reference to Dojo's standard JavaScript library (including fundamental utilities in Base, Dojo's tiny but powerful kernel) that you'll wonder how you ever lived without
  • An extensive look at additional Core features, such as animations, drag-and-drop, back-button handling, animations like wipe and slide, and more
  • Exhaustive coverage of out-of-the-box Dijits (Dojo widgets) as well as definitive coverage on how to create your own, either from scratch or building on existing ones
  • An itemized inventory of DojoX subprojects, the build tools, and the DOH, Dojo's unit-testing framework that you can use with Dojo—or anywhere else

If you're a DHTML-toting web developer, you need to read this book—whether you're a one-person operation or part of an organization employing scores of developers. Dojo packs the standard JavaScript library you've always wanted, and Dojo: The Definitive Guide helps you transform your ideas into working applications quickly by leveraging design concepts you already know.

Publisher resources

View/Submit Errata

Table of contents

  1. Dojo: The Definitive Guide
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Preface
      1. Why Dojo?
      2. What's in This Book
      3. What's Not in This Book
      4. Open Source Software Is Fluid
      5. About You
        1. Development Tools
        2. Essential Working Knowledge
          1. Closures
          2. Context
          3. Anonymous functions
      6. Conventions Used in This Book
        1. Style Conventions
      7. Using Code Examples
      8. Safari® Books Online
      9. We'd Like to Hear from You
      10. Acknowledgments
    5. I. Base and Core
      1. 1. Toolkit Overview
        1. Overview of Dojo's Architecture
          1. Base
          2. Core
          3. Dijit
          4. DojoX
          5. Util
        2. Prepping for Development
          1. Getting Dojo
            1. Downloading an official release
            2. Downloading from Subversion
            3. AOL's CDN
          2. Debugging with Firebug
          3. Browser Security Settings for Running Dojo Locally
          4. Lightweight Server Responses
        3. Terminology
        4. Bootstrapping
          1. dojo.addOnLoad
          2. Configuration with djConfig
        5. Exploring Dojo with Firebug
          1. Exploring Base
            1. dojo.byId
            2. dojo.connect
          2. Exploring Dijit
        6. Summary
      2. 2. Language and Browser Utilities
        1. Looking Up DOM Nodes
        2. Type Checking
          1. Duck Typing
        3. String Utilities
        4. Array Processing
          1. Finding Locations of Elements
          2. Testing Elements for a Condition
          3. Iterating Over Elements
          4. Transforming Elements
          5. String-As-Function Style Arguments
        5. Managing Source Code with Modules
          1. Motivation for Managing the Mayhem
          2. Custom Module Example Over XDomain
          3. Fibonacci Example with Local Toolkit Installation
          4. Building a Magic Genie Example Module
        6. JavaScript Object Utilities
          1. Mixins
          2. Extending Object Prototypes
          3. Cloning Objects
        7. Manipulating Object Context
          1. Partially Applying Parameters
          2. Hitching an Object to a Specific Context
          3. Delegation and Inheritance
        8. DOM Utilities
          1. Ancestry
          2. Selectability
          3. Styling Nodes
          4. Manipulating Attributes
          5. Placing Nodes
          6. The Box Model
        9. Browser Utilities
          1. Cookies
          2. Back Button Handling
        10. Summary
      3. 3. Event Listeners and Pub/Sub Communication
        1. Event and Keyboard Normalization
          1. Mouse and Keyboard Event Normalization
          2. Standardized Key Codes
        2. Event Listeners
          1. Event Propagation
          2. Leveraging Closures with dojo.connect
            1. One-time connections
            2. Setting up connections within a loop
          3. Connecting in Markup
        3. Publish/Subscribe Communication
        4. Summary
      4. 4. AJAX and Server Communication
        1. Quick Overview of AJAX
          1. JSON
        2. AJAX Made Easy
          1. XHR Examples
          2. General Purpose XMLHttpRequest Calls
          3. Hitching Up Callbacks
        3. Deferreds
          1. Deferred Examples Via CherryPy
            1. Using Deferreds returned from XHR functions
            2. Injecting Deferreds into XHR functions
            3. Custom canceller
            4. DeferredList
        4. Form and HTTP Utilities
        5. Cross-Site Scripting with JSONP
          1. JSONP Primer
        6. Core IO
          1. Using JSONP with Dojo
            1. Connecting to a Flickr data source
            2. Getting back JavaScript from a JSONP call
          2. IFRAME Transports
            1. File downloads with IFRAMEs
            2. Form submissions with IFRAMEs
            3. Non-HTML response types
            4. Manually creating a hidden IFRAME
        7. JSON Remote Procedure Calls
          1. JSON RPC Example
        8. OpenAjax Hub
        9. Summary
      5. 5. Node Manipulation
        1. Query: One Size Fits All
          1. Warm Up
          2. State Tracking Example
            1. The long, brittle way
            2. The short, robust way
        2. NodeList
          1. Array-Like Methods
            1. Chaining NodeList results
            2. String-as-Function style Arguments
            3. Enhanced filtering
          2. Style
          3. Placement
          4. DOM Event Shortcuts
          5. Animation
        3. Creating NodeList Extensions
        4. Behavior
        5. Summary
      6. 6. Internationalization (i18n)
        1. Introduction
        2. Internationalizing a Module
          1. Layout on Disk
          2. Defining String Tables
          3. Putting It All Together
            1. Use build tools for snappy performance
        3. Dates, Numbers, and Currency
          1. Dates
          2. Numbers
          3. Currency
        4. Summary
      7. 7. Drag-and-Drop
        1. Dragging
          1. Simple Moveables
          2. Drag Events
          3. Z-Indexing
          4. Constrained Moveables
        2. Dropping
          1. Pure Targets
          2. Custom Avatars
          3. Drop Events
          4. Scripting Droppables
        3. Summary
      8. 8. Animation and Special Effects
        1. Animation
          1. Simple Fades
          2. Animating Arbitrary CSS Properties
          3. Programatically Controlling Animations
        2. Core fx
          1. Sliding
          2. Wiping
          3. Chaining and Combining
          4. Toggling
        3. Animation + Drag-and-Drop = Fun!
        4. Colors
          1. Creating and Blending Colors
          2. Named Color Values Available Via Base
          3. Additional Color Values Available Via Core
        5. Summary
      9. 9. Data Abstraction
        1. Shifting the Data Paradigm
        2. Data API Overview
        3. The APIs
          1. The Read API
          2. The Identity API
          3. The Write API
          4. The Notification API
        4. Core Implementations of Data APIs
          1. ItemFileReadStore
            1. Hierarchical JSON and JSON with references
            2. ItemFileReadStore walkthrough
              1. Fetching an item by identity
              2. Fetching an item by arbitrary criteria
            3. Querying child items
            4. ItemFileWriteStore
              1. Modifying an existing item
              2. Creating and deleting items
              3. Custom saves
              4. Responding to notifications
          2. Serializing and Deserializing Custom Data Types
            1. Implicit type-mapping
            2. Custom type maps
        5. Summary
      10. 10. Simulated Classes and Inheritance
        1. JavaScript Is Not Java
        2. One Problem, Many Solutions
          1. Typical JavaScript Inheritance
          2. Mixin Pattern
          3. Delegation Pattern
        3. Simulating Classes with Dojo
          1. The Basic Class Creation Pattern
          2. A Single Inheritance Example
            1. A common gotcha with prototype-based inheritance
            2. Calling an inherited method
        4. Multiply Inheriting with Mixins
          1. Multiple Inheritance Oddities
        5. Summary
    6. II. Dijit and Util
      1. 11. Dijit Overview
        1. Motivation for Dijit
          1. Low Coupling, High Cohesion
        2. Accessibility (a11y)
          1. Common a11y Issues
          2. WAI-ARIA
        3. Dijit for Designers
          1. Themes
          2. Nodes Versus Dijits, DOM Events Versus Dijit Methods
        4. The Parser
          1. Parsing a Widget When the Page Loads
          2. Manually Parsing a Widget
          3. Demystifying the Parser
        5. Hands-on Dijit with NumberSpinner
          1. Creating from Markup
          2. Programmatic Creation
          3. Lots of Niceties
          4. Defining Methods in Markup
        6. Overview of Stock Dijits
          1. Form Dijits
          2. Layout Dijits
          3. Application Dijits
        7. Dijit API Drive-By
        8. Summary
      2. 12. Dijit Anatomy and Lifecycle
        1. Dijit Anatomy
          1. Web Development Review
          2. Dijits to the Rescue
        2. Dijit Lifecycle Methods
          1. The _Widget Lifecycle
            1. Lifecycle methods
            2. Essential properties
          2. Mixing in _Templated
            1. Lifecycle methods
            2. Essential properties
        3. Your First Dijit: HelloWorld
          1. HelloWorld Dijit (Take 1: Bare Bones)
            1. HTML page
            2. CSS
            3. Template
            4. JavaScript
          2. HelloWorld Dijit (Take 2: Modifying The Template)
          3. HelloWorld Dijit (Take 3: Interning the Template)
          4. HelloWord Dijit (Take 4: Passing in Parameters)
          5. HelloWorld Dijit (Take 5: Associating Events with Dijits)
        4. Parent-Child Relationships with _Container and _Contained
        5. Rapidly Prototyping Widgets in Markup
        6. Summary
      3. 13. Form Widgets
        1. Drive-By Form Review
        2. Form Dijits
        3. TextBox Variations
            1. TextBox
          1. ValidationTextBox
          2. MappedTextBox and RangeBoundTextBox
          3. TimeTextBox and DateTextBox
            1. Commonalities between DateTextBox and TimeTextBox
            2. Serializing data to the server
            3. Don't forget about inherited properties
            4. NumberTextBox
            5. NumberSpinner
            6. CurrencyTextBox
            7. ComboBox
        4. FilteringSelect
        5. MultiSelect
        6. Textarea Variations
          1. Textarea
          2. SimpleTextarea
        7. Button Variations
          1. Button
          2. ToggleButton
          3. CheckBox
          4. RadioButton
          5. DropDownButton
          6. ComboButton
        8. Slider
          1. HorizontalSlider
          2. VerticalSlider
        9. Form
          1. HTML Form Tag Synopsis
          2. Form
        10. Summary
      4. 14. Layout Widgets
        1. Layout Dijit Commonalities
          1. Programmatic Creation
          2. Keyboard Support
        2. ContentPane
        3. BorderContainer
        4. StackContainer
          1. Procrastination (a.k.a. Lazy Loading) May Yield Better Performance
        5. TabContainer
        6. AccordionContainer
        7. Rendering and Visibility Considerations
        8. Summary
      5. 15. Application Widgets
        1. Tooltip
        2. Dialog Widgets
          1. Dialog
          2. TooltipDialog
        3. ProgressBar
        4. ColorPalette
        5. Toolbar
        6. Menu
        7. TitlePane
        8. InlineEditBox
        9. Tree
          1. Simple Tree
          2. Simple Forest
          3. Responding to Click Events
          4. Tree-Related APIs
          5. Drag-and-Drop with the Tree
            1. Drag-and-droppable Tree example
        10. Editor
          1. Editor Architecture
          2. Editor Plug-Ins
        11. Summary
      6. 16. Build Tools, Testing, and Production Considerations
        1. Building
          1. Running a Build
          2. Build Profiles
            1. Setting up a build profile
            2. Setting up a (more clever) build profile
            3. Standard build profile
            4. ShrinkSafe optimization and other common options
        2. Dojo Objective Harness (DOH)
          1. Rhino Test Harness Without Dojo
          2. Rhino Test Harness with Dojo
        3. Browser-Based Test Harness
          1. Browser Test Example
          2. Asynchronous Browser Test Example
        4. Performance Considerations
            1. Benefits of XDomain builds
            2. Don't optimize prematurely
        5. Summary
    7. A. A Firebug Primer
      1. Installation
      2. To Allow or Not to Allow?
      3. Now for the Fun Stuff
      4. Inspect
      5. Console
      6. HTML and CSS
        1. Script and DOM
      7. Net
      8. Go Forth and Dismantle
    8. B. A Brief Survey of DojoX
    9. Index
    10. About the Author
    11. Colophon
    12. SPECIAL OFFER: Upgrade this ebook with O’Reilly

Product information

  • Title: Dojo: The Definitive Guide
  • Author(s): Matthew A. Russell
  • Release date: June 2008
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596551728