function colorSelectedHandler($element, $colorPicker) {
var annotationProperty = selectedColorPicker;
var annotation = window.ControlUtils.getSelectedAnnotation();
if (!annotation) {
return;
}
var color = colorNameToRGB($element.attr('data-color'));
if (isRemovingColors) {
var colorName = colorToHex(color);
if (colorName !== 'transparent') {
userPrefs.removeToolColor(annotation, annotationProperty, colorName);
currentToolColors = userPrefs.getToolColors(annotation);
$element.remove();
}
} else {
deselectColor($colorPicker);
selectColor($element);
if (color) {
annotation[annotationProperty] = color;
am.updateAnnotation(annotation);
am.trigger('annotationChanged', [[annotation], 'modify']);
readerControl.fireEvent('defaultToolValueChanged', [annotation, annotationProperty, color]);
window.ControlUtils.updateAnnotPreview(annotation);
}
}
}