Javascript and Mootools Classes, and the Mootools Class Internals
Total Page:16
File Type:pdf, Size:1020Kb
BOOKS FOR PROFESSIONALS BY PROFESSIONALS® THE EXPERT’S VOICE® IN WEB DEVELOPMENT Companion eBook Available Written for Pro JavaScript with MooTools MooTools 1.3 Pro JavaScript with MooTools is unlike any other JavaScript book on the mar- Pro JavaScript JavaScript 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 Pro Mark Joseph Obcena 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. JavaScript The final section really sets the book apart from all others, as it discusses with 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. MooTools with THE APRESS ROADMAP MooTools MooTools Pro JavaScript Learning Advanced JavaScript Programming Essentials with MooTools Beginning JavaScript with DOM Scripting Practical Prototype Pro and script.aculo.us JavaScript Design Patterns Companion eBook Extending the Power of JavaScript Beyond the Browser by Using MooTools Obcena SOURCE CODE ONLINE www.apress.com Mark Joseph Obcena Foreword by Valerio Proietti, MooTools Founder and Lead Developer US $44.99 Shelve in: Web Development / JavaScript User level: Intermediate–Advanced Pro JavaScript with MooTools Learning Advanced JavaScript Programming ■ ■ ■ Mark Joseph Obcena i 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 [email protected], or visit www.springeronline.com. For information on translations, please e-mail [email protected], 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. ii To the one who owns my heart. iii 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 Downloaded from http://www.pookebook.com ■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 iv 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