<commit_before>###############################################################################
# Displays popovers on hover
###############################################################################

( ($) ->

	drmPopover = {
		
	}
	
	holders = $ '.popover-holder'
	buttons = holders.find 'button'
	popovers = holders.find '.drm-popover'
	html = $ 'html'

	buttons.on 'click', (e) ->
		popoverId = $(@).data 'popover'
		popover = $("##{popoverId}")

		popover.toggle()
		e.stopPropagation()
		
		if popover.offset().left < 0
			position = popover.position().left
			popover.css('left': (Math.abs(popover.offset().left) + 10) + position)

	html.click ->
		popovers.hide()	

) jQuery<commit_msg>fixed popover top and left viewport overflow problem<commit_after>###############################################################################
# Displays popovers on hover
###############################################################################

( ($) ->

	drmPopover = {
		holders: $ '.popover-holder'

		init: ->
			buttons = @.holders.find 'button'
			popovers = @.holders.find '.drm-popover'

			buttons.on 'click', @.togglePopover

			$('html').click ->
				popovers.hide()	

		togglePopover: (e) ->
			popoverId = $(@).data 'popover'
			popover = $("##{popoverId}")

			popover.toggle()
			e.stopPropagation()

			drmPopover.checkPosition.call popover

		checkPosition: ->
			that = $ @
			positionLeft = that.position().left
			offsetLeft = that.offset().left
			positionTop = that.position().top
			offsetTop = that.offset().top
			popoverHeight = that.height()

			if offsetLeft < 0				
				that.css('left': (Math.abs(offsetLeft) + 10) + positionLeft)
			else if offsetTop < 0
				that.css('bottom': (Math.abs(positionTop) - popoverHeight) - Math.abs(offsetTop)) 					
	}

	drmPopover.init()	

) jQuery
{'fraction_non_alphanumeric': 0.31006047278724574, 'fraction_numerical': 0.0038482682792743265, 'mean_word_length': 4.055555555555555, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 11, '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': '6976052', 'n_tokens_mistral': 658, 'n_tokens_neox': 545, 'n_words': 104}