DroepMenu - JavaScript-QuelltextQuelltext von droepmenu.js |
![]() ![]() ![]() |
Dies ist die Auflistung der Datei droepmenu.js,
die die Funktionalität für die Fenstergeometrieausrichtung bereitstellt.
Im folgenden Quelltext sind Prozedurdeklarationen rot und Kommentare grün markiert. |
![]() ![]() ![]() ![]() |
/* Droeppez Menuestruktur
* (c) 2002 Ulrich Kritzner
* Die Verwendung dieses Scripts in kommerziellen Seiten ist kostenpflichtig
*/
var dms_left=-500,dms_top=-500;
var dms_padding=1;
var dms_bgcolor="#EEEEEE",dms_titlecolor="#DDDDEE",dms_bordercolor="#000000",dms_xcolor="#EECCCC",dms_acolor="#CCEECC";
var dms_menus=new Array();
var dms_zIndex=1;
function CreateAllMenus()
{
var i;
for (i=0;i<dms_menus.length;i++)
dms_menus[i].CreateMenu(1);
}
function HideAllMenus()
{
var i;
for (i=0;i<dms_menus.length;i++)
dms_menus[i].HideMenu();
}
function dms_AddSeparator(text)
{
this.kind[this.entries]="separator";
this.texts[this.entries]=text;
this.links[this.entries]="none";
this.targets[this.entries]=0;
this.entries++;
}
function dms_AddEntry(text,link,target)
{
this.kind[this.entries]="link";
this.texts[this.entries]=text;
this.links[this.entries]=link;
if (target)
this.targets[this.entries]=target;
else
this.targets[this.entries]=0;
this.entries++;
}
function dms_AddSubMenu(submenu)
{
this.kind[this.entries]="menu";
this.texts[this.entries]=submenu.title;
this.links[this.entries]=submenu;
this.targets[this.entries]=0;
this.entries++;
}
function dms_GetDivSection()
{
if (this.divsection)
return;
if (window.document.all)
this.divsection=eval("window.document.all."+this.name+".style");
else
if (typeof(window.document.getElementById)=="function")
this.divsection=window.document.getElementById(this.name).style;
else
this.divsection=eval("window.document."+this.name);
}
function dms_HideMenu()
{
var i,elem,nodeName;
if ((this.status==0)||(this.movable==0))
return;
j=this.mylink;
if (j>-1)
{
elem=window.document.links[j];
while (typeof(elem)=="object")
{
if (elem.nodeName.toUpperCase()=="TD")
{
elem.style.background=dms_bgcolor;
elem=0;
}
if (typeof(elem)=="object")
if (typeof(elem.offsetParent)=="object")
elem=elem.offsetParent;
}
}
this.GetDivSection();
this.status=0;
this.x=dms_left;
this.y=dms_top;
this.zIndex=0;
this.divsection.left=this.x;
this.divsection.top=this.y;
this.divsection.zIndex=0;
for (i=0;i<this.entries;i++)
if (this.kind[i]=="menu")
this.links[i].HideMenu();
}
function dms_ShowSubMenu(n,j)
{
var i,x,width=1,height=1,y,elem,nodeName,marked=0,nodename,inmyrange=1;
if ((this.status==0)&&(this.movable==1))
return;
for (i=0;i<this.entries;i++)
if (this.kind[i]=="menu")
this.links[i].HideMenu();
x=0;
y=0;
elem=window.document.links[j];
while ((typeof(elem)=="object")&&(typeof(elem.offsetTop)=="number"))
{
y+=elem.offsetTop;
x+=elem.offsetLeft;
nodename=elem.nodeName.toUpperCase();
if ((nodename=="TD")&&(!marked))
{
elem.style.background=dms_acolor;
marked=1;
}
if (nodename=="DIV")
inmyrange=0;
if ((nodename=="TABLE")&&(inmyrange))
{
if (this.horz)
y=elem.offsetTop;
else
x=elem.offsetLeft;
width=elem.offsetWidth;
height=elem.offsetHeight;
}
if (nodename=="BODY")
elem=0;
if (typeof(elem)=="object")
if (typeof(elem.offsetParent)=="object")
elem=elem.offsetParent;
}
if (this.horz)
width=0;
else
height=0;
dms_menus[n].ShowThisMenu(x+width-1,y+height-1,this.zIndex+1,j);
}
function dms_ShowThisMenu(x,y,zIndex,j)
{
if ((this.status==1)||(this.movable==0))
return;
this.GetDivSection();
this.mylink=j;
this.status=1;
this.zIndex=zIndex;
this.x=x;
this.y=y;
this.divsection.zIndex=this.zIndex;
this.divsection.left=this.x;
this.divsection.top=this.y;
}
function dms_ShowMenu(x,y)
{
HideAllMenus();
this.ShowThisMenu(x,y,dms_zIndex,-1);
}
function dms_CreateMenu(movable)
{
if (this.created)
return;
this.created=1;
if (movable)
document.write("<div name=\""+this.name+"\" id=\""+this.name+"\" style=\"position:absolute; left:"+dms_left+"; top:"+dms_top+"; visibility:show;\">\n");
else
{
this.movable=0;
document.write("<div name=\""+this.name+"\" id=\""+this.name+"\" style=\"position:relative; visibility:show;\">\n");
}
document.write("<table style=\"border: 1px solid "+dms_bordercolor+";\" border=\"0\" cellpadding=\""+dms_padding+"\" cellspacing=\"0\">\n");
if (this.movable)
{
document.write("<tr><td style=\"border-right: 1px solid "+dms_bordercolor+"; background-color:"+dms_titlecolor+"; white-space:nowrap;\" align=\"center\"> "+this.title+" </td>\n");
document.write("<td align=\"center\" width=\"10\" style=\"background-color:"+dms_xcolor+";\">");
document.write("<a style=\"text-decoration:none\" href=\"javascript:dms_menus["+this.mynumber+"].HideMenu();\">");
document.write("<img border=\"0\" src=\"menu_x.gif\" alt=\"close\">");
document.write("</a></td></tr>\n");
}
else
if (this.title)
{
document.write("<tr><td colspan=\"2\" style=\"background-color:"+dms_titlecolor+"; white-space:nowrap;\" align=\"center\"> "+this.title+" </td></tr>\n");
}
if (this.horz)
this.CreateMenuHorz(movable);
else
this.CreateMenuVert(movable);
document.write("</table>\n");
document.write("</div>\n");
}
function dms_CreateMenuHorz(movable)
{
var i,j,separator=1,septext="";
var stylesep="style=\"border-top: 1px solid "+dms_bordercolor+"; background-color:"+dms_bgcolor+"; white-space:nowrap;\"";
var stylenosep="style=\"background-color:"+dms_bgcolor+"; white-space:nowrap;\"";
for (i=0;i<this.entries;i++)
{
if (this.kind[i]=="separator")
{
separator=1;
septext=this.texts[i];
}
if (separator)
{
if (i>0)
document.write("</tr></table></td></tr>\n");
document.write("<tr><td "+stylesep+" colspan=\"2\">\n");
if (septext)
{
document.write(" "+septext+" \n");
document.write("</td></tr>\n");
document.write("<tr><td "+stylenosep+" colspan=\"2\">\n");
}
document.write("<table border=\"0\" cellpadding=\""+dms_padding+"\" cellspacing=\"0\"><tr>\n");
}
separator=0;
if (this.kind[i]=="link")
{
document.write("<td "+stylenosep+">\n");
if (this.targets[i])
document.write(" <a href=\""+this.links[i]+"\" target=\""+this.targets[i]+"\">"+this.texts[i]+"</a>\n");
else
document.write(" <a href=\""+this.links[i]+"\">"+this.texts[i]+"</a>\n");
document.write("</td><td "+stylenosep+"> </td>\n");
}
if (this.kind[i]=="menu")
{
j=window.document.links.length;
document.write("<td "+stylenosep+">\n");
document.write(" <a href=\"javascript:dms_menus["+this.mynumber+"].ShowSubMenu("+this.links[i].mynumber+","+j+");\">"+this.texts[i]+"</a>\n");
document.write("</td><td "+stylenosep+"><img border=\"0\" src=\"menu_down.gif\" alt=\"open\"></td>\n");
}
separator=0;
}
document.write("</tr></table></td></tr>\n");
}
function dms_CreateMenuVert(movable)
{
var i,j,separator=1,mystyle;
var stylesep="style=\"border-top: 1px solid "+dms_bordercolor+"; background-color:"+dms_bgcolor+"; white-space:nowrap;\"";
var stylenosep="style=\"background-color:"+dms_bgcolor+"; white-space:nowrap;\"";
for (i=0;i<this.entries;i++)
{
if (this.kind[i]=="separator")
{
separator=1;
if (this.texts[i])
{
separator=0;
document.write("<tr><td align=\"center\" style=\"border-top: 1px solid "+dms_bordercolor+"; background-color:"+dms_bgcolor+";\">\n");
document.write(" "+this.texts[i]+" \n");
document.write("</td><td style=\"border-top: 1px solid "+dms_bordercolor+"; background-color:"+dms_bgcolor+";\"> </td></tr>\n");
}
}
if (separator)
mystyle=stylesep;
else
mystyle=stylenosep;
if (this.kind[i]=="link")
{
document.write("<tr><td align=\"left\" "+mystyle+">\n");
if (this.targets[i])
document.write(" <a href=\""+this.links[i]+"\" target=\""+this.targets[i]+"\">"+this.texts[i]+"</a>\n");
else
document.write(" <a href=\""+this.links[i]+"\">"+this.texts[i]+"</a>\n");
document.write("</td><td "+mystyle+"> </td></tr>\n");
}
if (this.kind[i]=="menu")
{
j=window.document.links.length;
document.write("<tr><td align=\"left\" "+mystyle+">\n");
document.write(" <a href=\"javascript:dms_menus["+this.mynumber+"].ShowSubMenu("+this.links[i].mynumber+","+j+");\">"+this.texts[i]+"</a> \n");
document.write("</td><td align=\"right\" "+mystyle+"><img border=\"0\" src=\"menu_right.gif\" alt=\"open\"></td></tr>\n");
}
separator=0;
}
}
function MenuStruct(title,horz)
{
var i;
i=dms_menus.length;
this.horz=0;
if (typeof(horz)!="undefined")
if (horz)
this.horz=1;
this.movable=1;
this.mynumber=i;
this.mylink=-1;
this.status=0;
this.created=0;
this.zIndex=0;
this.divsection=0;
this.x=dms_left;
this.y=dms_top;
this.name="dms_"+i;
this.title=title;
this.entries=0;
this.kind=new Array();
this.links=new Array();
this.targets=new Array();
this.texts=new Array();
this.AddSeparator=dms_AddSeparator;
this.AddEntry=dms_AddEntry;
this.AddSubMenu=dms_AddSubMenu;
this.GetDivSection=dms_GetDivSection;
this.HideMenu=dms_HideMenu;
this.ShowSubMenu=dms_ShowSubMenu;
this.ShowThisMenu=dms_ShowThisMenu;
this.ShowMenu=dms_ShowMenu;
this.CreateMenu=dms_CreateMenu;
this.CreateMenuHorz=dms_CreateMenuHorz;
this.CreateMenuVert=dms_CreateMenuVert;
dms_menus[i]=this;
dms_menus.length=i+1;
}
|
![]() ![]() ![]() |
Autor: Ulrich Kritzner |