I am working on a WordPress theme and I am using the built in iris color picker (by Automatic).
Iris supports color palettes by default, however it displays all colors on one single line, and once you add more than 8 colors, the color boxes get very small (see JSFiddle demo below).
Is there anyway to add a new row of colors to the iris color picker?
Here’s the default jQuery plus JSFiddle
jQuery(document).ready(function($){
$('#color-picker').iris({
hide: false,
palettes: ['#125', '#459', '#78b', '#ab0', '#de3', '#f0f', '#125', '#459', '#78b', '#ab0', '#de3', '#f0f'],
});
});
It seems the iris plugin makes a few calculations for the design width and height based on the amount of palettes used. The function option responsible for this can be found here: https://github.com/Automattic/Iris/blob/master/src/iris.js#L466-L513
Since I am not that familiar with JavaScript, I don’t really know how to override a function option inside of a plugin without touching the core file.
Here is a jQuery hack I quickly wrote. It’s not the best solution, but it does the trick. (not the best solution because the iris plugin still makes the calculations of the width and height, although they’re not being used in the end)
http://jsfiddle.net/rcm0pdu1/16/