Template:Team:HokkaidoU Japan/JS
From 2014.igem.org
(Difference between revisions)
Line 15: | Line 15: | ||
//define the defaults for the plugin and how to call it | //define the defaults for the plugin and how to call it | ||
- | $.fn. | + | $.fn.dcmegamenu = function(options){ |
//set default options | //set default options | ||
var defaults = { | var defaults = { | ||
Line 38: | Line 38: | ||
//act upon the element that is passed into the design | //act upon the element that is passed into the design | ||
- | return $ | + | return $dcmegamenuObj.each(function(options){ |
var clSubParent = defaults.classSubParent; | var clSubParent = defaults.classSubParent; | ||
Line 87: | Line 87: | ||
} | } | ||
function megaReset(){ | function megaReset(){ | ||
- | $('li',$ | + | $('li',$dcmegamenuObj).removeClass('mega-hover'); |
- | $('.sub',$ | + | $('.sub',$dcmegamenuObj).hide(); |
} | } | ||
Line 94: | Line 94: | ||
$arrow = '<span class="dc-mega-icon"></span>'; | $arrow = '<span class="dc-mega-icon"></span>'; | ||
var clParentLi = clParent+'-li'; | var clParentLi = clParent+'-li'; | ||
- | var menuWidth = $ | + | var menuWidth = $dcmegamenuObj.outerWidth(); |
- | $('> li',$ | + | $('> li',$dcmegamenuObj).each(function(){ |
//Set Width of sub | //Set Width of sub | ||
var $mainSub = $('> ul',this); | var $mainSub = $('> ul',this); | ||
Line 147: | Line 147: | ||
var fw = menuWidth - cpad; | var fw = menuWidth - cpad; | ||
$mainSub.parent('.'+clContainer).css({width: fw+'px'}); | $mainSub.parent('.'+clContainer).css({width: fw+'px'}); | ||
- | $ | + | $dcmegamenuObj.addClass('full-width'); |
} | } | ||
var iw = $('.mega-unit',$mainSub).outerWidth(true); | var iw = $('.mega-unit',$mainSub).outerWidth(true); | ||
Line 202: | Line 202: | ||
}); | }); | ||
// Set position of mega dropdown to bottom of main menu | // Set position of mega dropdown to bottom of main menu | ||
- | var menuHeight = $('> li > a',$ | + | var menuHeight = $('> li > a',$dcmegamenuObj).outerHeight(true); |
- | $('.'+clContainer,$ | + | $('.'+clContainer,$dcmegamenuObj).css({top: menuHeight+'px'}).css('z-index','1000'); |
if(defaults.event == 'hover'){ | if(defaults.event == 'hover'){ | ||
Line 214: | Line 214: | ||
out: megaOut | out: megaOut | ||
}; | }; | ||
- | $('li',$ | + | $('li',$dcmegamenuObj).hoverIntent(config); |
} | } | ||
Line 225: | Line 225: | ||
}); | }); | ||
- | $('> li > a.'+clParent,$ | + | $('> li > a.'+clParent,$dcmegamenuObj).click(function(e){ |
var $parentLi = $(this).parent(); | var $parentLi = $(this).parent(); | ||
if($parentLi.hasClass('mega-hover')){ | if($parentLi.hasClass('mega-hover')){ |
Revision as of 07:57, 20 August 2014