1 /*global View CodeMirror render_template panels */
2 var XMLView = View.extend({
5 template: 'xml-view-template',
9 init: function(element, model, template) {
10 this._super(element, model, template);
12 this.freeze('Ćadowanie edytora...');
13 this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
14 parserfile: 'parsexml.js',
15 path: "/static/js/lib/codemirror/",
16 stylesheet: "/static/css/xmlcolors.css",
17 parserConfig: {useHTMLKludges: false},
21 onChange: this.editorDataChanged.bind(this),
22 initCallback: this.editorDidLoad.bind(this)
26 editorDidLoad: function(editor) {
27 $(editor.frame).css({width: '100%', height: '100%'});
30 .addObserver(this, 'data', this.modelDataChanged.bind(this))
31 .addObserver(this, 'synced', this.modelSyncChanged.bind(this));
33 if (!this.model.get('synced')) {
34 this.freeze('Niezsynchronizowany...');
37 this.editor.setCode(this.model.get('data'));
42 // $.fbind(self, self.hotkeyPressed),
43 // $.fbind(self, self.isHotkey)
47 editorDataChanged: function() {
48 this.model.set('data', this.editor.getCode());
51 modelDataChanged: function(property, value) {
52 if (this.editor.getCode() != value) {
53 this.editor.setCode(value);
57 modelSyncChanged: function(property, value) {
61 this.freeze('Niezsynchronizowany...');
66 this.model.removeObserver(this);
67 $(this.editor.frame).remove();
73 panels['xml'] = XMLView;