<commit_before>###*
 * Responsive Elements
 *
 * Inspired by https://github.com/kumailht/responsive-elements
 * 
 * @copyright <NAME> 2014
 * @version   1.1.0
###

do ->
	window.re = do ->
		b = this

		# Configuration
		b.config =
			attr:         'data-respond'
			widthAttr:    'data-width'
			refreshRate:  50
			rootFontSize: parseInt (getComputedStyle document.documentElement).fontSize
			baseFontSize: 16
			start:        100
			end:          900
			interval:     50

		# DOM elements
		b.dom =
			window:   window
			elements: document.querySelectorAll "[#{b.config.attr}]"

		# Utilities
		util =
			debounce: (func, wait, immediate) ->
				->
					context = @
					args    = arguments

					later = ->
						timeout = null;

						if ! immediate
							result = func.apply context, args

					callNow = immediate and ! timeout

					clearTimeout timeout

					timeout = setTimeout later, wait

					if callNow
						result = func.apply context, args

					result

		# Bind listeners
		bind = ->
			dom.window.addEventListener 'load', respondAll
			dom.window.addEventListener 'resize', debounceRespondAll

		# Unbind listeners
		unbind = ->
			dom.window.removeEventListener 'load', respondAll, false
			dom.window.removeEventListener 'resize', debounceRespondAll, false

		# Respond all elements
		respondAll = (e) ->
			for element in dom.elements
				respond element

		# Respond with a debounce
		debounceRespondAll = util.debounce respondAll, b.config.refreshRate

		# Respond single element
		respond = (element) ->
			params = parseParams (element.getAttribute b.config.attr)

			data = makeData element.offsetWidth, params

			element.setAttribute b.config.widthAttr, (data.join ' ')

		# Make responsive data
		makeData = (width, params) ->
			data = []

			i = if params.interval > params.start then params.interval else ~~(params.start / params.interval) * params.interval

			width = width * (b.config.baseFontSize / b.config.rootFontSize)

			while i <= params.end
				data.push "gt#{i}" if i < width
				data.push "lt#{i}" if i >= width

				i += params.interval

			data

		# Parse parameters
		parseParams = (string) ->
			params  =
				start:    b.config.start
				end:      b.config.end
				interval: b.config.interval

			matches = string.match /([a-zA-Z]+|[0-9]+)/g

			if ! matches
				return params

			for match, i in matches by 2
				switch match[0].toLowerCase()
					when 's' then params.start    = +matches[i + 1]
					when 'e' then params.end      = +matches[i + 1]
					when 'i' then params.interval = +matches[i + 1]

			params

		# Public methods
		# Set configuration
		b.setConfig = (config) ->
			for key, value of config
				b.config[key] = value if b.config[key]?

			b.dom.elements = document.querySelectorAll "[#{b.config.attr}]"

			b

		# Enable
		b.enable = (config) ->
			if config
				b.setConfig config
				
			bind()
			b

		# Disable
		b.disable = ->
			unbind()
			b

		# Refresh
		b.refresh = ->
			respondAll()
			b

		# Return self
		b<commit_msg>Was returning the window instead of re object<commit_after>###*
 * Responsive Elements
 *
 * Inspired by https://github.com/kumailht/responsive-elements
 * 
 * @copyright <NAME> 2014
 * @version   1.1.1
###

do ->
	window.re = new ->
		b = this

		# Configuration
		b.config =
			attr:         'data-respond'
			widthAttr:    'data-width'
			refreshRate:  50
			rootFontSize: parseInt (getComputedStyle document.documentElement).fontSize
			baseFontSize: 16
			start:        100
			end:          900
			interval:     50

		# DOM elements
		b.dom =
			window:   window
			elements: document.querySelectorAll "[#{b.config.attr}]"

		# Utilities
		util =
			debounce: (func, wait, immediate) ->
				->
					context = @
					args    = arguments

					later = ->
						timeout = null;

						if ! immediate
							result = func.apply context, args

					callNow = immediate and ! timeout

					clearTimeout timeout

					timeout = setTimeout later, wait

					if callNow
						result = func.apply context, args

					result

		# Bind listeners
		bind = ->
			b.dom.window.addEventListener 'load', respondAll
			b.dom.window.addEventListener 'resize', debounceRespondAll

		# Unbind listeners
		unbind = ->
			b.dom.window.removeEventListener 'load', respondAll, false
			b.dom.window.removeEventListener 'resize', debounceRespondAll, false

		# Respond all elements
		respondAll = (e) ->
			for element in b.dom.elements
				respond element

		# Respond with a debounce
		debounceRespondAll = util.debounce respondAll, b.config.refreshRate

		# Respond single element
		respond = (element) ->
			params = parseParams (element.getAttribute b.config.attr)

			data = makeData element.offsetWidth, params

			element.setAttribute b.config.widthAttr, (data.join ' ')

		# Make responsive data
		makeData = (width, params) ->
			data = []

			i = if params.interval > params.start then params.interval else ~~(params.start / params.interval) * params.interval

			width = width * (b.config.baseFontSize / b.config.rootFontSize)

			while i <= params.end
				data.push "gt#{i}" if i < width
				data.push "lt#{i}" if i >= width

				i += params.interval

			data

		# Parse parameters
		parseParams = (string) ->
			params  =
				start:    b.config.start
				end:      b.config.end
				interval: b.config.interval

			matches = string.match /([a-zA-Z]+|[0-9]+)/g

			if ! matches
				return params

			for match, i in matches by 2
				switch match[0].toLowerCase()
					when 's' then params.start    = +matches[i + 1]
					when 'e' then params.end      = +matches[i + 1]
					when 'i' then params.interval = +matches[i + 1]

			params

		# Public methods
		# Set configuration
		b.setConfig = (config) ->
			for key, value of config
				b.config[key] = value if b.config[key]?

			b.dom.elements = document.querySelectorAll "[#{b.config.attr}]"

			b

		# Enable
		b.enable = ->
			bind()
			b

		# Disable
		b.disable = ->
			unbind()
			b

		# Refresh
		b.refresh = ->
			respondAll()
			b

		# Return self
		b
{'fraction_non_alphanumeric': 0.11382925611582626, 'fraction_numerical': 0.008653686137460476, 'mean_word_length': 2.5002912055911475, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, 'https://': 2, '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': '7119381', 'n_tokens_mistral': 2400, 'n_tokens_neox': 1872, 'n_words': 513}