]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Fix config editor read-only mode attribute 3532/head
authormoisseev <moiseev@mezonplus.ru>
Tue, 27 Oct 2020 15:18:00 +0000 (18:18 +0300)
committermoisseev <moiseev@mezonplus.ru>
Tue, 27 Oct 2020 15:18:00 +0000 (18:18 +0300)
interface/js/app/config.js

index 101935c35872d01c4ac11807e91cda67183bc044..f6a54d65a2595c998b5e5cf512e13b280f174224 100644 (file)
@@ -152,11 +152,13 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                     codejar: true,
                     elt: "div",
                     class: "editor language-clike",
+                    readonly_attr: {contenteditable: false},
                 }
                 // Fallback to textarea if the browser does not support ES6
                 : {
                     elt: "textarea",
                     class: "form-control map-textarea",
+                    readonly_attr: {readonly: true},
                 };
 
             // Modal form for maps
@@ -168,11 +170,20 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                         Map: item.map
                     },
                     success: function (data) {
-                        var readonly = "";
+                        $("<" + editor.elt + ' id="editor" class="' + editor.class + '" data-id="' + item.map + '">' +
+                            rspamd.escapeHTML(data[0].data) +
+                            "</" + editor.elt + ">").appendTo("#modalBody");
+
+                        if (editor.codejar) {
+                            jar = new CodeJar(
+                                document.querySelector("#editor"),
+                                withLineNumbers(Prism.highlightElement)
+                            );
+                        }
+
                         var icon = "fa-edit";
-                        var text = rspamd.escapeHTML(data[0].data);
                         if (item.editable === false || rspamd.read_only) {
-                            readonly = " readonly";
+                            $("#editor").attr(editor.readonly_attr);
                             icon = "fa-eye";
                             $("#modalSaveGroup").hide();
                         } else {
@@ -181,18 +192,6 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                         $("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon);
                         $("#modalTitle").html(item.uri);
 
-                        $("<" + editor.elt + ' id="editor" class="' + editor.class + '"' + readonly +
-                            ' data-id="' + item.map + '">' +
-                            text +
-                            "</" + editor.elt + ">").appendTo("#modalBody");
-
-                        if (editor.codejar) {
-                            jar = new CodeJar(
-                                document.querySelector("#editor"),
-                                withLineNumbers(Prism.highlightElement)
-                            );
-                        }
-
                         $("#modalDialog").modal("show");
                     },
                     errorMessage: "Cannot receive maps data",