Skip to Content
Dojo: The Definitive Guide
book

Dojo: The Definitive Guide

by Matthew A. Russell
June 2008
Intermediate to advanced
488 pages
15h 3m
English
O'Reilly Media, Inc.
Content preview from Dojo: The Definitive Guide

ColorPalette

ColorPalette is another simple standalone widget that is helpful for providing a more visual and interactive way of allowing a user to select a color—perfect for situations in which you allow the user to customize the theme of an application, for example. By default, the palette comes in two canned sizes, 3 × 4 or 7 × 10, with pre-selected popular web colors.

Tip

You may already be wondering why you can't configure your own set of colors for the palette. As it turns out, the palettes that appear are images, not panes of HTML markup, and they were designed this way for a11y reasons, even though it does not seem ideal. Thus, if you want to extend ColorPalette to display a custom selection, it is certainly doable—you'd just have to read the source and get your hands dirty by hacking on some of the private attributes.

Using a ColorPalette in markup is quite simple; the following listing illustrates:

<div dojoType="dijit.ColorPalette">
    <script type="dojo/method" event="onChange" args="selectedColor">
        /* hide the palette, perhaps? */
        console.log(selectedColor);
    </script>
</div>

Like ProgressBar, ColorPalette is a nice and simple standalone. Table 15-4 shows the full story.

Table 15-4. ColorPalette API

Name (default)

Type

Comment

defaultTimeout

Integer

The duration before a key that is held down becomes typematic. 500 by default.

timeoutChangeRate

Number

The amount of time that is used to change the typematic rate. A value of 1.0 means that typematic events are fired at regular intervals, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

The Dojo Toolkit: Visual QuickStart Guide

The Dojo Toolkit: Visual QuickStart Guide

Steven Holzner
Java EE 8 Cookbook

Java EE 8 Cookbook

Edson Yanaga, Elder Moraes

Publisher Resources

ISBN: 9780596516482Errata Page