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.123 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.121 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.120 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.119 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.118 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.117 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.116 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.115 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.113 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.112 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.111 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.110 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.109 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.108 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.106 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.105 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.104 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.103 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.102 app/assets/javascripts/renalware/toggler.js
renalware-core-2.0.101 app/assets/javascripts/renalware/toggler.js