Class: UU::OS::Form::ColorPicker

Inherits:
Input show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/form/color_picker.rb

Overview

Component for choosing color.

Defined Under Namespace

Classes: Palette

Constant Summary

UU_OS_PALETTE =

Constant denoting palette containing standard uuOS colors.

'UU_OS_PALETTE'

Instance Attribute Summary (collapse)

Attributes inherited from Input

#disabled, #read_only, #required, #submit_value_change, #value_change_action_uri, #width

Attributes inherited from GVC::Component

#attributes, #code, #component_type, #form, #height, #id, #name, #width

Method Summary

Methods inherited from GVC::Component

#add_message, #focus, #initialize, #messages

Constructor Details

This class inherits a constructor from UU::OS::GVC::Component

Instance Attribute Details

- (Object) data

Data containing palette of colors. If no data is supplied, default palette is used containing colors from Palette.

Examples:

# default palette
colorpicker.data = {:palette => UU::OS::Form::ColorPicker::UU_OS_PALETTE}

# custom palette
colorpicker.data = {:palette => ["#ff0000", "#00ff00", "#0000ff"]}

# custom palette
palette = UU::OS::Form::ColorPicker::Palette
colorpicker.data = {:palette => [palette::YELLOW, palette::ORANGE]}


26
27
28
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/color_picker.rb', line 26

def data
  @data
end

- (Object) data_uri

URI of a uuCommand to use for loading data. The data returned from the uuCommand must be in a format supported by data attribute.



30
31
32
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/color_picker.rb', line 30

def data_uri
  @data_uri
end

- (Object) value

Selected color in hexadecimal format, such as "#ff0000". It is possible to set a pre-defined color from the Palette or a custom color. Note that if a value that is not present in the used palette is set, the palette offered to the user won't contain that color, so if the user chooses yet another color, (s)he won't be able to get back to the original one.

Examples:

# set custom color
colorpicker.value = "#c0a5ca"

# set color from standard palette
colorpicker.value = UU::OS::Form::ColorPicker::Palette::ORANGE

# get value and use it for coloring a button component (note that
# class Palette is able to return color names only for colors from
# default palette)
color_hex = colorpicker.value
button.style_class = UU::OS::Form::ColorPicker::Palette.to_hash().key(color_hex)


51
52
53
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/color_picker.rb', line 51

def value
  @value
end