Pro JavaScript with MooTools: Learning Advanced JavaScript Programming

Book description

Pro JavaScript with MooTools is unlike any other JavaScript book on the market today. While similar books focus on either JavaScript as a language of the browser or how to use JavaScript Frameworks, Pro JavaScript with MooTools fills the gap between these topics and moves beyond—exploring the advanced features of JavaScript and how the MooTools framework uses these features to further improve the language itself.

The book itself takes a unique three-pronged approach. It first walks you through the advanced features of JavaScript and the MooTools framework, including native augmentation and type creation, a comprehensive discussion of JavaScript functions, Object-Oriented programming with native JavaScript and MooTools Classes, and the MooTools Class internals. You'll then learn all about Javascript in the DOM: the Elements classes and its internals, the MooTools Event system, Selector engines and MooTools Slick, Ajax and the Request Object, and Animation and the Fx classes.

The final section really sets the book apart from all others, as it discusses JavaScript outside the browsers. You'll take an in-depth look at CommonJS and MooTools, using MooTools outside the browser to build ORM, creating simple CommonJS applications via the MooTools Deck framework, and creating complex Server-Side applications using Raccoon.

Table of contents

  1. Copyright
  2. Foreword
  3. About the Author
  4. About the Technical Reviewer
  5. Acknowledgments
  6. Preface
  7. I. Exploring JavaScript and MooTools
    1. 1. JavaScript and MooTools
      1. 1.1. JavaScript
      2. 1.2. MooTools
      3. 1.3. The Language Extension
      4. 1.4. Your Toolkit
        1. 1.4.1. JavaScript Interpreter
        2. 1.4.2. JavaScript Console
        3. 1.4.3. MooTools Core and the Snippet Runner
        4. 1.4.4. Code Editor and JSLint
      5. 1.5. The Wrap Up
    2. 2. Functions
      1. 2.1. The Function
      2. 2.2. One Function, Multiple Forms
        1. 2.2.1. Function Declaration
        2. 2.2.2. Function Expression
        3. 2.2.3. Named Function Expression
      3. 2.3. Single-Execution Function
        1. 2.3.1. Function Object
      4. 2.4. Arguments
      5. 2.5. Return Values
      6. 2.6. Function Internals
        1. 2.6.1. Executable Code and Execution Contexts
        2. 2.6.2. Variables and Variable Instantiation
        3. 2.6.3. Scoping and the Scope Chain
        4. 2.6.4. Closures
        5. 2.6.5. The "this" Keyword
      7. 2.7. Advanced Function Techniques
        1. 2.7.1. Limiting Scope
        2. 2.7.2. Currying
        3. 2.7.3. Decoration
        4. 2.7.4. Combination
      8. 2.8. MooTools and Functions
        1. 2.8.1. Function Binding
        2. 2.8.2. Extending Functions with Methods
      9. 2.9. The Wrap Up
    3. 3. Objects
      1. 3.1. JavaScript is Prototypal(-ish)
      2. 3.2. A Language of Objects
      3. 3.3. The Building Blocks of Objects
        1. 3.3.1. Constructor Functions
        2. 3.3.2. Prototypes
      4. 3.4. Inheritance
      5. 3.5. The Prototype Chain
        1. 3.5.1. Deliberate Chains
      6. 3.6. Simplified Prototypal Programming
      7. 3.7. The Wrap Up
    4. 4. Classes
      1. 4.1. From Prototypes to Classes
      2. 4.2. The MooTools Class System
      3. 4.3. Constructors and Initializers
      4. 4.4. Rethinking Members
        1. 4.4.1. Rethinking Methods
        2. 4.4.2. Rethinking Properties
      5. 4.5. Inheritance
        1. 4.5.1. Overridden Methods
        2. 4.5.2. Inside this.parent()
      6. 4.6. Mixins
      7. 4.7. The Wrap Up
    5. 5. Classes: The Extras
      1. 5.1. Mutators
        1. 5.1.1. Implementing Your Own Mutators
        2. 5.1.2. Mutator Gotchas
      2. 5.2. The Built-in Mixins
        1. 5.2.1. The Chain Mixin
        2. 5.2.2. The Events Mixin
        3. 5.2.3. The Options Mixin
      3. 5.3. Static Members
      4. 5.4. Encapsulation and Visibility
        1. 5.4.1. Private Methods
        2. 5.4.2. Protected Methods
      5. 5.5. MooTools and Classes
      6. 5.6. The Wrap-Up
    6. 6. Types
      1. 6.1. Values and Type Systems
      2. 6.2. An Alternative Type System
      3. 6.3. Native Types and Values
        1. 6.3.1. Null and Undefined
        2. 6.3.2. Primitive Types
          1. 6.3.2.1. Booleans
          2. 6.3.2.2. Numbers
          3. 6.3.2.3. String
          4. 6.3.2.4. Primitives as Objects
        3. 6.3.3. Composite Types
          1. 6.3.3.1. Object-to-Primitive Casting
          2. 6.3.3.2. The Base Object
          3. 6.3.3.3. Functions
          4. 6.3.3.4. Arrays
          5. 6.3.3.5. Regular Expressions
          6. 6.3.3.6. Dates
          7. 6.3.3.7. Error Objects
      4. 6.4. Type Casting
        1. 6.4.1. Casting Using Constructors
        2. 6.4.2. Casting Using Native Functions and Idioms
      5. 6.5. The MooTools Type System
        1. 6.5.1. The Type Constructor and Function Subclassing
        2. 6.5.2. Instance Checking
        3. 6.5.3. Type Detection
      6. 6.6. Working with Type Objects
        1. 6.6.1. Implementing New Members
        2. 6.6.2. Aliases and Mirroring
        3. 6.6.3. The extend Method and Generics
      7. 6.7. Creating New Types
        1. 6.7.1. A Table Type
        2. 6.7.2. The Table Constructor
        3. 6.7.3. Setter, Getter, and Removal
        4. 6.7.4. Membership Methods
        5. 6.7.5. Keys, Values and Traversals
        6. 6.7.6. Our Final Type
      8. 6.8. The Wrap-Up
  8. II. Conquering the Client Side
    1. 7. JavaScript in a Window
      1. 7.1. A Language for Every Computer
      2. 7.2. Life Cycle of a Page
      3. 7.3. Pause, Script
      4. 7.4. The Scripted Browser
        1. 7.4.1. The Document Object Model
        2. 7.4.2. The Browser Object Model
          1. 7.4.2.1. The navigator Object
          2. 7.4.2.2. The location Object
          3. 7.4.2.3. The history Object
      5. 7.5. Frameworks, Libraries, and Toolkits
      6. 7.6. MooTools and the Browser
        1. 7.6.1. Fixing Browsers with MooTools
        2. 7.6.2. Browser Detection
        3. 7.6.3. Feature Detection
      7. 7.7. The Wrap-Up
    2. 8. Elements
      1. 8.1. Families and Trees
      2. 8.2. Is My DOM Ready Yet?
      3. 8.3. DOM Scripting with MooTools
        1. 8.3.1. Selecting Elements
          1. 8.3.1.1. The ID Selector
          2. 8.3.1.2. CSS-Based Selectors
          3. 8.3.1.3. Relation-Based Selectors
        2. 8.3.2. An Elemental Segue
        3. 8.3.3. Moving Elements Around
          1. 8.3.3.1. inject
          2. 8.3.3.2. replaces
          3. 8.3.3.3. wraps
          4. 8.3.3.4. grab
        4. 8.3.4. Modifying Element Objects
          1. 8.3.4.1. Working with Attributes
          2. 8.3.4.2. Working with Styles
          3. 8.3.4.3. Get, Set, and Erase
        5. 8.3.5. Creating Elements
        6. 8.3.6. Destroying Elements
      4. 8.4. The Element Type
        1. 8.4.1. Revisiting document.id
        2. 8.4.2. Extending Element
      5. 8.5. The Elements Type
      6. 8.6. The Universal Modificators
      7. 8.7. Element Storage
      8. 8.8. The Wrap Up
    3. 9. Selector Engines
      1. 9.1. What Node?
      2. 9.2. Selecting in Style
        1. 9.2.1. Selector Engines
        2. 9.2.2. A Whirlwind Tour of CSS Selector Notation
          1. 9.2.2.1. Simple Selectors
          2. 9.2.2.2. Pseudo-Selectors
          3. 9.2.2.3. Combined Selectors
          4. 9.2.2.4. Selector Grouping
      3. 9.3. Slick: the MooTools Selector Engine
        1. 9.3.1. Selecting Elements with Slick
        2. 9.3.2. Combinator Prefixes
        3. 9.3.3. Reverse Combinators
        4. 9.3.4. Pseudo-Selector Functions
      4. 9.4. Inside Slick
        1. 9.4.1. The Slick Parser Engine
        2. 9.4.2. The Slick Selection Engine
      5. 9.5. The Wrap-Up
    4. 10. Events
      1. 10.1. A Loopy World
      2. 10.2. The Event Loop
      3. 10.3. Event-Based Programming
      4. 10.4. The Event Models
        1. 10.4.1. The Internet Explorer Model
          1. 10.4.1.1. Attaching Event Handlers
          2. 10.4.1.2. The Global Event Object
          3. 10.4.1.3. Cancelling Default Actions
          4. 10.4.1.4. Event Propagation
          5. 10.4.1.5. Detaching Event Handlers
          6. 10.4.1.6. Dispatching Events
        2. 10.4.2. The DOM Level 2 Model
          1. 10.4.2.1. Attaching Events
          2. 10.4.2.2. Event Objects
          3. 10.4.2.3. The Current Target
          4. 10.4.2.4. Three Phases of Event Propagation
          5. 10.4.2.5. Stopping Event Propagation
          6. 10.4.2.6. Preventing Default Action
          7. 10.4.2.7. Event Flavors
          8. 10.4.2.8. Detaching Event Handlers
          9. 10.4.2.9. Dispatching Events
      5. 10.5. The MooTools Event System
        1. 10.5.1. Attaching Event Handlers
        2. 10.5.2. Preventing Default Action
        3. 10.5.3. Stopping Event Propagation
        4. 10.5.4. Stopping Events All Together
        5. 10.5.5. Detaching Event Handlers
        6. 10.5.6. Dispatching Events
      6. 10.6. Event System Internals
        1. 10.6.1. The Event Type
        2. 10.6.2. Two Layers
        3. 10.6.3. The Event Table
        4. 10.6.4. Event Handler Wrapping
        5. 10.6.5. Event Handler Detachment and Dispatch
        6. 10.6.6. Custom Events
      7. 10.7. The Wrap-Up
    5. 11. Request
      1. 11.1. Requests and Responses
      2. 11.2. The XMLHttpRequest Object
      3. 11.3. Going Async
      4. 11.4. The MooTools Request Class
        1. 11.4.1. Creating New Requests
        2. 11.4.2. Adding Request Headers
        3. 11.4.3. Sending Data
        4. 11.4.4. Attaching Event Handlers
          1. 11.4.4.1. The request Event
          2. 11.4.4.2. The complete Event
          3. 11.4.4.3. The isSuccess Function
          4. 11.4.4.4. The success Event
          5. 11.4.4.5. The failure Event
        5. 11.4.5. Timeouts
        6. 11.4.6. Event Handler Declarations
        7. 11.4.7. Sending the Request
        8. 11.4.8. Request Sending Modes
        9. 11.4.9. Our Final Code
      5. 11.5. Subclassing Request
        1. 11.5.1. Request Internals
          1. 11.5.1.1. The send Method
          2. 11.5.1.2. The onStateChange Method
        2. 11.5.2. Success Overriding
      6. 11.6. The Wrap-Up
    6. 12. Animation
      1. 12.1. Getting Animated
      2. 12.2. Being Stylish
        1. 12.2.1. CSS Styles
        2. 12.2.2. Explicit, Implicit, and Computed
        3. 12.2.3. Revisiting Style Methods
      3. 12.3. Time for Some Action
        1. 12.3.1. Timers
        2. 12.3.2. Timer Execution
      4. 12.4. A Basic JavaScript Animation
      5. 12.5. MooTools Fx Classes
        1. 12.5.1. Animation Objects
        2. 12.5.2. Tween and Morph
          1. 12.5.2.1. Fx.Tween
          2. 12.5.2.2. Fx.Morph
        3. 12.5.3. Fx Methods and Events
      6. 12.6. Fx Internals
        1. 12.6.1. The Fx Base Class
          1. 12.6.1.1. Initialization and Class Options
          2. 12.6.1.2. The step Method
          3. 12.6.1.3. Timers
          4. 12.6.1.4. The start Method
        2. 12.6.2. CSS Animation
      7. 12.7. The Wrap-Up
  9. III. Breaking from the Browser
    1. 13. JavaScript without Limits
      1. 13.1. Breaking out of the Browser
      2. 13.2. CommonJS
      3. 13.3. Common Modules
        1. 13.3.1. Export and Require
        2. 13.3.2. Module Paths
      4. 13.4. MooTools and CommonJS
      5. 13.5. Meso: MooTools in the Middle
      6. 13.6. The Wrap-Up
    2. 14. MooTools on Deck
      1. 14.1. Revisiting Request and Response
      2. 14.2. JavaScript on the Server
      3. 14.3. JSGI
        1. 14.3.1. JSGI and CommonJS Engines
          1. 14.3.1.1. Flusspferd
          2. 14.3.1.2. RingoJS
          3. 14.3.1.3. NodeJS
          4. 14.3.1.4. v8cgi
        2. 14.3.2. A Common Deck
      4. 14.4. Enter Deck
        1. 14.4.1. Getting Decked
        2. 14.4.2. Routing
        3. 14.4.3. Middleware using Modules
      5. 14.5. Deck Internals
        1. 14.5.1. Request and Response
        2. 14.5.2. The Filtered Model
        3. 14.5.3. Dispatching
        4. 14.5.4. The Router
      6. 14.6. The Wrap-Up
      7. 14.7. The Wrap-Up to Conquer All Wrap-Ups
  10. A. Resources
    1. A.1. JavaScript
    2. A.2. MooTools

Product information

  • Title: Pro JavaScript with MooTools: Learning Advanced JavaScript Programming
  • Author(s): Mark Joseph Obcena
  • Release date: January 2010
  • Publisher(s): Apress
  • ISBN: 9781430230540