Dojo The Definitive Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

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.

Author(s): Matthew A. Russell
Edition: 1
Publisher: O'Reilly Media
Year: 2008

Language: English
Pages: 488
Tags: Библиотека;Компьютерная литература;HTML / CSS / JavaScript;

Dojo: The Definitive Guide......Page 1
Table of Contents......Page 9
Foreword......Page 15
Preface......Page 17
Why Dojo?......Page 18
What’s in This Book......Page 21
What’s Not in This Book......Page 24
About You......Page 25
Closures......Page 26
Context......Page 27
Anonymous functions......Page 29
Style Conventions......Page 30
Using Code Examples......Page 31
Acknowledgments......Page 32
Part I......Page 35
Overview of Dojo’s Architecture......Page 37
Base......Page 38
Dijit......Page 39
Util......Page 40
Downloading an official release......Page 41
Downloading from Subversion......Page 42
AOL’s CDN......Page 43
Debugging with Firebug......Page 44
Lightweight Server Responses......Page 45
Terminology......Page 46
Bootstrapping......Page 49
dojo.addOnLoad......Page 51
Configuration with djConfig......Page 52
Exploring Base......Page 55
dojo.byId......Page 58
dojo.connect......Page 60
Exploring Dijit......Page 62
Summary......Page 65
Looking Up DOM Nodes......Page 66
Duck Typing......Page 67
String Utilities......Page 68
Finding Locations of Elements......Page 69
Testing Elements for a Condition......Page 70
Iterating Over Elements......Page 71
Transforming Elements......Page 72
String-As-Function Style Arguments......Page 73
Motivation for Managing the Mayhem......Page 74
Custom Module Example Over XDomain......Page 76
Fibonacci Example with Local Toolkit Installation......Page 78
Building a Magic Genie Example Module......Page 79
Mixins......Page 82
Extending Object Prototypes......Page 83
Cloning Objects......Page 85
Manipulating Object Context......Page 86
Partially Applying Parameters......Page 87
Hitching an Object to a Specific Context......Page 88
DOM Utilities......Page 89
Styling Nodes......Page 90
Manipulating Attributes......Page 91
The Box Model......Page 92
Cookies......Page 96
Back Button Handling......Page 98
Summary......Page 100
Mouse and Keyboard Event Normalization......Page 101
Standardized Key Codes......Page 103
Event Listeners......Page 104
Event Propagation......Page 107
Setting up connections within a loop......Page 108
Connecting in Markup......Page 109
Publish/Subscribe Communication......Page 110
Summary......Page 113
Quick Overview of AJAX......Page 114
JSON......Page 115
AJAX Made Easy......Page 116
XHR Examples......Page 119
Hitching Up Callbacks......Page 121
Deferreds......Page 123
Deferred Examples Via CherryPy......Page 125
Using Deferreds returned from XHR functions......Page 127
Injecting Deferreds into XHR functions......Page 129
DeferredList......Page 131
Form and HTTP Utilities......Page 132
Cross-Site Scripting with JSONP......Page 133
JSONP Primer......Page 134
Using JSONP with Dojo......Page 135
Getting back JavaScript from a JSONP call......Page 136
IFRAME Transports......Page 137
File downloads with IFRAMEs......Page 138
Form submissions with IFRAMEs......Page 139
Non-HTML response types......Page 141
Manually creating a hidden IFRAME......Page 142
JSON RPC Example......Page 144
OpenAjax Hub......Page 146
Summary......Page 147
Node Manipulation......Page 148
Query: One Size Fits All......Page 149
Warm Up......Page 150
State Tracking Example......Page 153
The short, robust way......Page 154
NodeList......Page 155
Array-Like Methods......Page 156
Chaining NodeList results......Page 157
Style......Page 159
Placement......Page 160
DOM Event Shortcuts......Page 162
Animation......Page 163
Creating NodeList Extensions......Page 164
Behavior......Page 165
Summary......Page 169
Introduction......Page 170
Layout on Disk......Page 171
Putting It All Together......Page 172
Dates......Page 174
Numbers......Page 175
Currency......Page 176
Summary......Page 177
Simple Moveables......Page 178
Drag Events......Page 183
Z-Indexing......Page 185
Constrained Moveables......Page 186
Dropping......Page 189
Pure Targets......Page 191
Custom Avatars......Page 192
Drop Events......Page 193
Scripting Droppables......Page 197
Summary......Page 198
Simple Fades......Page 199
Animating Arbitrary CSS Properties......Page 203
Programatically Controlling Animations......Page 208
Sliding......Page 210
Wiping......Page 213
Chaining and Combining......Page 215
Toggling......Page 218
Animation + Drag-and-Drop = Fun!......Page 219
Colors......Page 220
Creating and Blending Colors......Page 221
Named Color Values Available Via Base......Page 223
Additional Color Values Available Via Core......Page 224
Summary......Page 228
Shifting the Data Paradigm......Page 230
Data API Overview......Page 231
The Read API......Page 232
The Identity API......Page 235
The Write API......Page 236
The Notification API......Page 237
Core Implementations of Data APIs......Page 238
Hierarchical JSON and JSON with references......Page 239
ItemFileReadStore walkthrough......Page 240
Querying child items......Page 244
ItemFileWriteStore......Page 246
Implicit type-mapping......Page 253
Custom type maps......Page 254
Summary......Page 255
JavaScript Is Not Java......Page 256
Typical JavaScript Inheritance......Page 257
Mixin Pattern......Page 259
Delegation Pattern......Page 260
Simulating Classes with Dojo......Page 261
The Basic Class Creation Pattern......Page 263
A Single Inheritance Example......Page 264
A common gotcha with prototype-based inheritance......Page 267
Calling an inherited method......Page 269
Multiply Inheriting with Mixins......Page 271
Multiple Inheritance Oddities......Page 273
Summary......Page 275
Part II......Page 277
Motivation for Dijit......Page 279
Low Coupling, High Cohesion......Page 280
Accessibility (a11y)......Page 282
Common a11y Issues......Page 283
WAI-ARIA......Page 284
Dijit for Designers......Page 285
Themes......Page 287
Nodes Versus Dijits, DOM Events Versus Dijit Methods......Page 289
Parsing a Widget When the Page Loads......Page 291
Manually Parsing a Widget......Page 292
Demystifying the Parser......Page 293
Creating from Markup......Page 295
Programmatic Creation......Page 296
Lots of Niceties......Page 297
Defining Methods in Markup......Page 298
Form Dijits......Page 300
Layout Dijits......Page 301
Application Dijits......Page 302
Dijit API Drive-By......Page 304
Summary......Page 305
Dijit Anatomy......Page 306
Dijits to the Rescue......Page 307
Dijit Lifecycle Methods......Page 309
Lifecycle methods......Page 310
Essential properties......Page 313
Mixing in _Templated......Page 314
Essential properties......Page 315
HTML page......Page 316
Template......Page 318
JavaScript......Page 319
HelloWorld Dijit (Take 2: Modifying The Template)......Page 320
HelloWorld Dijit (Take 3: Interning the Template)......Page 321
HelloWord Dijit (Take 4: Passing in Parameters)......Page 322
HelloWorld Dijit (Take 5: Associating Events with Dijits)......Page 325
Rapidly Prototyping Widgets in Markup......Page 327
Summary......Page 329
Drive-By Form Review......Page 331
Form Dijits......Page 334
TextBox......Page 338
ValidationTextBox......Page 341
TimeTextBox and DateTextBox......Page 344
Commonalities between DateTextBox and TimeTextBox......Page 348
Serializing data to the server......Page 350
NumberTextBox......Page 351
CurrencyTextBox......Page 352
ComboBox......Page 353
FilteringSelect......Page 357
MultiSelect......Page 358
Button......Page 359
ToggleButton......Page 361
CheckBox......Page 362
RadioButton......Page 364
DropDownButton......Page 365
ComboButton......Page 366
HorizontalSlider......Page 367
VerticalSlider......Page 370
Form......Page 372
Summary......Page 373
Layout Dijit Commonalities......Page 374
Programmatic Creation......Page 375
ContentPane......Page 376
BorderContainer......Page 380
StackContainer......Page 385
TabContainer......Page 387
AccordionContainer......Page 389
Rendering and Visibility Considerations......Page 391
Summary......Page 392
Tooltip......Page 393
Dialog......Page 394
TooltipDialog......Page 396
ProgressBar......Page 398
ColorPalette......Page 400
Toolbar......Page 401
Menu......Page 403
TitlePane......Page 408
InlineEditBox......Page 409
Tree......Page 411
Simple Tree......Page 412
Simple Forest......Page 414
Responding to Click Events......Page 416
Tree-Related APIs......Page 417
Drag-and-Drop with the Tree......Page 419
Drag-and-droppable Tree example......Page 420
Editor......Page 422
Editor Architecture......Page 425
Editor Plug-Ins......Page 426
Summary......Page 429
Building......Page 430
Running a Build......Page 431
Setting up a build profile......Page 434
Setting up a (more clever) build profile......Page 436
Standard build profile......Page 437
ShrinkSafe optimization and other common options......Page 438
Rhino Test Harness Without Dojo......Page 441
Rhino Test Harness with Dojo......Page 443
Browser-Based Test Harness......Page 445
Asynchronous Browser Test Example......Page 446
Performance Considerations......Page 447
Summary......Page 449
To Allow or Not to Allow?......Page 451
Now for the Fun Stuff......Page 453
Inspect......Page 454
Console......Page 456
Script and DOM......Page 458
Go Forth and Dismantle......Page 461
A Brief Survey of DojoX......Page 462
Index......Page 465