Sha256: e24aab987d5e98dce57f4a1ae9909ffe7bd7bf5dde6ce3167760677f4178c40d

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 Bytes

Contents

require 'rails_admin/config/fields/base'

module RailsAdmin
  module Config
    module Fields
      module Types
        class Color < RailsAdmin::Config::Fields::Base
          RailsAdmin::Config::Fields::Types::register(self)
          
          register_instance_option :pretty_value do
            bindings[:view].content_tag :strong, value.to_s, :style => "color: #{color}"
          end

          register_instance_option :partial do
            :form_colorpicker
          end
          
          register_instance_option :color do
            if value.present?
              if value =~ /^[0-9a-fA-F]{3,6}$/
                '#' + value
              else
                value
              end
            else
              'white'
            end
          end
          
          register_instance_option :export_value do
            formatted_value
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elucid-rails_admin-0.0.1 lib/rails_admin/config/fields/types/color.rb