2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-03-13 06:09:10 +08:00
|
|
|
React = require "react"
|
|
|
|
Tooltip = require "./tooltip"
|
2015-05-15 08:08:30 +08:00
|
|
|
{ComponentRegistry} = require("nylas-exports")
|
2015-03-13 06:09:10 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2015-04-30 08:38:16 +08:00
|
|
|
@mouseDownListener = _.bind(@tooltip.onMouseDown, @tooltip)
|
2015-03-13 06:09:10 +08:00
|
|
|
@mouseOverListener = _.bind(@tooltip.onMouseOver, @tooltip)
|
|
|
|
@mouseOutListener = _.bind(@tooltip.onMouseOut, @tooltip)
|
|
|
|
|
2015-04-30 08:38:16 +08:00
|
|
|
window.addEventListener("mousedown", @mouseDownListener)
|
2015-03-13 06:09:10 +08:00
|
|
|
window.addEventListener("mouseover", @mouseOverListener)
|
|
|
|
window.addEventListener("mouseout", @mouseOutListener)
|
|
|
|
|
|
|
|
deactivate: ->
|
|
|
|
React.unmountComponentAtNode(@item)
|
|
|
|
document.querySelector(atom.workspaceViewParentSelector).removeChild(@item)
|
|
|
|
|
2015-04-30 08:38:16 +08:00
|
|
|
window.removeEventListener("mousedown", @mouseDownListener)
|
2015-03-13 06:09:10 +08:00
|
|
|
window.removeEventListener("mouseover", @mouseOverListener)
|
|
|
|
window.removeEventListener("mouseout", @mouseOutListener)
|
|
|
|
|
|
|
|
serialize: -> @state
|