Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Preface

This book is geared towards web developers who have a basic understanding of JavaScript and the related technologies that are involved with it, namely HTML and CSS. If you're familiar with a programming or server-side scripting language, code authoring in MooTools will be very familiar.

The goal of this book is to give you a functional and pragmatic understanding of MooTools and is not intended for learning JavaScript, HTML, CSS, and concepts such as the DOM and unobtrusive JavaScript.

This is the first book specifically designed for absolute newcomers to MooTools. It is a Packt Beginner's Guide, which means it is packed with clear step-by-step instructions for performing the most useful tasks.

MooTools is an open source, lightweight, modular object-oriented programming JavaScript web application framework. The goal of the software is to provide a means for intermediate to advanced web developers to write cross-browser JavaScript in an elegant, flexible, and efficient fashion. The MooTools JavaScript framework includes built-in functions for manipulation of CSS, DOM elements, native JavaScript objects, AJAX requests, and more.

You will start learning by 'doing' immediately. As each chapter in the book progresses, the topics get more complex. First you get to grips with the fundamentals of MooTools including downloading, installation, and basic syntax. Once you've grasped the basics you learn to make the most of MooTools' powerful framework. You will learn to bring web pages to life with animation and create exciting web pages with AJAX. You will also learn to customize MooTools to suit your own needs by creating your own plug-ins. You will soon be well on the way to creating web applications and web pages worthy of the Web 2.0 world

What this book covers

Chapter 1, MooTools and Me shows how to download and install Mootools. It demonstrates how to troubleshoot the most common installation problems. Writing a simple MooTools code block to test that the installation has worked is also explained.

Chapter 2, Writing JavaScript with MooTools demonstrates the difference between normal JavaScript against MooTools code. It explains how MooTools code can be far simpler and more efficient than ordinary JavaScript to achieve the same task.

Chapter 3, Selecting DOM Elements gives an overview of the Document Object Model tree and an in-depth discussion of the $() function in the Element class. It showcases basic DOM relationships such as parents, children, and siblings. It also demonstrates how to select page links and then give them a certain color or style

Chapter 4, The Core's Useful Utility Functions introduces native JavaScript variable definitions. It goes through each function and demonstrates how it works.

Chapter 5, Working with Events explains different browser events such as mouse click, mouse hover, mouse moving and key press. It demonstrates how to build a super-charged web form in MooTools. Events are covered showing how to add event listeners to web page elements.

Chapter 6, Bringing Web Pages to Life Using Animation introduces the different animation options available in MooTools. It demonstrates how to create a featured area slider. It demonstrates the MooTools Fx class and its useful methods for working with MooTools effects.

Chapter 7, Going 2.0 with Ajax shows the basics of Ajax. It demonstrates how MooTools makes working with Ajax easy. It will explain how XML files can be used to simulate a relational database.

Chapter 8, Beefing up MooTools Using the MooTools More Plugins demonstrates how to install and use the plug in system. It will explain how the Accordion area can be used to display content in an engaging and compact manner using the Fx Accordian plugin. It will also cover creating user-friendly forms using the OverText plugin.

Chapter 9, Creating Your Own Plugin will show the benefits of creating your own plugin such as reusability and customization. It will explain the guidelines and standards that should be adhered to for creating a plugin. It will also demonstrate how to build a simple plugin.

What you need for this book

You will need a computer. It can be running any operating system of your preference. To be able to complete the exercises and examples in each chapter, you will need to have a text editor. Operating systems usually come with one, such as Notepad, on Microsoft Windows, or TextEdit, on Mac OS X. To view the results of the exercises and examples, you will need access to a web browser. The web browsers used in this book are free and can be found on the internet.

Below is a list of the web browsers used in this book:

  • Mozilla FireFox

  • Opera

  • Apple Safari

  • Google Chrome

  • Internet Explorer

Who this book is for

This book is perfect for MooTools newcomers. You do not require any familiarity with MooTools whatsoever, only a willingness to learn. Basic knowledge of JavaScript syntax and concepts is the only requirement. This book will allow you to grasp the basics of MooTools so that you will be well on the way to creating exciting, customizable web pages and applications.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We build a function called pageCustomizer that will customize our page."

A block of code will be set as follows:

if(Browser.Engine.trident){
alert('You\'re using Internet Explorer');
} else{
alert('You\'re not using Internet Explorer');
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold:

if(userPlatform!='other' || userPlatform!='ipod' ) {
$$('.download-options').destroy();

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "Click on the #child div ".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/4589_Code.zip to directly download the example code.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.