class Maglove::Widgets::Button

Public Instance Methods

button_classes() click to toggle source
# File lib/maglove/widgets/button.rb, line 21
def button_classes
  classes = ["btn", "btn-#{@options[:style]}", @options[:size], @options[:type], "_typeloft_editable"]
  classes.push("btn-media") if @options[:media]
  classes.join(" ")
end
button_options() click to toggle source
# File lib/maglove/widgets/button.rb, line 27
def button_options
  result = { class: button_classes, href: (@options[:href] or "#"), style: button_styles }
  result["data-media"] = @options[:media] if @options[:media] and !@options[:media].empty?
  result
end
button_styles() click to toggle source
# File lib/maglove/widgets/button.rb, line 33
def button_styles
  style_string @options, :border_radius, :border_width, :border_style, :border_color, :background_color do |sb|
    sb.add(:border_style, "solid")
  end
end
defaults() click to toggle source
# File lib/maglove/widgets/button.rb, line 8
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
identifier() click to toggle source
# File lib/maglove/widgets/button.rb, line 4
def identifier
  "button"
end
template(scope) { || ... } click to toggle source
# File lib/maglove/widgets/button.rb, line 39
def template(scope, &block)
  scope.haml_tag :a, button_options do
    if options[:media] and !options[:media].blank?
      scope.haml_tag :video do
        scope.haml_tag :source, { src: options[:media], type: "video/mp4" }
      end
    end
    yield if block
  end
end