2 Editor.MessageCenter = Editor.Object.extend({
5 this.flashMessages = [];
6 this.firstFlashMessage = null;
8 console.log("MSC-init:", Date(), this);
11 addMessage: function(type, tag, text, flash)
13 if (!tag) tag = '#default'
24 this.flashMessages.push({
31 if(this.flashMessages[0] && (this.flashMessages[0].tag == tag))
33 clearTimeout(this.timeout);
35 this.changeFlashMessage();
40 /* queue was empty at the start */
41 if (this.flashMessages.length == 1) {
42 console.log("MSC-added-fisrt", Date(), this);
43 this.set('firstFlashMessage', this.flashMessages[0]);
44 this.timeout = setTimeout(this.changeFlashMessage.bind(this), 3000);
51 changeFlashMessage: function()
53 console.log("MSC-change", Date(), this);
54 var previous = this.flashMessages.splice(0, 1);
56 if (this.flashMessages.length > 0)
58 console.log("MSC-chaning-first", Date(), this);
59 this.set('firstFlashMessage', this.flashMessages[0]);
60 this.timeout = setTimeout(this.changeFlashMessage.bind(this), 3000);
62 console.log("MSC-emptying", Date(), this);
63 this.set('firstFlashMessage', null);
70 var messageCenter = new Editor.MessageCenter();