class Maglove::Widget::LegacyContainer

Public Instance Methods

defaults() click to toggle source
# File lib/maglove/widget/container.rb, line 29
def defaults
  {
    animate: "none",
    image_source: false,
    image_position: "center_center",
    image_size: "cover",
    parallax_effect: "none",
    parallax_speed: 0.6,
    background_color: nil,
    bg_color: nil,
    opacity: nil,
    border_radius: nil,
    border_width: nil,
    border_color: "#111111",
    border_style: nil,
    style: "default",
    padding_top: nil,
    padding_right: nil,
    padding_bottom: nil,
    padding_left: nil,
    alignment: "center",
    min_height: nil,
    max_height: nil,
    max_width: nil,
    margin_top: nil,
    margin_right: nil,
    margin_bottom: nil,
    margin_left: nil,
    overflow_y: nil
  }
end
identifier() click to toggle source
# File lib/maglove/widget/container.rb, line 25
def identifier
  "container"
end
render() { |self| ... } click to toggle source
Calls superclass method Maglove::Widget::V1#render
# File lib/maglove/widget/container.rb, line 61
def render(&block)
  super do
    haml_tag :section, container_options do
      haml_tag :div, image_options do
        yield self if block_given?
        drop_container
      end
    end
  end
end

Private Instance Methods

container_classes() click to toggle source
# File lib/maglove/widget/container.rb, line 87
def container_classes
  classes = ["one-container"]
  classes.push("animate #{options[:animate]}") if options[:animate] != "none"
  classes.push("container-#{options[:style]}") unless options[:style].empty?
  classes.push("container-image-#{options[:image_size]}") unless options[:image_size].empty?
  classes.push("container-parallax") if !options[:parallax_effect].empty? and options[:parallax_effect] != "none"
  classes.join(" ")
end
container_options() click to toggle source
# File lib/maglove/widget/container.rb, line 74
def container_options
  result = { class: container_classes, style: container_styles }
  if !options[:parallax_effect].empty? and options[:parallax_effect] != "none"
    result["data-parallax-style"] = options[:parallax_effect]
    result["data-parallax-speed"] = options[:parallax_speed]
  end
  result
end
container_styles() click to toggle source
# File lib/maglove/widget/container.rb, line 96
def container_styles
  style_string options, :opacity, :border, :opacity, :border_radius, :border_width, :border_color, :border_style, :margin do |sb|
    sb.add(:background_color, (options[:background_color] == "custom") ? options[:bg_color] : nil)
    if options[:background_color] == "overlay"
      sb.add(:background_image, options[:image_source], "linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(<%= value %>)")
    else
      sb.add(:background_image, options[:image_source], "url(<%= value %>)")
    end
    sb.add(:background_position, options[:image_position], "<%= value.split('_').join(' ') %>")
  end
end
image_options() click to toggle source
# File lib/maglove/widget/container.rb, line 83
def image_options
  { class: "one-container-image", style: image_styles }
end
image_styles() click to toggle source
# File lib/maglove/widget/container.rb, line 108
def image_styles
  if options[:alignment] == "left"
    options[:margin_left] = "0"
    options[:margin_right] = "auto"
  elsif options[:alignment] == "right"
    options[:margin_left] = "auto"
    options[:margin_right] = "0"
  else
    options[:margin_left] = "auto"
    options[:margin_right] = "auto"
  end

  style_string options, :min_height, :max_height, :max_width, :padding, :overflow_y, :margin_left, :margin_right
end