Module: PureAdmin::DropdownHelper

Defined in:
app/helpers/pure_admin/dropdown_helper.rb

Overview

Note:

this helper depends MenuHelper

Helper methods for dropdown functionality.

The recommended way of using this helper is

dropdown 'Tools', class: ''do
  dropdown_item :name, 'url', item_html: { class: '' }
end

Instance Method Summary collapse

Instance Method Details

Renders a dropdown to the view. respected here.

Parameters:

  • name (String)

    the name to display on the main dropdown link.

  • options (Hash) (defaults to: {})

    all options that can be passed to the menu_helper as menu_html are

Yields:

  • The contents for the dropdown



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/pure_admin/dropdown_helper.rb', line 18

def dropdown(name, options = {}, &block)
  opts = {}
  opts[:menu_html] = options
  opts[:menu_html][:class] = merge_html_classes('dropdown pure-menu-horizontal', opts[:class])

  content = capture(&block)
  content = (:ul, content, class: 'pure-menu-children')
  content = (:li, link_to(name, '', class: 'pure-menu-link') + content,
    class: 'pure-menu-item pure-menu-has-children')

  menu(opts) { content }
end

Renders a dropdown item to the view.

Parameters:

  • name (String) (defaults to: nil)

    the name to pass to PureAdmin::MenuHelper.menu_item_and_link

  • name (url) (defaults to: nil)

    the url to pass to PureAdmin::MenuHelper.menu_item_and_link

  • name (Hash) (defaults to: nil)

    the options to pass to PureAdmin::MenuHelper.menu_item_and_link

Yields:

  • the content to pass to PureAdmin::MenuHelper.menu_item_and_link



37
38
39
# File 'app/helpers/pure_admin/dropdown_helper.rb', line 37

def dropdown_item(name = nil, url = nil, options = nil, &block)
  menu_item_and_link(name, url, options, &block)
end