Class: Spark::NavMenuHelper::TreeNav
- Inherits:
-
MenuHelper::Menu
- Object
- SparkEngine::BlockHelper
- Helper
- MenuHelper::Menu
- Spark::NavMenuHelper::TreeNav
- Defined in:
- app/helpers/spark/nav_menu_helper.rb
Direct Known Subclasses
Constant Summary
Constants inherited from MenuHelper::Menu
Instance Method Summary collapse
-
#initialize(title = nil, options = {}) ⇒ TreeNav
constructor
A new instance of TreeNav.
- #item(content, url, options = {}, &block) ⇒ Object
- #item_tree(name, options = {}, &block) ⇒ Object
Methods inherited from MenuHelper::Menu
#display, #group, #header, #link
Constructor Details
#initialize(title = nil, options = {}) ⇒ TreeNav
Returns a new instance of TreeNav.
29 30 31 32 33 34 35 36 |
# File 'app/helpers/spark/nav_menu_helper.rb', line 29 def initialize( title = nil, = {} ) config({ tag: :ul, base_class: 'nav-tree', role: 'tree' }) super( title, ) end |
Instance Method Details
#item(content, url, options = {}, &block) ⇒ Object
38 39 40 41 42 |
# File 'app/helpers/spark/nav_menu_helper.rb', line 38 def item(content, url, ={}, &block) ['role'] = 'treeitem' super( content, url, , &block ) end |
#item_tree(name, options = {}, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/helpers/spark/nav_menu_helper.rb', line 44 def item_tree( name, ={}, &block ) content, url, = parse_item_args( "#", , &block) return if content.blank? || ( .include?('if') && !.delete('if') ) || ( .include?('unless') && !!.delete('unless') ) node = Spark::Helpers.dasherize( name.strip.downcase ).gsub('-','_') active = !!(.delete( 'active' ) || content.match(/item-active/)) .merge!({ 'role' => 'treeitem', 'aria-expanded' => active || (node), 'data-node' => node }) name, = set_content( name, ) classes = [config[:base_class] + "-item-wrapper"] classes.push( 'tree-active' ) if !!( .delete( 'active' ) || content.match(/item-active/)) = add_class( , classes ) content_tag( config[:item_tag], ) do concat link_to("#", class: config[:base_class] + '-item'){ concat name.call concat use_svg( 'chevron-down', class: 'expand-icon' ) } concat content_tag( :ul, role: 'group', class: config[:base_class] + '-group' ) { content } end end |