Class: Maglove::Widgets::Slider
- Inherits:
-
Base
- Object
- Base
- Maglove::Widgets::Slider
show all
- Defined in:
- lib/maglove/widgets/slider.rb
Defined Under Namespace
Modules: Helpers
Instance Attribute Summary
Attributes inherited from Base
#options, #scope
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #widget_options
Instance Method Details
#defaults ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/maglove/widgets/slider.rb', line 8
def defaults
{
slides: "3",
height: "auto",
margin_bottom: "0px",
background_color: "#EEEEEE",
buttons_position: "bottom",
autoplay: "true",
autoplay_timeout: "3000"
}
end
|
#identifier ⇒ Object
4
5
6
|
# File 'lib/maglove/widgets/slider.rb', line 4
def identifier
"slider"
end
|
#slider_classes ⇒ Object
32
33
34
35
36
|
# File 'lib/maglove/widgets/slider.rb', line 32
def slider_classes
classes = ["owl-carousel", "owl-loaded", "owl-text-select-on", "owl-theme"]
classes.push("position-#{@options[:buttons_position]}") unless @options[:buttons_position].empty?
classes.join(" ")
end
|
#slider_options ⇒ Object
20
21
22
23
|
# File 'lib/maglove/widgets/slider.rb', line 20
def slider_options
data = { class: slider_classes, autoplay: @options[:autoplay], autoplay_timeout: @options[:autoplay_timeout] }
{ class: "owl-carousel", style: slider_styles, data: data }
end
|
#slider_styles ⇒ Object
25
26
27
28
29
30
|
# File 'lib/maglove/widgets/slider.rb', line 25
def slider_styles
style_string @options, :margin, :height, :background_color do |sb|
sb.add(:min_height, "120px")
sb.add(:overflow, "hidden")
end
end
|
#template(&block) ⇒ Object
38
39
40
41
42
|
# File 'lib/maglove/widgets/slider.rb', line 38
def template(&block)
haml_tag :div, slider_options do
yield if block
end
end
|