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.element = $(element);
10 this.model = $(model).get(0);
11 this.template = template || this.template;
12 this.element.html(render_template(this.template, {}));
15 .addObserver(this, 'xml-freeze')
16 .addObserver(this, 'xml-unfreeze');
18 this.freeze('Ładowanie edytora...');
19 this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
20 parserfile: 'parsexml.js',
21 path: "/static/js/lib/codemirror/",
22 stylesheet: "/static/css/xmlcolors.css",
23 parserConfig: {useHTMLKludges: false},
27 onChange: this.changed.bind(this),
28 initCallback: this.editorDidLoad.bind(this)
33 this.model.set('text', this.editor.getCode());
36 editorDidLoad: function(editor) {
37 editor.setCode('Ładowanie edytora...');
38 $(editor.frame).css({width: '100%', height: '100%'});
39 this.editor.setCode(this.model.get('text'));
40 this.model.addObserver(this, 'text-changed');
43 // $.fbind(self, self.hotkeyPressed),
44 // $.fbind(self, self.isHotkey)
48 handle: function(event, data) {
49 console.log('handle', this, event, data);
50 if (event == 'text-changed') {
51 this.freeze('Niezsynchronizowany');
53 } else if (event == 'xml-freeze') {
54 this.freeze('Ładowanie XMLa...');
55 } else if (event == 'xml-unfreeze') {
56 this.editor.setCode(this.model.get('text'));
62 this.model.removeObserver(this);
63 $(this.editor.frame).remove();
69 panels.push({name: 'xml', klass: XMLView});