-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuCreator-min.js
1 lines (1 loc) · 6.14 KB
/
menuCreator-min.js
1
var menuBuffereds={};var uniqueVar="MC"+String.fromCharCode(Math.floor(Math.random()*(97-122+1))+122)+String.fromCharCode(Math.floor(Math.random()*(97-122+1))+122)+String.fromCharCode(Math.floor(Math.random()*(97-122+1))+122);var uniqueIDtmp;var menuDivInterval={};var menuDivClearInterval={};var menuToUp=function(){};var menuRow=function(){};var menuLineHeight=function(){};var menuLineHeightFunc=function(b,a){if(a!=undefined){menuBuffereds[a].menuLineHeight=b}else{menuLineHeight=b}};var speedMenu=function(){};var speedMenuFunc=function(b,a){if(typeof a=="string"){menuBuffereds[a].speedMenu=(b>=$("#"+a+" .menuOl .menuLi").length-1)?menuBuffereds[a].menuLineHeight*($("#"+a+" .menuOl .menuLi").length-1):menuBuffereds[a].menuLineHeight*b}else{speedMenu=b}};var menuId=function(a){return Object.keys(menuBuffereds)[a]};var menuIdGoBack=function(a){return $("#"+uniqueVar+"d"+a.id.match(/\d+/g)[0])[0]};var InitMenuVar=function(b,a,h,g,f){if(typeof f=="string"){menuBuffereds[f].menuLineHeight=menuLineHeightFunc;menuBuffereds[f].speedMenu=speedMenuFunc;menuBuffereds[f].menuToUp=(h==undefined||h)?true:false;menuBuffereds[f].menuRow=(g==undefined||g)?true:false;menuBuffereds[f].menuLineHeight(parseInt(b),f);menuBuffereds[f].speedMenu(a,f);$("#"+f+" .menuDivSize").css({"overflow-y":"hidden","max-height":menuBuffereds[f].menuLineHeight+"px"});if(menuBuffereds[f].menuToUp){$("#"+f+" .menuOl").css({bottom:(($("#"+f+" .menuOl .menuLi").length-1)*menuBuffereds[f].menuLineHeight)+"px","line-height":menuBuffereds[f].menuLineHeight+"px",position:"relative","text-align":"center",margin:"0",padding:"0"});if(!menuBuffereds[f].menuRow){$("#"+f).css({display:"table-cell"})}else{$("#"+f).css({display:"table-row"})}}else{$("#"+f+" .menuOl").css({top:"0px","line-height":menuBuffereds[f].menuLineHeight+"px",position:"relative","text-align":"center",margin:"0",padding:"0"});if(!menuBuffereds[f].menuRow){$("#"+f).css({display:"table-cell"})}else{$("#"+f).css({display:"table-row"})}}if(!menuBuffereds[f].menuRow){$("#"+f+" .menuDivFix").css({display:"table-row"})}}else{menuLineHeight=menuLineHeightFunc;speedMenu=speedMenuFunc;menuToUp=(h==undefined||h)?true:false;menuRow=(g==undefined||g)?true:false;menuLineHeight(parseInt(b));speedMenu(a)}};var menuOrgFunc=function(b,c){var d=($("#"+b.id+" .menuLi").length<2)?menuBuffereds[menuIdGoBack(b).id].menuLineHeight:$("#"+b.id+" .menuLi").length*menuBuffereds[menuIdGoBack(b).id].menuLineHeight;if(c){if($(b).height()<($("#"+b.id+" .menuLi").length*menuBuffereds[menuIdGoBack(b).id].menuLineHeight)){$(b).css({"max-height":($(b).height()+menuBuffereds[menuIdGoBack(b).id].speedMenu)+"px"});if(menuBuffereds[menuIdGoBack(b).id].menuToUp){$("#"+b.id+" .menuOl").css({bottom:d-($(b).height())+"px"})}}else{clearInterval(menuDivInterval[menuIdGoBack(b).id])}}else{if($(b).height()>menuBuffereds[menuIdGoBack(b).id].menuLineHeight){$(b).css({"max-height":($(b).height()-menuBuffereds[menuIdGoBack(b).id].speedMenu)+"px"});if(menuBuffereds[menuIdGoBack(b).id].menuToUp){$("#"+b.id+" .menuOl").css({bottom:d-($(b).height())+"px"})}}else{clearInterval(menuDivInterval[menuIdGoBack(b).id])}}};(function(){jQuery.fn.hands=function(a,b){this.delegate("li","focus mouseenter",a);this.delegate("li","blur mouseleave",b);this.delegate("a","keydown",function(c){if(c.which==13){this.click()}})};jQuery.fn.addMenu=function(j,o){if(typeof menuLineHeight=="function"||typeof speedMenu=="function"||typeof menuRow=="function"||typeof menuToUp=="function"){return console.log("InitMenuVar(LineHeight, Speed); //To init Vars and set as default.")}o=(o==undefined)?{}:o;if(typeof j=="string"){var g=j;j={};j[g]=null}uniqueIDtmp=uniqueVar;var a=function(i){uniqueIDtmp+=i;return uniqueIDtmp+Object.keys(menuBuffereds).length};if(menuToUp){o[Object.keys(j)[0]]=j[Object.keys(j)[0]]}else{for(var b in o){j[b]=o[b]}o=j}var h=0;var c=document.createElement("div");c.className="menuDiv";c.id=a("d");var k=document.createElement("div");k.className="menuDivFix";k.id=a("d");var n=document.createElement("div");n.className="menuDivSize";n.id=a("d");var d=document.createElement("ol");d.reversed=true;d.className="menuOl";d.id=a("o");var e=a("l");var m=a("a");for(ell in o){var f=document.createElement("li");f.className="menuLi";f.id=e+"-"+h;$(f).css({"list-style":"none"});var l=document.createElement("a");l.className="menuAnchor";l.innerHTML=ell;l.tabIndex=(Object.keys(o).length-1>h)?-1:1;l.href=(o[ell]!=null)?o[ell]:"javascript:void(0);";l.id=m+"-"+h;f.appendChild(l);d.appendChild(f);h++}n.appendChild(d);k.appendChild(n);c.appendChild(k);this[0].appendChild(c);if(this[0].className.search("menu")<0){this[0].className+=(this[0].className.length<=0)?"menu":" menu"}menuBuffereds[c.id]=new Object({menu:this[0],links:o});InitMenuVar(menuLineHeight,speedMenu,menuToUp,menuRow,c.id);$(this[0]).css({display:"table","white-space":"nowrap"});$(".menuDiv").hands(function(r){$("#"+this.id+" a").css({color:"rgb(216, 216, 216)"});$(".menu a").each(function(s,t){t.tabIndex=-1});$("#"+$(this).parent().parent().get(0).id+" .menuLi a").each(function(s,t){t.tabIndex=(menuBuffereds[menuIdGoBack(t).id].menuToUp)?$("#"+menuIdGoBack(t).id+" .menuLi").length-s:s+1});var p=parseInt(menuIdGoBack(this).id.match(/\d+/g)[0]);var i=parseInt(Object.keys(menuBuffereds)[Object.keys(menuBuffereds).length-1].match(/\d+/g)[0]);var q=parseInt(Object.keys(menuBuffereds)[0].match(/\d+/g)[0]);$("#"+uniqueVar+"d"+((p>=i)?q:p+1)+" .menuLi:"+(menuBuffereds[Object.keys(menuBuffereds)[((p>=i)?q:p+1)]].menuToUp?"last-of-type":"first-of-type")+" a").get(0).tabIndex=$("#"+menuIdGoBack(this).id+" .menuLi a").length+1;clearInterval(menuDivInterval[menuIdGoBack(this).id]);menuDivInterval[menuIdGoBack(this).id]=setInterval("menuOrgFunc("+$(this).parent().parent().get(0).id+", true)",0);r.stopPropagation()},function(i){$("#"+this.id+" a").css({color:"rgb(0, 0, 0)"});$(".menu a").each(function(p,q){if(jQuery.inArray($(q).parent().toArray()[0],$(".menu .menuLi:"+(menuBuffereds[menuIdGoBack(q).id].menuToUp?"last-of-type":"first-of-type")).toArray())>-1){q.tabIndex=1}else{q.tabIndex=-1}});clearInterval(menuDivInterval[menuIdGoBack(this).id]);menuDivInterval[menuIdGoBack(this).id]=setInterval("menuOrgFunc("+$(this).parent().parent().get(0).id+", false)",0);i.stopPropagation()})}})();