Copy StatusMessage to admin.utils module, eventually to be moved here

This commit is contained in:
Rohan Mitchell
2015-12-10 09:32:04 +11:00
parent c1a80b1e8f
commit eba2aae353
3 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
angular.module("admin.utils").factory "StatusMessage", ($timeout) ->
new class StatusMessage
types:
progress: {timeout: false, style: {color: '#ff9906'}}
alert: {timeout: 5000, style: {color: 'grey'}}
notice: {timeout: false, style: {color: 'grey'}}
success: {timeout: 5000, style: {color: '#9fc820'}}
failure: {timeout: false, style: {color: '#da5354'}}
statusMessage:
text: ""
style: {}
display: (type, text) ->
@statusMessage.text = text
@statusMessage.style = @types[type].style
$timeout.cancel @statusMessage.timeout if @statusMessage.timeout
timeout = @types[type].timeout
if timeout
@statusMessage.timeout = $timeout =>
@clear()
, timeout, true
clear: ->
@statusMessage.text = ''
@statusMessage.style = {}