class HtmlCom::Accordion
Attributes
to_css[R]
to_html[R]
to_js[R]
Public Class Methods
new(xml, debug: false)
click to toggle source
# 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
Private Instance Methods
xsl()
click to toggle source
# File lib/htmlcom.rb, line 70 def xsl() xsl= %q( <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'> <xsl:template match='accordion'> <xsl:element name='tags'> <xsl:attribute name='mode'>accordion</xsl:attribute> <xsl:apply-templates select='panel' /> </xsl:element> </xsl:template> <xsl:template match='panel'> <xsl:element name='tag'> <xsl:attribute name='title'> <xsl:value-of select='@title'/> </xsl:attribute> <xsl:attribute name='class'> <xsl:value-of select='@class'/> </xsl:attribute> <xsl:element name="input"> <xsl:attribute name="type">hidden</xsl:attribute> <xsl:if test='@onopen!=""'> <xsl:attribute name="onclick"><xsl:value-of select="@onopen"/></xsl:attribute> </xsl:if> <xsl:if test='@onclose!=""'> <xsl:attribute name="ondblclick"><xsl:value-of select="@onclose"/></xsl:attribute> </xsl:if> </xsl:element> <xsl:copy-of select="*"/> <xsl:if test='@ajaxid!=""'> <!-- used with onopen --> <div id='{@ajaxid}'>$<xsl:value-of select="@ajaxid"/></div> </xsl:if> </xsl:element> </xsl:template> </xsl:stylesheet> ) end