class HTopNav
Public Class Methods
new(items = [])
click to toggle source
Calls superclass method
HDivTag::new
# File lib/hwidgets/htopnav.rb, line 3 def initialize(items = []) super(class: "hpriority-nav") @items = items end
test1()
click to toggle source
# File lib/hwidgets/htopnav.rb, line 43 def self.test1() items = [ {type: 'link', name: 'QuickManager', href:'#quickmanager'}, {type: 'link', name: 'QuickOrder', href:'#quickorder'}, {type: 'link', name: 'Item3', href:'#3'}, {type: 'link', name: 'Item4', href:'#4'}, {type: 'link', name: 'Item5', href:'#5'}, {type: 'link', name: 'Item6', href:'#6'}, {type: 'link', name: 'Item7', href:'#7'}, {type: 'link', name: 'Item8', href:'#8'}, {type: 'link', name: 'Item9', href:'#9'}, {type: 'link', name: '', href:'#', icon: 'glyphicon glyphicon-user'}, {type: 'more-menu', name: 'More', content: [] }, {type: 'other-menu', name: 'Administrator', content: [{type: 'link', name: 'User', href:'#'}] } ] return HTopNav.new(items).html() end
test2()
click to toggle source
# File lib/hwidgets/htopnav.rb, line 63 def self.test2() items = [ {type: 'link', href:'#', icon: 'glyphicon glyphicon-home'}, {type: 'link', name: 'Item1', href:'#1'}, {type: 'link', name: 'Item2', href:'#2'}, {type: 'link', name: 'Item3', href:'#3'}, {type: 'link', name: 'Item4', href:'#4'}, {type: 'link', name: 'Item5', href:'#5'}, {type: 'link', name: 'Item6', href:'#6'}, {type: 'link', name: 'Item7', href:'#7'}, {type: 'link', name: 'Item8', href:'#8'}, {type: 'link', name: 'Item9', href:'#9'}, {type: 'more-menu', name: '', icon: 'glyphicon glyphicon-menu-hamburger', content: [{type: 'link', name: 'moreItem', href:'#', icon: 'glyphicon glyphicon-refresh'}] }, {type: 'other-menu', name: 'Administrator', icon: 'glyphicon glyphicon-print', content: [{type: 'link', name: 'User', href:'#', icon: 'glyphicon glyphicon-user'}] } ] return HTopNav.new(items).html() end
Public Instance Methods
a(innerHTML = '', icon: nil, **args)
click to toggle source
# File lib/hwidgets/htopnav.rb, line 14 def a(innerHTML = '', icon: nil, **args) a = HWidget.new("a", "", args) a << HWidget.new('span', class: icon) if icon a << HWidget.new('span', innerHTML) return a end
addItem(value)
click to toggle source
# File lib/hwidgets/htopnav.rb, line 8 def addItem(value) @items << value return self end
html()
click to toggle source
Calls superclass method
HWidget#html
# File lib/hwidgets/htopnav.rb, line 23 def html() @items.each do |value| if(value[:type] == 'link') self << self.a(value[:name], icon: value[:icon], href: value[:href]) elsif (value[:type].include? 'menu') type = value[:type].sub('menu', '') containerDiv = HDivTag.new(class: "#{type}container") containerDiv << self.a(value[:name], icon: value[:icon], class: "#{type}item") self << containerDiv menuDiv = HDivTag.new(class: 'menu') value[:content].each do |menuValue| menuDiv << self.a(menuValue[:name], icon: menuValue[:icon], href: menuValue[:href]) end containerDiv << menuDiv end end return super end