Module: Imaginable::InstanceTag
- Defined in:
- lib/imaginable/form_builder.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
25 26 27 |
# File 'lib/imaginable/form_builder.rb', line 25 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#build_imaginable_crop_content(options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/imaginable/form_builder.rb', line 62 def build_imaginable_crop_content( = {}) has_existing_image = @object.method("has_#{method_name}?").call if has_existing_image image = @object.method("#{method_name}").call end dom_prefix = "#{@object_name}_#{@method_name}" container_div = content_tag('div', :style => 'display:none', :class => 'imaginable_crop_container') { content_div = content_tag('div', :id => "#{dom_prefix}_imaginable_crop_content", :class => 'imaginable_crop_content') { content_div_content = content_tag('div', :id => "#{dom_prefix}_imaginable_crop_header", :class => 'imaginable_crop_header') {"Crop Image"} content_div_content << content_tag('div', :id => "#{dom_prefix}_imaginable_crop_description", :class => 'imaginable_crop_description') {"Please crop your image by dragging the corners of the crop-selection."} if has_existing_image content_div_content << tag('img', :id => "#{dom_prefix}_imaginable_crop_image", :class => 'imaginable_crop_image', :src => image.url(:format => 'none', :width => 500, :height => 500)) else content_div_content << tag('img', :id => "#{dom_prefix}_imaginable_crop_image", :class => 'imaginable_crop_image', :src => '/images/blank.gif') end content_div_content << content_tag('div', :id => "#{dom_prefix}_imageinable_crop_buttons", :class => 'imaginable_crop_buttons') { = content_tag('a', :id => "#{dom_prefix}_imaginable_cancel_crop_button", :class => 'imaginable_cancel_crop_button', :href => '#') {"Cancel"} << content_tag('a', :id => "#{dom_prefix}_imaginable_save_crop_button", :class => 'imaginable_save_crop_button', :href => '#') {"Save"} } } } end |
#to_image_field_tag(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/imaginable/form_builder.rb', line 29 def to_image_field_tag( = {}) has_existing_image = @object.method("has_#{method_name}?").call if has_existing_image image = @object.method("#{method_name}").call end [:preview_width] ||= 0 [:preview_height] ||= 0 dom_prefix = "#{@object_name}_#{@method_name}" tag_text = content_tag('div', :id => "#{dom_prefix}_container", :class => "imaginable", :'data-imaginable-prefix' => dom_prefix, :'data-imaginable-upload-server' => Imaginable.upload_server, :'data-imaginable-scale-server' => Imaginable.scale_server, :'data-imaginable-preview-width' => [:preview_width], :'data-imaginable-force-crop' => [:force_crop], :'data-imaginable-format' => [:format], :'data-imaginable-new-version' => "'#{UUIDTools::UUID..to_i.to_s}'") { sub_tag_text = build_imaginable_crop_content() if has_existing_image sub_tag_text << tag('img', :id => "#{dom_prefix}_preview_image", :src => image.url(:format => [:format], :width => [:preview_width], :height => [:preview_height]), :class => "imaginable_preview_image") else sub_tag_text << tag('img', :id => "#{dom_prefix}_preview_image", :src => '/images/blank.gif', :style => 'display:none;', :class => "imaginable_preview_image") end sub_tag_text << content_tag('div', :id => "#{dom_prefix}_file_list", :class => "imaginable_file_list") { "" } sub_tag_text << content_tag('a', :id => "#{dom_prefix}_browse_button", :class => 'imaginable_browse_files_button', :href => '#') { "Select file" } sub_tag_text << content_tag('a', :id => "#{dom_prefix}_crop_button", :class => 'imaginable_crop_button', :href => "##{dom_prefix}_imaginable_crop_content", :style => "display:none;") { "Crop Image" } } end |