1(function($){ 2 $.fn.dropdowns = function (options) { 3 4 var defaults = { 5 toggleWidth: 1060 6 } 7 8 var options = $.extend(defaults, options); 9 10 var ww = document.body.clientWidth; 11 12 var addParents = function() { 13 $(".nav li a").each(function() { 14 if ($(this).next().length > 0) { 15 $(this).addClass("parent"); 16 } 17 }); 18 } 19 20 var adjustMenu = function() { 21 if (ww < options.toggleWidth) { 22 $(".toggleMenu").css("display", "inline-block"); 23 if (!$(".toggleMenu").hasClass("active")) { 24 $(".nav").hide(); 25 $("#nav-icon1").removeClass("open"); 26 } else { 27 $(".nav").show(); 28 $("#nav-icon1").addClass("open"); 29 } 30 $(".nav li").unbind('mouseenter mouseleave'); 31 $(".nav li a.parent").unbind('click').bind('click', function(e) { 32 // must be attached to anchor element to prevent bubbling 33 e.preventDefault(); 34 $(".nav li").not(this).removeClass("hover"); 35 $(this).parent("li").toggleClass("hover"); 36 }); 37 } 38 else if (ww >= options.toggleWidth) { 39 $(".toggleMenu").css("display", "none"); 40 $(".nav").show(); 41 $(".nav li").removeClass("hover"); 42 $(".nav li a").unbind('click'); 43 $(".nav li").unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() { 44 // must be attached to li so that mouseleave is not triggered when hover over submenu 45 $(this).toggleClass('hover'); 46 }); 47 } 48 } 49 50 return this.each(function() { 51 $(".toggleMenu").click(function(e) { 52 e.preventDefault(); 53 $(this).toggleClass("active"); 54 $(this).next(".nav").toggle(); 55 adjustMenu(); 56 }); 57 adjustMenu(); 58 addParents(); 59 $(window).bind('resize orientationchange', function() { 60 ww = document.body.clientWidth; 61 adjustMenu(); 62 }); 63 }); 64 65 } 66})(jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.