Translations update
[KiwiIRC.git] / client / src / views / notification.js
1 _kiwi.view.Notification = Backbone.View.extend({
2 className: 'notification',
3
4 events: {
5 'click .close': 'close'
6 },
7
8 initialize: function(title, content) {
9 this.title = title;
10 this.content = content;
11 },
12
13 render: function() {
14 this.$el.html($('#tmpl_notifications').html());
15 this.$('h6').text(this.title);
16
17 // HTML string or jquery object
18 if (typeof this.content === 'string') {
19 this.$('.content').html(this.content);
20 } else if (typeof this.content === 'object') {
21 this.$('.content').empty().append(this.content);
22 }
23
24 return this;
25 },
26
27 show: function() {
28 var that = this;
29
30 this.render().$el.appendTo(_kiwi.app.view.$el);
31
32 // The element won't have any CSS transitions applied
33 // until after a tick + paint.
34 _.defer(function() {
35 that.$el.addClass('show');
36 });
37 },
38
39 close: function() {
40 this.remove();
41 }
42 });