coffeescript-ui
Version:
Coffeescript User Interface System
109 lines (91 loc) • 2.65 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('./ProgressMeter.html'));
class CUI.ProgressMeter extends CUI.DOMElement
constructor: (opts) ->
super(opts)
= new CUI.Template
name: "progress-meter"
map:
icon: true
text: true
fill: true
if
else if .length
__checkState: (state) ->
state in or (typeof(state) == "number" and state >= 0 and state <= 100)
initOpts: ->
super()
if not .states
.states = Object.keys(CUI.defaults.ProgressMeter.states)
states:
check: Array
state:
check: (v) =>
# css property to set to the current
# percent fill, filler will be hidden
# if percent is null
css_property_percent:
default: "width"
check: String
size:
default: "auto"
mandatory: true
check: ["auto","mini","normal","big"]
appearance:
default: "auto"
mandatory: true
check: ["auto","normal","important"]
onUpdate:
check: Function
for state in .states
"icon_"+state,
default: CUI.defaults.ProgressMeter.states[state]
check: (v) =>
v instanceof CUI.Icon or CUI.util.isString(v)
getState: ->
getMeter: ->
setState: (state) ->
CUI.util.assert(, "ProgressMeter.setState", "state needs to be "+.join(",")+" or between 0 and 100.", state: state)
if typeof(state) == "number"
state = Math.round(state*100)/100
if == state
return
= state
if in
icon = @["_icon_"+]
if icon instanceof CUI.Icon
.replace(icon, "icon")
else if not CUI.util.isEmpty(icon)
.replace(new CUI.Icon(icon: icon), "icon")
else
.empty("icon")
# console.debug icon,
.DOM.setAttribute("state", )
.empty("text")
fill_css = {} #display: ""
fill_css[] = ""
else
.DOM.setAttribute("state", "percent")
.empty("icon")
.replace(Math.round()+"%", "text")
fill_css = {} #display: ""
fill_css[] = +"%"
CUI.dom.setStyle(.map.fill, fill_css)
?.call(@, @)
@
CUI.defaults.ProgressMeter =
states:
waiting: "fa-hourglass"
spinning: "svg-spinner cui-spin-stepped"