# File app/inputs/rich_picker_input.rb, line 7 def to_html @editor_options = Rich.options(options[:config], object_name, object.id) local_input_options = { :class => 'rich-picker', :style => editor_options[:style] } input_wrapping do label_html << input_field(local_input_options) << button << preview << javascript end end
# File app/inputs/rich_picker_input.rb, line 26 def input_field(local_input_options) if editor_options[:hidden_input] == true builder.hidden_field(method, local_input_options.merge(input_html_options)) else builder.text_field(method, local_input_options.merge(input_html_options)) end end
# File app/inputs/rich_picker_input.rb, line 58 def javascript %Q{ <script> $(function(){ $('##{input_html_options[:id]}_input a').click(function(e){ e.preventDefault(); assetPicker.showFinder('##{input_html_options[:id]}', #{editor_options.to_json}) }); }); </script> }.html_safe end
# File app/inputs/rich_picker_input.rb, line 70 def preview return unless editor_options[:type] != 'file' path = preview_image_path klass = "class='rich-image-preview'" style = "style='max-width:#{editor_options[:preview_size]}; max-height:#{editor_options[:preview_size]};'" if path %Q{ </br></br><img src='#{preview_image_path}' #{klass} #{style} /> }.html_safe else %Q{ </br></br><div #{klass} #{style}></div> }.html_safe end end
# File app/inputs/rich_picker_input.rb, line 34 def preview_image_path method_value = object.send(method) # return placeholder image if this is a non-image picker OR if there is no value set return editor_options[:placeholder_image] if editor_options[:type].to_s == 'file' return editor_options[:placeholder_image] unless method_value.present? column_type = column_for(method).type if column_type == :integer file = Rich::RichFile.find(method_value) file.rich_file.url(:rich_thumb) #we ask paperclip directly for the file, so asset paths should not be an issue else # should be :string method_value end end