cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="expandable">
  <button>Expand all</button>
<div class="expandable-item">
    <a class="expandable-item__header js-toggle-expand" role="tab" id="headingpanel-1" href="#panel-1" data-toggle="collapse" aria-expanded="false" aria-controls="panel-1">
        <h3 class="expandable-item__title gamma"><span class="link-text">Expandable item title</span><span class="expandable-item__icon"></span></h3>
    </a>

    <div id="panel-1" class="expandable-item__body" role="tabpanel" aria-expanded="false" aria-labelledby="panel-1">

<p>Vestibulum quis vestibulum neque, ut suscipit eros. Phasellus sagittis ipsum vitae euismod sollicitudin. Vestibulum eu nulla id nisl maximus pharetra. Vivamus bibendum placerat elit. Quisque feugiat sapien ut ante semper, at pellentesque risus laoreet. Aliquam dapibus massa vitae nisi sollicitudin, eget efficitur augue porta. Sed in sem enim.
      </p><p>
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam non est sit amet nunc eleifend ultricies. Suspendisse tristique tempus nibh, ac porttitor magna. Pellentesque urna enim, auctor et aliquet sit amet, consectetur vitae tortor. </p>

    </div>
</div>
  
  <div class="expandable-item">
    <a class="expandable-item__header js-toggle-expand" role="tab" id="headingpanel-2" href="#panel-2" data-toggle="collapse" aria-expanded="false" aria-controls="panel-2">
        <h3 class="expandable-item__title gamma"><span class="link-text">Another expandable item title</span><span class="expandable-item__icon"></span></h3>
    </a>

    <div id="panel-2" class="expandable-item__body" role="tabpanel" aria-expanded="false" aria-labelledby="panel-2">
<p>
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam non est sit amet nunc eleifend ultricies. Suspendisse tristique tempus nibh, ac porttitor magna. Pellentesque urna enim, auctor et aliquet sit amet, consectetur vitae tortor. </p>
<p>Vestibulum quis vestibulum neque, ut suscipit eros. Phasellus sagittis ipsum vitae euismod sollicitudin. Vestibulum eu nulla id nisl maximus pharetra. Vivamus bibendum placerat elit. Quisque feugiat sapien ut ante semper, at pellentesque risus laoreet. Aliquam dapibus massa vitae nisi sollicitudin, eget efficitur augue porta. Sed in sem enim.
      </p>

    </div>
</div>
</div>
            
          
!
            
              'use strict';

var Expandable = {
  init: function() {
    var that = this;

    that.expandable = $('.expandable');
    
    
    
    that.expandable.on('click', 'button', function (event) {
      var expandButton = $(this);
      
      expandButton.toggleClass('open');
      
      if (expandButton.hasClass('open')) {
        expandButton.text('Close all');
        that.expandable.find('.expandable-item').addClass('expandable-item--open') 
      that.expandable.find('.expandable-item__body').show()
      } else {
        expandButton.text('Expand all');
        that.expandable.find('.expandable-item').removeClass('expandable-item--open') 
        that.expandable.find('.expandable-item__body').hide()
      }
    });
    
    

    //Handle changing display on panel headers when open
    that.expandable.on('click', '.js-toggle-expand', function(event) {

      event.preventDefault();

      var expandableItem = $(this).closest('.expandable-item');

      if (expandableItem.hasClass('expandable-item--open')) {
        that.closeExpandableItem(expandableItem);

      } else {
        if (that.expandable.hasClass('expandable--single')) {
          that.closeExpandableItem(expandableItem.siblings('.expandable-item'));
        }
        that.openExpandableItem(expandableItem);
      }
    });
  },

  openExpandableItem: function(expandableItem) {
    var expandableItemBody = expandableItem.find('.expandable-item__body');

    expandableItemBody.attr('aria-expanded', 'true');
    expandableItem.addClass('expandable-item--open');
    expandableItemBody.slideDown(200, function() {
      // hacky IE8 fix to force redraw of changed inline-block element
      expandableItem.closest('.grid__item').toggleClass('foo');
      expandableItem.closest('.grid__item').toggleClass('foo');
    });
  },

  closeExpandableItem: function(expandableItem) {
    var expandableItemBody = expandableItem.find('.expandable-item__body');

    expandableItemBody.attr('aria-expanded', 'false');
    expandableItem.removeClass('expandable-item--open');
    expandableItemBody.slideUp(200, function() {
      // hacky IE8 fix to force redraw of changed inline-block element
      expandableItem.closest('.grid__item').toggleClass('foo');
      expandableItem.closest('.grid__item').toggleClass('foo');
    });
  },

  showAllExpandableItems: function() {
    var expandableItems = this.expandable.find('.expandable-item');

    for (var i = 0, il = expandableItems.length; i < il; i++) {
      this.openExpandableItem($(expandableItems[i]));
    }
  }
};

// initialize
Expandable.init();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console