Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Created October 3, 2008 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heycarsten/14632 to your computer and use it in GitHub Desktop.
Save heycarsten/14632 to your computer and use it in GitHub Desktop.
LearnHub.ColorPalette = {
init : function()
{
$$('.color-palette-swatch-color').
invoke('observe', 'click', LearnHub.ColorPalette.selectSwatchViaEvent);
},
selectSwatch : function(element)
{
LearnHub.ColorPalette.unselectAllSwatches();
element.addClassName('selected');
element.adjacent('input[type=radio]')[0].checked = true;
},
selectSwatchViaEvent : function(event)
{
element = event.findElement('.color-palette-swatch-color');
LearnHub.ColorPalette.selectSwatch(element);
},
unselectAllSwatches : function()
{
$$('.color-palette-swatch-color').
invoke('removeClassName', 'selected');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment