Class: Ezframe::Materialize
Defined Under Namespace
Classes: Card, Collection, Tab
Class Method Summary
collapse
Class Method Details
.add_sibling(dest, elem) ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/ezframe/materialize.rb', line 93
def add_sibling(dest, elem)
if dest.is_a?(Array)
dest.push(elem)
else
[dest, elem]
end
end
|
.checkbox(ht_h) ⇒ Object
81
82
83
84
85
|
# File 'lib/ezframe/materialize.rb', line 81
def checkbox(ht_h)
ht_h[:tag] = "input"
ht_h[:type] = "checkbox"
return Ht.label(child: [ht_h, { tag: "span", child: ht_h[:value] }])
end
|
.convert(ht_h) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ezframe/materialize.rb', line 27
def convert(ht_h)
return nil unless ht_h
return ht_h if (ht_h.is_a?(Hash) && ht_h[:final])
new_h = ht_h.clone
if ht_h.is_a?(Array)
new_h = ht_h.map { |v| convert(v) }
elsif ht_h.is_a?(Hash)
unless ht_h[:tag]
EzLog.info("convert: no tag: #{ht_h.inspect}")
return nil
end
case ht_h[:tag].to_sym
when :checkbox
return checkbox(ht_h)
when :radio
return radio(ht_h)
when :icon
return icon(ht_h)
when :form
return new_h = form(ht_h)
when :table
new_h.add_class(%w[striped highlight])
end
new_h[:child] = convert(ht_h[:child]) if ht_h[:child]
end
return new_h
end
|
64
65
66
67
68
|
# File 'lib/ezframe/materialize.rb', line 64
def form(ht_h)
new_h = ht_h.clone
new_h[:child] = convert(new_h[:child])
return new_h
end
|
.icon(ht_h) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/ezframe/materialize.rb', line 55
def icon(ht_h)
new_h = ht_h.clone
EzLog.info "[warn] no name attribute for icon ht_h: #{ht_h.inspect}" unless new_h[:name]
new_h.add_class(%w[material-icons align-icon])
new_h.update({ tag: "i", child: ht_h[:name] })
new_h.delete(:name)
return new_h
end
|
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/ezframe/materialize.rb', line 70
def input(ht_h)
ht_h[:tag] = "input"
width_s = "s#{ht_h[:width_s] || 12}"
ht_h.delete(:witdth_s)
label = Ht.label(class: %w[active], for: ht_h[:name], child: ht_h[:label], final: true )
cls = ["input-field", "col", width_s]
new_h = Ht.div(class: cls, child: [ht_h, label])
new_h = Ht.div(child: new_h, class: "row")
return new_h
end
|
.into_bottom_of_body ⇒ Object
23
24
25
|
# File 'lib/ezframe/materialize.rb', line 23
def into_bottom_of_body
""
end
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ezframe/materialize.rb', line 6
def
css_a = Config[:extra_css_list]&.map {|file| "<link href=\"#{file}\" rel=\"stylesheet\">\n" }
js_a = Config[:extra_js_list]&.map {|file| "<script src=\"#{file}\"></script>\n" }
css_files = Dir["./asset/css/*.css"]||[]
css_a += css_files.sort.map do |file|
file.gsub!("./asset", "")
"<link href=\"#{file}\" rel=\"stylesheet\">\n"
end
js_files = Dir["./asset/js/*.js"]||[]
js_a += js_files.sort.map do |file|
file.gsub!("./asset", "")
"<script src=\"#{file}\"></script>\n"
end
(css_a+js_a).join
end
|
101
102
103
104
105
106
107
108
|
# File 'lib/ezframe/materialize.rb', line 101
def loading
Ht.div(class: %w[preloader-wrapper big active], child:
Ht.div(class: %w[spinner-layer spinner-green], child: [
Ht.multi_div([%w[circle-clipper left], %w[circle]], ""),
Ht.multi_div([%w[gap-patch], %w[circle]], ""),
Ht.multi_div([%w[circle-clipper right], %w[circle]], "")
]))
end
|
.radio(ht_h) ⇒ Object
87
88
89
90
91
|
# File 'lib/ezframe/materialize.rb', line 87
def radio(ht_h)
ht_h[:tag] = "input"
ht_h[:type] = "radio"
return Ht.label(child: [ht_h, { tag: "span", child: ht_h[:label] }])
end
|