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.0.pre.rc5 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.rc4 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.rc3 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.rc1 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta12 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta11 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta10 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta9 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta8 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta7 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta6 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.0.pre.beta5 app/assets/javascripts/renalware/toggler.js