Tired of getting swamped in the nitty-gritty of cross-browser, Web 2.0-grade JavaScript? Get back in the game with Prototype and script.aculo.us, two extremely popular JavaScript libraries, that make it a walk in the park. Be it AJAX, drag and drop, auto-completion, advanced visual effects, or many other great features, all you need is write one or two lines of script that look so good they could almost pass for Ruby code! Web applications are getting richer and richer, with more interaction baked in every day. But JavaScript, DOM, CSS and a full host of other Web standards are quite complex, and the result isn't always browser compliant. The Prototype and script.aculo.us libraries are veritable treasure troves, smoothing over all the usual nitty-gritty differences between browsers, and making most common features a breeze to implement. With this book, you can quickly wield the whole power of these extraordinary libraries. Dive into Prototype, the library that makes JavaScript so much more powerful, and it looks a lot like Ruby code. Exploring the DOM, handling events, taming AJAX, and radically simplifying most of your scripting code: it all becomes easy-and very portable-with Prototype. When it comes to advanced UI features, script.aculo.us is every web developer's dream come true: whether you need to create auto-completed text inputs, implement in-place editors, provide customized drag-and-drop behaviors, capture your users' attention with visual effects or simply build DOM fragments more efficiently, it's all there, and lightweight too. This book guides you through all the details of these features, letting you use many technologies on the server side, suchasPHP, vanilla Ruby, and Ruby On Rails, in countless examples illustrating every aspect. Power users will also learn the design philosophies of the libraries, and how to contribute to them and augment them for their own needs.
Author(s): Christophe Porteneuve
Series: Pragmatic programmers
Edition: 1
Publisher: Pragmatic
Year: 2007
Language: English
Pages: 431
City: Raleigh, N.C
Tags: Библиотека;Компьютерная литература;HTML / CSS / JavaScript;Ext JS / Sencha Ext JX / Sencha Touch;
Contents......Page 8
Preface......Page 13
It's About Time......Page 15
What's in This Book, and How Is It Organized?......Page 17
Acknowledgments......Page 18
Prototype......Page 20
What Is Prototype, and What Is It Not?......Page 21
What Does Our JavaScript Look Like When Using Prototype?......Page 22
Prototype Jargon and Concepts......Page 37
What Are Prototypes Anyway?......Page 39
Running Prototype Code Samples in This Book......Page 41
Quick Fetching of Smart Elements with $......Page 42
$w, Because Array Literals Are Boring......Page 44
$$ Searches with Style......Page 45
$A, the Collection Unifier......Page 47
$F Is a Field Expert......Page 49
Handling Ranges with $R......Page 50
Generic Object Manipulation......Page 52
Proper Function Binding......Page 58
Your Functions Actually Know More Tricks......Page 62
Numbers......Page 65
Strings......Page 68
Arrays......Page 76
Full-Spectrum JSON Support......Page 82
The Core Method: Iterating with each......Page 88
Getting General Information About Our Collection......Page 91
Finding Elements and Applying Filters......Page 93
Grouping Elements and Pasting Collections Together......Page 95
Computing a Derived Collection or Value......Page 99
Order Now: Getting Extreme Values and Using Custom Sorts......Page 102
Enumerable Is Actually a Module......Page 104
Event......Page 108
The Events Hall of Fame......Page 125
Reacting to Form-Related Content Changes......Page 127
Extending DOM Elements......Page 130
Element, Your New Best Friend......Page 132
Selector......Page 167
Debugging Our DOM-Related Code......Page 168
Toward a Better User Interface......Page 173
Looking at Form Fields......Page 177
Submitting Forms Through Ajax......Page 178
Keeping an Eye on Forms and Fields......Page 183
Before We Start…......Page 186
Hitting the Road: Ajax.Request......Page 192
Streamlining: Ajax.Updater......Page 208
Polling: Ajax.PeriodicalUpdater......Page 215
Debugging Ajax......Page 219
Ajax Considered Harmful? Thinking About Accessibility and Ergonomy......Page 220
Storing Values in a Hash......Page 225
Expressing Ranges of…Well, Anything You Want!......Page 230
Periodical Execution Without Risk of Reentrance......Page 231
Templating Made Easy......Page 233
Examining the Current Browser and Prototype Library......Page 236
Element Extension and the $ Function......Page 241
Iterations vs. Regular Loops......Page 242
Recent Speed Boosts You Should Know About......Page 243
Small Is Beautiful......Page 244
Building a Fancy Task List......Page 245
Laying the Groundwork......Page 246
It Takes Only 40 Lines: The JavaScript Code......Page 248
script.aculo.us......Page 252
The Modules of script.aculo.us......Page 253
Using script.aculo.us in Your Pages......Page 255
What Are Those Effects, and Why Should We Use Them?......Page 257
Core Effects......Page 259
Diving into Effects......Page 265
Combined Effects......Page 269
Unlocking the Cool Factor: Effect Queues......Page 272
Effect Helpers......Page 274
How to Create Our Own Effects......Page 276
Dragging Stuff Around......Page 283
Controlling How It Starts, Where It Goes, & How It Ends......Page 289
Ghosting......Page 297
Dragging and Scrolling......Page 298
Dropping Stuff......Page 301
Customizing Drop Behavior......Page 302
Sorting with Drag and Drop......Page 307
Common Pitfalls......Page 319
The Basics......Page 323
Local Autocompletion......Page 325
Getting Ajaxy......Page 330
Using Rich-Markup Choices......Page 334
Autocompleting Multiple Values in One Field......Page 335
Reacting to Completion with Callbacks......Page 339
Building DOM Fragments the Easy Way: Builder......Page 343
Building Explicitly......Page 344
Using an (X)HTML Representation......Page 347
What's In-Place Editing Exactly?......Page 349
A Simple Example......Page 352
How Can We Tweak the Ajax Persistence?......Page 354
Customizing the Appearance......Page 355
Dealing with Multiple Lines......Page 363
Editing Alternative Text......Page 364
Disabling In-Place Editing......Page 367
Offering a List of Values Instead of Text Typing......Page 368
Sliders......Page 373
Creating a Simple Slider......Page 374
Customizing the Basics......Page 376
Restricting Range or Allowed Values......Page 378
Defining Multiple Values......Page 381
Where Does It Work?......Page 386
Playing Multiple Sounds on Multiple Tracks......Page 387
Building Over: Classes, Inheritance, and DOM Extension......Page 391
Contributing!......Page 398
Useful Blogs by Prototype Core Members......Page 411
JavaScript Masters......Page 412
Bibliography......Page 413
Installing and Using Ruby......Page 414
On Linux......Page 415
Running a Ruby Script......Page 416
``But I Don't Know a Thing About Ruby!''......Page 417
A......Page 418
C......Page 419
D......Page 420
E......Page 421
G......Page 422
J......Page 423
M......Page 424
P......Page 425
R......Page 426
S......Page 427
U......Page 429
W......Page 430
Z......Page 431