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.



20
21
22
23
24
25
26
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
57
58
59
60
61
62
63
64
65
# File 'lib/htmlcom.rb', line 20

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.



18
19
20
# File 'lib/htmlcom.rb', line 18

def to_css
  @to_css
end

#to_htmlObject (readonly)

Returns the value of attribute to_html.



18
19
20
# File 'lib/htmlcom.rb', line 18

def to_html
  @to_html
end

#to_jsObject (readonly)

Returns the value of attribute to_js.



18
19
20
# File 'lib/htmlcom.rb', line 18

def to_js
  @to_js
end

#to_tagsObject (readonly)

Returns the value of attribute to_tags.



18
19
20
# File 'lib/htmlcom.rb', line 18

def to_tags
  @to_tags
end