9780596516482
index.html

Dojo: The Definitive Guide

Matthew A. Russell

O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or .

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc. Dojo: The Definitive Guide, the image of a lion-tailed monkey, and related trade dress are trademarks of O'Reilly Media, Inc.

Java™ is a trademark of Sun Microsystems, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.


Dedication

This book is dedicated to every single web developer who has lost sleep because of ridiculous browser idiosyncrasies.

Foreword
Preface
Why Dojo?
What's in This Book
What's Not in This Book
Open Source Software Is Fluid
About You
Development Tools
Essential Working Knowledge
Conventions Used in This Book
Style Conventions
Using Code Examples
Safari® Books Online
We'd Like to Hear from You
Acknowledgments
I. Base and Core
1. Toolkit Overview
Overview of Dojo's Architecture
Base
Core
Dijit
DojoX
Util
Prepping for Development
Getting Dojo
Debugging with Firebug
Browser Security Settings for Running Dojo Locally
Lightweight Server Responses
Terminology
Bootstrapping
dojo.addOnLoad
Configuration with djConfig
Exploring Dojo with Firebug
Exploring Base
Exploring Dijit
Summary
2. Language and Browser Utilities
Looking Up DOM Nodes
Type Checking
Duck Typing
String Utilities
Array Processing
Finding Locations of Elements
Testing Elements for a Condition
Iterating Over Elements
Transforming Elements
String-As-Function Style Arguments
Managing Source Code with Modules
Motivation for Managing the Mayhem
Custom Module Example Over XDomain
Fibonacci Example with Local Toolkit Installation
Building a Magic Genie Example Module
JavaScript Object Utilities
Mixins
Extending Object Prototypes
Cloning Objects
Manipulating Object Context
Partially Applying Parameters
Hitching an Object to a Specific Context
Delegation and Inheritance
DOM Utilities
Ancestry
Selectability
Styling Nodes
Manipulating Attributes
Placing Nodes
The Box Model
Browser Utilities
Cookies
Back Button Handling
Summary
3. Event Listeners and Pub/Sub Communication
Event and Keyboard Normalization
Mouse and Keyboard Event Normalization
Standardized Key Codes
Event Listeners
Event Propagation
Leveraging Closures with dojo.connect
Connecting in Markup
Publish/Subscribe Communication
Summary
4. AJAX and Server Communication
Quick Overview of AJAX
JSON
AJAX Made Easy
XHR Examples
General Purpose XMLHttpRequest Calls
Hitching Up Callbacks
Deferreds
Deferred Examples Via CherryPy
Form and HTTP Utilities
Cross-Site Scripting with JSONP
JSONP Primer
Core IO
Using JSONP with Dojo
IFRAME Transports
JSON Remote Procedure Calls
JSON RPC Example
OpenAjax Hub
Summary
5. Node Manipulation
Query: One Size Fits All
Warm Up
State Tracking Example
NodeList
Array-Like Methods
Style
Placement
DOM Event Shortcuts
Animation
Creating NodeList Extensions
Behavior
Summary
6. Internationalization (i18n)
Introduction
Internationalizing a Module
Layout on Disk
Defining String Tables
Putting It All Together
Dates, Numbers, and Currency
Dates
Numbers
Currency
Summary
7. Drag-and-Drop
Dragging
Simple Moveables
Drag Events
Z-Indexing
Constrained Moveables
Dropping
Pure Targets
Custom Avatars
Drop Events
Scripting Droppables
Summary
8. Animation and Special Effects
Animation
Simple Fades
Animating Arbitrary CSS Properties
Programatically Controlling Animations
Core fx
Sliding
Wiping
Chaining and Combining
Toggling
Animation + Drag-and-Drop = Fun!
Colors
Creating and Blending Colors
Named Color Values Available Via Base
Additional Color Values Available Via Core
Summary
9. Data Abstraction
Shifting the Data Paradigm
Data API Overview
The APIs
The Read API
The Identity API
The Write API
The Notification API
Core Implementations of Data APIs
ItemFileReadStore
Serializing and Deserializing Custom Data Types
Summary
10. Simulated Classes and Inheritance
JavaScript Is Not Java
One Problem, Many Solutions
Typical JavaScript Inheritance
Mixin Pattern
Delegation Pattern
Simulating Classes with Dojo
The Basic Class Creation Pattern
A Single Inheritance Example
Multiply Inheriting with Mixins
Multiple Inheritance Oddities
Summary
II. Dijit and Util
11. Dijit Overview
Motivation for Dijit
Low Coupling, High Cohesion
Accessibility (a11y)
Common a11y Issues
WAI-ARIA
Dijit for Designers
Themes
Nodes Versus Dijits, DOM Events Versus Dijit Methods
The Parser
Parsing a Widget When the Page Loads
Manually Parsing a Widget
Demystifying the Parser
Hands-on Dijit with NumberSpinner
Creating from Markup
Programmatic Creation
Lots of Niceties
Defining Methods in Markup
Overview of Stock Dijits
Form Dijits
Layout Dijits
Application Dijits
Dijit API Drive-By
Summary
12. Dijit Anatomy and Lifecycle
Dijit Anatomy
Web Development Review
Dijits to the Rescue
Dijit Lifecycle Methods
The _Widget Lifecycle
Mixing in _Templated
Your First Dijit: HelloWorld
HelloWorld Dijit (Take 1: Bare Bones)
HelloWorld Dijit (Take 2: Modifying The Template)
HelloWorld Dijit (Take 3: Interning the Template)
HelloWord Dijit (Take 4: Passing in Parameters)
HelloWorld Dijit (Take 5: Associating Events with Dijits)
Parent-Child Relationships with _Container and _Contained
Rapidly Prototyping Widgets in Markup
Summary
13. Form Widgets
Drive-By Form Review
Form Dijits
TextBox Variations
ValidationTextBox
MappedTextBox and RangeBoundTextBox
TimeTextBox and DateTextBox
FilteringSelect
MultiSelect
Textarea Variations
Textarea
SimpleTextarea
Button Variations
Button
ToggleButton
CheckBox
RadioButton
DropDownButton
ComboButton
Slider
HorizontalSlider
VerticalSlider
Form
HTML Form Tag Synopsis
Form
Summary
14. Layout Widgets
Layout Dijit Commonalities
Programmatic Creation
Keyboard Support
ContentPane
BorderContainer
StackContainer
Procrastination (a.k.a. Lazy Loading) May Yield Better Performance
TabContainer
AccordionContainer
Rendering and Visibility Considerations
Summary
15. Application Widgets
Tooltip
Dialog Widgets
Dialog
TooltipDialog
ProgressBar
ColorPalette
Toolbar
Menu
TitlePane
InlineEditBox
Tree
Simple Tree
Simple Forest
Responding to Click Events
Tree-Related APIs
Drag-and-Drop with the Tree
Editor
Editor Architecture
Editor Plug-Ins
Summary
16. Build Tools, Testing, and Production Considerations
Building
Running a Build
Build Profiles
Dojo Objective Harness (DOH)
Rhino Test Harness Without Dojo
Rhino Test Harness with Dojo
Browser-Based Test Harness
Browser Test Example
Asynchronous Browser Test Example
Performance Considerations
Summary
A. A Firebug Primer
Installation
To Allow or Not to Allow?
Now for the Fun Stuff
Inspect
Console
HTML and CSS
Script and DOM
Net
Go Forth and Dismantle
B. A Brief Survey of DojoX
Index
Site last updated on: June 2, 2011 at 07:51:26 AM PDT