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 if (!this.model.get('synced')) {
38 this.parent.freeze('Niezsynchronizowany...');
41 this.editor.setCode(this.model.get('data'));
45 // $.fbind(self, self.hotkeyPressed),
46 // $.fbind(self, self.isHotkey)
50 editorDataChanged: function() {
51 this.model.set('data', this.editor.getCode());
54 modelDataChanged: function(property, value) {
55 if (this.editor.getCode() != value) {
56 this.editor.setCode(value);
60 modelSyncChanged: function(property, value) {
62 this.parent.unfreeze();
64 this.parent.freeze('Niezsynchronizowany...');
69 this.model.removeObserver(this);
70 $(this.editor.frame).remove();
76 panels['xml'] = XMLView;