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_content textarea").change(function () {
8 $(this).parents(".richtext_container").find(".richtext_preview").empty();
12 * Install a handler to switch to preview mode
14 $(".richtext_container button[data-bs-target$='_preview']").on("show.bs.tab", function () {
15 var editor = $(this).parents(".richtext_container").find("textarea");
16 var preview = $(this).parents(".richtext_container").find(".richtext_preview");
17 var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
19 if (preview.contents().length === 0) {
20 preview.oneTime(500, "loading", function () {
21 preview.addClass("loading");
24 preview.load(editor.data("previewUrl"), { text: editor.val() }, function () {
25 preview.stopTime("loading");
26 preview.removeClass("loading");
30 preview.css("min-height", minHeight + "px");