3 class CodeMirrorPerspective extends $.wiki.Perspective {
5 var old_callback = options.callback;
6 options.callback = function(){
9 this.codemirror = CodeMirror.fromTextArea($(
10 '#codemirror_placeholder').get(0), {
14 readOnly: CurrentDocument.readonly || false,
18 $('#source-editor').keydown(function(event) {
23 var button = $("#source-editor button[data-ui-accesskey='"+c+"']");
24 if(button.length == 0)
26 button.get(0).click();
27 event.preventDefault();
30 $('#source-editor .toolbar').toolbarize({
31 actionContext: self.codemirror
34 // textarea is no longer needed
35 $('#codemirror_placeholder').remove();
36 old_callback.call(self);
42 this.config().position = this.codemirror.getScrollInfo().top;
46 this.codemirror.scrollTo(0, this.config().position || 0);
49 onEnter(success, failure) {
52 this.codemirror.setValue(this.doc.text);
54 this.unfreezeState(this._uistate);
56 if(success) success();
59 onExit(success, failure) {
63 this.doc.setText(this.codemirror.getValue());
65 $.wiki.exitTab('#SearchPerspective');
67 if(success) success();
71 $.wiki.CodeMirrorPerspective = CodeMirrorPerspective;