In this chapter we covered three projects. In the first project, we saw how we could integrate another existing Drupal JavaScript library —autocomplete.js — into our site. We used a taxonomy to add suggestions to our search box.

After that, we integrated one of the jQuery UI tools—the accordion widget—into our site. Using this tool, we turned our lefthand navigation into a compact, but elegant accordion menu.

Finally, we learned how to extend jQuery by writing a jQuery plug-in. In a couple dozen lines of code, we wrote a complete plug-in that takes advantage of jQuery's DOM tools and looping structures. During this section, we talked about closures and discovered that we'd been writing them all along.

This is the final chapter of the book. In our earlier chapters, we started out with some fairly clumsy JavaScript, just barely integrated into a Drupal theme. Now, seven chapters later, we know how to write Drupal-centred JavaScript with the use of jQuery, Drupal's own JavaScript libraries, and even external libraries such as jQuery UI. We've worked with both themes and modules. We've even written a little bit of PHP code.

The purpose of this book has been to give you access to the JavaScript tools which are often used for Drupal development, and to show you how to use them in this context. We have only scratched the surface of what can be done with these tools. This book, if I have been successful, gives you a foundation. From here, you can begin building the next generation of JavaScript-enabled Drupal web applications.


AJAX about 198 in Web 2.0 199 web development 198 working 200 XHR 200 AJAX project about 204

comment notifications 219 goals 206 RSS 205 web clips 204

web clips tool, creating 207-209 Asynchronous JavaScript And XML. See

AJAX autocompletion about 287 working 287

autocompletion project about 287

JavaScript tool, creating 294 module, creating 291-294 plan 289

search_autocomplete_init() function 293 search autocomplete JavaScript, creating 294-298

search_autocomplete.module file 292 taxonomy, creating 289-291 theory 288

bettereditor.js script, simple editor project about 268- 272 addTag() theme 278-284

buttonBar() theme function 285 button() theme function 284 editor() behavior 272-277 insertTag() function 277 bettereditor.module file, simple editor project $button array 261

$button array, translating to JavaScript

264-267 arrays, building 261 bettereditor_help() function 260 bettereditor_init() function 260, 261 hook_help(), implementing 258, 260 hook_init(), implementing 258, 260 tag attribute 263 block module about 20

blocks, selecting 21 custom module 20 demoblock 20 navigation block 20

blocks collapsible project behavior.js file contents 102 Drupal.behaviors.slideBlocks(), defining 103 generic structure, blocks 104 menu section, Frobnitz theme 103

camel case 35 channel, RSS

about 206 items 206 closures, jQuery UI

about 312

divWrap() function, defining 315 comment notifications, AJAX project comment notifcation tool, creating 219 comments, displaying as notifications 219 comment watcher 226 JSON view, creating 221 prerequisites, JSON view 221 Views Datasource, installing 220 Views, installing 220 comment watcher about 226

comment notification, theming 235 comment watcher behavior 230 CommentWatcher.check() function 231 comment_watcher element, setting up 230 CommentWatcher.formatContent() function 236

CommentWatcher.getLastID() function 237 CommentWatcher.setLastID() function 237 CommentWatcher.settings.maxLength, settings 229 cookies, building 238 cookies, managing 237 cookies, setting 239 custom theming function 235 CSS file 52

Devel package about 26 modules 26 Dojo 60 DOM API 41 dot-info file 47 Drupal autocompletion project 287 block module 20 drupal_add_js() function 254, 266 drupal_parse_info_file() 253 Drupal.theme.prototype.commentArea(). 235

first JavaScript, creating 32 first jQuery script 62 hook system 250 JavaScript, handling 30 JavaScript, working with 30

jQuery plug-in project 309 jQuery project 73 jQuery UI project 299 jQuery, using 71 languages 8 nodes 22 RSS 205

script autoloader project 244 simple editor project 256 theming project 161 translation engine 127 translation funcions 128 translation system 127 Translation template extractor, installing 138

user module 19

weekend countdown project 139 drupal_add_js() function 266 Drupal architecture about 15 diagram 16 Drupal Core 16 modules 18 PAC design pattern 16 Theme Engine 18


about 98 context 99 example 98

Firebug console example 100

Drupal.checkPlain() function, utilities about 108 example 108 html() method 109 mystring, creating 108 string, encoding 109

Drupal coding standards differences between PHP and JavaScript 35 Drupal Core 16

Drupal.encodeURIComponent() function, utilities 112

Drupal.formatPlural() function about 136 working 136, 137 Drupal.getSelection() function 113 Drupal JavaScript creating 32

Was this article helpful?

0 0

Post a comment