X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/fbedc8f26f2879a46629edc72ce20e3e85135523..461c5c048f565ffbc0d9fad72f642c9de8704079:/src/redakcja/static/js/wiki/view_editor_source.js

diff --git a/src/redakcja/static/js/wiki/view_editor_source.js b/src/redakcja/static/js/wiki/view_editor_source.js
index ab8eaf08..478cb11b 100644
--- a/src/redakcja/static/js/wiki/view_editor_source.js
+++ b/src/redakcja/static/js/wiki/view_editor_source.js
@@ -1,76 +1,58 @@
 (function($) {
 
-    function CodeMirrorPerspective(options) {
-	var old_callback = options.callback;
-        options.callback = function(){
-	    var self = this;
+    class CodeMirrorPerspective extends $.wiki.Perspective {
+        constructor(options) {
+            super(options);
+            var self = this;
 
-	    this.codemirror = CodeMirror.fromTextArea($(
+            this.codemirror = CodeMirror.fromTextArea($(
                 '#codemirror_placeholder').get(0), {
                     mode: 'xml',
                     lineWrapping: true,
-		    lineNumbers: true,
-		    readOnly: CurrentDocument.readonly || false,
+                    lineNumbers: true,
+                    readOnly: CurrentDocument.readonly || false,
                     identUnit: 0,
                 });
 
+            $('#source-editor').keydown(function(event) {
+                if(!event.altKey)
+                    return;
 
-	    $('#source-editor').keydown(function(event) {
-		if(!event.altKey)
-		    return;
-
-		var c = event.key;
-		var button = $("#source-editor button[data-ui-accesskey='"+c+"']");
-		if(button.length == 0)
-		    return;
+                var c = event.key;
+                var button = $("#source-editor button[data-ui-accesskey='"+c+"']");
+                if(button.length == 0)
+                    return;
                 button.get(0).click();
                 event.preventDefault();
-	    });
-
-	    $('#source-editor .toolbar').toolbarize({
-		actionContext: self.codemirror
-	    });
-
-	    // textarea is no longer needed
-	    $('#codemirror_placeholder').remove();
-	    old_callback.call(self);
-	}
-
-        $.wiki.Perspective.call(this, options);
-    };
-
-
-    CodeMirrorPerspective.prototype = new $.wiki.Perspective();
-
-    CodeMirrorPerspective.prototype.freezeState = function() {
-        this.config().position =  this.codemirror.getScrollInfo().top;
-    };
-
-    CodeMirrorPerspective.prototype.unfreezeState = function () {
-        this.codemirror.scrollTo(0, this.config().position || 0);
-    };
-
-	CodeMirrorPerspective.prototype.onEnter = function(success, failure) {
-		$.wiki.Perspective.prototype.onEnter.call(this);
+            });
 
-		this.codemirror.setValue(this.doc.text);
+            $('#source-editor .toolbar').toolbarize({
+                actionContext: self.codemirror
+            });
 
-		this.unfreezeState(this._uistate);
+            // textarea is no longer needed
+            $('#codemirror_placeholder').remove();
+        }
 
-		if(success) success();
-	}
+        onEnter(success, failure) {
+            super.onEnter();
+            this.codemirror.setValue(this.doc.text);
+            this.codemirror.scrollTo(0, this.config().position || 0);
 
-	CodeMirrorPerspective.prototype.onExit = function(success, failure) {
-		this.freezeState();
+            if(success) success();
+        }
 
-		$.wiki.Perspective.prototype.onExit.call(this);
-	    this.doc.setText(this.codemirror.getValue());
+        onExit(success, failure) {
+            super.onExit();
+            this.config().position =  this.codemirror.getScrollInfo().top;
+            this.doc.setText(this.codemirror.getValue());
 
             $.wiki.exitTab('#SearchPerspective');
 
-	    if(success) success();
-	}
+            if(success) success();
+        }
+    }
 
-	$.wiki.CodeMirrorPerspective = CodeMirrorPerspective;
+    $.wiki.CodeMirrorPerspective = CodeMirrorPerspective;
 
 })(jQuery);