Cover image for JavaScript Web Applications

Book description

Building rich JavaScript applications that bring the desktop experience to the Web is now possible, thanks to powerful JavaScript engines and the CSS3 and HTML5 specifications. The key is moving state to the client side, but that’s no simple task. This book takes you through all the steps necessary to create state-of-the-art JavaScript applications, including structure, templating, frameworks, and communicating with the server.

Table of Contents

  1. JavaScript Web Applications
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. Preface
      1. Who Is This Book For?
      2. How This Book Is Organized
      3. Conventions Used in This Book
      4. Accompanying Files
      5. Code Conventions
        1. jQuery Examples
      6. Holla
      7. Author’s Note
      8. Safari® Books Online
      9. How to Contact Us
    3. 1. MVC and Classes
      1. Early Days
      2. Adding Structure
      3. What Is MVC?
        1. The Model
        2. The View
        3. The Controller
      4. Toward Modularity, Creating Classes
      5. Adding Functions to Classes
      6. Adding Methods to Our Class Library
      7. Class Inheritance Using Prototype
      8. Adding Inheritance to Our Class Library
      9. Function Invocation
      10. Controlling Scope in Our Class Library
      11. Adding Private Functions
      12. Class Libraries
    4. 2. Events and Observing
      1. Listening to Events
      2. Event Ordering
      3. Canceling Events
      4. The Event Object
      5. Event Libraries
      6. Context Change
      7. Delegating Events
      8. Custom Events
      9. Custom Events and jQuery Plug-Ins
      10. Non-DOM Events
    5. 3. Models and Data
      1. MVC and Namespacing
      2. Building an ORM
        1. Prototypal Inheritance
        2. Adding ORM Properties
        3. Persisting Records
      3. Adding ID Support
      4. Addressing References
      5. Loading in Data
        1. Including Data Inline
        2. Loading Data with Ajax
        3. JSONP
        4. Security with Cross-Domain Requests
      6. Populating Our ORM
      7. Storing Data Locally
      8. Adding Local Storage to Our ORM
      9. Submitting New Records to the Server
    6. 4. Controllers and State
      1. Module Pattern
        1. Global Import
        2. Global Export
      2. Adding a Bit of Context
        1. Abstracting into a Library
        2. Loading Controllers After the Document
        3. Accessing Views
        4. Delegating Events
      3. State Machines
      4. Routing
        1. Using the URL’s Hash
        2. Detecting Hash Changes
        3. Ajax Crawling
        4. Using the HTML5 History API
    7. 5. Views and Templating
      1. Dynamically Rendering Views
      2. Templates
        1. Template Helpers
        2. Template Storage
      3. Binding
        1. Binding Up Models
    8. 6. Dependency Management
      1. CommonJS
        1. Declaring a Module
        2. Modules and the Browser
      2. Module Loaders
        1. Yabble
        2. RequireJS
      3. Wrapping Up Modules
      4. Module Alternatives
        1. LABjs
      5. FUBCs
    9. 7. Working with Files
      1. Browser Support
      2. Getting Information About Files
      3. File Inputs
      4. Drag and Drop
        1. Dragging
        2. Dropping
        3. Cancel Default Drag/Drop
      5. Copy and Paste
        1. Copying
        2. Pasting
      6. Reading Files
        1. Blobs and Slices
      7. Custom Browse Buttons
      8. Uploading Files
        1. Ajax Progress
      9. jQuery Drag and Drop Uploader
        1. Creating a Drop Area
        2. Uploading the File
    10. 8. The Real-Time Web
      1. Real Time’s History
      2. WebSockets
        1. Node.js and Socket.IO
      3. Real-Time Architecture
      4. Perceived Speed
    11. 9. Testing and Debugging
      1. Unit Testing
        1. Assertions
        2. QUnit
        3. Jasmine
      2. Drivers
      3. Headless Testing
        1. Zombie
        2. Ichabod
      4. Distributed Testing
      5. Providing Support
      6. Inspectors
        1. Web Inspector
        2. Firebug
      7. The Console
        1. Console Helpers
      8. Using the Debugger
      9. Analyzing Network Requests
      10. Profile and Timing
    12. 10. Deploying
      1. Performance
      2. Caching
      3. Minification
      4. Gzip Compression
      5. Using a CDN
      6. Auditors
      7. Resources
    13. 11. The Spine Library
      1. Setup
      2. Classes
        1. Instantiation
        2. Extending Classes
        3. Context
      3. Events
      4. Models
        1. Fetching Records
        2. Model Events
        3. Validation
        4. Persistence
      5. Controllers
        1. Proxying
        2. Elements
        3. Delegating Events
        4. Controller Events
        5. Global Events
        6. The Render Pattern
        7. The Element Pattern
      6. Building a Contacts Manager
        1. Contact Model
        2. Sidebar Controller
        3. Contacts Controller
        4. App Controller
    14. 12. The Backbone Library
      1. Models
        1. Models and Attributes
      2. Collections
        1. Controlling a Collection’s Order
      3. Views
        1. Rendering Views
        2. Delegating Events
        3. Binding and Context
      4. Controllers
      5. Syncing with the Server
        1. Populating Collections
        2. On the Server Side
        3. Custom Behavior
      6. Building a To-Do List
    15. 13. The JavascriptMVC Library
      1. Setup
      2. Classes
        1. Instantiation
        2. Calling Base Methods
        3. Proxies
        4. Static Inheritance
        5. Introspection
        6. A Model Example
      3. Model
        1. Attributes and Observables
        2. Extending Models
        3. Setters
        4. Defaults
        5. Helper Methods
        6. Service Encapsulation
          1. Create a task
          2. Get a task
          3. Get tasks
          4. Update a task
          5. Destroy a task
        7. Type Conversion
        8. CRUD Events
      4. Using Client-Side Templates in the View
        1. Basic Use
        2. jQuery Modifiers
        3. Loading from a Script Tag
        4. $.View and Subtemplates
        5. Deferreds
        6. Packaging, Preloading, and Performance
      5. $.Controller: The jQuery Plug-in Factory
        1. Overview
        2. Controller Instantiation
        3. Event Binding
        4. Templated Actions
      6. Putting It All Together: An Abstract CRUD List
    16. A. jQuery Primer
      1. DOM Traversal
      2. DOM Manipulation
      3. Events
      4. Ajax
      5. Being a Good Citizen
      6. Extensions
      7. Creating a Growl jQuery Plug-in
    17. B. CSS Extensions
      1. Variables
      2. Mixins
      3. Nested Rules
      4. Including Other Stylesheets
      5. Colors
      6. How Do I Use Less?
        1. Via the Command Line
        2. Via Rack
        3. Via JavaScript
        4. Less.app
    18. C. CSS3 Reference
      1. Prefixes
      2. Colors
      3. Rounded Corners
      4. Drop Shadows
      5. Text Shadow
      6. Gradients
      7. Multiple Backgrounds
      8. Selectors
        1. Nth Child
        2. Direct Descendants
        3. Selector Negation
      9. Transitions
      10. Border Images
      11. Box Sizing
      12. Transformations
      13. Flexible Box Model
      14. Fonts
      15. Graceful Degradation
        1. Modernizr
        2. Google Chrome Frame
      16. Creating a Layout
    19. Index
    20. About the Author
    21. Colophon
    22. SPECIAL OFFER: Upgrade this ebook with O’Reilly