1 $(document).ready(function () {
3 * When the text in an edit pane is changed, clear the contents of
4 * the associated preview pne so that it will be regenerated when
5 * the user next switches to it.
7 $(".richtext_container textarea").change(function () {
8 var container = $(this).closest(".richtext_container");
10 container.find(".tab-pane[id$='_preview']").empty();
14 * Install a handler to switch to preview mode
16 $(".richtext_container button[data-bs-target$='_preview']").on("show.bs.tab", function () {
17 var container = $(this).closest(".richtext_container");
18 var editor = container.find("textarea");
19 var preview = container.find(".tab-pane[id$='_preview']");
20 var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
22 if (preview.contents().length === 0) {
23 preview.oneTime(500, "loading", function () {
24 preview.addClass("loading");
27 preview.load(editor.data("previewUrl"), { text: editor.val() }, function () {
28 preview.stopTime("loading");
29 preview.removeClass("loading");
33 preview.css("min-height", minHeight + "px");
36 var updateHelp = function () {
37 $(".richtext_container .richtext_help_sidebar:not(:visible):not(:empty)").each(function () {
38 var container = $(this).closest(".richtext_container");
39 $(this).children().appendTo(container.find(".tab-pane[id$='_help']"));
41 $(".richtext_container .richtext_help_sidebar:visible:empty").each(function () {
42 var container = $(this).closest(".richtext_container");
43 container.find(".tab-pane[id$='_help']").children().appendTo($(this));
44 if (container.find("button[data-bs-target$='_help'].active").length) {
45 container.find("button[data-bs-target$='_edit']").tab("show");
51 $(window).on("resize", updateHelp);