Sha256: 395e1542ad4bb7224c37d083e4195f15ad26433c62e425d59daed9b0f3e0c6f2

Contents?: true

Size: 1.76 KB

Versions: 24

Compression:

Stored size: 1.76 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-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

24 entries across 24 versions & 1 rubygems

Version Path
decidim-core-0.26.0 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.0.rc2 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.26.0.rc1 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.2 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.1 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.0 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.0.rc4 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.0.rc3 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.0.rc2 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.25.0.rc1 app/packs/src/decidim/diff_mode_dropdown.js
decidim-core-0.24.3 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.23.6 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.24.2 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.23.5 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.24.1 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.24.0 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.24.0.rc2 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.23.4 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.24.0.rc1 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6
decidim-core-0.23.3 app/assets/javascripts/decidim/diff_mode_dropdown.js.es6