From 96bd15b3e2e347f9dccf565cf35c62e958f6b034 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Thu, 12 Jan 2023 11:55:34 -0600 Subject: [PATCH] Display cell content via context menu (#634) --- static/css/app.css | 53 ++++++++++++++++++++++++++++++++++++++++++++++ static/index.html | 12 +++++++++++ static/js/app.js | 36 +++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/static/css/app.css b/static/css/app.css index 72a57e2..f095c8f 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -625,6 +625,59 @@ float: left; } +#content_modal { + display: none; + width: 60%; + height: 400px; + position: fixed; + top: 20%; + left: 20%; + background: #fff; + border: 1px solid #ccc; + box-shadow: #ddd 0 0 20px; +} + +#content_modal .content { + border: 0px none; + position: relative; + padding: 8px; + white-space: break-spaces; + background: #fff; + overflow-y: scroll; + height: 366px; + box-sizing: border-box; +} + +#content_modal .title { + font-weight: bold; + line-height: 24px; + background: #f5f5f5; + padding: 4px 4px 4px 8px; +} + +#content_modal .actions { + float: right; +} + +#content_modal .actions .fa { + float: right; + width: 24px; + height: 24px; + line-height: 24px; + font-size: 13px; + text-align: center; + background: #fff; + border: 1px solid #ddd; + border-radius: 3px; + cursor: pointer; + margin-left: 4px; +} + +#content_modal .actions .fa:hover { + border-color: #999; + box-shadow: #eee 0 0 5px; +} + /* -------------------------------------------------------------------------- */ #custom_query { diff --git a/static/index.html b/static/index.html index 9374c0b..59a6fcf 100644 --- a/static/index.html +++ b/static/index.html @@ -139,6 +139,17 @@ +
+
+ Cell Content +
+ + +
+
+

+  
+
@@ -312,6 +323,7 @@
diff --git a/static/js/app.js b/static/js/app.js index e078777..691a34a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1146,6 +1146,11 @@ function bindTableHeaderMenu() { var menuItem = $(e.target); switch(menuItem.data("action")) { + case "display_value": + var value = $(context).text(); + $("#content_modal .content").text(value); + $("#content_modal").show(); + break; case "copy_value": copyToClipboard($(context).text()); break; @@ -1375,8 +1380,39 @@ function onInputResize(event) { resizeInput(computedHeight); } +function bindContentModalEvents() { + var contentModal = document.getElementById("content_modal"); + + $(window).on("click", function(e) { + // Automatically hide the modal on any click outside of the modal window + if (e.target && !contentModal.contains(e.target)) { + $("#content_modal").hide(); + } + }); + + $("#content_modal .content-modal-action").on("click", function() { + switch ($(this).data("action")) { + case "copy": + copyToClipboard($("#content_modal pre").text()); + break; + case "close": + $("#content_modal").hide(); + break; + } + }); + + $("#results").on("dblclick", "td > div", function() { + var value = unescapeHtml($(this).html()); + if (!value) return; + + $("#content_modal pre").html(value); + $("#content_modal").show(); + }) +} + $(document).ready(function() { bindInputResizeEvents(); + bindContentModalEvents(); $("#table_content").on("click", function() { showTableContent(); }); $("#table_structure").on("click", function() { showTableStructure(); });