<commit_before>###
 * coffeescript-ui - Coffeescript User Interface System (CUI)
 * Copyright (c) 2013 - 2016 Programmfabrik GmbH
 * MIT Licence
 * https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###

class WaitBlock extends Block
	constructor: (@opts={}) ->
		super(@opts)
		if @_inactive
			@DOM.addClass("cui-wait-block-inactive")

		if @_fullscreen
			@DOM.addClass("cui-wait-block-fullscreen")

	initOpts: ->
		super()
		@mergeOpt "icon",
			check: (v) ->
				v instanceof Icon or isString(v)

		@removeOpt("header")
		@removeOpt("content")

		@addOpts
			# inactive is used to block content
			# from being accessed
			inactive:
				check: Boolean
			element:
				check: (v) ->
					isElement(v) or isElement(v.DOM)
			# use to put this wait block fullscreen
			fullscreen:
				check: Boolean

	readOpts: ->
		super()
		assert(xor(@_element, @_fullscreen), "new WaitBlock", "opts.element or opt.fullscreen needs to be set.", opts: @opts)

		if @_fullscreen
			@__element = $(document.body)
		else if @_element.DOM
			@__element = @_element.DOM
		else
			@__element = @_element

		if not @_inactive and not @opts.hasOwnProperty("icon")
			@_icon = "spinner"

		@__shown = false
		@__savedPosition = null
		@

	getTemplateName: ->
		"wait-block"

	show: ->
		position = @__element[0].style.position
		if not DOM.isPositioned(@__element[0])
			@__savedPosition = @__element[0].style.position
			@__element[0].style.position = "relative"
		else
			@__savedPosition = null

		@__element.addClass("cui-wait-block-active")
		if @_fullscreen
			@DOM.appendTo(@__element)
		else
			@__element.append(@DOM)
		@__shown = true
		@

	isShown: ->
		!!@__shown

	hide: ->
		if not @isShown()
			return @
		@DOM.detach()
		if @__savedPosition != null
			@__element[0].style.position = @__savedPosition

		@__element.removeClass("cui-wait-block-active")
		@__shown = false
		@__savedPosition = null
		@

	destroy: ->
		@hide()
		super()<commit_msg>WaitBlock: Move to CUI.WaitBlock.<commit_after>###
 * coffeescript-ui - Coffeescript User Interface System (CUI)
 * Copyright (c) 2013 - 2016 Programmfabrik GmbH
 * MIT Licence
 * https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###

class CUI.WaitBlock extends CUI.Block
	constructor: (@opts={}) ->
		super(@opts)
		if @_inactive
			@DOM.addClass("cui-wait-block-inactive")

		if @_fullscreen
			@DOM.addClass("cui-wait-block-fullscreen")

	initOpts: ->
		super()
		@mergeOpt "icon",
			check: (v) ->
				v instanceof Icon or isString(v)

		@removeOpt("header")
		@removeOpt("content")

		@addOpts
			# inactive is used to block content
			# from being accessed
			inactive:
				check: Boolean
			element:
				check: (v) ->
					isElement(v) or isElement(v.DOM)
			# use to put this wait block fullscreen
			fullscreen:
				check: Boolean

	readOpts: ->
		super()
		assert(xor(@_element, @_fullscreen), "new WaitBlock", "opts.element or opt.fullscreen needs to be set.", opts: @opts)

		if @_fullscreen
			@__element = $(document.body)
		else if @_element.DOM
			@__element = @_element.DOM
		else
			@__element = @_element

		if not @_inactive and not @opts.hasOwnProperty("icon")
			@_icon = "spinner"

		@__shown = false
		@__savedPosition = null
		@

	getTemplateName: ->
		"wait-block"

	show: ->
		position = @__element[0].style.position
		if not DOM.isPositioned(@__element[0])
			@__savedPosition = @__element[0].style.position
			@__element[0].style.position = "relative"
		else
			@__savedPosition = null

		@__element.addClass("cui-wait-block-active")
		if @_fullscreen
			@DOM.appendTo(@__element)
		else
			@__element.append(@DOM)
		@__shown = true
		@

	isShown: ->
		!!@__shown

	hide: ->
		if not @isShown()
			return @
		@DOM.detach()
		if @__savedPosition != null
			@__element[0].style.position = @__savedPosition

		@__element.removeClass("cui-wait-block-active")
		@__shown = false
		@__savedPosition = null
		@

	destroy: ->
		@hide()
		super()

WaitBlock = CUI.WaitBlock
{'fraction_non_alphanumeric': 0.14035526644983737, 'fraction_numerical': 0.006504878658994246, 'mean_word_length': 3.5277463193657983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5778619', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1409, 'n_words': 314}