Drupal 6 JavaScript and jQuery 1st Edition Matt Butcher instant download
Drupal 6 JavaScript and jQuery 1st Edition Matt Butcher instant download
https://ebookfinal.com/download/drupal-6-javascript-and-
jquery-1st-edition-matt-butcher/
https://ebookfinal.com/download/drupal-7-module-development-1st-
edition-matt-butcher/
https://ebookfinal.com/download/drupal-6-performance-tips-1st-edition-
james/
https://ebookfinal.com/download/javascript-jquery-the-missing-manual-
second-edition-david-sawyer-mcfarland/
Learning jQuery Better Interaction Design and Web
Development with Simple Javascript Techniques 1st Ed.
Edition Jonathan Chaffer
https://ebookfinal.com/download/learning-jquery-better-interaction-
design-and-web-development-with-simple-javascript-techniques-1st-ed-
edition-jonathan-chaffer/
https://ebookfinal.com/download/learning-php-mysql-javascript-with-
jquery-css-html5-early-release-5th-5th-edition-robin-nixon/
https://ebookfinal.com/download/design-and-prototyping-for-drupal-
drupal-for-designers-1st-edition-nordin/
Drupal 6 JavaScript and jQuery 1st Edition Matt
Butcher Digital Instant Download
Author(s): Matt Butcher
ISBN(s): 9781847196163, 1847196160
Edition: 1
File Details: PDF, 3.51 MB
Year: 2009
Language: english
Drupal 6 JavaScript and jQuery
Matt Butcher
BIRMINGHAM - MUMBAI
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Drupal 6 JavaScript and jQuery
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the author, Packt Publishing,
nor its dealers or distributors will be held liable for any damages caused or alleged
to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-847196-16-3
www.packtpub.com
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Credits
Reviewers
Editorial Team Leader
Dave Myburgh
Akshara Aware
Paul Lovvik
Project Coordinator
Development Editor
Leena Purkait
Swapna V. Verlekar
Proofreader
Technical Editor
Joel T. Johnson
Amey Kanse
Production Coordinator
Copy Editor
Rajni R. Thorat
Sneha Kulkarni
Cover Work
Indexer
Rajni R. Thorat
Hemangini Bari
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
About the author
Thanks to Gábor Hojtsy and Ariel Hitron for helping with the
sections on the JavaScript translation system. Greg Knaddison
and a few others organized DrupalCamp Colorado, which was the
test bed for many of the ideas and examples in the book. Douglas
Paterson and Leena Purkait not only managed the process of putting
this book together, but also worked with me to make this book
the pilot for the RAW program. Thanks also to the DrupalCamp
Chicago crowd, who provided feedback on the later chapters. John
Forsythe was instrumental in getting the early chapters prepared
for the RAW release. Dave Myburgh and Paul Lovvik provided
copious comments on the book. Larry Garfield, Nate Striedinger,
Ken Rickard, Greg Dunlap, John Wilkins, Sam Boyer, and the rest
of the Palantir team, have (wittingly or unwittingly) been great
sources of information and inspiration. Thanks also to Scott Dexter
and Samir Chopra, whose work has continued to fortify my belief in
FOSS ethics. Katherine, Anna, Claire, and Angie had to give up the
occasional Sunday afternoon activities so that I could write this book.
To them, I indubitably owe the greatest debt of gratitude.
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
About the reviewers
Dave Myburgh has been involved with computers even before the Web existed.
He studied to be a molecular biologist, but discovered that he liked working with
computers more than bacteria. He had his own computer business in South Africa
(where he grew up), which involved technical support and sales. He even created
a few static web sites for clients during that time.
He went back to science for a few years when he first came to Canada, and then
got sucked into the world of Drupal when a friend wanted a site for a local historical
society. Since then, he has once again started his own company that now builds
web sites exclusively in Drupal (he doesn't "do static" anymore). There is no lack
of work in the Drupal world, and he now balances his time between work and
family. He has also reviewed several Drupal books, including Drupal 5 Themes
and Drupal 6 Themes.
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Table of Contents
Preface 1
Chapter 1: Drupal and JavaScript 7
Do you speak...? 8
PHP 9
SQL 10
HTML 11
CSS 12
XML 13
JavaScript 14
Drupal's architecture 15
The Drupal Core 16
The Theme Engine 18
Modules 18
Users, nodes, and blocks 19
Users 19
Blocks 20
Nodes 22
Drupal JavaScript development tools 23
A good editor 24
Firebug 24
The Drupal Devel package 26
Summary 28
Chapter 2: Working with JavaScript in Drupal 29
How Drupal handles JavaScript 30
Where Drupal JavaScript comes from? 31
Project overview: printer-friendly page content 32
The printer script 33
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Table of Contents
[ ii ]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Table of Contents
[ iii ]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Table of Contents
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Table of Contents
[v]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Preface
JavaScript: It's not just for calculators and image rollovers.
Drupal 6 is loaded with new features, not all of which are necessarily implemented
in PHP. This unique book, for web designers and developers, will guide you through
what can be done with JavaScript (and especially with jQuery) in Drupal 6.
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.
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!
If you've dipped your toe in the water of theme or module development with Drupal
6, this is the book that will 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, to making you
a master of the jQuery library in the world of Drupal themes and modules.
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Preface
Chapter 2 covers the basics on how JavaScript can be used within Drupal 6. We will
begin by exploring how JavaScript is included in Drupal pages, and then create our
first script for Drupal.
Chapter 4 focuses on Drupal Behaviors and the major utility functions provided by
drupal.js, which provides functions for behaviors, translation, theming, as well as
other utility functions.
Chapter 5 focuses on the translation system in Drupal, and the JavaScript tools
that are used in conjunction with that system. We will look at installing and
configuring multiple languages using JavaScript functions, and then extracting
and translating strings.
Chapter 6 focuses on the JavaScript theming system. We will look at the JavaScript
theming module, and examine some of the themes and user interface tools that it
provides. We will implement our own template system based on HTML, CSS,
and JavaScript.
Chapter 7 focuses on the AJAX family of tools. We will learn to use jQuery's
built-in AJAX support to get content from Drupal, and also use JSON (JavaScript
Object Notation) as a JavaScript-friendly way of sending data from Drupal.
You are expected to know about the basic operation of Drupal, and be familiar with
the concept of theming and modules in Drupal. No experience with creating themes
or modules is required.
[2]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Preface
You will also need to know the basics of client-side web development. This includes
HTML, CSS, but you should also have a rudimentary grasp of JavaScript syntax.
Familiarity with PHP programming will be an advantage, since we will be writing
PHPTemplate files and (at the end) creating Drupal modules. However, PHP is
covered thoroughly enough that even the PHP neophyte will not find the text
too demanding. The book also covers the jQuery JavaScript library and its use in
Drupal, but no knowledge of jQuery is expected. You will learn everything you
need in this book.
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 can include other contexts through the
use of the include directive."
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items will be made bold:
if(sel.id == txtareaID && sel.start != sel.end) {
txtareaEle.value = SimpleEditor.insertTag(
sel.start,
sel.end,
$(this).hasClass('bold') ? 'strong' : 'em',
txtareaEle.value
);
sel.start = sel.end = -1;
}
New terms and important words are introduced in a bold-type font. Words that you
see on the screen, in menus or dialog boxes for example, appear in our text like this:
"clicking the Next button moves you to the next screen".
[3]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Preface
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.
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
suggest@packtpub.com.
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.
[4]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Preface
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 this you can
save other readers from frustration, and help to improve subsequent versions of
this book. If you find any errata, 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 are added to the list of existing errata. The 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 the location address or website name immediately so we can pursue
a remedy.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
some aspect of the book, and we will do our best to address it.
[5]
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Drupal and JavaScript
If you're anything like me, you're reading this first paragraph with two questions
in mind: Is this book going to cover the topics I need? And, is this book any good?
(Again, if you're anything like me you're groaning already that the author has
lapsed into indulgent first-person navel-gazing.)
Regarding the second question, I'm obviously not the person whose opinion you'll
want. But here's the answer to the first question: The aim of this book is to provide
a practical, hands-on approach to using the JavaScript scripting language to extend
and customize the Drupal 6 Content Management System (CMS).
Drupal 6 offers JavaScript tools designed to enable developers to turn Drupal sites
into Web 2.0 platforms. That's why this book exists. We're going to see how to use
Drupal's JavaScript support to assemble the building blocks needed to enhance
the client-side experience. Tools such as jQuery, language translation, and AJAX
support—all included in Drupal's core—provide powerful features that we will
explore. While we won't be developing word processors or webmail applications,
we will be developing widgets and tools that can be assembled in many different
ways to enrich the user's experience. Most importantly, we'll be doing this in a
practical and hands-on way.
What do I mean by ‘practical and hands-on'? I mean that every chapter after this one
will be organized around one or more projects. While preparing my previous book,
"Learning Drupal 6 Module Development", Packt Publishing, 978-1847194442, I came to
appreciate the power of Drupal's well-integrated JavaScript libraries. In this book,
we will use those libraries in conjunction with other Drupal technologies to create
functional pieces of code that you can use. Or even better yet, use them as a starting
point to create something even more well-suited to meet your own needs. We won't
be agonizing over the details of every function, nor will we spend a lot of time
looking at the theory. Instead, the pace will be crisp as we work on code, learn
how it works, and how it can be used.
This material is copyright and is licensed for the sole use by Richard Ostheimer on 18th June 2009
2205 hilda ave., , missoula, , 59801
Discovering Diverse Content Through
Random Scribd Documents
felt that the rhythm of dancing is a kind of arrested music, which
Degas has certainly given us, as in the feet that poise, the silent
waves of wandering sound of the dancer's moving melody, and her
magic. A man of singular, but not universal, genius, Degas, his work
being done, leaves behind him a sense of intense regret; for he
created a new art in painting, that is to say, in painting the sex he
adored, without pity and without malice.
If any prose is immortal, this is; and creative also, and imaginative,
and lyrical: it has vision, and it has the sense of the immense
contrast between "this majestical roof" and "this quintessence of
dust" to which we are all reduced at the end.
I have always felt that a play of Shakespeare, seen on the stage,
should give one the impression of assisting at "a solemn music." The
rhythm of Shakespeare's art is not fundamentally different from that
of Beethoven, and Romeo and Juliet is a suite, Hamlet a symphony.
To act either of these plays with whatever qualities of another kind,
and to fail in producing this musical rhythm from beginning to end,
is to fail in the very foundation. It has been said that Shakespeare
will sacrifice his drama to his poetry, and even Hamlet has been
quoted against him. But let Hamlet be rightly acted, and whatever
has seemed mere meditation will be realized as a part of that
thought which makes or waits on action. The outlines of the tragedy
are crude, irresistible melodrama, still irresistible to the gallery; and
the greatness of the play, though it comes to us by means of its
poetry, comes to us legitimately as a growth out of melodrama.
I have often asked myself this question, when I have sat in the stalls
watching a play, and having to write about it: is the success of this
piece due to the playwright's skill or to the skill of the actors? Nor is
any question more difficult to answer than this; which Lamb
certainly does his best to answer in one of his underlined sentences,
in regard to the actor. "He must be thinking all the while of his
appearance, because he knows that all the while the spectators are
judging of it." And again when he says: "In fact, the things aimed at
in theatrical representations are to arrest the spectator's eye upon
the form and the gesture, and to give a more favorable hearing to
what is spoken: it is not what the character is, but how he looks; not
what he says, but how he speaks it." Was anything more
fundamentally true ever said on what the actor ought to do? Lamb
answered it again, in his instinctive fashion of aiming his arrow
straight at the mark, when he said of a performance of Shakespeare
in which there were two great actors, that "it seemed to embody
and realize conceptions which had hitherto assumed no distinct
shape," but that "when the novelty is past, we find to our cost that
instead of realizing an idea, we have only materialized and brought
down a fine vision to the standard of flesh and blood."
Every artist who has the sense of the sublime knows that the pure
genius is essentially silent, and that his revelation has in it more of
vision than of reality. For when he deigns to appear, he is
constrained, under penalty of extinction, to lessen himself so as to
pass into the Inaccessible. He creates; if he fails in creation, he is of
necessity condemned to the utter darkness. He is the ordinator of
chaos: he calls and disposes of the blind elements; and when we are
uplifted in our admiration before some sublime work, it is not that he
creates an idea in us: it is that, under the divine influence of the
man of genius, this idea, which was in us, obscure to itself, is
reawakened.
I am confronted now with Villiers de l'Isle Adam in his conjectures in
regard to certain questions—never yet settled—in Hamlet. A modern
man of taste might ask what Shakespeare would have answered if
the actor who played Hamlet's part were to interrogate the Specter
"escaped from hideous Night" as to whether he had seen God's face,
whether he wanted to be concerned with, not the eternal mysteries,
but with what he had seen in hell and what he hated seeing on
earth; and, if he had come only to utter absurdities, really, why need
he have died at all?
The Ghost, by the mere fact of being there, seems, at first sight, an
absurdity; but if he has really seen God and the Absolute and if he
has entered into them—which is impossible—the sublimity of his
words might seem to be superfluous; and yet the incoherencies that
he utters are all the more terrifying because of their
incomprehensibility. "The secret of the Absolute cannot be expressed
with syntax, and therefore one cannot ask the ghost to produce
more than an impression." The Specter, for Shakespeare, is not a
human being: he is obsession. Had he wanted Hamlet really to
perceive the ghost and had he thought this dramatic effect ought to
seize on the imagination of the audience, it was because he was
certain that every one of them, in the ghost perceived by Hamlet,
would see the familiar ghost that actually haunts himself.
Hamlet's soliloquy "To be or not to be" is a magnificent disavowal—
on the part of Shakespeare. And if one excuses the contradiction by
supposing that Hamlet tried to deliver himself from the obsession, to
doubt, one can only reply that he never doubts the Ghost itself, but
the nature of this ghost; for he says at the end of the second act:
The spirit I have seen
May be the devil: and the devil hath power
To assume a pleasing shape; yea, and perhaps,
Out of my weakness and my melancholy,
(As he is very potent with such spirits),
Abuses me to damn me.
Therefore if we compare the motive and the spirit of those sickly
phrases with those of the soliloquy, we shall realize that this has no
relation whatsoever with the superstitious character of Hamlet; even
more so, because every single word of them is in flagrant
contradiction with the entire drama.
I have no intention of discussing either Mr. Martin Hervey's
representation of Hamlet or the somber and sinister Hamlet acted by
Josef Keinz in Berlin; or the performance of Tree, or of Forbes-
Robertson; or of any one's, with the exception of that given by
Edward Sothern. He is by no means the only Hamlet, for there are
always—to quote Browning—"points in Hamlet's soul unseized by the
Germans yet." Sothern had depth in his acting; and there was
nothing fantastic in his grave, subdued, powerful, and piteous
representation, in which no symbol, no figment of a German brain,
no metaphysical Faust, loomed before us, but a man more to be
pitied and not less to be honored than any man in Elsinore. Yet
when one considers what Hamlet actually was—and there is no
getting at the depths of his mystery—one finds, for one thing, a man
too intensely restless to make up his mind on any question of
thought, of conduct, and that he does for the most part the opposite
of what he says. The pretense of madness is an almost transparent
pretense, and used often for a mere effect of malicious wit, in the
confusion of fools, or at the prompting of mere nerves. To me
Hamlet seems to be cursed with the veritable genius of inaction.
Always he is alone, even when he is in a crowd; he is the most
sensitive of all Shakespeare's creations; his nerves are jarred, when
knaves would play on him as one plays on an instrument; his blood
is feverish, infected with the dark melancholy that haunts him. Does
he love Ophelia? I see in him no passion for loving: to him passion is
an abstract thing. In any case, irresolution is baneful to him;
irresolution that loses so many chances, for which no one forgives
himself. This Swinburne denies, supposing that the signal
characteristic of Hamlet's inmost nature "is by no means irresolution
or hesitation or any form of weakness, but rather the strong conflux
of contending forces;" adding, what is certainly true, that the
compulsory expedition of Hamlet to England and his hot-headed
daring prove to us his almost unscrupulous resolution in time of
practical need. Only, when all Hamlet's plans of revenge have been
executed, with the one exception of his unnecessary death, before
he utters his last immortal words "The rest is silence," the thought of
death to him is as if a veil had been withdrawn for an instant, the
veil which renders life possible, and, for that instant, he has seen.
LEONARDO DA VINCI
II
Two men of genius, in our own generation, have revealed for all time
the always inexplicable magic of Leonardo da Vinci: Walter Pater in
his prose and Dante Gabriel Rossetti in his sonnet. It is impossible
not to quote this lyrical prose.
III
IV
IMPRESSIONISTIC WRITING
PARADOXES ON POETS
THE END
*** END OF THE PROJECT GUTENBERG EBOOK DRAMATIS
PERSONÆ ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com