Sha256: 64c7d106c37f13d30fccf6ef8326a2ff956c769dec7ecdd393f4713b692a744b

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

/*
 * expansion panel
 * upon selecting the collapsed panel,
 * it expands to display in full
 */
var ExpansionPanel = function ($) {
  // constants >>>
  var DATA_KEY = 'bs.collapse';
  var EVENT_KEY = "." + DATA_KEY;
  var ClassName = {
    SHOW: 'show',
    SHOW_PREDECESSOR: 'show-predecessor'
  };
  var Event = {
    HIDE: "hide" + EVENT_KEY,
    SHOW: "show" + EVENT_KEY
  };
  var Selector = {
    PANEL: '.expansion-panel',
    PANEL_BODY: '.expansion-panel .collapse' // <<< constants

  };
  $(document).on("" + Event.HIDE, Selector.PANEL_BODY, function () {
    var target = $(this).closest(Selector.PANEL);
    target.removeClass(ClassName.SHOW);
    var predecessor = target.prev(Selector.PANEL);

    if (predecessor.length) {
      predecessor.removeClass(ClassName.SHOW_PREDECESSOR);
    }
  }).on("" + Event.SHOW, Selector.PANEL_BODY, function () {
    var target = $(this).closest(Selector.PANEL);
    target.addClass(ClassName.SHOW);
    var predecessor = target.prev(Selector.PANEL);

    if (predecessor.length) {
      predecessor.addClass(ClassName.SHOW_PREDECESSOR);
    }
  });
}($);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
material-sass-4.0.0 assets/javascripts/material/components/expansion-panel.js