import Service from '@ember/service'; // @@TODO@@ - 10-27-17 - move errors to addon import Errors from 'ui/utils/errors'; export default Service.extend({ init: function() { $.jGrowl.defaults.pool = 6; $.jGrowl.defaults.closeTemplate = ''; $.jGrowl.defaults.closerTemplate = '
'; }, close: function() { $("div.jGrowl").jGrowl("close"); }, raw: function(title, body, opt) { opt = opt || {}; if ( title ) { opt.header = title; } return $.jGrowl(body, opt); }, success: function(title, body) { this.raw(title, body, { theme: 'success' }); }, message: function(title, body) { this.raw(title, body, { theme: 'message' }); }, error: function(title, body) { this.raw(title, body, { sticky: true, theme: 'error' }); }, fromError: function(title, err) { var body = Errors.stringify(err); this.error(title,body); }, });