From 8401cd0d140fd9bd0a2b12415745179e90c7e27a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 8 Aug 2024 06:28:55 +0300 Subject: [PATCH] Move help card between pane/sidebar depending on sidebar visibility --- app/assets/javascripts/richtext.js | 14 ++++++++++++++ app/views/shared/_richtext_field.html.erb | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index cb0bd1f27..1383a34df 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -32,4 +32,18 @@ $(document).ready(function () { preview.css("min-height", minHeight + "px"); }); + + var updateHelp = function () { + $(".richtext_container .richtext_help_sidebar:not(:visible):not(:empty)").each(function () { + var container = $(this).closest(".richtext_container"); + $(this).children().appendTo(container.find(".tab-pane[id$='_help']")); + }); + $(".richtext_container .richtext_help_sidebar:visible:empty").each(function () { + var container = $(this).closest(".richtext_container"); + container.find(".tab-pane[id$='_help']").children().appendTo($(this)); + }); + }; + + updateHelp(); + $(window).on("resize", updateHelp); }); diff --git a/app/views/shared/_richtext_field.html.erb b/app/views/shared/_richtext_field.html.erb index c3ad9e3be..5b84fd6ed 100644 --- a/app/views/shared/_richtext_field.html.erb +++ b/app/views/shared/_richtext_field.html.erb @@ -6,7 +6,7 @@ - @@ -24,6 +24,6 @@ - + -- 2.39.5