Class: Maglove::Widget::LegacyButton

Inherits:
V1
  • Object
show all
Defined in:
lib/maglove/widget/button.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

#button_attributesObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/maglove/widget/button.rb', line 40

def button_attributes
  {
    "class" => "_typeloft_editable btn btn-#{options[:style]} #{options[:size]} #{options[:type]} #{options[:media] ? 'btn-media' : ''}",
    "href" => (options[:href] or "#"),
    "style" => style_string(options, :border_radius, :border_width, :border_style, :border_color, :background_color) do |sb|
      sb.add(:border_style, "solid")
    end,
    "data-media" => options[:media]
  }
end

#defaultsObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/maglove/widget/button.rb', line 27

def defaults
  {
    background_color: "#e6e6e6",
    border_radius: "4px",
    border_width: "1px",
    border_style: "solid",
    media: false,
    size: "btn-lg",
    style: "primary",
    type: "btn-fit"
  }
end

#identifierObject



23
24
25
# File 'lib/maglove/widget/button.rb', line 23

def identifier
  "button"
end

#render(&block) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/maglove/widget/button.rb', line 51

def render(&block)
  super do
    haml_tag :a, button_attributes do
      if options[:media] and !options[:media].blank?
        haml_tag :video do
          haml_tag :source, { src: options[:media], type: "video/mp4" }
        end
      end
      yield self if block_given?
    end
  end
end