Class: Ezframe::Materialize
Defined Under Namespace
Classes: Card, Collection, Tab
Class Method Summary
collapse
Class Method Details
.add_sibling(dest, elem) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/ezframe/materialize.rb', line 96
def add_sibling(dest, elem)
if dest.is_a?(Array)
dest.push(elem)
else
[dest, elem]
end
end
|
.checkbox(ht_h) ⇒ Object
84
85
86
87
88
|
# File 'lib/ezframe/materialize.rb', line 84
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
54
55
56
|
# 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]
mylog("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
|
67
68
69
70
71
|
# File 'lib/ezframe/materialize.rb', line 67
def form(ht_h)
new_h = ht_h.clone
new_h[:child] = convert(new_h[:child])
return new_h
end
|
.icon(ht_h) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/ezframe/materialize.rb', line 58
def icon(ht_h)
new_h = ht_h.clone
mylog "[warn] no name attribute for icon ht_h: #{ht_h.inspect}" unless new_h[:name]
new_h.add_class("material-icons")
new_h.update({ tag: "i", child: ht_h[:name] })
new_h.delete(:name)
return new_h
end
|
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/ezframe/materialize.rb', line 73
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.map do |file|
file.gsub!("./asset", "")
"<link href=\"#{file}\" rel=\"stylesheet\">\n"
end
js_files = Dir["./asset/js/*.js"]||[]
js_a += js_files.map do |file|
file.gsub!("./asset", "")
"<script src=\"#{file}\"></script>\n"
end
(css_a+js_a).join
end
|
104
105
106
107
108
109
110
111
|
# File 'lib/ezframe/materialize.rb', line 104
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
90
91
92
93
94
|
# File 'lib/ezframe/materialize.rb', line 90
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
|