1. Trang chủ
  2. » Công Nghệ Thông Tin

pro javascript with mootools

430 425 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 430
Dung lượng 4,12 MB

Nội dung

BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Pro JavaScript with MooTools Pro JavaScript with MooTools is unlike any other JavaScript book on the mar- ket 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 Class 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 browser. You’ll take an in-depth look at CommonJS and MooTools, using MooTools outside the browser using Meso, and creating CommonJS web applications via the MooTools Deck framework. Mark Joseph Obcena US $44.99 Shelve in: Web Development / JavaScript User level: Intermediate–Advanced THE APRESS ROADMAP Pro JavaScript Design Patterns Pro JavaScript with MooTools MooTools Essentials Practical Prototype and script.aculo.us Beginning JavaScript with DOM Scripting www.apress.com SOURCE CODE ONLINE Companion eBook Obcena JavaScript with MooTools Companion eBook Available Pro THE EXPERT’S VOICE ® IN WEB DEVELOPMENT Pro JavaScript with MooTools Learning Advanced JavaScript Programming Mark Joseph Obcena Foreword by Valerio Proietti, MooTools Founder and Lead Developer Extending the Power of JavaScript Beyond the Browser by Using MooTools Written for MooTools 1.3 www.it-ebooks.info www.it-ebooks.info i Pro JavaScript with MooTools Learning Advanced JavaScript Programming ■ ■ ■ Mark Joseph Obcena www.it-ebooks.info ii Pro JavaScript with MooTools: Learning Advanced JavaScript Programming Copyright © 2010 by Mark Joseph A. Obcena All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-3054-0 ISBN-13 (electronic): 978-1-4302-3055-7 Printed and bound in the United States of America (POD) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editors: Frank Pohlmann and Ben Renow-Clarke Technical Reviewer: Simo Kinnunen Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Mary Tobin Copy Editor: Sharon Terdeman Compositor: MacPS, LLC Indexer: Julie Grady Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. www.it-ebooks.info iii To the one who owns my heart. www.it-ebooks.info iv Contents at a Glance ■Contents v ■Foreword xiv ■About the Author xv ■About the Technical Reviewer xvi ■Acknowledgments xvii ■Preface xviii Part I: Exploring JavaScript and MooTools 1 ■Chapter 1: JavaScript and MooTools 3 ■Chapter 2: Functions 11 ■Chapter 3: Objects 47 ■Chapter 4: Classes 71 ■Chapter 5: Classes: The Extras 99 ■Chapter 6: Types 127 Part II: Conquering the Client Side 171 ■Chapter 7: JavaScript in a Window 173 ■Chapter 8: Elements 187 ■Chapter 9: Selector Engines 245 ■Chapter 10: Events 261 ■Chapter 11: Request 307 ■Chapter 12: Animation 339 Part III: Breaking from the Browser 359 ■Chapter 13: JavaScript without Limits 361 ■Chapter 14: MooTools on Deck 371 ■Appendix: Resources 387 ■Index 389 www.it-ebooks.info v Contents ■ Contents at a Glance iv ■Foreword xiv ■About the Author xv ■About the Technical Reviewer xvi ■Acknowledgments xvii ■Preface xviii Part I: Exploring JavaScript and MooTools 1 ■Chapter 1: JavaScript and MooTools 3 JavaScript 3 MooTools 4 The Language Extension 5 Your Toolkit 5 JavaScript Interpreter 6 JavaScript Console 6 MooTools Core and the Snippet Runner 8 Code Editor and JSLint 9 The Wrap Up 10 ■Chapter 2: Functions 11 The Function 11 One Function, Multiple Forms 12 Function Declaration 12 Function Expression 14 Named Function Expression 15 www.it-ebooks.info ■ CONTENTS vi Single-Execution Function 17 Function Object 19 Arguments 20 Return Values 24 Function Internals 25 Executable Code and Execution Contexts 25 Variables and Variable Instantiation 27 Scoping and the Scope Chain 29 Closures 31 The “this” Keyword 33 Advanced Function Techniques 36 Limiting Scope 36 Currying 38 Decoration 39 Combination 41 MooTools and Functions 42 Function Binding 43 Extending Functions with Methods 44 The Wrap Up 46 ■Chapter 3: Objects 47 JavaScript is Prototypal(-ish) 47 A Language of Objects 48 The Building Blocks of Objects 50 Constructor Functions 50 Prototypes 53 Inheritance 56 The Prototype Chain 61 Deliberate Chains 63 Simplified Prototypal Programming 65 www.it-ebooks.info ■ CONTENTS vii The Wrap Up 68 ■Chapter 4: Classes 71 From Prototypes to Classes 71 The MooTools Class System 73 Constructors and Initializers 75 Rethinking Members 77 Rethinking Methods 78 Rethinking Properties 80 Inheritance 83 Overridden Methods 86 Inside this.parent() 90 Mixins 91 The Wrap Up 96 ■Chapter 5: Classes: The Extras 99 Mutators 99 Implementing Your Own Mutators 101 Mutator Gotchas 104 The Built-in Mixins 106 The Chain Mixin 106 The Events Mixin 109 The Options Mixin 112 Static Members 114 Encapsulation and Visibility 118 Private Methods 120 Protected Methods 121 MooTools and Classes 125 The Wrap-Up 126 ■Chapter 6: Types 127 Values and Type Systems 127 www.it-ebooks.info ■ CONTENTS viii An Alternative Type System 129 Native Types and Values 131 Null and Undefined 131 Primitive Types 132 Composite Types 135 Type Casting 143 Casting Using Constructors 144 Casting Using Native Functions and Idioms 145 The MooTools Type System 147 The Type Constructor and Function Subclassing 147 Instance Checking 148 Type Detection 151 Working with Type Objects 152 Implementing New Members 153 Aliases and Mirroring 155 The extend Method and Generics 158 Creating New Types 160 A Table Type 160 The Table Constructor 162 Setter, Getter, and Removal 163 Membership Methods 164 Keys, Values and Traversals 165 Our Final Type 167 The Wrap-Up 168 Part II: Conquering the Client Side 171 ■Chapter 7: JavaScript in a Window 173 A Language for Every Computer 173 Life Cycle of a Page 174 Pause, Script 175 www.it-ebooks.info [...]... address this particular issue for the MooTools framework MooTools is in the unique position of being one of the more popular frameworks that extend and improve JavaScript rather than bury it in the guise of an API MooTools works with native JavaScript, uses native JavaScript, and feels like native JavaScript MooTools users, therefore, are exposed to the power of JavaScript at every level—all they have... cast: JavaScript and MooTools xix www.it-ebooks.info ■ CONTENTS xx www.it-ebooks.info PART I Exploring JavaScript and MooTools www.it-ebooks.info 2 www.it-ebooks.info CHAPTER 1 ■■■ JavaScript and MooTools Before we begin our exploration of how to get the most out of JavaScript using the powerful MooTools framework, let’s focus a little on JavaScript and MooTools individually We’ll also talk about the JavaScript. .. refer to MooTools, they call it a JavaScript library or a JavaScript framework Though these descriptions aren’t necessarily wrong, they don’t encapsulate the main idea behind MooTools which is to leverage and improve the JavaScript language itself Therefore, I prefer to call MooTools something else: a language extension Developers using MooTools are expected to be JavaScript programmers first, MooTools. .. writing awesome JavaScript and MooTools material for years, in articles (like his “Up the Moo herd” series) and in actual code (Raccoon!) His blog is a mustread for anyone wanting to learn or expand his knowledge of MooTools, or JavaScript in general Pro JavaScript with MooTools isn’t simply a well-written technical book This book thoroughly explains how object-oriented programming works in JavaScript, ... computer, and some you can easily download for free So without further ado, here are the components of a JavaScript developer’s toolkit 5 www.it-ebooks.info CHAPTER 1 ■ JAVASCRIPT AND MOOTOOLS JavaScript Interpreter A JavaScript interpreter (or engine) is a program that parses and executes JavaScript programs You’ll need an interpreter that implements at least JavaScript version 1.5, which is equivalent to... the MooTools community could share their code And with the release of version 1.3, MooTools has once again reinvented itself with a simpler Type system, an improved Class implementation and a fast new selector engine From its 3 KB beginnings as an effects library, MooTools has grown into one of the best and most powerful JavaScript frameworks around The Language Extension MooTools complements JavaScript. .. really at times Fortunately, that’s where this book comes in Pro JavaScript with MooTools will take you on a journey from the building blocks of JavaScript, through the prototypal concepts, to the very inner workings of MooTools By the time you’re finished reading it, MooTools will hold no more secrets from you When I think about the best MooTools articles I have ever read on the Web, Mark’s blog, Keetology,... second In the MooTools community, a lot of emphasis is given to learning how to properly write JavaScript, and everyone is expected to know at least the basics of programming This is because MooTools itself is so intertwined with JavaScript that learning the framework without having a basic grasp of the language would be impossible What’s often surprising for new users is just how much MooTools feels... native counterpart for working with web documents MooTools makes the process of working with JavaScript easier on so many levels and it inspires developers to add more features to the language In the chapters that follow you’ll see just how much MooTools complements the language While this is primarily a JavaScript book, MooTools is used as an exemplar of what’s possible with the language, and how you—using... their quirkiness This book is about JavaScript as it relates to the MooTools framework Like any other language, JavaScript s predictability has a lot to do with the people who code with it While it is pretty predictable, JavaScript does have some quirks and unique features that might not be apparent at base level Unfortunately, a lot of us who proudly proclaim to be JavaScript developers don’t take time . FOR PROFESSIONALS BY PROFESSIONALS ® Pro JavaScript with MooTools Pro JavaScript with MooTools is unlike any other JavaScript book on the mar- ket today. While similar books focus on either JavaScript. in: Web Development / JavaScript User level: Intermediate–Advanced THE APRESS ROADMAP Pro JavaScript Design Patterns Pro JavaScript with MooTools MooTools Essentials Practical Prototype and script.aculo.us. Exploring JavaScript and MooTools 1 ■Chapter 1: JavaScript and MooTools 3 JavaScript 3 MooTools 4 The Language Extension 5 Your Toolkit 5 JavaScript Interpreter 6 JavaScript Console 6 MooTools

Ngày đăng: 24/04/2014, 15:47