Commit | Line | Data |
---|---|---|
50ac472f D |
1 | _kiwi.view.StatusMessage = Backbone.View.extend({ |
2 | initialize: function () { | |
3 | this.$el.hide(); | |
4 | ||
5 | // Timer for hiding the message after X seconds | |
6 | this.tmr = null; | |
7 | }, | |
8 | ||
9 | text: function (text, opt) { | |
10 | // Defaults | |
11 | opt = opt || {}; | |
12 | opt.type = opt.type || ''; | |
13 | opt.timeout = opt.timeout || 5000; | |
14 | ||
15 | this.$el.text(text).addClass(opt.type); | |
16 | this.$el.slideDown($.proxy(_kiwi.app.view.doLayout, _kiwi.app.view)); | |
17 | ||
18 | if (opt.timeout) this.doTimeout(opt.timeout); | |
19 | }, | |
20 | ||
21 | html: function (html, opt) { | |
22 | // Defaults | |
23 | opt = opt || {}; | |
24 | opt.type = opt.type || ''; | |
25 | opt.timeout = opt.timeout || 5000; | |
26 | ||
5ce8f9e2 | 27 | this.$el.html(html).addClass(opt.type); |
50ac472f D |
28 | this.$el.slideDown($.proxy(_kiwi.app.view.doLayout, _kiwi.app.view)); |
29 | ||
30 | if (opt.timeout) this.doTimeout(opt.timeout); | |
31 | }, | |
32 | ||
33 | hide: function () { | |
34 | this.$el.slideUp($.proxy(_kiwi.app.view.doLayout, _kiwi.app.view)); | |
35 | }, | |
36 | ||
37 | doTimeout: function (length) { | |
38 | if (this.tmr) clearTimeout(this.tmr); | |
39 | var that = this; | |
40 | this.tmr = setTimeout(function () { that.hide(); }, length); | |
41 | } | |
42 | }); |