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 console.log('XMLView#init model:', model);
12 this.template = template || this.template;
13 this.element.html(render_template(this.template, {}));
16 .bind('modelxmlfreeze.xmlview',
17 function() { this.freeze('Ładowanie danych z serwera...'); }.bind(this))
18 .bind('modelxmlunfreeze.xmlview',
19 this.unfreeze.bind(this));
21 this.freeze('Ładowanie edytora...');
22 this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
23 parserfile: 'parsexml.js',
24 path: "/static/js/lib/codemirror/",
25 stylesheet: "/static/css/xmlcolors.css",
26 parserConfig: {useHTMLKludges: false},
30 // onChange: function() {
31 // self.fireEvent('contentChanged');
33 initCallback: this.editorDidLoad.bind(this)
37 editorDidLoad: function(editor) {
38 console.log('init', this.model);
39 editor.setCode('Ładowanie...');
40 $(editor.frame).css({width: '100%', height: '100%'});
41 this.editor.setCode(this.model.xml);
42 $(this.model).bind('modelxmlchanged.xmlview', this.codeChanged.bind(this));
46 // $.fbind(self, self.hotkeyPressed),
47 // $.fbind(self, self.isHotkey)
51 codeChanged: function() {
52 console.log('setCode:', this.editor, this.model);
53 this.editor.setCode(this.model.xml);
59 .unbind('modelxmlchanged.xmlview')
60 .unbind('modelxmlfreeze.xmlview')
61 .unbind('modelxmlunfreeze.xmlview');
62 $(this.editor.frame).remove();
68 panels.push({name: 'xml', klass: XMLView});