class Ezframe::Materialize
Public Class Methods
add_sibling(dest, elem)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
form(ht_h)
click to toggle source
# 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)
click to toggle source
# 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
input(ht_h)
click to toggle source
# 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()
click to toggle source
# File lib/ezframe/materialize.rb, line 23 def into_bottom_of_body "" end
into_html_header()
click to toggle source
# File lib/ezframe/materialize.rb, line 6 def into_html_header 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
loading()
click to toggle source
# 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)
click to toggle source
# 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