Preface
Modern web application user interface design requires rapid development and proven results. jQuery UI, a trusted suite of official plugins for the jQuery JavaScript library, gives you a solid platform on which you can build rich and engaging interfaces with maximum compatibility, stability, and minimum time and effort.
jQuery UI has a series of ready-made, great-looking user interface widgets and a comprehensive set of core interaction helpers designed to be implemented in a consistent and developer-friendly way. With all this, the amount of code that you need to write personally to take a project from conception to completion is drastically reduced.
Specially revised for Version 1.10 of jQuery UI, this book has been written to maximize your experience with the library by breaking down each component and walking you through examples that progressively build upon your knowledge, taking you from beginner to advanced usage in a series of easy-to-follow steps.
In this book, you'll learn how each component can be initialized in a basic default implementation and then see how easy it is to customize its appearance and configure its behavior to tailor it to the requirements of your application. You'll look at the configuration options and the methods exposed by each component's API to see how these can be used to bring out the best in the library.
Events play a key role in any modern web application if it is to meet the expected minimum requirements of interactivity and responsiveness. Each chapter will show you the custom events fired by the component covered and how these events can be intercepted and acted upon.
What this book covers
Chapter 1, Introducing jQuery UI, lets you find out exactly what the library is, where it can be downloaded from, and how the files within it are structured. We also look at ThemeRoller, which browsers support the library, how it is licensed, and how the API has been simplified to give the components a consistent and easy-to-use programming model.
Chapter 2, The CSS Framework and Other Utilities, looks in detail at the extensive CSS framework, which provides a rich environment for integrated theming through Themeroller and also allows developers to easily supply their own custom themes or skins. We also cover the new position utility and have a look at all the unique features and series of configuration options that it provides.
Chapter 3, Using the Tabs Widget, looks at the first widget, which is the tabs widget, a simple but effective means of presenting structured content in an engaging and interactive widget.
Chapter 4, The Accordion Widget, looks at the accordion widget, another component dedicated to the effective display of content. Highly engaging and interactive, the accordion makes a valuable addition to any web page and its API is exposed in full to show exactly how it can be used.
Chapter 5, The Dialog, focuses on the dialog widget. The dialog behaves in the same way as a standard browser alert, but it does so in a much less intrusive and more visitor-friendly manner. We look at how it can be configured and controlled to provide maximum benefit and appeal.
Chapter 6, The Slider and Progressbar Widgets, provides a less commonly used, but no less valuable user interface tool for collecting input from your visitors, and displaying the results of an action to them. We look closely at the APIs of both components throughout this chapter to see the variety of ways in which it can be implemented, and put to good use in our web applications.
Chapter 7, The Datepicker Widget, looks at the datepicker. This component packs a huge amount of functionality into an attractive and highly usable tool, allowing your visitors to effortlessly select dates. We look at the wide range of configurations that its API makes possible as well as seeing how easy common tasks such as skinning and localization are made.
Chapter 8, The Button and Autocomplete Widgets, looks at the brand new button, and recently revived autocomplete. Long-time users of the library will remember the autocomplete from a previous version of the library. The widget is now back, fully updated to fit in with the latest version of the library and in this chapter we get to see how it can be used to great effect.
Chapter 9, Creating Menus, takes us through how to create and add menus to our websites or application. We'll see how, with minimal code, we can turn a bunch of ordinary hyperlinks into an interactive system for navigating around your site, which will help engage your site's visitors and make it easy to find content.
Chapter 10, Working with Tooltips, will show us how, with minimal effort, we can easily provide a context-based system of support, by displaying important messages or feedback to the end user. This is particularly important in instances where visitors to your site may have inadvertently entered incorrect information; we can help get them back onto the right track!
Chapter 11, Drag and Drop, begins to look at the low-level interaction helpers, tackling first the related drag-and-droppable components. We look at how they can be implemented individually and how they can be used together to enhance your user interfaces.
Chapter 12, The Resizable Component, looks at the resizing component and how it is used with the dialog widget seen earlier in the book. We see how it can be applied to any element on the page to allow it to be resized in a smooth and attractive way.
Chapter 13, Selecting and Sorting with jQuery UI, looks at the final two interaction helpers in this chapter; the selectable and sortable components. We can use the components to select and sort elements in a website or application, although the sortable component really comes into its own when working with lists, as you can reorder them by dragging items to a new position in the list. Both components can help you add a high level of professionalism and interactivity to your site, while at the same time blurring the boundaries between desktop and browser-based applications.
Chapter 14, UI Effects, is dedicated solely to the special effects that are included with the library. We look at an array of different effects that allow you to show, hide, move, and jiggle elements in a variety of attractive and appealing animations.
Chapter 15, The Widget Factory, the downloadable chapter of the book provides an extensive look at the widget factory and how it allows us to quickly and easily create our very own jQuery UI plugins. The widget factory solves lots of common problems for you and can greatly improve productivity; it also extensively improves code reuse, making it a great fit for jQuery UI as well as many other stateful plugins. You can find this chapter at http://www.packtpub.com/sites/default/files/downloads/2209OS_Chapter_15.pdf.
Appendix, Help and Support, covers the basics of downloading the library. It provides the Getting Help section which helps readers with answers to all their queries throughout the book.
What you need for this book
All you need to work through most of the examples in this book is a simple text or code editor and a browser. One or two of the more advanced examples rely on PHP, but for convenience, I've included these examples in the code download that accompanies this book.
Who this book is for
The book is for frontend developers who need to quickly learn how to use jQuery UI, or designers who wish to see how jQuery UI functions, behaves, and looks. To get the most out of this book you should have a good working knowledge of HTML, CSS, and JavaScript, and ideally be comfortable using jQuery.
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, database table names, folder names, filenames, file extensions, path names, dummy URLs, user input, and Twitter handles are shown as follows: "When prompted for a location to unpack the archive to, choose the jqueryui
folder that we just created."
A block of code is set as follows:
<link rel="stylesheet" href="development-bundle/themes/base/jquery.ui.tabs.css"> <link rel="stylesheet" href="development-bundle/themes/base/jquery.ui.theme.css">
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
$(".ui-positioned-element").position({ of: ".ui-positioning-element", my: "right bottom", at: "right bottom" });
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 the text like this: "When we view the page and select the Images tab, after a short delay we should see six new images."
Note
Warnings or important notes appear in a box like this.
Tip
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 send an e-mail to <feedback@packtpub.com>
, and mention the book title via the subject of your message.
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 get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Downloading the color images of this book
We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/2209OS_ColorImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books – maybe a mistake in the text or the 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 errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. 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 website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com>
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 <questions@packtpub.com>
if you are having a problem with any aspect of the book, and we will do our best to address it.