maglove-widgets 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 747d243b052fb6e447af302a6a501cef1e5e6f16
4
+ data.tar.gz: 0cdc2815023a692cb50027edbf7c03be6f9d9890
5
+ SHA512:
6
+ metadata.gz: d13fa67542c94ff7c5d271d909adbee91fcdeaefca4c8300ca9617a9ca9f4cabe48dbd81cb858131ecd9652b003ce1c97651e934aaaffbea5e62a98e5321da02
7
+ data.tar.gz: 26c4c6fb495c36a6d3f84dd60605c0dbdfb3154d9053dc3cec09982f97fe4a46419ebc1cf33275f084d26e48ee9e1f65aa30da1702c65709485bee80348221ce
@@ -0,0 +1,3 @@
1
+ /.env
2
+ .DS_Store
3
+ /maglove-widgets-*.gem
@@ -0,0 +1,157 @@
1
+ # kind_of? is a good way to check a type
2
+ Style/ClassCheck:
3
+ EnforcedStyle: kind_of?
4
+
5
+ # It's better to be more explicit about the type
6
+ Style/BracesAroundHashParameters:
7
+ Enabled: false
8
+
9
+ # specs sometimes have useless assignments, which is fine
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - '**/spec/**/*'
13
+
14
+ # We could potentially enable the 2 below:
15
+ Style/IndentHash:
16
+ Enabled: false
17
+
18
+ Style/AlignHash:
19
+ Enabled: false
20
+
21
+ # HoundCI doesn't like this rule
22
+ Style/DotPosition:
23
+ Enabled: false
24
+
25
+ # We allow !! as it's an easy way to convert ot boolean
26
+ Style/DoubleNegation:
27
+ Enabled: false
28
+
29
+ # Sometimes we allow a rescue block that doesn't contain code
30
+ Lint/HandleExceptions:
31
+ Enabled: false
32
+
33
+ # Cop supports --auto-correct.
34
+ Lint/UnusedBlockArgument:
35
+ Enabled: false
36
+
37
+ # Needed for $verbose
38
+ Style/GlobalVars:
39
+ Enabled: false
40
+
41
+ # We want to allow class Fastlane::Class
42
+ Style/ClassAndModuleChildren:
43
+ Enabled: false
44
+
45
+ # $? Exit
46
+ Style/SpecialGlobalVars:
47
+ Enabled: false
48
+
49
+ Metrics/AbcSize:
50
+ Enabled: false
51
+
52
+ Metrics/MethodLength:
53
+ Enabled: false
54
+
55
+ Metrics/CyclomaticComplexity:
56
+ Enabled: false
57
+
58
+ # The %w might be confusing for new users
59
+ Style/WordArray:
60
+ MinSize: 19
61
+
62
+ # raise and fail are both okay
63
+ Style/SignalException:
64
+ Enabled: false
65
+
66
+ # Better too much 'return' than one missing
67
+ Style/RedundantReturn:
68
+ Enabled: false
69
+
70
+ # Having if in the same line might not always be good
71
+ Style/IfUnlessModifier:
72
+ Enabled: false
73
+
74
+ # and and or is okay
75
+ Style/AndOr:
76
+ Enabled: false
77
+
78
+ # Configuration parameters: CountComments.
79
+ Metrics/ClassLength:
80
+ Max: 320
81
+
82
+
83
+ # Configuration parameters: AllowURI, URISchemes.
84
+ Metrics/LineLength:
85
+ Max: 370
86
+
87
+ # Configuration parameters: CountKeywordArgs.
88
+ Metrics/ParameterLists:
89
+ Max: 17
90
+
91
+ Metrics/PerceivedComplexity:
92
+ Max: 20
93
+
94
+ # Sometimes it's easier to read without guards
95
+ Style/GuardClause:
96
+ Enabled: false
97
+
98
+ # We allow both " and '
99
+ Style/StringLiterals:
100
+ Enabled: false
101
+
102
+ # something = if something_else
103
+ # that's confusing
104
+ Style/ConditionalAssignment:
105
+ Enabled: false
106
+
107
+ # Better to have too much self than missing a self
108
+ Style/RedundantSelf:
109
+ Enabled: false
110
+
111
+ # e.g.
112
+ # def self.is_supported?(platform)
113
+ # we may never use `platform`
114
+ Lint/UnusedMethodArgument:
115
+ Enabled: false
116
+
117
+ # the let(:key) { ... }
118
+ Lint/ParenthesesAsGroupedExpression:
119
+ Exclude:
120
+ - '**/spec/**/*'
121
+
122
+ # This would reject is_ in front of methods
123
+ # We use `is_supported?` everywhere already
124
+ Style/PredicateName:
125
+ Enabled: false
126
+
127
+ # We allow the $
128
+ Style/PerlBackrefs:
129
+ Enabled: false
130
+
131
+ # Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb
132
+ Style/SpaceAroundOperators:
133
+ Exclude:
134
+ - '**/spec/actions_specs/xcodebuild_spec.rb'
135
+
136
+ AllCops:
137
+ Include:
138
+ - '**/fastlane/Fastfile'
139
+ Exclude:
140
+ - './vendor/**/*'
141
+ - db/schema.rb
142
+
143
+ # We're not there yet
144
+ Style/Documentation:
145
+ Enabled: false
146
+
147
+ # Added after upgrade to 0.38.0
148
+ Style/MutableConstant:
149
+ Enabled: false
150
+
151
+ # length > 0 is good
152
+ Style/ZeroLengthPredicate:
153
+ Enabled: false
154
+
155
+ # Adds complexity
156
+ Style/IfInsideElse:
157
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ maglove-widgets (1.0.0)
5
+ bundler (~> 1.10)
6
+ haml (~> 4.0)
7
+ hamloft (~> 0.2.4)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ haml (4.0.7)
13
+ tilt
14
+ hamloft (0.2.4)
15
+ haml (~> 4.0)
16
+ nokogiri (~> 1.6)
17
+ mini_portile2 (2.1.0)
18
+ nokogiri (1.6.8.1)
19
+ mini_portile2 (~> 2.1.0)
20
+ tilt (2.0.5)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ maglove-widgets!
27
+
28
+ BUNDLED WITH
29
+ 1.12.4
@@ -0,0 +1,2 @@
1
+ [MagLove Widgets](http://bitbucket.org/magloft/maglove-widgets/) - MagLove Widgets
2
+ ==================================================================================
@@ -0,0 +1,32 @@
1
+ require "maglove/widgets/base"
2
+ require "maglove/widgets/banner"
3
+ require "maglove/widgets/button"
4
+ require "maglove/widgets/columns"
5
+ require "maglove/widgets/container"
6
+ require "maglove/widgets/heading"
7
+ require "maglove/widgets/horizontal_rule"
8
+ require "maglove/widgets/image"
9
+ require "maglove/widgets/paragraph"
10
+ require "maglove/widgets/scrollable_image"
11
+ require "maglove/widgets/slider"
12
+ require "maglove/widgets/video"
13
+ require "maglove/widgets/yahoo_screen"
14
+ require "maglove/widgets/youtube"
15
+
16
+ module Maglove
17
+ module Widgets
18
+ Hamloft.register_widget(Banner)
19
+ Hamloft.register_widget(Button)
20
+ Hamloft.register_widget(Columns)
21
+ Hamloft.register_widget(Container)
22
+ Hamloft.register_widget(Heading)
23
+ Hamloft.register_widget(HorizontalRule)
24
+ Hamloft.register_widget(Image)
25
+ Hamloft.register_widget(Paragraph)
26
+ Hamloft.register_widget(ScrollableImage)
27
+ Hamloft.register_widget(Slider)
28
+ Hamloft.register_widget(Video)
29
+ Hamloft.register_widget(YahooScreen)
30
+ Hamloft.register_widget(Youtube)
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Banner < Base
4
+ def identifier
5
+ "banner"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ style: "dark",
11
+ alignment: "center"
12
+ }
13
+ end
14
+ end
15
+ module Helpers
16
+ def banner_widget(options = {}, &block)
17
+ widget_block(Widgets::Banner.new(options)) do |widget|
18
+ haml_tag :div, class: "banner-outer align-#{widget.options[:alignment]}" do
19
+ haml_tag :div, class: "banner banner-#{widget.options[:style]}" do
20
+ yield if block
21
+ drop_container
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Base
4
+ include Hamloft::Helpers
5
+ attr_accessor :options
6
+
7
+ def identifier
8
+ "base"
9
+ end
10
+
11
+ def defaults
12
+ {}
13
+ end
14
+
15
+ def initialize(options)
16
+ @options = defaults.merge(options)
17
+ end
18
+
19
+ def typeloft_widget_options
20
+ attributes = {
21
+ :class => "_typeloft_widget",
22
+ :"data-widget-identifier" => identifier
23
+ }
24
+ @options.each do |k, v|
25
+ if k == :padding or k == :margin
26
+ [:top, :right, :bottom, :left].each do |dir|
27
+ attributes["data-attribute-#{k}_#{dir}"] = v
28
+ end
29
+ end
30
+ attributes["data-attribute-#{k}"] = v
31
+ end
32
+ attributes
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,60 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Button < Base
4
+ def identifier
5
+ "button"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ background_color: "#e6e6e6",
11
+ border_radius: "4px",
12
+ border_width: "1px",
13
+ border_style: "solid",
14
+ media: false,
15
+ size: "btn-lg",
16
+ style: "primary",
17
+ type: "btn-fit"
18
+ }
19
+ end
20
+
21
+ def button_classes
22
+ classes = ["btn", "btn-#{@options[:style]}", @options[:size], @options[:type], "_typeloft_editable"]
23
+ classes.push("btn-media") if @options[:media]
24
+ classes.join(" ")
25
+ end
26
+
27
+ def button_options
28
+ result = { class: button_classes, href: (@options[:href] or "#"), style: button_styles }
29
+ result["data-media"] = @options[:media] if @options[:media] and !@options[:media].empty?
30
+ result
31
+ end
32
+
33
+ def button_styles
34
+ style_string @options, :border_radius, :border_width, :border_style, :border_color, :background_color do |sb|
35
+ sb.add(:border_style, "solid")
36
+ end
37
+ end
38
+
39
+ module Helpers
40
+ def button_widget(options = {}, contents = nil, &block)
41
+ if options.class.name == "String"
42
+ contents = options
43
+ options = {}
44
+ end
45
+ widget_block(Widgets::Button.new(options)) do |widget|
46
+ haml_tag :a, widget.button_options do
47
+ if widget.options[:media] and !widget.options[:media].blank?
48
+ haml_tag :video do
49
+ haml_tag :source, { src: widget.options[:media], type: "video/mp4" }
50
+ end
51
+ end
52
+ haml_concat(contents) if contents
53
+ yield if block
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,90 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Columns < Base
4
+ attr_reader :columns
5
+ attr_reader :column_count
6
+ attr_reader :total_columns
7
+
8
+ def initialize(options)
9
+ super(options)
10
+ @column_count = 0
11
+ column_array = @options[:columns].to_s.split("x")
12
+ if column_array.length == 1
13
+ @total_columns = column_array[0].to_i
14
+ @columns = Array.new(@total_columns) { 12 / @total_columns }
15
+ else
16
+ @total_columns = column_array.length
17
+ @columns = column_array
18
+ end
19
+ end
20
+
21
+ def next_span
22
+ value = @columns[@column_count]
23
+ @column_count += 1
24
+ value
25
+ end
26
+
27
+ def row_options
28
+ {
29
+ class: "row row-#{@options[:style]}",
30
+ style: style_string(@options, :margin_bottom)
31
+ }
32
+ end
33
+
34
+ def identifier
35
+ "columns"
36
+ end
37
+
38
+ def defaults
39
+ {
40
+ columns: "2",
41
+ style: "default",
42
+ margin_bottom: "",
43
+ collapse_options: "sm"
44
+ }
45
+ end
46
+
47
+ module Helpers
48
+ def column(row, &block)
49
+ # get and increase span
50
+ next_span = row.next_span
51
+ if next_span
52
+ phone_cols = row.options[:collapse_options] == "xs" ? next_span : "12"
53
+ haml_tag :div, class: "column col-#{phone_cols} col-tablet-#{next_span} col-#{row.options[:collapse_options]}-#{next_span}" do
54
+ yield if block
55
+ drop_container
56
+ end
57
+ else
58
+ haml_tag :pre do
59
+ haml_concat "ERROR: Row does not allow column at position #{row.column_count}"
60
+ end
61
+ end
62
+ end
63
+
64
+ def columns_widget(options = {}, &block)
65
+ widget_block(Widgets::Columns.new(options)) do |widget|
66
+ haml_tag :div, widget.row_options do
67
+ yield(widget) if block
68
+ end
69
+ end
70
+ end
71
+
72
+ def columns_widget_compose(key, options = {}, &block)
73
+ columns_widget = Widgets::Columns.new(options)
74
+ items = variable(key, [])
75
+ # calculate row and column count
76
+ row_count = (items.length.to_f / columns_widget.total_columns).ceil
77
+ col_count = columns_widget.total_columns
78
+ (0...row_count).each do |row_index|
79
+ columns_widget(options) do |row|
80
+ (0...col_count).each do |col_index|
81
+ index = (row_index * col_count) + col_index
82
+ yield(row, items[index]) unless items[index].nil?
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,84 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Container < Base
4
+ def identifier
5
+ "container"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ animate: "none",
11
+ image_source: false,
12
+ image_position: "center_center",
13
+ image_size: "cover",
14
+ parallax_effect: "none",
15
+ background_color: "",
16
+ bg_color: "",
17
+ opacity: "",
18
+ border_radius: "",
19
+ border_width: "",
20
+ border_style: "",
21
+ style: "default",
22
+ padding_top: "",
23
+ padding_right: "",
24
+ padding_bottom: "",
25
+ padding_left: "",
26
+ min_height: "",
27
+ max_height: "",
28
+ margin_top: "",
29
+ margin_right: "",
30
+ margin_bottom: "",
31
+ margin_left: ""
32
+ }
33
+ end
34
+
35
+ def container_options
36
+ result = { class: container_classes, style: container_styles }
37
+ result["data-parallax-style"] = @options[:parallax_effect] if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
38
+ result
39
+ end
40
+
41
+ def image_options
42
+ { class: "one-container-image", style: image_styles }
43
+ end
44
+
45
+ def container_classes
46
+ classes = ["one-container"]
47
+ classes.push("animate #{@options[:animate]}") if @options[:animate] != "none"
48
+ classes.push("container-#{@options[:style]}") unless @options[:style].empty?
49
+ classes.push("container-image-#{@options[:image_size]}") unless @options[:image_size].empty?
50
+ classes.push("container-parallax") if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
51
+ classes.join(" ")
52
+ end
53
+
54
+ def container_styles
55
+ style_string @options, :opacity, :border, :opacity, :border_radius, :border_width, :border_style, :margin do |sb|
56
+ sb.add(:background_color, @options[:background_color] == "custom" ? @options[:bg_color] : nil)
57
+ if @options[:background_color] == "overlay"
58
+ sb.add(:background_image, @options[:image_source], "linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(<%= value %>)")
59
+ else
60
+ sb.add(:background_image, @options[:image_source], "url(<%= value %>)")
61
+ end
62
+ sb.add(:background_position, @options[:image_position], "<%= value.split('_').join(' ') %>")
63
+ end
64
+ end
65
+
66
+ def image_styles
67
+ style_string @options, :min_height, :max_height, :padding
68
+ end
69
+
70
+ module Helpers
71
+ def container_widget(options = {}, &block)
72
+ widget_block(Widgets::Container.new(options)) do |widget|
73
+ haml_tag :section, widget.container_options do
74
+ haml_tag :div, widget.image_options do
75
+ yield if block
76
+ drop_container
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,35 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Heading < Base
4
+ def identifier
5
+ "heading"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ type: "h1",
11
+ style: "default",
12
+ align: "left",
13
+ margin_bottom: "1em"
14
+ }
15
+ end
16
+
17
+ module Helpers
18
+ def heading_widget(options = {}, contents = nil, &block)
19
+ if options.class.name == "String"
20
+ contents = options
21
+ options = {}
22
+ end
23
+ widget_block(Widgets::Heading.new(options)) do |widget|
24
+ haml_tag :header, class: "#{widget.options[:style]} align-#{widget.options[:align]}", style: style_string(widget.options, :margin, :padding) do
25
+ haml_tag widget.options[:type], class: "_typeloft_editable _typeloft_widget_autoselect" do
26
+ haml_concat(contents) if contents
27
+ yield if block
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module Maglove
2
+ module Widgets
3
+ class HorizontalRule < Base
4
+ def identifier
5
+ "horizontal_rule"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ style: 'solid',
11
+ color: 'dark',
12
+ max_height: 'inherit'
13
+ }
14
+ end
15
+
16
+ module Helpers
17
+ def horizontal_rule_widget(options = {})
18
+ widget_block(Widgets::HorizontalRule.new(options)) do |widget|
19
+ haml_tag :hr, style: "max-height: #{widget.options[:max_height]}", class: "#{widget.options[:style]} #{widget.options[:color]}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,63 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Image < Base
4
+ def identifier
5
+ "image"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ style: "img-responsive",
11
+ align: "center",
12
+ source: false,
13
+ magnify: false,
14
+ margin_bottom: "0",
15
+ tooltip_icon: "bullhorn",
16
+ tooltip_text_alignment: "justify",
17
+ tooltip_text_size: "medium",
18
+ tooltip_position: "top-right",
19
+ tooltip_text: ""
20
+ }
21
+ end
22
+
23
+ def image_classes
24
+ classes = ["image-widget"]
25
+ classes.push("align-#{@options[:align]}")
26
+ classes.push("popup-position-#{@options[:tooltip_position]}") if popup?
27
+ classes.join(" ")
28
+ end
29
+
30
+ def popup?
31
+ !@options[:tooltip_text].blank?
32
+ end
33
+
34
+ module Helpers
35
+ def image_widget(options = {})
36
+ widget_block(Widgets::Image.new(options)) do |widget|
37
+ haml_tag :div, class: widget.image_classes, style: style_string(widget.options, :margin, :padding) do
38
+ if widget.popup?
39
+ haml_tag :i, class: "popup fa fa-lg fa-#{widget.options[:tooltip_icon]}"
40
+ haml_tag :div, class: "popup-box", style: "font-size: #{widget.options[:tooltip_text_size]}, text-align: #{widget.options[:tooltip_text_alignment]};" do
41
+ haml_concat(widget.options[:tooltip_text])
42
+ end
43
+ end
44
+ haml_tag :img, class: "image #{widget.options[:style]} #{widget.options[:magnify] ? 'magnific-image' : ''}", src: widget.options[:source]
45
+ haml_tag :div, class: "image-drop-target"
46
+ end
47
+ end
48
+ end
49
+
50
+ def image_widget_link(options = {})
51
+ widget_block(Widgets::Image.new(options)) do |widget|
52
+ haml_tag :div, class: "image-widget align-#{widget.options[:align]}" do
53
+ link options[:href] do
54
+ haml_tag :img, style: style_string(widget.options, :margin, :padding), class: "image #{widget.options[:style]} #{widget.options[:magnify] ? 'magnific-image' : ''}", src: widget.options[:source]
55
+ end
56
+ haml_tag :div, class: "image-drop-target"
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,44 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Paragraph < Base
4
+ def identifier
5
+ "paragraph"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ style: "default",
11
+ align: "left",
12
+ size: "md",
13
+ margin_bottom: "1em",
14
+ drop_cap: "",
15
+ drop_cap_color: "#000000",
16
+ line_height: ""
17
+ }
18
+ end
19
+
20
+ module Helpers
21
+ def paragraph_widget(options = {}, contents = nil, &block)
22
+ if options.class.name == "String"
23
+ contents = options
24
+ options = {}
25
+ end
26
+ widget_block(Widgets::Paragraph.new(options)) do |widget|
27
+ haml_tag :div, style: style_string(widget.options, :margin, :padding), class: "paragraph #{widget.options[:style]} align-#{widget.options[:align]} size-#{widget.options[:size]}" do
28
+ unless widget.options[:drop_cap].empty?
29
+ haml_tag :span, class: "__dropcap", style: "color: #{widget.options[:drop_cap_color]};" do
30
+ haml_concat(widget.options[:drop_cap])
31
+ end
32
+ end
33
+
34
+ haml_tag :span, class: "paragraph-content _typeloft_editable _typeloft_widget_autoselect", style: style_string(widget.options, :line_height) do
35
+ haml_concat(contents) if contents
36
+ yield if block
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ module Maglove
2
+ module Widgets
3
+ class ScrollableImage < Base
4
+ def identifier
5
+ "scrollable_image"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ source: false,
11
+ show_navigation: true,
12
+ height: "400px",
13
+ margin_bottom: "0px"
14
+ }
15
+ end
16
+
17
+ module Helpers
18
+ def scrollable_image_widget(options = {})
19
+ widget_block(Widgets::ScrollableImage.new(options)) do |widget|
20
+ haml_tag :div, class: "scrollable-image-container #{widget.options[:show_navigation] ? 'show-navigation' : ''}", style: style_string(widget.options, :margin, :padding, :height) do
21
+ haml_tag :div, class: "scrollable-image-inner" do
22
+ haml_tag :img, class: "scrollable-image", src: widget.options[:source]
23
+ end
24
+ if widget.options[:show_navigation]
25
+ haml_tag :div, class: "scrollable-image-navigator scrollable-image-navigator-left"
26
+ haml_tag :div, class: "scrollable-image-navigator scrollable-image-navigator-right"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,56 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Slider < Base
4
+ def identifier
5
+ "slider"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ slides: "3",
11
+ height: "auto",
12
+ margin_bottom: "0px",
13
+ background_color: "#EEEEEE",
14
+ buttons_position: "bottom",
15
+ autoplay: "true",
16
+ autoplay_timeout: "3000"
17
+ }
18
+ end
19
+
20
+ def slider_options
21
+ data = { class: slider_classes, autoplay: @options[:autoplay], autoplay_timeout: @options[:autoplay_timeout] }
22
+ { class: "owl-carousel", style: slider_styles, data: data }
23
+ end
24
+
25
+ def slider_styles
26
+ style_string @options, :margin, :height, :background_color do |sb|
27
+ sb.add(:min_height, "120px")
28
+ sb.add(:overflow, "hidden")
29
+ end
30
+ end
31
+
32
+ def slider_classes
33
+ classes = ["owl-carousel", "owl-loaded", "owl-text-select-on", "owl-theme"]
34
+ classes.push("position-#{@options[:buttons_position]}") unless @options[:buttons_position].empty?
35
+ classes.join(" ")
36
+ end
37
+
38
+ module Helpers
39
+ def slider_widget(options = {}, &block)
40
+ widget_block(Widgets::Slider.new(options)) do |widget|
41
+ haml_tag :div, widget.slider_options do
42
+ yield if block
43
+ end
44
+ end
45
+ end
46
+
47
+ def slider_item(options = {}, &block)
48
+ haml_tag :div, class: "item" do
49
+ yield if block
50
+ drop_container
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,36 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Video < Base
4
+ def identifier
5
+ "video"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ width: "640",
11
+ height: "360",
12
+ preload: "auto",
13
+ style: "default",
14
+ source: false,
15
+ poster: false,
16
+ autoplay: false,
17
+ controls: true,
18
+ loop: false,
19
+ margin_bottom: "0"
20
+ }
21
+ end
22
+
23
+ module Helpers
24
+ def video_widget(options = {})
25
+ widget_block(Widgets::Video.new(options)) do |widget|
26
+ haml_tag :div, class: "video-widget player-style-#{widget.options[:style]}" do
27
+ haml_tag :video, controls: true, poster: widget.options[:poster], style: "width: 100%" do
28
+ haml_tag :source, src: widget.options[:source].to_s, type: "video/mp4"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ module Maglove
2
+ module Widgets
3
+ class YahooScreen < Base
4
+ def identifier
5
+ "yahoo_screen"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ yahoo_screen_id: "apple-iwatch-iphone-6-135616256",
11
+ width: "800",
12
+ height: "600"
13
+ }
14
+ end
15
+
16
+ module Helpers
17
+ def yahoo_screen_widget(options = {}, &block)
18
+ widget_block(Widgets::YahooScreen.new(options)) do |widget|
19
+ haml_tag :div, class: "flex-video widescreen", style: style_string(widget.options, :margin, :padding) do
20
+ haml_tag :iframe, src: "http://screen.yahoo.com/#{widget.options[:yahoo_screen_id]}.html?format=embed", type: "text/html", style: "max-width: 100%; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;", allowfullscreen: "", frameborder: "0", webkitallowfullscreen: "", mozallowfullscreen: ""
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Maglove
2
+ module Widgets
3
+ class Youtube < Base
4
+ def identifier
5
+ "youtube"
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ youtube_id: "LFYNP40vfmE",
11
+ width: "800",
12
+ height: "600"
13
+ }
14
+ end
15
+
16
+ module Helpers
17
+ def youtube_widget(options = {}, &block)
18
+ widget_block(Widgets::Youtube.new(options)) do |widget|
19
+ haml_tag :div, class: "flex-video widescreen", style: style_string(widget.options, :margin, :padding) do
20
+ haml_tag :iframe, src: "https://www.youtube.com/embed/#{widget.options[:youtube_id]}", type: "text/html", style: "max-width: 100%; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;", allowfullscreen: "", frameborder: "0", webkitallowfullscreen: "", mozallowfullscreen: ""
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "maglove-widgets"
6
+ s.version = "1.0.0"
7
+ s.licenses = ["BSD-3-Clause"]
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Tobias Strebitzer"]
10
+ s.email = ["tobias.strebitzer@magloft.com"]
11
+ s.homepage = "https://bitbucket.org/MagLoft/maglove-widgets"
12
+ s.summary = "MagLove Widgets Repository"
13
+ s.description = "This gem contains shared widgets for MagLove."
14
+ s.required_rubygems_version = '>= 2.4.7'
15
+ s.add_runtime_dependency "bundler", "~> 1.10"
16
+ s.add_runtime_dependency 'haml', "~> 4.0"
17
+ s.add_runtime_dependency 'hamloft', "~> 0.2.4"
18
+ s.files = `git ls-files`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
+ s.require_path = 'lib'
21
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maglove-widgets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tobias Strebitzer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hamloft
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.4
55
+ description: This gem contains shared widgets for MagLove.
56
+ email:
57
+ - tobias.strebitzer@magloft.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - lib/maglove/widgets.rb
68
+ - lib/maglove/widgets/banner.rb
69
+ - lib/maglove/widgets/base.rb
70
+ - lib/maglove/widgets/button.rb
71
+ - lib/maglove/widgets/columns.rb
72
+ - lib/maglove/widgets/container.rb
73
+ - lib/maglove/widgets/heading.rb
74
+ - lib/maglove/widgets/horizontal_rule.rb
75
+ - lib/maglove/widgets/image.rb
76
+ - lib/maglove/widgets/paragraph.rb
77
+ - lib/maglove/widgets/scrollable_image.rb
78
+ - lib/maglove/widgets/slider.rb
79
+ - lib/maglove/widgets/video.rb
80
+ - lib/maglove/widgets/yahoo_screen.rb
81
+ - lib/maglove/widgets/youtube.rb
82
+ - maglove-widgets.gemspec
83
+ homepage: https://bitbucket.org/MagLoft/maglove-widgets
84
+ licenses:
85
+ - BSD-3-Clause
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 2.4.7
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.6
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: MagLove Widgets Repository
107
+ test_files: []