Sha256: 95399c6e161b91f36bcfb6b771bafe6a75e636a100d99301b973c7a92e6c4929

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

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

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

    if ($target.attr("id") === "diff-view-unified") {
      $allDiffViews.addClass("hide");
      $(".row.diff_view_unified_escaped").removeClass("hide");
    }
    if ($target.attr("id") === "diff-view-split") {
      $allDiffViews.addClass("hide");
      $(".row.diff_view_split_escaped").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-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") === "escaped-html") {
      $visibleDiffViews.filter("[id$=_unescaped]").addClass("hide");
      $visibleDiffViews.filter("[id$=_escaped]").removeClass("hide");
    }
    if ($target.attr("id") === "unescaped-html") {
      $visibleDiffViews.filter("[id$=_escaped]").addClass("hide");
      $visibleDiffViews.filter("[id$=_unescaped]").removeClass("hide");
    }
  })
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-core-0.22.0 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6