4ed9fc0a2598271c3d1669ac60f4905163a0f22d
[redakcja.git] / project / static / js / views / xml.js
1 /*global Class CodeMirror render_template panels */
2 var XMLView = Class.extend({
3   element: null,
4   template: 'xml-view-template',
5   editor: null,
6   
7   init: function(element, template) {
8     this.element = $(element);
9     this.template = template || this.template;
10     this.element.html(render_template(this.template, {}));
11     
12     var self = this;
13         this.editor = CodeMirror.fromTextArea($('textarea', this.element)[0], {
14       parserfile: 'parsexml.js',
15       path: "/static/js/lib/codemirror/",
16       stylesheet: "/static/css/xmlcolors.css",
17       parserConfig: {useHTMLKludges: false},
18       // onChange: function() {
19       //        self.fireEvent('contentChanged');
20       // },
21       initCallback: function(editor) {
22         console.log('whatever');
23         // editor.grabKeys(
24         //   $.fbind(self, self.hotkeyPressed),
25         //   $.fbind(self, self.isHotkey)
26         // );
27         editor.setCode('Ala ma kota a kot ma AlÄ™!');
28       }
29     });
30     console.log(this.editor);
31     $(this.editor.frame).css({width: '100%', height: '100%'});
32   },
33   
34   dispose: function() {
35     
36   }
37 });
38
39 // Register view
40 panels.push({name: 'xml', klass: XMLView});