<commit_before>###############################################################################
# Displays tooltips on click
###############################################################################

( ($) ->
	
    drmTooltips = {
        config: {
            tooltip: $ '.drm-has-tooltip'
            speed: 300
        }

        init: (config) ->
            $.extend @config, config

            drmTooltips.config.tooltip.on 'mouseenter', @.addTooltip
            drmTooltips.config.tooltip.on 'mouseleave', @.removeTooltip

        addTooltip: ->
            that = $ @
            content = that.data 'title'
            oldTooltip = $ "div.drm-tooltip-#{position}:contains(#{content})"
            position = that.data 'position'

            if oldTooltip.length == 0
                newTooltip = $ '<div></div>', {
                    text: content,
                    class: "drm-tooltip-#{position}"
                }

                newTooltip.hide().insertBefore that
                tooltipCSS = drmTooltips.positionTooltip.call(that, newTooltip, position)

                newTooltip.css(tooltipCSS).fadeIn drmTooltips.config.speed

        positionTooltip: (newTooltip, position) ->
            that = $ @
            positionTop = that.offset().top + parseInt(that.css('padding-top'), 10)
            positionLeft = that.offset().left + parseInt(that.css('padding-left'), 10)
            height = parseInt(newTooltip.outerHeight()
            width = parseInt(newTooltip.outerWidth()
            elWidth = parseInt(that.outerWidth()
            elHeight = parseInt(that.outerHeight()

            if position == 'left'
                tooltipTop = positionTop - (elHeight / 2)
                tooltipLeft = positionLeft - width + 10
            else if position == 'right'
                tooltipTop = positionTop - (elHeight / 2)
                tooltipLeft = positionLeft + elWidth + 15
            else if position == 'bottom'
                tooltipTop = positionTop
                tooltipLeft = positionLeft
            else
                tooltipTop = positionTop - ((elHeight + height) / 2) - 10
                tooltipLeft = positionLeft + ((elWidth + width) / 2)

            console.log "Top: #{tooltipTop} #{positionTop}, Left: #{tooltipLeft} #{positionLeft}"
            console.log "Height: #{height} #{elHeight}, Width: #{width} #{elWidth}"
            tooltipCSS = {'top': "#{tooltipTop}px", 'left': "#{tooltipLeft}px"}

            return tooltipCSS            

        removeTooltip: ->
            that = $ @
            content = that.data 'title'
            position = that.data 'position'
            oldTooltip = $ "div.drm-tooltip-#{position}:contains(#{content})"

            if oldTooltip.length > 0
                oldTooltip.fadeOut drmTooltips.config.speed, ->
                    $(@).remove()
    }
<commit_msg>bug fix<commit_after>###############################################################################
# Displays tooltips on click
###############################################################################

( ($) ->
	
    drmTooltips = {
        config: {
            tooltip: $ '.drm-has-tooltip'
            speed: 300
        }

        init: (config) ->
            $.extend @config, config

            drmTooltips.config.tooltip.on 'mouseenter', @.addTooltip
            drmTooltips.config.tooltip.on 'mouseleave', @.removeTooltip

        addTooltip: ->
            that = $ @
            content = that.data 'title'
            oldTooltip = $ "div.drm-tooltip-#{position}:contains(#{content})"
            position = that.data 'position'

            if oldTooltip.length == 0
                newTooltip = $ '<div></div>', {
                    text: content,
                    class: "drm-tooltip-#{position}"
                }

                newTooltip.hide().insertBefore that
                tooltipCSS = drmTooltips.positionTooltip.call(that, newTooltip, position)

                newTooltip.css(tooltipCSS).fadeIn drmTooltips.config.speed

        positionTooltip: (newTooltip, position) ->
            that = $ @
            positionTop = that.offset().top + parseInt(that.css('padding-top'), 10)
            positionLeft = that.offset().left + parseInt(that.css('padding-left'), 10)
            height = parseInt(newTooltip.outerHeight(), 10)
            width = parseInt(newTooltip.outerWidth(), 10)
            elWidth = parseInt(that.outerWidth(), 10)
            elHeight = parseInt(that.outerHeight(), 10)

            if position == 'left'
                tooltipTop = positionTop - (elHeight / 2)
                tooltipLeft = positionLeft - width + 10
            else if position == 'right'
                tooltipTop = positionTop - (elHeight / 2)
                tooltipLeft = positionLeft + elWidth + 15
            else if position == 'bottom'
                tooltipTop = positionTop
                tooltipLeft = positionLeft
            else
                tooltipTop = positionTop - ((elHeight + height) / 2) - 10
                tooltipLeft = positionLeft + ((elWidth + width) / 2)

            console.log "Top: #{tooltipTop} #{positionTop}, Left: #{tooltipLeft} #{positionLeft}"
            console.log "Height: #{height} #{elHeight}, Width: #{width} #{elWidth}"
            tooltipCSS = {
                'top': "#{tooltipTop}px"
                'left': "#{tooltipLeft}px"
            }

            return tooltipCSS            

        removeTooltip: ->
            that = $ @
            content = that.data 'title'
            position = that.data 'position'
            oldTooltip = $ "div.drm-tooltip-#{position}:contains(#{content})"

            if oldTooltip.length > 0
                oldTooltip.fadeOut drmTooltips.config.speed, ->
                    $(@).remove()
    }

{'fraction_non_alphanumeric': 0.16870584180596243, 'fraction_numerical': 0.00792693434430467, 'mean_word_length': 1.7770334928229665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '813544', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1445, 'n_words': 303}