1 /*global View CodeMirror render_template panels */
2 var XMLView = View.extend({
6 template: 'xml-view-template',
10 init: function(element, model, parent, template) {
11 this._super(element, model, template);
14 this.parent.freeze('Ćadowanie edytora...');
15 this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
16 parserfile: 'parsexml.js',
17 path: "/static/js/lib/codemirror/",
18 stylesheet: "/static/css/xmlcolors.css",
19 parserConfig: {useHTMLKludges: false},
23 onChange: this.editorDataChanged.bind(this),
24 initCallback: this.editorDidLoad.bind(this)
28 editorDidLoad: function(editor) {
29 $(editor.frame).css({width: '100%', height: '100%'});
32 .addObserver(this, 'data', this.modelDataChanged.bind(this))
33 .addObserver(this, 'synced', this.modelSyncChanged.bind(this));
35 this.parent.unfreeze();
37 this.editor.setCode(this.model.get('data'));
38 if (!this.model.get('synced')) {
39 this.parent.freeze('Niezsynchronizowany...');
44 // $.fbind(self, self.hotkeyPressed),
45 // $.fbind(self, self.isHotkey)
49 editorDataChanged: function() {
50 this.model.set('data', this.editor.getCode());
53 modelDataChanged: function(property, value) {
54 if (this.editor.getCode() != value) {
55 this.editor.setCode(value);
59 modelSyncChanged: function(property, value) {
61 this.parent.unfreeze();
63 this.parent.freeze('Niezsynchronizowany...');
68 this.model.removeObserver(this);
69 $(this.editor.frame).remove();
75 panels['xml'] = XMLView;