Module: Crimagify::ApplicationHelper
- Defined in:
- app/helpers/crimagify/application_helper.rb
Instance Method Summary collapse
- #image_cropper(object, options, image_options = {}) ⇒ Object
- #images_id(object) ⇒ Object
- #link_to_add_fields(name, f, association) ⇒ Object
- #nested_image_cropper(object, options, image_options = {}) ⇒ Object
- #nested_images_id(object) ⇒ Object
Instance Method Details
#image_cropper(object, options, image_options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/crimagify/application_helper.rb', line 4 def image_cropper(object, , = {}) [:class] = "#{[:class]} img_start" img = object.crimagify_images.where("image_name=?", [:image_name]) version_name = [:ratio] if [:label_title].nil? [:label_title] == "Image" end if [:choose_text].nil? [:choose_text] == "Choose image" end if img == [] url_image = "crimagify/no_selected_image.jpg" else url_image = img.first.image_url([:ratio]).to_s rescue "" end if url_image == "" if ENV['DEFAULT_IMAGE'].nil? url_image = "crimagify/no_selected_image.jpg" else url_image = ENV['DEFAULT_IMAGE'].to_s end end render(:partial => "crimagify/crop_partials/fields_cropper", :locals => { id_image: [:image_name], url_image: url_image, image_options: , version_name: version_name, label_title: [:label_title], choose_text: [:choose_text] }) end |
#images_id(object) ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/helpers/crimagify/application_helper.rb', line 29 def images_id(object) html = "" html << content_tag(:input, nil, :id => :parent, :name => :parent, :type => :hidden, :value => "#{object.class.name}") html << content_tag(:input, nil, :id => :parent_id, :name => :parent_id, :type => :hidden, :value => "#{object.id}") html << content_tag(:input, nil, :id => :id_images, :name => :id_images, :type => :hidden, :value => "") return raw html end |
#link_to_add_fields(name, f, association) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/crimagify/application_helper.rb', line 74 def link_to_add_fields(name, f, association) new_object = f.object.send(association).klass.new #data variables parent_object = f.object.class.name.underscore id = new_object.object_id tag_parent = association.to_s fields = f.fields_for(association, new_object, child_index: id) do |builder| render(association.to_s.singularize + "_fields", f: builder) end link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", ""), parent: tag_parent, parentobject: parent_object}) end |
#nested_image_cropper(object, options, image_options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/crimagify/application_helper.rb', line 37 def nested_image_cropper(object, , = {}) [:class] = "#{[:class]} img_start" img = object.crimagify_images.where("image_name=?", [:image_name]) version_name = [:ratio] if [:label_title].nil? [:label_title] == "Image" end if [:choose_text].nil? [:choose_text] == "Choose image" end if img == [] if ENV['DEFAULT_IMAGE'].nil? url_image = "crimagify/no_selected_image.jpg" else url_image = ENV['DEFAULT_IMAGE'].to_s end else url_image = img.first.image_url([:ratio]).to_s rescue "" end if url_image == "" if ENV['DEFAULT_IMAGE'].nil? url_image = "crimagify/no_selected.jpg" else url_image = ENV['DEFAULT_IMAGE'].to_s end end render(:partial => "crimagify/crop_partials/nested_cropper", :locals => { id_image: [:image_name], url_image: url_image, image_options: , version_name: version_name, label_title: [:label_title], choose_text: [:choose_text] }) end |
#nested_images_id(object) ⇒ Object
66 67 68 69 70 71 72 |
# File 'app/helpers/crimagify/application_helper.rb', line 66 def nested_images_id(object) html = "" html << content_tag(:input, nil, :class => :parent, :name => :parent, :type => :hidden, :value => "#{object.class.name}") html << content_tag(:input, nil, :class => :parent_id, :name => :parent_id, :type => :hidden, :value => "#{object.id}") html << content_tag(:input, nil, :class => :id_images, :name => :id_images, :type => :hidden, :value => "") return raw html end |