 
         return unbindEvents
 
+
+    # The module's public interface.
     return {
-        bind: -> attachTooltips()
+        bind: -> bindAll()
         unbind: -> unbindAll()
     }
-
 )

                tip.setAttribute 'aria-hidden', true
            , 30

        @addEventListener 'mouseover', onMouseOver
        @addEventListener 'mouseout', onMouseOut

        unbindEvents = =>
            tip.removeEventListener 'mouseover', onMouseOver
            tip.removeEventListener 'mouseout', onMouseOut

# Wrappers for AMD and CommonJS. Fallback to global scope.
((root, factory) ->

    # If AMD is used.
    if typeof define is "function" and define.amd
        define [], factory

    # If CommonJS is used.
    else if typeof module is "object" and module.exports
        module.exports = factory()

    # Otherwise bind to `window` object.
    else
        root.AriaTips = factory()

)(this, ->

    ###
        * Tooltips are the elements that are displayed when the mouse hovers a
        trigger.

        * Triggers are the elements that listen to mouseover events in order to
        show the tooltips.
    ###


    # Number of pixels the tooltip's arrow takes.
    ARROW_DELTA = 6


    # Unbinders are functions that unbind events on triggers. They are defined
    # when the events are bound.
    unbinders = []


    # Do all the magic needed to show the tooltips!
    bindAll = ->
        # Unbind all existing events in order to prevent listening to the same
        # event multiple times.
        unbindAll()

        # Get all tooltips in the DOM.
        tips = document.querySelectorAll '[role=tooltip]'

        for tip in tips
            # Tooltips need to be appended to body for global positioning.
            document.body.appendChild tip

            # Get all triggers in the DOM.
            triggers = document.querySelectorAll "[aria-describedby=#{tip.id}]"
            for trigger in triggers

                # Bind the mouseover/mouseout events on the trigger.
                unbinder = bindEvents.call trigger

                # Store the returned function to unbind the events if needed.
                unbinders.push unbinder


    # Remove all the magic that show the tooltips.
    unbindAll = ->
        unbinder() for unbinder in unbinders
        unbinders = []


    # Return the opposite position, given a position.
    oppositePosition = (position) ->
        switch position
            when 'top'    then 'bottom'
