Class: HtmlCom::Accordion

Inherits:
Object
  • Object
show all
Defined in:
lib/htmlcom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, debug: false) ⇒ Accordion

Returns a new instance of Accordion.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/htmlcom.rb', line 33

def initialize(xml, debug: false)

  xml, @debug = xml, debug

  # transform the accordion XML to tags XML
  tags = Nokogiri::XSLT(xsl()).transform(Nokogiri::XML(xml))\
      .to_xhtml(indent: 0)

  @to_tags = tags # used for debugging the structure

  jmb = JsMenuBuilder.new(tags, debug: debug)

  pg = if Rexle.new(xml).root.attributes[:navbar] then

    a = jmb.to_h.keys.sort.map {|key, _| [key, '#' + key.downcase]}

    navbar = JsMenuBuilder.new(:sticky_navbar, {sticky_navbar: a,
                                                debug: debug})

    @to_css = navbar.to_css + "\n" + jmb.to_css
    @to_js = navbar.to_js + "\n" + jmb.to_js


    jmb.to_webpage do |css, html, js|

      [
        navbar.to_css + "\n" + css,
        navbar.to_html + "\n" + html,
        navbar.to_js + "\n" + js
      ]

    end

  else

    @to_css = jmb.to_css
    @to_js = jmb.to_js

    jmb.to_webpage

  end

  # apply the AJAX
  @to_html = JsAjaxWizard.new(pg).to_html

end

Instance Attribute Details

#to_cssObject (readonly)

Returns the value of attribute to_css.



31
32
33
# File 'lib/htmlcom.rb', line 31

def to_css
  @to_css
end

#to_htmlObject (readonly)

Returns the value of attribute to_html.



31
32
33
# File 'lib/htmlcom.rb', line 31

def to_html
  @to_html
end

#to_jsObject (readonly)

Returns the value of attribute to_js.



31
32
33
# File 'lib/htmlcom.rb', line 31

def to_js
  @to_js
end

#to_tagsObject (readonly)

Returns the value of attribute to_tags.



31
32
33
# File 'lib/htmlcom.rb', line 31

def to_tags
  @to_tags
end