lib/maglove/widgets/container.rb in maglove-widgets-1.1.9 vs lib/maglove/widgets/container.rb in maglove-widgets-2.0.0
- old
+ new
@@ -5,46 +5,30 @@
"container"
end
def defaults
{
- animate: "none",
- image_source: false,
- image_position: "center_center",
- image_size: "cover",
- parallax_effect: "none",
- parallax_speed: 0.6,
- background_color: "",
- bg_color: "",
- opacity: "",
- border_radius: "",
- border_width: "",
- border_color: "#111111",
- border_style: "",
- style: "default",
- padding_top: "",
- padding_right: "",
- padding_bottom: "",
- padding_left: "",
- alignment: "center",
- min_height: "",
- max_height: "",
- max_width: "",
- margin_top: "",
- margin_right: "",
- margin_bottom: "",
- margin_left: "",
- overflow_y: ""
+ animate: "none",
+ image_source: false,
+ image_position: "center_center",
+ parallax_effect: "none",
+ bg_color: "",
+ opacity: "",
+ border_radius: "",
+ border_width: "",
+ border_style: "",
+ border_color: "transparent",
+ style: "default",
+ min_height: "",
+ max_height: "",
+ overflow_y: ""
}
end
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["data-parallax-style"] = @options[:parallax_effect] if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
result
end
def image_options
{ class: "one-container-image", style: image_styles }
@@ -52,40 +36,20 @@
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
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 %>)")
- elsif
- sb.add(:background_image, @options[:image_source], "url(<%= value %>)")
- end
- sb.add(:background_position, @options[:image_position], "<%= value.split('_').join(' ') %>")
- end
+ style_string @options, :opacity, :border, :opacity, :border_radius, :border_width, :border_style, :border_color, :min_height
end
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
+ style_string @options, :max_height, :overflow_y
end
module Helpers
def container_widget(options = {}, &block)
widget_block(Widgets::Container.new(options)) do |widget|
@@ -98,6 +62,6 @@
end
end
end
end
end
-end
\ No newline at end of file
+end