antos-frontend/src/core/BaseService.coffee
2017-08-16 00:27:32 +02:00

42 lines
1014 B
CoffeeScript

MAIL = this.OS.courrier
_API = this.OS.API
class BaseService extends this.OS.GUI.BaseModel
constructor: (name) ->
super name
@icon = undefined
@iconclass = "fa-paper-plane-o"
@text = ""
@timer = undefined
@holder = undefined
init: ()->
#implement by user
# event registe, etc
# scheme loader
attach: (h) ->
@holder = h
update: () -> @holder.update() if @holder
watch: ( t, f) ->
me = @
func = () ->
f()
me.timer = setTimeout (() -> func()), t
func()
onexit: (evt) ->
console.log "clean timer" if @timer
clearTimeout @timer if @timer
@cleanup(evt)
($ @scheme).remove() if @scheme
main: () ->
show: () ->
awake: (e) ->
#implement by user to tart the service
cleanup: (evt) ->
#implemeted by user
BaseService.type = 2
BaseService.singleton = true
this.OS.GUI.BaseService = BaseService