Class: Maglove::Widget::LegacyImage

Inherits:
V1
  • Object
show all
Defined in:
lib/maglove/widget/image.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from V1

#drop_container, #widget_options

Methods inherited from Base

#initialize, #style_string, #widget_options

Constructor Details

This class inherits a constructor from Maglove::Widget::Base

Instance Method Details

#defaultsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/maglove/widget/image.rb', line 26

def defaults
  {
    style: "img-responsive",
    align: "center",
    title: nil,
    source: false,
    magnify: false,
    magnify_title: nil,
    margin_bottom: "0",
    max_width: "100%",
    min_width: "0",
    tooltip_icon: "bullhorn",
    tooltip_text_alignment: "justify",
    tooltip_text_size: "medium",
    tooltip_position: "top-right",
    tooltip_text: nil
  }
end

#identifierObject



22
23
24
# File 'lib/maglove/widget/image.rb', line 22

def identifier
  "image"
end

#render(&block) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/maglove/widget/image.rb', line 45

def render(&block)
  super do
    image_class = "image-widget align-#{options[:align]}"
    image_class += " popup-position-#{options[:tooltip_position]}" unless options[:tooltip_text].nil?
    haml_tag :div, class: image_class, style: "min-width: #{options[:min_width]}; max-width: #{options[:max_width]}; #{style_string(options, :margin, :padding)}" do
      wrap_image_link do
        unless options[:tooltip_text].nil?
          haml_tag :i, class: "popup fa fa-lg fa-#{options[:tooltip_icon]}"
          haml_tag :div, class: "popup-box", style: "font-size: #{options[:tooltip_text_size]}, text-align: #{options[:tooltip_text_alignment]};" do
            haml_concat(options[:tooltip_text])
          end
        end
        haml_tag :img, class: "image #{options[:style]} #{options[:magnify] ? 'magnific-image' : ''}", src: options[:source], title: options[:title], data: {magnify_title: options[:magnify_title]}
        haml_tag :div, class: "image-drop-target"
      end
    end
  end
end