-/*global View CodeMirror ButtonToolbarView render_template panels */
+/*global View CodeMirror ToolbarView render_template panels */
var XMLView = View.extend({
_className: 'XMLView',
element: null,
var self = this;
$('.xmlview-toolbar', this.element).bind('resize.xmlview', this.resized.bind(this));
-
-
+
+ // scroll to the given position (if availble)
+ this.scrollCallback = this.scrollOnRequest.bind(this);
+ $(document).bind('xml-scroll-request', this.scrollCallback);
+
this.parent.freeze('Ćadowanie edytora...');
this.editor = new CodeMirror($('.xmlview', this.element).get(0), {
parserfile: 'parsexml.js',
parserConfig: {
useHTMLKludges: false
},
- textWrapping: false,
+ textWrapping: true,
tabMode: 'spaces',
indentUnit: 0,
onChange: this.editorDataChanged.bind(this),
},
dispose: function() {
+ $(document).unbind('xml-scroll-request', this.scrollCallback);
+
this.model.removeObserver(this);
$(this.editor.frame).remove();
this._super();
var ch = String.fromCharCode(code & 0xff).toLowerCase();
/* # console.log(ch.charCodeAt(0), '#', buttons); */
- var buttons = $('.buttontoolbarview-button[title='+ch+']', this.element);
+ var buttons = $('.buttontoolbarview-button[hotkey='+ch+']', this.element);
var mod = 0;
if(event.altKey) mod |= 0x01;
this.buttonToolbar.buttonPressed({
target: button
});
+ },
+
+ scrollOnRequest: function(event, data)
+ {
+ try {
+ var line = this.editor.nthLine(data.line);
+ this.editor.selectLines(line, (data.column-1));
+ } catch(e) {
+ console.log('Exception in scrollOnRequest:', e);
+ }
}
});