hamloft 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/hamloft/engine.rb +8 -0
- data/lib/hamloft/helpers.rb +0 -167
- data/lib/hamloft/version.rb +1 -1
- data/lib/hamloft/widget.rb +30 -0
- data/lib/hamloft.rb +10 -12
- metadata +4 -15
- data/lib/hamloft/widget/banner.rb +0 -18
- data/lib/hamloft/widget/base.rb +0 -33
- data/lib/hamloft/widget/button.rb +0 -32
- data/lib/hamloft/widget/columns.rb +0 -49
- data/lib/hamloft/widget/container.rb +0 -73
- data/lib/hamloft/widget/heading.rb +0 -19
- data/lib/hamloft/widget/horizontal_rule.rb +0 -19
- data/lib/hamloft/widget/image.rb +0 -21
- data/lib/hamloft/widget/paragraph.rb +0 -20
- data/lib/hamloft/widget/slider.rb +0 -34
- data/lib/hamloft/widget/yahoo_screen.rb +0 -19
- data/lib/hamloft/widget/youtube.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16e216815687bac00a7e0381965af9f6f29c47c0
|
4
|
+
data.tar.gz: 32862fed9404f57f38003d009f3022ee8146e048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c240feb3b020b594fed4ea8404668c39077bfbff2505a25362034602f8ed231db6c4b4dd4411fc3558d557451344e150c812eb2c8995b3d9eb8531965eb1170
|
7
|
+
data.tar.gz: 9cfc5d6592e3c0750e672cad0ee8e64df09a22bf6b2a3174ff44ab220dbab22a796e3068ab33e6156ff85747e0d35d9606517f92c2748fcc64ac251af64ad538
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hamloft (0.1.
|
4
|
+
hamloft (0.1.7)
|
5
5
|
activesupport (~> 4.2)
|
6
6
|
haml (~> 4.0)
|
7
7
|
nokogiri (~> 1.6)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (4.2.5)
|
12
|
+
activesupport (4.2.5.1)
|
13
13
|
i18n (~> 0.7)
|
14
14
|
json (~> 1.7, >= 1.7.7)
|
15
15
|
minitest (~> 5.1)
|
@@ -26,8 +26,8 @@ GEM
|
|
26
26
|
json (1.8.3)
|
27
27
|
method_source (0.8.2)
|
28
28
|
mini_portile2 (2.0.0)
|
29
|
-
minitest (5.8.
|
30
|
-
nokogiri (1.6.7.
|
29
|
+
minitest (5.8.4)
|
30
|
+
nokogiri (1.6.7.2)
|
31
31
|
mini_portile2 (~> 2.0.0.rc2)
|
32
32
|
parser (2.2.2.6)
|
33
33
|
ast (>= 1.1, < 3.0)
|
@@ -59,7 +59,7 @@ GEM
|
|
59
59
|
ruby-progressbar (1.7.5)
|
60
60
|
slop (3.6.0)
|
61
61
|
thread_safe (0.3.5)
|
62
|
-
tilt (2.0.
|
62
|
+
tilt (2.0.2)
|
63
63
|
tzinfo (1.2.2)
|
64
64
|
thread_safe (~> 0.1)
|
65
65
|
|
@@ -73,4 +73,4 @@ DEPENDENCIES
|
|
73
73
|
rubocop (~> 0.32)
|
74
74
|
|
75
75
|
BUNDLED WITH
|
76
|
-
1.
|
76
|
+
1.11.2
|
data/lib/hamloft/engine.rb
CHANGED
@@ -18,6 +18,14 @@ module Hamloft
|
|
18
18
|
scope_object.instance_eval do
|
19
19
|
extend Haml::Helpers
|
20
20
|
extend Hamloft::Helpers
|
21
|
+
|
22
|
+
# Inject widget helpers
|
23
|
+
Hamloft.widgets.each do |widget|
|
24
|
+
if defined?(widget::Helpers)
|
25
|
+
extend widget::Helpers
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
@haml_buffer = buffer
|
22
30
|
end
|
23
31
|
begin
|
data/lib/hamloft/helpers.rb
CHANGED
@@ -33,7 +33,6 @@ module Hamloft
|
|
33
33
|
block.call if block
|
34
34
|
end
|
35
35
|
end
|
36
|
-
# <a href="http://www.google.com/?referrer=Baker" class="">
|
37
36
|
|
38
37
|
def font(font_face, &block)
|
39
38
|
haml_tag :font, :face => font_face do
|
@@ -67,171 +66,5 @@ module Hamloft
|
|
67
66
|
block.call(widget) if block
|
68
67
|
end
|
69
68
|
end
|
70
|
-
|
71
|
-
def column(row, &block)
|
72
|
-
# get and increase span
|
73
|
-
next_span = row.next_span
|
74
|
-
if next_span
|
75
|
-
phone_cols = (row.options[:collapse_options] == "xs") ? next_span : "12"
|
76
|
-
haml_tag :div, :class => "column col-#{phone_cols} col-tablet-#{next_span} col-#{row.options[:collapse_options]}-#{next_span}" do
|
77
|
-
block.call if block
|
78
|
-
drop_container
|
79
|
-
end
|
80
|
-
else
|
81
|
-
haml_tag :pre do
|
82
|
-
haml_concat "ERROR: Row does not allow column at position #{row.column_count}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def columns_widget(options={}, &block)
|
88
|
-
widget_block(Widget::Columns.new(options)) do |widget|
|
89
|
-
haml_tag :div, widget.row_options do
|
90
|
-
block.call(widget) if block
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def columns_widget_compose(key, options={}, &block)
|
96
|
-
columns_widget = Widget::Columns.new(options)
|
97
|
-
items = variable(key, [])
|
98
|
-
# calculate row and column count
|
99
|
-
row_count = (items.length.to_f / columns_widget.total_columns).ceil
|
100
|
-
col_count = columns_widget.total_columns
|
101
|
-
(0...row_count).each do |row_index|
|
102
|
-
columns_widget(options) do |row|
|
103
|
-
(0...col_count).each do |col_index|
|
104
|
-
index = (row_index * col_count) + col_index
|
105
|
-
block.call(row, items[index]) if not items[index].nil?
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def container_widget(options={}, &block)
|
112
|
-
widget_block(Widget::Container.new(options)) do |widget|
|
113
|
-
haml_tag :section, widget.container_options do
|
114
|
-
haml_tag :div, widget.image_options do
|
115
|
-
block.call if block
|
116
|
-
drop_container
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def slider_widget(options={}, &block)
|
123
|
-
widget_block(Widget::Slider.new(options)) do |widget|
|
124
|
-
haml_tag :div, widget.slider_options do
|
125
|
-
block.call if block
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def slider_item(options={}, &block)
|
131
|
-
haml_tag :div, class: "item" do
|
132
|
-
block.call if block
|
133
|
-
drop_container
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def banner_widget(options={}, &block)
|
138
|
-
widget_block(Widget::Banner.new(options)) do |widget|
|
139
|
-
haml_tag :div, :class => "banner-outer align-#{widget.options[:alignment]}" do
|
140
|
-
haml_tag :div, :class => "banner banner-#{widget.options[:style]}" do
|
141
|
-
block.call if block
|
142
|
-
drop_container
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def youtube_widget(options={}, &block)
|
149
|
-
widget_block(Widget::Youtube.new(options)) do |widget|
|
150
|
-
haml_tag :div, class: "flex-video widescreen", style: style_string(widget.options, :margin, :padding) do
|
151
|
-
haml_tag :iframe, src: "http://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: ""
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def yahoo_screen_widget(options={}, &block)
|
157
|
-
widget_block(Widget::YahooScreen.new(options)) do |widget|
|
158
|
-
haml_tag :div, class: "flex-video widescreen", style: style_string(widget.options, :margin, :padding) do
|
159
|
-
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: ""
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def image_widget_link(options={})
|
165
|
-
widget_block(Widget::Image.new(options)) do |widget|
|
166
|
-
haml_tag :div, :class => "image-widget align-#{widget.options[:align]}" do
|
167
|
-
link options[:href] do
|
168
|
-
haml_tag :img, style: style_string(widget.options, :margin, :padding), class: "image #{widget.options[:style]} #{widget.options[:magnify] ? "magnific-image" : ""}", src: widget.options[:source]
|
169
|
-
end
|
170
|
-
haml_tag :div, :class => "image-drop-target"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def horizontal_rule_widget(options={})
|
176
|
-
widget_block(Widget::HorizontalRule.new(options)) do |widget|
|
177
|
-
haml_tag :hr, style: "max-height: #{widget.options[:max_height]}", class: "#{widget.options[:style]} #{widget.options[:color]}"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def image_widget(options={})
|
182
|
-
widget_block(Widget::Image.new(options)) do |widget|
|
183
|
-
haml_tag :div, :class => "image-widget align-#{widget.options[:align]}", style: style_string(widget.options, :margin, :padding) do
|
184
|
-
haml_tag :img, class: "image #{widget.options[:style]} #{widget.options[:magnify] ? "magnific-image" : ""}", src: widget.options[:source]
|
185
|
-
haml_tag :div, class: "image-drop-target"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def heading_widget(options={}, contents=nil, &block)
|
191
|
-
if options.class.name == "String"
|
192
|
-
contents = options
|
193
|
-
options = {}
|
194
|
-
end
|
195
|
-
widget_block(Widget::Heading.new(options)) do |widget|
|
196
|
-
haml_tag :header, :class => "#{widget.options[:style]} align-#{widget.options[:align]}", style: style_string(widget.options, :margin, :padding) do
|
197
|
-
haml_tag widget.options[:type], :class => "_typeloft_editable _typeloft_widget_autoselect" do
|
198
|
-
haml_concat(contents) if contents
|
199
|
-
block.call if block
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def paragraph_widget(options={}, contents=nil, &block)
|
206
|
-
if options.class.name == "String"
|
207
|
-
contents = options
|
208
|
-
options = {}
|
209
|
-
end
|
210
|
-
widget_block(Widget::Paragraph.new(options)) do |widget|
|
211
|
-
haml_tag :div, :style => style = style_string(widget.options, :margin, :padding), :class => "paragraph _typeloft_editable _typeloft_widget_autoselect #{widget.options[:style]} align-#{widget.options[:align]} size-#{widget.options[:size]}" do
|
212
|
-
haml_concat(contents) if contents
|
213
|
-
block.call if block
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
def button_widget(options={}, contents=nil, &block)
|
219
|
-
if options.class.name == "String"
|
220
|
-
contents = options
|
221
|
-
options = {}
|
222
|
-
end
|
223
|
-
widget_block(Widget::Button.new(options)) do |widget|
|
224
|
-
haml_tag :a, widget.button_options do
|
225
|
-
if widget.options[:media] and !widget.options[:media].blank?
|
226
|
-
haml_tag :video do
|
227
|
-
haml_tag :source, {src: widget.options[:media], type: "video/mp4"}
|
228
|
-
end
|
229
|
-
end
|
230
|
-
haml_concat(contents) if contents
|
231
|
-
block.call if block
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
69
|
end
|
237
70
|
end
|
data/lib/hamloft/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Hamloft
|
2
|
+
class Widget
|
3
|
+
include Hamloft::Helpers
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def identifier
|
7
|
+
"base"
|
8
|
+
end
|
9
|
+
|
10
|
+
def defaults
|
11
|
+
{}
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(options)
|
15
|
+
@options = defaults.merge(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def typeloft_widget_options
|
19
|
+
attributes = {
|
20
|
+
:class => "_typeloft_widget",
|
21
|
+
:"data-widget-identifier" => identifier
|
22
|
+
}
|
23
|
+
@options.each do |k, v|
|
24
|
+
attributes["data-attribute-#{k}"] = v
|
25
|
+
end
|
26
|
+
attributes
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/hamloft.rb
CHANGED
@@ -6,21 +6,11 @@ require "hamloft/options"
|
|
6
6
|
require "hamloft/style_builder"
|
7
7
|
require "hamloft/helpers"
|
8
8
|
require "hamloft/template"
|
9
|
-
require "hamloft/widget
|
10
|
-
require "hamloft/widget/container"
|
11
|
-
require "hamloft/widget/columns"
|
12
|
-
require "hamloft/widget/image"
|
13
|
-
require "hamloft/widget/heading"
|
14
|
-
require "hamloft/widget/button"
|
15
|
-
require "hamloft/widget/paragraph"
|
16
|
-
require "hamloft/widget/banner"
|
17
|
-
require "hamloft/widget/youtube"
|
18
|
-
require "hamloft/widget/yahoo_screen"
|
19
|
-
require "hamloft/widget/horizontal_rule"
|
20
|
-
require "hamloft/widget/slider"
|
9
|
+
require "hamloft/widget"
|
21
10
|
|
22
11
|
module Hamloft
|
23
12
|
@@_templates = {}
|
13
|
+
@@_widgets = []
|
24
14
|
|
25
15
|
def self.render(haml, variables={})
|
26
16
|
Hamloft::Engine.new(haml, remove_whitespace: true).render(Object.new, variables)
|
@@ -30,6 +20,14 @@ module Hamloft
|
|
30
20
|
@@_templates[key] = template
|
31
21
|
end
|
32
22
|
|
23
|
+
def self.register_widget(klass)
|
24
|
+
@@_widgets.push(klass)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.widgets
|
28
|
+
@@_widgets
|
29
|
+
end
|
30
|
+
|
33
31
|
def self.template(key)
|
34
32
|
@@_templates[key]
|
35
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamloft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -114,18 +114,7 @@ files:
|
|
114
114
|
- lib/hamloft/style_builder.rb
|
115
115
|
- lib/hamloft/template.rb
|
116
116
|
- lib/hamloft/version.rb
|
117
|
-
- lib/hamloft/widget
|
118
|
-
- lib/hamloft/widget/base.rb
|
119
|
-
- lib/hamloft/widget/button.rb
|
120
|
-
- lib/hamloft/widget/columns.rb
|
121
|
-
- lib/hamloft/widget/container.rb
|
122
|
-
- lib/hamloft/widget/heading.rb
|
123
|
-
- lib/hamloft/widget/horizontal_rule.rb
|
124
|
-
- lib/hamloft/widget/image.rb
|
125
|
-
- lib/hamloft/widget/paragraph.rb
|
126
|
-
- lib/hamloft/widget/slider.rb
|
127
|
-
- lib/hamloft/widget/yahoo_screen.rb
|
128
|
-
- lib/hamloft/widget/youtube.rb
|
117
|
+
- lib/hamloft/widget.rb
|
129
118
|
- spec/fixtures/template/tumblr.rb
|
130
119
|
- spec/fixtures/test.haml
|
131
120
|
- spec/hamloft_spec.rb
|
@@ -150,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
139
|
version: '0'
|
151
140
|
requirements: []
|
152
141
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.1
|
154
143
|
signing_key:
|
155
144
|
specification_version: 4
|
156
145
|
summary: Hamloft - MagLoft Widget Parser.
|
data/lib/hamloft/widget/base.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
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
|
-
attributes["data-attribute-#{k}"] = v
|
26
|
-
end
|
27
|
-
attributes
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
3
|
-
class Button < Base
|
4
|
-
|
5
|
-
def identifier
|
6
|
-
"button"
|
7
|
-
end
|
8
|
-
|
9
|
-
def defaults
|
10
|
-
{
|
11
|
-
style: "primary",
|
12
|
-
type: "btn-fit",
|
13
|
-
size: "btn-lg",
|
14
|
-
media: false
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def button_classes
|
19
|
-
classes = ["btn", "btn-#{@options[:style]}", @options[:size], @options[:type], "_typeloft_editable"]
|
20
|
-
classes.push("btn-media") if @options[:media]
|
21
|
-
classes.join(" ")
|
22
|
-
end
|
23
|
-
|
24
|
-
def button_options
|
25
|
-
result = {class: button_classes, href: (@options[:href] or "#"), style: style_string(@options, :margin, :padding)}
|
26
|
-
result["data-media"] = @options[:media] if @options[:media] and !@options[:media].empty?
|
27
|
-
result
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
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 = @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
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
3
|
-
class Container < Base
|
4
|
-
|
5
|
-
def identifier
|
6
|
-
"container"
|
7
|
-
end
|
8
|
-
|
9
|
-
def defaults
|
10
|
-
{
|
11
|
-
animate: "none",
|
12
|
-
image_source: false,
|
13
|
-
image_position: "center_center",
|
14
|
-
image_size: "cover",
|
15
|
-
parallax_effect: "none",
|
16
|
-
background_color: "",
|
17
|
-
bg_color: "",
|
18
|
-
opacity: "",
|
19
|
-
border_radius: "",
|
20
|
-
border_width: "",
|
21
|
-
border_style: "",
|
22
|
-
style: "default",
|
23
|
-
padding_top: "",
|
24
|
-
padding_right: "",
|
25
|
-
padding_bottom: "",
|
26
|
-
padding_left: "",
|
27
|
-
min_height: "",
|
28
|
-
max_height: "",
|
29
|
-
margin_top: "",
|
30
|
-
margin_right: "",
|
31
|
-
margin_bottom: "",
|
32
|
-
margin_left: ""
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def container_options
|
37
|
-
result = {class: container_classes, style: container_styles}
|
38
|
-
result["data-parallax-style"] = @options[:parallax_effect] if not @options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
|
39
|
-
result
|
40
|
-
end
|
41
|
-
|
42
|
-
def image_options
|
43
|
-
{class: "one-container-image", style: image_styles}
|
44
|
-
end
|
45
|
-
|
46
|
-
def container_classes
|
47
|
-
classes = ["one-container"]
|
48
|
-
classes.push("animate #{@options[:animate]}") if @options[:animate] != "none"
|
49
|
-
classes.push("container-#{@options[:style]}") if not @options[:style].empty?
|
50
|
-
classes.push("container-image-#{@options[:image_size]}") if not @options[:image_size].empty?
|
51
|
-
classes.push("container-parallax") if not @options[:parallax_effect].empty? and @options[:parallax_effect] != "none"
|
52
|
-
classes.join(" ")
|
53
|
-
end
|
54
|
-
|
55
|
-
def container_styles
|
56
|
-
style_string @options, :opacity, :border, :opacity, :border_radius, :border_width, :border_style, :margin do |sb|
|
57
|
-
sb.add(:background_color, @options[:background_color] == "custom" ? @options[:bg_color] : nil)
|
58
|
-
if @options[:background_color] == "overlay"
|
59
|
-
sb.add(:background_image, @options[:image_source], "linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(<%= value %>)")
|
60
|
-
else
|
61
|
-
sb.add(:background_image, @options[:image_source], "url(<%= value %>)")
|
62
|
-
end
|
63
|
-
sb.add(:background_position, @options[:image_position], "<%= value.split('_').join(' ') %>")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def image_styles
|
68
|
-
style_string @options, :min_height, :max_height, :padding
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/lib/hamloft/widget/image.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
3
|
-
class Image < Base
|
4
|
-
|
5
|
-
def identifier
|
6
|
-
"image"
|
7
|
-
end
|
8
|
-
|
9
|
-
def defaults
|
10
|
-
{
|
11
|
-
style: "img-responsive",
|
12
|
-
align: "center",
|
13
|
-
source: false,
|
14
|
-
magnify: false,
|
15
|
-
margin_bottom: "0"
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
3
|
-
class Slider < Base
|
4
|
-
|
5
|
-
def identifier
|
6
|
-
"slider"
|
7
|
-
end
|
8
|
-
|
9
|
-
def defaults
|
10
|
-
{
|
11
|
-
slides: "3",
|
12
|
-
height: "auto",
|
13
|
-
margin_bottom: "0px",
|
14
|
-
background_color: "#EEEEEE",
|
15
|
-
autoplay: "true",
|
16
|
-
autoplay_timeout: "3000"
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def slider_options
|
21
|
-
data = {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, "200px")
|
28
|
-
sb.add(:overflow, "hidden")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Hamloft
|
2
|
-
module Widget
|
3
|
-
class YahooScreen < Base
|
4
|
-
|
5
|
-
def identifier
|
6
|
-
"yahoo_screen"
|
7
|
-
end
|
8
|
-
|
9
|
-
def defaults
|
10
|
-
{
|
11
|
-
yahoo_screen_id: "apple-iwatch-iphone-6-135616256",
|
12
|
-
width: "800",
|
13
|
-
height: "600"
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|