Sha256: 181b57a8773d9f2077d15d87feb040865a8535fc53cbca4019007a41da147330

Contents?: true

Size: 1.78 KB

Versions: 21

Compression:

Stored size: 1.78 KB

Contents

$(() => {
  const $allDiffViews = $(".row.diff_view");

  $(document).on("click", ".diff-view-by a.diff-view-mode", (event) => {
    event.preventDefault();
    const $target = $(event.target)
    let type = "escaped";
    const $selected = $target.parents(".is-dropdown-submenu-parent").find("#diff-view-selected");
    if ($selected.text().trim() === $target.text().trim()) {
      return;
    }

    $selected.text($target.text());

    if ($target.attr("id") === "diff-view-unified") {
      if ($(".row.diff_view_split_escaped").hasClass("hide")) {
        type = "unescaped";
      }

      $allDiffViews.addClass("hide");
      $(`.row.diff_view_unified_${type}`).removeClass("hide");
    }
    if ($target.attr("id") === "diff-view-split") {
      if ($(".row.diff_view_unified_escaped").hasClass("hide")) {
        type = "unescaped";
      }

      $allDiffViews.addClass("hide");
      $(`.row.diff_view_split_${type}`).removeClass("hide");
    }
  })

  $(document).on("click", ".diff-view-by a.diff-view-html", (event) => {
    event.preventDefault();
    const $target = $(event.target);
    $target.parents(".is-dropdown-submenu-parent").find("#diff-view-html-selected").text($target.text());
    const $visibleDiffViewsId = $allDiffViews.not(".hide").first().attr("id").split("_").slice(1, -1).join("_");
    const $visibleDiffViews = $allDiffViews.filter(`[id*=${$visibleDiffViewsId}]`)

    if ($target.attr("id") === "diff-view-escaped-html") {
      $visibleDiffViews.filter("[id$=_unescaped]").addClass("hide");
      $visibleDiffViews.filter("[id$=_escaped]").removeClass("hide");
    }
    if ($target.attr("id") === "diff-view-unescaped-html") {
      $visibleDiffViews.filter("[id$=_escaped]").addClass("hide");
      $visibleDiffViews.filter("[id$=_unescaped]").removeClass("hide");
    }
  })
});

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.8 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.7 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.6 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.10 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.9 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.5 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.8 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.4 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.3 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.7 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.5 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.2 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.1 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.4 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.0 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.3 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.0.rc2 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.27.0.rc1 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.2 app/packs/src/decidim/diff_mode_dropdown.js