Sha256: 1496309f09197fb9a921634ee7000e32c318e77800ba81eef3b90e9a4e4a839d
Contents?: true
Size: 839 Bytes
Versions: 15
Compression:
Stored size: 839 Bytes
Contents
class ColorPickerInput < Formtastic::Inputs::StringInput DEFAULT_PALETTE = [ "#000000", "#333333", "#663300", "#CC0000", "#CC3300", "#FFCC00", "#009900", "#006666", "#0066FF", "#0000CC", "#663399", "#CC0099", "#FF9999", "#FF9966", "#FFFF99", "#99FF99", "#66FFCC", "#99FFFF", "#66CCFF", "#9999FF", "#FF99FF", "#FFCCCC", "#FFCC99", "#FFFFFF", ] def to_html input_wrapping do [ label_html, builder.hidden_field(method, input_html_options), ].join("\n").html_safe end end def input_html_options opts = {} opts["class"] = 'color-picker' opts["data-palette"] = (@options[:palette] || DEFAULT_PALETTE).to_json opts["value"] = @object.public_send(method) super.merge(opts) end end
Version data entries
15 entries across 15 versions & 1 rubygems