]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Rework symbol description tooltips
authormoisseev <moiseev@mezonplus.ru>
Thu, 17 Jun 2021 16:19:13 +0000 (19:19 +0300)
committermoisseev <moiseev@mezonplus.ru>
Thu, 17 Jun 2021 16:19:13 +0000 (19:19 +0300)
interface/js/app/history.js
interface/js/app/rspamd.js
interface/js/app/upload.js

index 8feb527e1aa7cadb6a28a8dadeac9ce0d232ff9a..3ab8d1d319fca94dce5b442eb0358b373b865d50 100644 (file)
@@ -352,12 +352,6 @@ define(["jquery", "footable"],
                         if (Object.prototype.hasOwnProperty.call(tables, "history") &&
                             version === prevVersion) {
                             tables.history.rows.load(items);
-                            if (version) { // Non-legacy
-                                // Is there a way to get an event when all rows are loaded?
-                                rspamd.waitForRowsDisplayed("history", items.length, function () {
-                                    rspamd.drawTooltips();
-                                });
-                            }
                         } else {
                             rspamd.destroyTable("history");
                             // Is there a way to get an event when the table is destroyed?
index 1679db1b3894ac125a1ef9792ba2a53f709fa0fb..a99cbd4fb1b37579aef7ee876486dd96e7b87fcb 100644 (file)
@@ -50,7 +50,6 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
     var timer_id = [];
     var locale = null;
     var selData = null; // Graph's dataset selector state
-    var symbolDescriptions = {};
 
     NProgress.configure({
         minimum: 0.01,
@@ -210,17 +209,6 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         }, (id === "#autoRefresh") ? 0 : 1000);
     }
 
-    function drawTooltips() {
-        // Update symbol description tooltips
-        $.each(symbolDescriptions, function (key, description) {
-            $("abbr[data-sym-key=" + key + "]").tooltip({
-                placement: "bottom",
-                html: true,
-                title: description
-            });
-        });
-    }
-
     function getPassword() {
         return sessionStorage.getItem("Password");
     }
@@ -520,6 +508,12 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
             tabClick("#" + $("#navBar > ul > .nav-item > .nav-link.active").attr("id"));
         });
 
+        $("body").tooltip({
+            selector: ".symbol-default abbr[title]",
+            placement: "left",
+            html: true
+        });
+
         // Radio buttons
         $(document).on("click", "input:radio[name=\"clusterName\"]", function () {
             if (!this.disabled) {
@@ -764,7 +758,6 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
 
     // Scan and History shared functions
 
-    ui.drawTooltips = drawTooltips;
     ui.unix_time_format = unix_time_format;
     ui.set_page_size = set_page_size;
 
@@ -776,7 +769,6 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                 var cell_val = sort_symbols(ui.symbols[table][i], compare_function);
                 row.cells[symbolsCol].val(cell_val, false, true);
             });
-            drawTooltips();
         }
 
         $("#selSymOrder_" + table).unbind().change(function () {
@@ -883,10 +875,6 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                 filtering: FooTable.actionFilter
             },
             on: {
-                "ready.ft.table": drawTooltips,
-                "after.ft.sorting": drawTooltips,
-                "after.ft.paging": drawTooltips,
-                "after.ft.filtering": drawTooltips,
                 "expand.ft.row": function (e, ft, row) {
                     setTimeout(function () {
                         var detail_row = row.$el.next();
@@ -1020,18 +1008,15 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                 }
 
                 rspamd.preprocess_item(rspamd, item);
-                Object.keys(item.symbols).forEach(function (key) {
-                    var sym = item.symbols[key];
+                Object.values(item.symbols).forEach(function (sym) {
                     sym.str = '<span class="symbol-default ' + get_symbol_class(sym.name, sym.score) + '"><strong>';
 
                     if (sym.description) {
-                        sym.str += '<abbr data-sym-key="' + key + '">' +
-                            sym.name + "</abbr></strong> (" + sym.score + ")</span>";
-                        // Store description for tooltip
-                        symbolDescriptions[key] = sym.description;
+                        sym.str += '<abbr title="' + sym.description + '">' + sym.name + "</abbr>";
                     } else {
-                        sym.str += sym.name + "</strong> (" + sym.score + ")</span>";
+                        sym.str += sym.name;
                     }
+                    sym.str += "</strong> (" + sym.score + ")</span>";
 
                     if (sym.options) {
                         sym.str += " [" + sym.options.join(",") + "]";
index 936e223e403baf2ee3d27669f9f357de6f0c0424..88b7da4233a56127b5f2d2ae98ff475eae91ae14 100644 (file)
@@ -148,7 +148,6 @@ define(["jquery"],
                             tables.scan.rows.load(items, true);
                             // Is there a way to get an event when all rows are loaded?
                             rspamd.waitForRowsDisplayed("scan", rows_total, function () {
-                                rspamd.drawTooltips();
                                 $("html, body").animate({
                                     scrollTop: $("#scanResult").offset().top
                                 }, 1000);