Class: HTopNav
Instance Attribute Summary
Attributes inherited from HWidget
Class Method Summary collapse
Instance Method Summary collapse
- #a(innerHTML = '', icon: nil, **args) ⇒ Object
- #addItem(value) ⇒ Object
- #html ⇒ Object
-
#initialize(items = []) ⇒ HTopNav
constructor
A new instance of HTopNav.
Methods inherited from HWidget
#_addJsSlot, #_set, #_setStyle, #addJsFunction, #appendChild, #appendChilds, #buildSignature, #closeTag, #connect, #copyConstructor, #get, #getChilds, #getElementBy, #getSystemProperty, #hotLog, #openTag, #replacePlaceholder, #reset, #set, #setChilds, #setCloseTag, #setClosedTag, #setEnablePlaceholder, #setInnerHTML, #setParent, #setPlaceholder, #setPlaceholders, #setProperties, #setSlots, #setStyle, #setStyles, #setSystemProperties, #setSystemProperty, #setTag, #storeSlots, #storeStyle, #strProperties, test, #unset, widgetSpace
Constructor Details
#initialize(items = []) ⇒ HTopNav
Returns a new instance of HTopNav.
3 4 5 6 |
# File 'lib/hwidgets/htopnav.rb', line 3 def initialize(items = []) super(class: "hpriority-nav") @items = items end |
Class Method Details
.test1 ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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 |
Instance Method Details
#a(innerHTML = '', icon: nil, **args) ⇒ Object
14 15 16 17 18 19 20 21 |
# 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) ⇒ Object
8 9 10 11 |
# File 'lib/hwidgets/htopnav.rb', line 8 def addItem(value) @items << value return self end |
#html ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 = HDivTag.new(class: 'menu') value[:content].each do || << self.a([:name], icon: [:icon], href: [:href]) end containerDiv << end end return super end |