Naprawienie przycisków.
[redakcja.git] / project / static / js / messages.js
1 /*global Editor*/
2 Editor.MessageCenter = Editor.Object.extend({
3   init: function() {
4     this.messages = [];
5     this.flashMessages = [];
6     this.firstFlashMessage = null;
7   },
8   
9   addMessage: function(type, text, flash) {
10     this.messages.push({type: type, text: text});
11     if (flash) {
12       this.flashMessages.push({type: type, text: flash});
13       if (this.flashMessages.length == 1) {
14         this.set('firstFlashMessage', this.flashMessages[0]);
15         setTimeout(this.changeFlashMessage.bind(this), 1000 * 10);
16       }
17     }
18   },
19   
20   changeFlashMessage: function() {
21     this.flashMessages.splice(0, 1);
22     if (this.flashMessages.length > 0) {
23       this.set('firstFlashMessage', this.flashMessages[0]);
24       setTimeout(this.changeFlashMessage.bind(this), 1000 * 10);
25     } else {
26       this.set('firstFlashMessage', null);
27     }
28   }
29   
30 });
31
32
33 var messageCenter = new Editor.MessageCenter();
34