Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#27469 closed enhancement (invalid)

Color picker palette can't be customized

Reported by: greglone's profile GregLone Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Customize Keywords:
Focuses: javascript Cc:

Description

Hello.

Under the color picker we have a palette with up to 6 colors (or 8?). Regarding iris, the option "palettes" can be a boolean, or, if we want custom colors, it must be an array.

In wp-admin/js/color-picker.js L27 we have $.extend( self.options, el.data() );.
The problem is:

  • if we pass a string, iris won't use it.
  • if we pass an array, $.extend() will change it into a string.

My solution is allowing us to pass a comma separated list of colors and split(). See the diff file.

Side note: add the width to the available options could be useful sometimes, I guess.

Attachments (1)

color_picker_palette.diff (6.2 KB) - added by GregLone 11 years ago.
Process the palettes

Download all attachments as: .zip

Change History (4)

@GregLone
11 years ago

Process the palettes

#1 @mattwiebe
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

This is actually unnecessary, what's there as-is works fine. jQuery's .data() support for HTML5 values will attempt to JSON.parse any data-* attributes, but they need to be in a format that works for JSON.parse, where only double quotes are parse-able. This won't work:

<input data-palettes="['#fff', '#000']">

but this will:

<input data-palettes='["#fff", "#000"]'>

Anyway, apologies for getting to this slowly.

If you have a use-case for width, please open another ticket for that. :)

#2 @GregLone
11 years ago

OK, thanks @mattwiebe, I wasn't aware of that behavior for .data(), my apologies.
No need to apology for the delay, it wasn't a huge problem :)

#3 @helen
11 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.