Skip to content

Instantly share code, notes, and snippets.

@edolyne
Last active August 29, 2015 14:13
Show Gist options
  • Save edolyne/76296cd70c9eb8f077c8 to your computer and use it in GitHub Desktop.
Save edolyne/76296cd70c9eb8f077c8 to your computer and use it in GitHub Desktop.
Adding Collapse To Blocks, and increasing font size for Atom headers
//Custom Styles for cp.css
.blocksft-header h3 {
font-size: 1.75em !important;
}
.blocksft-header:hover {
cursor: pointer;
}
.blocksft-block[data-blocks-state=collapsed] h3:after {
content: '';
position: relative;
top: -3px;
display: inline-block;
text-align: right;
margin-left: 40px;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid black;
}
.blocksft-block[data-blocks-state=expanded] h3:after {
content: '';
position: relative;
top: -3px;
display: inline-block;
text-align: right;
margin-left: 40px;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid black;
border-bottom: none;
}
.blocksft-block[data-blocks-state=collapsed] .blocksft-atoms {
overflow: hidden;
max-height: 0px;
}
.blocksft-block[data-blocks-state=expanded] .blocksft-atoms {
overflow: visible;
max-height: none;
}
// Blocks Collapse added to cp.js
// Abbreviated to protect original developer code
$('.blocksft').each(function() {
...
function createBlock(templateid) {
...
fireEvent("display", clone.find('[data-fieldtype]'));
clone.attr('data-blocks-state', 'expanded');
reorderFields();
...
}
...
//Add Data Attribute For State
$('.blocksft-block').attr('data-blocks-state', 'collapsed');
//Collapse Function
blocks.on('click', '.blocksft-header', function(e) {
e.preventDefault();
$(this).parent('.blocksft-block').attr('data-blocks-state', $(this).parent('.blocksft-block').attr('data-blocks-state') == 'expanded' ? 'collapsed' : 'expanded');
})
});
...
});
// Relationships & Assets were not saving correctly on submit so we are expanding these on submit click
$('#submit_button').click(function() {
$('.blocksft-block').attr('data-blocks-state', 'expanded');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment