Automattic / Iris

A(n awesome) Color Picker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add new colors to palette without overwriting the previous colors?

kmob2 opened this issue · comments

commented

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?