Signin  Pricing  Examples  Support

Libraries > topmenu.js

topmenu.js - Search Live Website Code
It's like doing CTRL+F on millions of websites' source code



NerdyData is a search engine for source code. Search the source code of 200 million websites.


JAVASCRIPT FILE http://telia.no/netcom-theme/js/topmenu.js


Libraries on telia.no


tsr-core.js

carousel.js

main.js

newsticker.js

slideshow.js

swfobject.js

topmenu.js

viewport.js



Explore More


adsbygoogle.js

show_ads.js

js_defer.IRaJtkfeqL.js

AllinOne.js

topmenu.js
				
$(function() {
mainMenuLeft = 0; 
if($("#navigation").length>0){
	mainMenuLeft = $("#navigation").position().left + $("#navigation").width();
}
if(mainMenuLeft==0){
	mainMenuLeft=480;
}
if ((screen.width >= 768)) {
$("#navigation > ul > li").bind("mouseenter", function (){
			$(this).find("a").addClass("hover");
            $(this).find(".sub").stop().show().css('filter',''); //Find sub and fade it in
            rowWidth = 0;
            numberOfItems = 0;
                    
            //Calculate row
            $(this).find("li.sublevel").each(function() { 
                rowWidth += ($(this).width());//+40);
                numberOfItems += 1;
                $(this).css("width", $(this).width());
            });
            
            $(this).find(".sub").css({'width' : rowWidth+10}); //Set Width
            var posSub = $(this).find(".sub");
            var posSubMenu = $(this).find(".sub-menu");
            if (posSub.width() > 0)
            {    
                
            	menuItemLeft = posSub.parent().position().left;
                menuAndBox = posSub.width() + menuItemLeft;
                if (menuAndBox > mainMenuLeft) {
                    newBoxLeft = mainMenuLeft - posSub.width()-menuItemLeft+$(".mainmenuright").width();
                    posSub.css("left", newBoxLeft);
                }else{
                	posSub.css("left", parseInt(posSub.parent().css("padding-left")));
                }
            }                             
            else {
            	posSub.css("display", "none");
            }
            $(this).find("li.sublevel").css("height", posSubMenu.height()); 
	        
            // Added if-statement to correctly adjust height if there is no dropdown meny header (text or link) 
            if(jQuery(this).find('div.sublevelcolumn').children().first().is('a') ||
	        		jQuery(this).find('div.sublevelcolumn').children().first().is('p')) { 
	        	$(this).find("ul.sublevellist").css("height", posSubMenu.height()-208); 
	        } else {
	        	$(this).find("ul.sublevellist").css("height", posSubMenu.height()-178); 
            }
        });

        $("#navigation > ul > li").bind("mouseleave", function (){

            $(this).find("a").removeClass("hover");
            
            $(this).find(".sub").stop().hide();
        });
}else{
	$("#navigation > ul > li").bind("click", function (e){
		$(".hover").removeClass("hover");
		if($(".sub:visible",this).length>0){
			return true;
		}
		$(".sub:visible").each(function(){
                  $(this).stop().fadeTo(100, 0, function() { //Fade to 0 opactiy
                    $(this).hide();  //after fading, hide it
                  });
		});

		$(this).find("a").addClass("hover");
                $(this).find(".sub").stop().show(); //Find sub and fade it in
                $(this).find(".sub").stop().fadeTo(0, 100);

        rowWidth = 0;
        numberOfItems = 0;
                
        //Calculate row
        $(this).find("li.sublevel").each(function() { 
            rowWidth += ($(this).width());//+40);
            numberOfItems += 1;
            $(this).css("width", $(this).width());
        });
        
        $(this).find(".sub").css({'width' : rowWidth+10}); //Set Width
        var posSub = $(this).find(".sub");
        var posSubMenu = $(this).find(".sub-menu");
        if (posSub.width() > 0)
        {   
        	e.preventDefault();
        	posSub.css("left", $("#navigation").position().left-$(this).position().left);
        	$("#top-menu-wrapper").animate({"height": 125+posSubMenu.height()},300);
        	$(".mainmenumiddle").animate({"height": 115+posSubMenu.height()},300);
        	$(".hero").animate({"top":115+posSubMenu.height()},300);
        }                             
        else {
        	posSub.css("display", "none");
        	$("#top-menu-wrapper").css("height", 125+posSubMenu.height())
        	$(".mainmenumiddle").css("height", 115+posSubMenu.height());
        }
       $(this).find("li.sublevel").css("height", posSubMenu.height()); 
	});
}
        
        var topmenuItemWidth = 0;
        var numberOfItems = 0;
        $("#navigation li.topmenu").each(function(){
        	topmenuItemWidth += ($(this).width());
        	numberOfItems += 1;
        });
        
        var topmenuItemPadding = Math.round((($("#navigation").width() - topmenuItemWidth)/numberOfItems)/2)-1;
        if(topmenuItemPadding >6 || $("#navigation").width() < 500){
        $("#navigation li.topmenu").each(function(){
        	$(this).css("padding-left", topmenuItemPadding).css("padding-right", topmenuItemPadding);
        });
        }else{
        	$("#navigation li.topmenu > a").each(function(){
            	//$(this).css("font-size",17);
            });
        	var topmenuItemWidth = 0;
            var numberOfItems = 0;
            $("#navigation li.topmenu").each(function(){
            	topmenuItemWidth += ($(this).width());
            	numberOfItems += 1;
            });
            
            var topmenuItemPadding = Math.round((($("#navigation").width() - topmenuItemWidth)/numberOfItems)/2)-1;
            $("#navigation li.topmenu").each(function(){
            	$(this).css("padding-left", topmenuItemPadding).css("padding-right", topmenuItemPadding);
            });
        }



});

$(document).ready(function(){
        var imageUrl = "/netcom-theme/images/logo/43px-telia-logo-animated-transparent.gif";
        var myImage = new Image();
        $('.headerlogo').mouseenter(function(){
            var separator = "?";
            if (imageUrl.indexOf("?") > -1) {separator = "&"}
            var rnd = Math.random() * 100000000;
            myImage.onload = function() {
                $('.headerlogo').css('background-image', 'url(' + myImage.src + ')');
            }
            myImage.src = imageUrl + separator + 'rnd=' + rnd.toString();
        });
});


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z