Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 431 trang
THÔNG TIN TÀI LIỆU
Cấu trúc
Contents
Preface
Introduction
It's About Time
What's in This Book, and How Is It Organized?
Acknowledgments
Prototype
Discovering Prototype
What Is Prototype, and What Is It Not?
Using Prototype in Our Project
What Does Our JavaScript Look Like When Using Prototype?
Prototype Jargon and Concepts
What Are Prototypes Anyway?
Running Prototype Code Samples in This Book
Quick Help with the Dollars
Shortcuts Should Be Short
Quick Fetching of Smart Elements with $
$w, Because Array Literals Are Boring
$$ Searches with Style
$A, the Collection Unifier
$F Is a Field Expert
$H Makes a Hash of Things
Handling Ranges with $R
Regular JavaScript on Steroids
Generic Object Manipulation
Proper Function Binding
Your Functions Actually Know More Tricks
Numbers
Strings
Arrays
Full-Spectrum JSON Support
Advanced Collections with Enumerable
The Core Method: Iterating with each
Getting General Information About Our Collection
Finding Elements and Applying Filters
Grouping Elements and Pasting Collections Together
Computing a Derived Collection or Value
Order Now: Getting Extreme Values and Using Custom Sorts
Turning Our Collection into an Array or Debugging String
Enumerable Is Actually a Module
Unified Event Handling
Event
The Events Hall of Fame
Reacting to Form-Related Content Changes
Playing with the DOM Is Finally Fun!
Extending DOM Elements
Element, Your New Best Friend
Selector
Debugging Our DOM-Related Code
Form Management
Toward a Better User Interface
Looking at Form Fields
Submitting Forms Through Ajax
Keeping an Eye on Forms and Fields
Ajax Has Never Been So Easy
Before We Start…
Hitting the Road: Ajax.Request
Streamlining: Ajax.Updater
Polling: Ajax.PeriodicalUpdater
Monitoring Ajax Activity: Ajax.Responders
Debugging Ajax
Ajax Considered Harmful? Thinking About Accessibility and Ergonomy
More Useful Helper Objects
Storing Values in a Hash
Expressing Ranges of…Well, Anything You Want!
Periodical Execution Without Risk of Reentrance
Templating Made Easy
Examining the Current Browser and Prototype Library
Performance Considerations
Element Extension and the $ Function
Iterations vs. Regular Loops
Obsolete Event Handlers
Recent Speed Boosts You Should Know About
Small Is Beautiful
Wrapping Up
Building a Fancy Task List
Laying the Groundwork
It Takes Only 40 Lines: The JavaScript Code
script.aculo.us
Discovering script.aculo.us
The Modules of script.aculo.us
Using script.aculo.us in Your Pages
Visual Effects
What Are Those Effects, and Why Should We Use Them?
Core Effects
Diving into Effects
Combined Effects
Unlocking the Cool Factor: Effect Queues
Effect Helpers
How to Create Our Own Effects
Drag and Drop
Dragging Stuff Around
Controlling How It Starts, Where It Goes, & How It Ends
Ghosting
Dragging and Scrolling
Monitoring Drags
Dropping Stuff
Customizing Drop Behavior
Sorting with Drag and Drop
Common Pitfalls
Autocompletion
The Basics
Local Autocompletion
Getting Ajaxy
Using Rich-Markup Choices
Autocompleting Multiple Values in One Field
Reacting to Completion with Callbacks
Building DOM Fragments the Easy Way: Builder
Building Explicitly
Using an (X)HTML Representation
In-Place Editing
What's In-Place Editing Exactly?
A Simple Example
How Can We Tweak the Ajax Persistence?
Customizing the Appearance
Dealing with Multiple Lines
Editing Alternative Text
Disabling In-Place Editing
Offering a List of Values Instead of Text Typing
Sliders
Creating a Simple Slider
Customizing the Basics
Restricting Range or Allowed Values
Tweaking an Existing Slider and Adding Controls
Defining Multiple Values
Sound Without Flash
Where Does It Work?
How Do We Play Sounds?
Playing Multiple Sounds on Multiple Tracks
Extending and Contributing
Building Over: Classes, Inheritance, and DOM Extension
Contributing!
Further Reading
Official Websites
Useful Blogs by Prototype Core Members
JavaScript Masters
Community and New Sites Around Ajax
ECMAScript Intimacy
Bibliography
Installing and Using Ruby
On Windows
On Linux
On Mac OS X
Running a Ruby Script
``But I Don't Know a Thing About Ruby!''
Index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Nội dung
[...]... the Prototype Core team, consisting of Seth Dillingham, Andrew Dupont, Mislav Marohni´ , Justin Palmer, Christophe Porteneuve, Tobie c Langel, Scott Raymond, and Dan Webb; the thousands of hours of work by hundreds of contributors from the Prototype and script.aculo.us community; and, of course, Christophe, for providing this very book Big thanks to all of them and to you Sam Stephenson (Creator of Prototype) ... (Prototype Core), Tom Gregory (a prominent voice on the official mailing list), Sébastien Gruhier (of Prototype Window Class fame), Amir Jaballah, Tobie Langel (Prototype Core), Justin Palmer (again), and Sunny Ripert Many readers also got onto the bandwagon at the beta stage and went so far as to report a number of typos, errata, and the like Among those, I’m especially grateful to Steve Erbach, Brandon... late evenings and afternoons I spent writing at my desk, pushing me ahead, and giving me strength and love at all turns I could not dream of more This book is for her 19 Part I Prototype Furious activity is no substitute for understanding H H Williams Chapter 2 Discovering Prototype This part provides in-depth coverage of Prototype, which is the JavaScript library at the core of this book Prototype is... standard algorithms, I/O systems, or what have you It stands in this middle ground between down -and- dirty manual coding of everything and full-fledged frameworks with their countless objects Most massive frameworks do indeed use Prototype internally and build upon it U SING P ROTOTYPE IN O UR P ROJECT Note, however, that there is a more visual-oriented library working closely with Prototype called script.aculo.us; ... src=" /prototype. js" > Where Can We Get Prototype? The official website is the authoritative source for the latest public version of Prototypeand also provides detailed, up-to-date API documentation with plenty of examples, tutorial-style articles, and a blog updated by the Prototype Core team It’s located at http://prototypejs.org 2.3 What Does Our JavaScript Look Like When Using Prototype? ... 3 http://groups.google.com/group/rubyonrails-spinoffs http://prototypejs.org 16 W HAT ’ S IN T HIS B OOK , AND H OW I S I T O RGANIZED ? • Like many people, you may just like having the physical copy of the book close at hand It just is nicer to the eye than on-screen text, you know? I discovered Prototype and script.aculo.us in late 2005 and dived into them for real around June 2006 (since my early... language whose design has heavily influenced our libraries: Prototype and script.aculo.us are “a web programmer’s best friends.” According to the feedback we’ve received, we’re not the only ones who feel that way Two -and- a-half years after the initial release, Prototype and script.aculo.us are in use on many of the web’s most popular websites and power all sorts of innovative web applications This rapid popular... short section of code in Prototype that implemented the now-ubiquitous “yellow fade technique.” With a desire to make web applications more user-friendly and provide eye candy that’s really useful to boot—it quickly grew into a complete real-time DOM-based effects engine, drag -and- drop framework, and controls library Version 1.0 was released in June 2005 You should understand that script.aculo.us is distinct... objects, and nifty tools, arranged in a reasonably consistent set But before we go ahead, we need to answer a few questions and tackle the more involved subjects with a clear mind and proper expectations For example, what’s Prototype exactly? What should we expect it to do for us? What kind of lingo may we need to learn? And apparently it relies on well, prototypes, so what are JavaScript prototypes... official web sites and are actually backend-agnostic: you can use them over PHP, NET, J2EE, Python, Delphi, or anything else that helps you produce dynamic web pages And indeed, thousands of developers do just that every day Also, script.aculo.us relies on Prototype, and both libraries are written in a consistent style These libraries will, quite simply, rock your world You will discover, as I and countless . JavaScript Code . . . . . . . 248 II script. aculo. us 252 13 Discovering script. aculo. us 253 13.1 The Modules of script. aculo. us . . . . . . . . . . . . . . . 253 13.2 Using script. aculo. us in.