Book Image

Drupal 6 JavaScript and jQuery

By : Matt Butcher
Book Image

Drupal 6 JavaScript and jQuery

By: Matt Butcher

Overview of this book

<p>JavaScript: It's not just for calculators and image rollovers.<br /><br />Drupal 6 is loaded with new features, and not all of them are necessarily implemented in PHP. This unique book, for web designers and developers, will take you through what can be done with JavaScript (and especially with jQuery) in Drupal 6.<br /><br />With the combination of the powerhouse jQuery library with its own robust set of JavaScript tools, Drupal 6 comes with a pre-packaged killer JavaScript environment. Cross-platform by nature, it provides all of the tools necessary to create powerful AJAX-enabled scripts, gorgeous visual effects, and view-enhancing behaviors. In addition, Drupal developers have ported some of its most powerful PHP tools – like a theming engine and support for localization and language translation – to JavaScript, making it possible to write simple scripts where once only complex PHP code could be used.<br /><br />This book gives you the keys to the toolbox, showing you how to use Drupal's JavaScript libraries to make your modules and themes more dynamic, interactive and responsive, and add effects to make your Drupal site explode into life! <br /><br />If you've dipped your toe in the water of theme or module development with Drupal 6, this is the book you want to make the look and behavior of your work something special. With it's project-based approach, this book is carefully constructed to guide you from how JavaScript fits into the overall Drupal architecture through to making you a master of the jQuery library in the world of Drupal themes and modules.</p>
Table of Contents (14 chapters)
Drupal 6 JavaScript and jQuery
Credits
About the author
About the reviewers
Preface

Project: a simple text editor


In this project we are going to create a simple text editor. We are going to begin with text areas and add a couple of buttons that insert HTML tags for us. In doing this project, we will make use of the jQuery techniques we learned in the previous chapter, as well as behaviors and some of the utility functions we saw earlier in this chapter.

Note

There are already several rich text editors available for Drupal, all of which are more advanced than the simple tool we will create here. The WYSIWYG API module is poised to become the de facto text editor going forward. It can be found at http://drupal.org/project/wysiwyg.

Our editor will have two buttons—a B button to make some text bold, and an I button to add italics. The editor will insert markup into the text so that the tags are visible to the user. For example, if the user types in the string This is bold, highlights the word "bold", and presses the B button, she or he will see the text This is <strong&gt...