   (let [offset 5]
     (+ (- top theight offset) js/window.scrollY)))
 
-(defn calc-position
+(defn- calc-position
   "Create a new tooltip at given selection. Creates a rectangle around the selection,
    which has position-properties and which are useful for positioning of the tooltip."
   [tooltip-width tooltip-height]


                 [:span
                  (vlib/safe-space) " " (vlib/safe-space)
                  [:span.pointer {:onClick #((lib/show-overlay) (hide))}
                   (vlib/fa-icon "fa-comments")
                   (translate :common :show-discuss :space)]]])))
(def tooltip (om/factory Tooltip))

     (move-to-selection (calc-position tooltip.offsetWidth tooltip.offsetHeight)))))


;; -----------------------------------------------------------------------------
;; Selection corrections

(defn- snap-selection
  "Selection optimizations. Snaps to a specific pattern. Currently selects the
  whole sentence, where the selected parts are part of."
  []
  (let [sel (js/document.getSelection)]
    (when (-> sel str count pos?)
      (.modify sel "move"   "backward" "sentence")
      (.modify sel "extend" "forward"  "sentence")
      (.modify sel "extend" "backward" "character")
      sel)))

(defn- save-selected-text
  "Get the user's selection and save it."
  []
  (let [selection (snap-selection)]
    (if-not (nil? selection)
      (do (move-to-selection)
          (lib/save-selection! (str selection)))
      (hide))))

(defn- listen
  "Helper function for mouse-click events."
  [el type]
