coffeescript-ui
Version:
Coffeescript User Interface System
93 lines (76 loc) • 2.13 kB
text/coffeescript
###
* 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
###
CUI.Template.loadTemplateText(require('./WaitBlock.html'));
class CUI.WaitBlock extends CUI.Block
constructor: (opts) ->
super(opts)
if
CUI.dom.addClass(, "cui-wait-block-inactive")
if
CUI.dom.addClass(, "cui-wait-block-fullscreen")
initOpts: ->
super()
"icon",
check: (v) ->
v instanceof CUI.Icon or CUI.util.isString(v)
# inactive is used to block content
# from being accessed
inactive:
check: Boolean
element:
check: (v) ->
CUI.util.isElement(v) or CUI.util.isElement(v.DOM)
# use to put this wait block fullscreen
fullscreen:
check: Boolean
readOpts: ->
super()
CUI.util.assert(CUI.util.xor(, ), "new CUI.WaitBlock", "opts.element or opt.fullscreen needs to be set.", opts: )
if
= document.body
else if .DOM
= .DOM
else
=
if not and not .hasOwnProperty("icon")
= "spinner"
= false
= null
@
getTemplateName: ->
"wait-block"
show: ->
if not CUI.dom.isPositioned()
= CUI.dom.getComputedStyle()["position"]
CUI.dom.setStyleOne(, "position", "relative")
else
= null
CUI.dom.addClass(.DOM, "cui-wait-block-active")
if
CUI.dom.append(, )
else
CUI.dom.append(, )
= true
@
isShown: ->
!!
hide: ->
if not
return @
CUI.dom.remove()
if != null
CUI.dom.setStyleOne(, "position", )
CUI.dom.removeClass(, "cui-wait-block-active")
= false
= null
@
destroy: ->
super()