Tworzenie domyślnych katalogów current i previous w setup w fabfile.py.
[redakcja.git] / project / static / js / views / flash.js
1 /*globals View render_template*/
2 var FlashView = View.extend({
3   template: 'flash-view-template',
4
5   init: function(element, model, template) {
6     this.shownMessage = null;
7     this._super(element, model, template);
8     this.setModel(model);
9   },
10   
11   setModel: function(model) {
12     if (this.model) {
13       this.model.removeObserver(this);
14     }
15     this.model = model;
16     this.shownMessage = null;
17     if (this.model) {
18       this.shownMessage = this.model.get('firstFlashMessage');
19       this.model.addObserver(this, 'firstFlashMessage', this.modelFirstFlashMessageChanged.bind(this));
20     }
21     this.render();
22   },
23   
24   render: function() {
25     this.element.html(render_template(this.template, this));
26   },
27   
28   modelFirstFlashMessageChanged: function(property, value) {
29     this.element.fadeOut('slow', function() {
30       this.element.css({'z-index': 0});
31       this.shownMessage = value;
32       this.render();
33
34       if(this.shownMessage) {
35         this.element.css({'z-index': 1000});
36         this.element.fadeIn('slow');
37       }
38     }.bind(this));
39   }
40 });