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

Version Path
activeadmin_addons-0.12.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.11.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.10.1 app/inputs/color_picker_input.rb
activeadmin_addons-0.10.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.9.3 app/inputs/color_picker_input.rb
activeadmin_addons-0.9.2 app/inputs/color_picker_input.rb
activeadmin_addons-0.9.1 app/inputs/color_picker_input.rb
activeadmin_addons-0.9.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.8.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.7.0 app/inputs/color_picker_input.rb
activeadmin_addons-0.6.4 app/inputs/color_picker_input.rb
activeadmin_addons-0.6.3 app/inputs/color_picker_input.rb
activeadmin_addons-0.6.2 app/inputs/color_picker_input.rb
activeadmin_addons-0.6.1 app/inputs/color_picker_input.rb
activeadmin_addons-0.6.0 app/inputs/color_picker_input.rb