1 /*global View render_template panels */
2 var HTMLView = View.extend({
3 _className: 'HTMLView',
6 template: 'html-view-template',
8 init: function(element, model, parent, template) {
9 this._super(element, model, template);
13 .addObserver(this, 'data', this.modelDataChanged.bind(this))
14 .addObserver(this, 'state', this.modelStateChanged.bind(this));
16 $('.htmlview', this.element).html(this.model.get('data'));
17 this.modelStateChanged('state', this.model.get('state'));
21 modelDataChanged: function(property, value) {
22 $('.htmlview', this.element).html(value);
25 modelStateChanged: function(property, value) {
26 if (value == 'synced' || value == 'dirty') {
28 } else if (value == 'unsynced') {
29 this.freeze('Niezsynchronizowany...');
30 } else if (value == 'loading') {
31 this.freeze('Ćadowanie...');
32 } else if (value == 'saving') {
33 this.freeze('Zapisywanie...');
34 } else if (value == 'error') {
35 this.freeze(this.model.get('error'));
41 $('.html-print-link', this.element).unbind();
45 $('.html-print-link', this.element).mouseover(
46 this.printView.bind(this)
51 printView: function(event) {
52 var base = $(event.target).attr('ui:baseref');
53 $(event.target).attr('href', base + "?revision=" + this.model.get('revision') );
59 this.model.load(true);
63 this.model.removeObserver(this);
69 panels['html'] = HTMLView;