Skip to content

Instantly share code, notes, and snippets.

@joeRinehart
Last active March 29, 2017 12:21
Show Gist options
  • Save joeRinehart/7b8748d234f8841b7d5c0b4fab07cedc to your computer and use it in GitHub Desktop.
Save joeRinehart/7b8748d234f8841b7d5c0b4fab07cedc to your computer and use it in GitHub Desktop.
MBR Calendar "Go to current month" on load
// get a reference to jQuery that shouldn't interfere with wordpressy bits
var ___safejQueryRef = ( $ == undefined ? jQuery : $ );
___safejQueryRef( function() {
// locally make all right with the universe, jQuerywise
var $ = ___safejQueryRef
// get tabs and panes
var tabs = $('.cherry-tabs-nav').children();
var panes = $('.cherry-tabs-pane');
// safety first
if ( tabs.length > 0 && tabs.length == panes.length ) {
// a few things we need
var activeTabClass = 'cherry-tabs-current';
var thisMonth = new Date().getMonth();
// turn all month 'buttons' off
tabs.toggleClass(activeTabClass, false);
// hide all month calendar displays
panes.css('display', 'none');
// show this month's calendar
if ( tabs.length >= thisMonth ) {
$(tabs[thisMonth]).toggleClass(activeTabClass, true);
}
// activate this month's tab
if ( panes.length >= thisMonth ) {
$(panes[thisMonth]).css('display', 'block');
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment