Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Created January 16, 2014 18:23
Show Gist options
  • Select an option

  • Save ChrisLTD/8460373 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisLTD/8460373 to your computer and use it in GitHub Desktop.
ACF Flexible Content layout collapse button
function close_flexible_content(){
$('.layout').attr('data-toggle', 'closed');
$('.acf-input-table').css('display', 'none');
}
function open_flexible_content(){
$('.layout').attr('data-toggle', 'open');
$('.acf-input-table').css('display', 'table');
}
close_flexible_content();
$('.field_type-flexible_content').prepend('<a class="toggle_flexible_content button button-small" style="float: right; margin-top: -8px;" href="#">Toggle Layout Boxes</a>')
$('body').on('click', '.toggle_flexible_content', function(event){
event.preventDefault();
$this = $(this);
if( $this.data('toggle') == 'open' ){
close_flexible_content();
$this.data('toggle', '');
} else {
open_flexible_content();
$this.data('toggle', 'open');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment