Class: Maglove::Widgets::Container

Inherits:
Base
  • Object
show all
Defined in:
lib/maglove/widgets/container.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from Base

#initialize, #widget_options

Constructor Details

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

Instance Method Details

#container_classesObject



33
34
35
36
37
38
39
# File 'lib/maglove/widgets/container.rb', line 33

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-parallax") if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
  classes.join(" ")
end

#container_optionsObject



23
24
25
26
27
# File 'lib/maglove/widgets/container.rb', line 23

def container_options
  result = { class: container_classes, style: container_styles }
  result["data-parallax-style"] = @options[:parallax_effect] if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
  result
end

#container_stylesObject



41
42
43
# File 'lib/maglove/widgets/container.rb', line 41

def container_styles
  style_string @options, :border, :border_radius, :border_width, :border_style, :border_color, :min_height
end

#defaultsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/maglove/widgets/container.rb', line 8

def defaults
  {
    animate: "none",
    parallax_effect: "none",
    border_radius: "",
    border_width: "",
    border_style: "",
    border_color: "transparent",
    style: "default",
    min_height: "",
    max_height: "",
    overflow_y: ""
  }
end

#identifierObject



4
5
6
# File 'lib/maglove/widgets/container.rb', line 4

def identifier
  "container"
end

#image_optionsObject



29
30
31
# File 'lib/maglove/widgets/container.rb', line 29

def image_options
  { class: "one-container-image", style: image_styles }
end

#image_stylesObject



45
46
47
# File 'lib/maglove/widgets/container.rb', line 45

def image_styles
  style_string @options, :max_height, :overflow_y
end

#template(&block) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/maglove/widgets/container.rb', line 49

def template(&block)
  haml_tag :section, container_options do
    haml_tag :div, image_options do
      yield if block
    end
  end
end