mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
033008e036
Summary: Add tooltip. To use just add a data-tooltip="plain string" Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1288
29 lines
1 KiB
CoffeeScript
29 lines
1 KiB
CoffeeScript
_ = require 'underscore-plus'
|
|
React = require "react"
|
|
Tooltip = require "./tooltip"
|
|
{ComponentRegistry} = require("inbox-exports")
|
|
|
|
module.exports =
|
|
item: null # The DOM item the main React component renders into
|
|
|
|
activate: (@state={}) ->
|
|
@item = document.createElement("div")
|
|
@item.setAttribute("id", "tooltip-container")
|
|
@item.setAttribute("class", "tooltip-container")
|
|
@tooltip = React.render(React.createElement(Tooltip), @item)
|
|
document.querySelector(atom.workspaceViewParentSelector).appendChild(@item)
|
|
|
|
@mouseOverListener = _.bind(@tooltip.onMouseOver, @tooltip)
|
|
@mouseOutListener = _.bind(@tooltip.onMouseOut, @tooltip)
|
|
|
|
window.addEventListener("mouseover", @mouseOverListener)
|
|
window.addEventListener("mouseout", @mouseOutListener)
|
|
|
|
deactivate: ->
|
|
React.unmountComponentAtNode(@item)
|
|
document.querySelector(atom.workspaceViewParentSelector).removeChild(@item)
|
|
|
|
window.removeEventListener("mouseover", @mouseOverListener)
|
|
window.removeEventListener("mouseout", @mouseOutListener)
|
|
|
|
serialize: -> @state
|