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
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/glib/json_ui/builder/mouse_events.rb', line 11

def tooltip(options)
  return unless 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]
    #   }
    # )

    action.popovers_show(
      key: key,
      placement: options[:placement] || 'top',
      content: ->(popover) do
        popover.body childViews: ->(view) {
          view.p styleClass: 'tooltip', text: options[:text]
        }
      end
    )
  end

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