Module: NfgUi::Bootstrap::Utilities::Tooltipable

Overview

  • else

    content_tag button.html_wrapper_element, button.html_options do

    = button.body
    

Tooltip placement: You can override the placement if needed by setting the tooltip_placement method in your target class – :top, :bottom, :left, :right

Example:

def tooltip_placement

:right

end

Instance Attribute Summary

Attributes included from Disableable

#as

Instance Method Summary collapse

Methods included from Disableable

#disabled

Instance Method Details

#dataObject



62
63
64
65
66
67
68
# File 'lib/nfg_ui/bootstrap/utilities/tooltipable.rb', line 62

def data
  if tooltip
    disabled ? super : super.merge!(tooltip_data_attributes)
  else
    super
  end
end

#disabled_component_tooltip_wrapper_html_optionsObject



70
71
72
73
74
75
# File 'lib/nfg_ui/bootstrap/utilities/tooltipable.rb', line 70

def disabled_component_tooltip_wrapper_html_options
  { data: tooltip_data_attributes,
    title: tooltip,
    class: 'd-inline-block',
    tabindex: '0' }
end

#html_optionsObject

There are a number of complex changes that need to be made to the html for disabled tooltipped buttons Read more:

getbootstrap.com/docs/4.1/components/tooltips/#disabled-elements



53
54
55
56
57
58
59
60
# File 'lib/nfg_ui/bootstrap/utilities/tooltipable.rb', line 53

def html_options
  return super if options[:tooltip].nil?

  component_title = disabled ? options.fetch(:title, nil) : tooltip
  component_styles = (options[:style] || '') + (disabled ? ' pointer-events: none;' : '') if disabled
  super.merge!(title: component_title,
               style: component_styles.try(:squish))
end

#tooltipObject



44
45
46
# File 'lib/nfg_ui/bootstrap/utilities/tooltipable.rb', line 44

def tooltip
  options.fetch(:tooltip, nil)
end