Fixed uncaught exception in RAL.
[redakcja.git] / project / static / js / views / html.js
1 /*global View render_template panels */
2 var HTMLView = View.extend({
3   _className: 'HTMLView',
4   element: null,
5   model: null,
6   template: 'html-view-template',
7   
8   init: function(element, model, parent, template) {
9     this._super(element, model, template);
10     this.parent = parent;
11     
12     this.model
13       .addObserver(this, 'data', this.modelDataChanged.bind(this))
14       .addObserver(this, 'synced', this.modelSyncChanged.bind(this));
15       
16     $('.htmlview', this.element).html(this.model.get('data'));
17     if (!this.model.get('synced')) {
18       this.parent.freeze('Niezsynchronizowany...');
19       this.model.load();
20     }
21   },
22   
23   modelDataChanged: function(property, value) {
24     $('.htmlview', this.element).html(value);
25   },
26   
27   modelSyncChanged: function(property, value) {
28     if (value) {
29       this.parent.unfreeze();
30     } else {
31       this.parent.freeze('Niezsynchronizowany...');
32     }
33   },
34   
35   dispose: function() {
36     this.model.removeObserver(this);
37     this._super();
38   }
39 });
40
41 // Register view
42 panels['html'] = HTMLView;