rgb(r,g,b) values are now displayed as hex colors, too
This commit is contained in:
parent
35022eaa92
commit
9201c41331
4 changed files with 37 additions and 17 deletions
|
@ -15,6 +15,19 @@ function openColorPicker(name, text) {
|
|||
var cpWindow = window.open("<% root.url path="colorpicker" %>?name=" + name + "&text=" + text, "cpWindow", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=350,height=320");
|
||||
}
|
||||
|
||||
function setColorPreview(name, color) {
|
||||
document.getElementById('cp2_' + name).style.backgroundColor = color;
|
||||
function normalizeColor(c) {
|
||||
if (c && c.length == 6) {
|
||||
var nonhex = new RegExp("[^0-9,a-f]");
|
||||
nonhex.ignoreCase = true;
|
||||
var found = c.match(nonhex);
|
||||
if (!found) {
|
||||
// color-string contains just hex-characters, so we prefix it with '#'
|
||||
return("#" + c);
|
||||
}
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
function setColorPreview(name, color) {
|
||||
document.getElementById('cp2_' + name).style.backgroundColor = normalizeColor(color);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue