Module: Builder::MouseEvents

Extended by:
ActiveSupport::Concern
Included in:
Glib::JsonUi::MenuBuilder::MenuItem, Glib::JsonUi::ViewBuilder::View
Defined in:
app/helpers/glib/json_ui/builder/mouse_events.rb

Instance Method Summary collapse

Instance Method Details

#tooltip(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/glib/json_ui/builder/mouse_events.rb', line 11

def tooltip(options)
  if !Rails.env.test?
    key = "tooltip_#{SecureRandom.uuid}"
  else
    key = 'tooltip_test'
  end
  onMouseEnter ->(action) do
    action.popovers_open(
      key: key,
      placement: options[:placement] || 'top',
      childViews: ->(view) {
        view.p styleClass: 'tooltip', text: options[:text]
      }
    )
  end

  onMouseLeave ->(action) do
    action.popovers_close key: key
  end
end