Sha256: e16419084ae55af44c8a931a4346fe5554afae0dc67501975b0b7b5f99ecdbcf

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

if (Object.const_defined?("Formtastic") && Gem.loaded_specs["formtastic"].version.version[0,1] == "2")
    
    class RichPickerInput < ::Formtastic::Inputs::StringInput

      def to_html 
        scope_type = object_name
        scope_id = object.id
        editor_options = Rich.options(options[:config], scope_type, scope_id)
        
        local_input_options = {
          :class => 'rich-picker',
          :style => editor_options[:style]
        }

        input_wrapping do

          label_html <<
          builder.text_field(method, local_input_options.merge(input_html_options)) <<
          " <a href='#{Rich.editor[:richBrowserUrl]}' class='button'>#{I18n.t('picker_browse')}</a>".html_safe <<
          "</br></br><img class='rich-image-preview' src='#{@object.send(method)}' style='height: 100px' />".html_safe <<
          "<script>$(function(){$('##{input_html_options[:id]}_input a').click(function(e){ e.preventDefault(); assetPicker.showFinder('##{input_html_options[:id]}', #{editor_options.to_json.html_safe})})})</script>".html_safe

        end
      end

    end
    
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rich-1.2.0 app/inputs/rich_picker_input.rb
rich-1.1.0 app/inputs/rich_picker_input.rb
rich-1.0.3 app/inputs/rich_picker_input.rb
rich-1.0.2 app/inputs/rich_picker_input.rb
rich-1.0.1 app/inputs/rich_picker_input.rb
rich-1.0.0 app/inputs/rich_picker_input.rb