1 /*global View CodeMirror render_template panels */
2 var XMLView = View.extend({
5 template: 'xml-view-template',
8 init: function(element, model, template) {
9 this._super(element, model, template);
11 this.freeze('Ładowanie edytora...');
12 this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
13 parserfile: 'parsexml.js',
14 path: "/static/js/lib/codemirror/",
15 stylesheet: "/static/css/xmlcolors.css",
16 parserConfig: {useHTMLKludges: false},
20 onChange: this.changed.bind(this),
21 initCallback: this.editorDidLoad.bind(this)
26 this.model.setData(this.editor.getCode());
29 editorDidLoad: function(editor) {
30 editor.setCode('Ładowanie edytora...');
31 $(editor.frame).css({width: '100%', height: '100%'});
32 this.editor.setCode(this.model.getData());
35 .addObserver(this, 'reloaded', function() {
36 this.editor.setCode(this.model.getData()); this.unfreeze(); }.bind(this))
37 .addObserver(this, 'needsReload', function() {
38 this.freeze('Niezsynchronizowany'); }.bind(this))
39 .addObserver(this, 'dataChanged', this.textDidChange.bind(this));
42 // $.fbind(self, self.hotkeyPressed),
43 // $.fbind(self, self.isHotkey)
47 textDidChange: function(event) {
48 console.log('textDidChange!');
49 if (this.editor.getCode() != this.model.getData()) {
50 this.editor.setCode(this.model.getData());
55 this.model.removeObserver(this);
56 $(this.editor.frame).remove();
62 panels['xml'] = XMLView;