class HtmlCom::Tabs
Attributes
active[R]
tab[R]
Public Class Methods
new(type=:tabs, headings: [], xml: nil, debug: false)
click to toggle source
current options for type:
:tabs, :full_page_tabs
# File lib/htmlcom.rb, line 159 def initialize(type=:tabs, headings: [], xml: nil, debug: false) @type, @debug = type, debug @build = JsMenuBuilder.new(type, headings: headings) @active_tab = 1 @tab = headings.map do |heading| Tab.new heading, content: "<h3>#{heading}</h3>", callback: self, debug: debug end if xml then @build.import(xml) end end
Public Instance Methods
active=(tabnum)
click to toggle source
# File lib/htmlcom.rb, line 177 def active=(tabnum) @active_tab = tabnum refresh() end
add_tab(title, content: '', index: nil)
click to toggle source
# File lib/htmlcom.rb, line 182 def add_tab(title, content: '', index: nil) tab = Tab.new(title, content: content) if index then @tab.insert index, tab else @tab << tab end refresh() end
delete_tab(i)
click to toggle source
# File lib/htmlcom.rb, line 196 def delete_tab(i) @tab.delete i refresh() end
ping()
click to toggle source
# File lib/htmlcom.rb, line 201 def ping() tabs = @tab.map do |tab| tab.title ? tab.to_a : nil end.compact.to_h if @debug then puts 'inside ping; tabs: ' + tabs.inspect puts '@active_tab: ' + @active_tab.inspect end @build = JsMenuBuilder.new(@type, tabs: tabs, active: @active_tab, debug: @debug) end
Also aliased as: refresh
to_bangtag()
click to toggle source
not yet working properly
# File lib/htmlcom.rb, line 232 def to_bangtag() XmlToSliml.new(@build.to_xml, spacer: '!')\ .to_s.lines.map {|x| '!' + x }.join end
to_css()
click to toggle source
# File lib/htmlcom.rb, line 219 def to_css() @build.to_css end
to_html()
click to toggle source
# File lib/htmlcom.rb, line 223 def to_html() @build.to_html end
to_js()
click to toggle source
# File lib/htmlcom.rb, line 227 def to_js() @build.to_js end
to_webpage()
click to toggle source
# File lib/htmlcom.rb, line 237 def to_webpage() @build.to_webpage end