Skip to content

Instantly share code, notes, and snippets.

@seyDoggy
Created January 2, 2013 14:06
Show Gist options
  • Save seyDoggy/4434825 to your computer and use it in GitHub Desktop.
Save seyDoggy/4434825 to your computer and use it in GitHub Desktop.
CRE4MY Navigation Justification
/*
CRE4MY Navigation Justification
AUTHOR: Adam Merrifield
LICENSE (noncommercial): GNU General Public License, version 2
(http://www.gnu.org/licenses/gpl-2.0.html)
DESCRIPTION: This is a free and open source (noncommercial)
snippet of code offered to the seyDesign Google Group to
adjust the navigation tab spread in the top navigation
bar in the CRE4MY RapidWeaver theme. This snippet is
free to use and distribute but must not be turned into
a commercial product in and of itself.
*/
jQuery(document).ready(function($) {
var CRE4MYNavJustify = (function(){
// VARIABLES
var tabNum = sdNav.tb1.find('> ul > li').length,/* get number of tabs */
navWidth = sdNav.tb1.width(),/* get nav width */
allWidth = sdNav.tb1.parent().width(),/* get nav parent width */
oldTabPadding = parseInt(sdNav.tb1.find('> ul > li > a').css('padding-left')),/* get current tab padding */
newTabPadding = (((allWidth - navWidth) / tabNum) / 2) + oldTabPadding,/* mathematically generate new tab padding */
siteHeader = $('header.siteHeader'),/* get siteHeader */
title = siteHeader.find('hgroup.title'),/* get title */
logo = siteHeader.find('a.logo'),/* get logo */
firstTab = sdNav.tb1.find('> ul > li:first-child > a');/* get first tab */
// FUNCTIONS
// remove title and logo
title.remove();
logo.remove();
// set new tab padding
sdNav.tb1.find('> ul > li > a').css({
'padding-left':newTabPadding + 1,/* 1px added to account for border width */
'padding-right':newTabPadding
});
// remove first tab's border and account for removal in padding
firstTab.css({
'border-left':'none',
'padding-left':newTabPadding + 2
});
// set first tab radius
if (siteHeader.hasClass('radiusAll')) firstTab.addClass('radiusLeft');
else if (siteHeader.hasClass('radiusBottom')) firstTab.addClass('radiusBottomLeft');
else if (siteHeader.hasClass('radiusTop')) firstTab.addClass('radiusTopLeft');
})();
});
@jacquesboot
Copy link

Is there a way to also justify the second tier navbar in the Cre4my 3 tiered navigation option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment