Automattic / Iris

A(n awesome) Color Picker
GNU General Public License v2.0
259 stars 67 forks source link

Add new colors to palette without overwriting the previous colors? #62

Closed kmob2 closed 7 years ago

kmob2 commented 7 years ago

I am using iris color picker (wordpress to exac) with a few preset color palettes. Now I want to add more colors, however I don't want to touch the previous code. I need a solution to extend the color palettes without touching the original code.

The problem I have, is that if I use the palette parameter again, it simply overwrites the previous selected palettes.

jQuery(document).ready(function($){
    $('#color-picker').iris({
        hide: false,
         palettes: ['#125', '#459', '#78b'],
    });

     $('#color-picker').iris({
         palettes: ['#000', '#000', '#000'],
    });
});

Here is my fiddle: http://jsfiddle.net/8ctrmsyx/

I also can't just add the previous color palettes, since there are dozens of different color pickers across the site, each with their own color palettes.

The easiest solution would be to somehow have a function to extend the palettes, rather than overwriting them.

How could I do that?