Sha256: 089ecfa2b38e2b9a6476046a427f9e1a112e9da3fda709571b5e542e303ca6d5

Contents?: true

Size: 1.52 KB

Versions: 132

Compression:

Stored size: 1.52 KB

Contents

function initTogglers() {

  function triggerMasonryLayoutRefresh() {
    $('.grid > .row').masonry('layout');
  }

  var togglers = $("a[data-behaviour='toggler']");
  if (togglers.length > 0) {
    $(togglers).on("click", function(event) {
      event.preventDefault();
      // Get e.g. the tr to toggle
      var toggled = $(event.target).attr("href");
      $(toggled).toggle();
      // If we are toggling open tr B by clicking a link within tr A above it,
      // add a class to the tr A sibling above it so it can also be styled
      // to match the expanded TR B below it, to create a clear connection between the two.
      $(toggled).prev().toggleClass("content-toggled");
      triggerMasonryLayoutRefresh();
    })
  }

  // css-toggler applies where you want a single line of text with a trailing ellipsis
  // contained in a .css-toggle-container to be expandable. Targeting the href selector here
  // will toggle the .expanded class on that element.
  // See the SCSS for what that class does, but it will probably take off the nowrap and allow
  // the content to expand downwards so it is all visible.
  // This is useful for expanding content in a table cell for example.
  var togglers = $("a[data-behaviour='css-toggler']");
  if (togglers.length > 0) {
    $(togglers).on("click", function(event) {
      event.preventDefault();
      var selectorsToToggle = $(event.target).attr("href");
      $(selectorsToToggle).toggleClass("expanded");
      triggerMasonryLayoutRefresh();
    })
  }
}

$(function() {
  initTogglers();
});

Version data entries

132 entries across 132 versions & 1 rubygems

Version Path
renalware-core-2.0.100 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.99 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.98 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.97 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.96 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.95 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.94 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.93 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.92 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.91 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.90 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.89 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.88 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.87 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.86 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.85 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.84 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.83 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.82 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.81 app/assets/javascripts/renalware/toggler.js