/*
* 本程序实现常用文件操作的右键菜单
*
* @Author:zx
* @Time:2006年4月20日
* @File:menus.js
* @version:1.0
*/
function menuTypes( )
{
this.name = '';
this.listId = '';
this.attachEvent = new Array();
this.locked = false;
this.useColor = '#CCCCCC';
this.overColor = '#000000';
this.title = '';
this.lockColor = '#BFDAF0';
this.font = 'Arial, Helvetica, sans-serif';
}
function menuDivStyle( )
{
this.bgColor = "#FFFFFF";
this.chColor = "#000000";
this.lcColor = "#CCCCCC";
this.bdColor = "#000000";
this.fontSize = 20;
this.alpha = 100;
this.bdSize = 1;
}
function menuSplitStyle( )
{
this.size = 1;
this.width = 80;
this.color = "#FF0000";
}
function menuMenuStyle( )
{
this.value = '';
this.menus = new Array( );
}
function menuElementStyle( )
{
this.fid = '';
this.cid = new Array( );
this.info = new menuMenuStyle( );
}
var menus =
{
menuEvents: new Array( ),
menuWindow: false,
elements: new Array( ),
opend: 'menusv1.0txzx',
menuId: 'menusv1.0txzx',
bgStyles: new menuDivStyle( ),
slStyles: new menuSplitStyle( ),
zIndex: 0,
isIe:navigator.appVersion.indexOf( "MSIE" )!=-1 ? true : false,
divInit: function( e , id )
{
var e = e || "";
if( !e )
{
return( false );
}
e.id = id;
e.innerHTML = "";
e.style.left = 0;
e.style.top = 0;
e.style.width = 0;
e.style.height =0;
e.style.position = "absolute";
menus.isIe ? e.style.filter = "alpha(opacity="+menus.bgStyles.alpha+")" : e.style.opacity = menus.bgStyles.alpha/100;
e.style.border = menus.bgStyles.bdSize+"px solid "+menus.bgStyles.bdColor;
e.style.backgroundColor = menus.bgStyles.bgColor;
e.style.fontSize = menus.bgStyles.fontSize+"px";
e.style.display = 'none';
return( true );
},
getFile: function( op )
{
if( !menus.menuEvents[op] )
{
menus.menuEvents[op] = new menuTypes( );
}
return( true );
},
regEvent: function( op , name , attachEvent )
{
try
{
menus.getFile( op );
name = name.toLowerCase();
menus.menuEvents[op].attachEvent[name] = attachEvent;
}
catch( e )
{
alert( 'regEvent属性出错!/r/n'+e );
return( false );
}
return( true );
},
opStyle: function( op , prototype , value )
{
var prototype = prototype || "";
var value = value || "";
var op = op || "";
if( !prototype || !op )
{
return( false );
}
menus.getFile( op );
try
{
if( prototype != "attachEvent" )
{
menus.menuEvents[op][prototype] = value;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "属性!");
return( false );
}
return( true );
},
divStyle:function( op , prototype , value )
{
var prototype = prototype || '';
var value = value || '';
try
{
if( prototype != 'alpha' )
{
menus.elements[op].info.value.style[prototype] = value;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
return( true );
},
bgStyle:function( prototype , value )
{
var prototype = prototype || "";
var value = value || "";
try
{
switch( prototype )
{
case "bgColor":
menus.bgStyles.bgColor = value;
break;
case "lcColor":
menus.bgStyles.lcColor = value;
break;
case "chColor":
menus.bgStyles.chColor = value;
break;
case "fontSize":
menus.bgStyles.fontSize = value;
break;
case "bdColor":
menus.bgStyles.bdColor = value;
break;
case "bdSize":
menus.bgStyles.bdSize = value;
break;
case "alpha":
menus.bgStyles.alpha = value;
break;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
return( true );
},
splitStyle: function( prototype , value )
{
var prototype = prototype || "";
var value = value || "";
try
{
menus.slStyles[prototype] = value;
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
},
div: function( id )
{
var div = document.getElementById( id );
if( !div )
{
div = document.createElement( 'div' );
document.body.appendChild( div );
menus.divInit( div , id );
}
div.style.display = 'block';
return( div );
},
freeAll: function( )
{
menus.zIndex = 0;
for( var i in menus.elements )
{
try
{
menus.elements[i].info.value.style.display = 'none';
}
catch( e )
{}
}
},
freeChild: function( op )
{
if( !menus.elements[op] )
{
return( false );
}
else
{
for( var i = 0 ; i < menus.elements[op].cid.length ; i++ )
{
menus.freeChild( menus.elements[op].cid[i] );
}
menus.elements[op].info.value.style.display = 'none';
}
return( true );
},
latelyMId: function( e )
{
var mId = menus.getMid( e );
if( mId )
{
return( mId );
}
else
{
return( menus.latelyMId( e.parentNode ) );
}
},
isParent: function( e , id )
{
if( !menus.elements[e] || !id )
{
return( false );
}
if( !menus.elements[e].fid )
{
return( false );
}
while( menus.elements[e].fid != id )
{
e = menus.elements[e].fid;
}
return( e ? true : false );
},
getMid: function( e )
{
var e = e || '';
if( !e || e.nodeType == 9 )
{
return( false );
}
var mId = e.getAttribute( 'menusId' );
if( !mId || !menus.elements[mId] )
{
return( false );
}
return( mId );
},
getMlid: function( e )
{
var e = e || '';
if( !e || e.nodeType == 9 )
{
return( false );
}
var mId = e.getAttribute( 'listId' );
if( !mId || !menus.elements[mId] )
{
return( false );
}
return( mId );
},
clicked: function( e )
{
var e = e || event;
var sel = menus.isIe ? e.srcElement : e.target;
var id = sel.getAttribute( 'opid' );
var mId = menus.getMlid( sel );
if( id && mId )
{
menus.childList( sel , mId );
}
else
{
menus.freeAll( );
}
if( e.button == 2 )
{
return( false );
}
var opEm = menus.menuEvents[ id ];
if( opEm && opEm.locked )
{
return( false );
}
var active = new Array( 'onclick' , 'onmouseup' );
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
eval( opEm.attachEvent[ active[i] ] );
}
}
return( true );
},
overed: function( e )
{
var e = e || event;
var s = menus.isIe ? 'srcElement' : 'target';
var sel = eval( 'e.'+s );
var active = new Array( 'onmouseover' );
var id = sel.getAttribute( 'opid' );
var mId = menus.getMid( sel );
var opEm = menus.menuEvents[ id ];
var el = '';
if( opEm && opEm.locked )
{
return( false );
}
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
el = opEm.attachEvent[ active[i] ].replace( /this/i , 'e.'+s );
eval( el.replace( /event/i , 'e' ) );
}
}
if( id )
{
var lately = menus.latelyMId( sel );
if( lately != menus.opend )
{
menus.freeChild( menus.opend );
}
var mId = menus.getMlid( sel );
if( mId )
{
menus.childList( sel , mId );
}
}
return( true );
},
outed: function( e )
{
var e = e || event;
var s = menus.isIe ? 'srcElement' : 'target';
var sel = eval( 'e.'+s );
var id = sel.getAttribute( 'opid' );
var opEm = menus.menuEvents[ id ];
var active = new Array( 'onmouseout' );
var el = '';
if( opEm && opEm.locked )
{
return( false );
}
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
el = opEm.attachEvent[ active[i] ].replace( /this/i , 'e.'+s );
eval( el.replace( /event/ , 'e' ) );
}
}
return( true );
},
lockEvent: function( e )
{
var e = e || '';
if( !e || !menus.menuEvents[e] )
{
return( false );
}
menus.menuEvents[e].locked = true;
return( true );
},
unLockEvent: function( e )
{
var e = e || '';
if( !e || !menus.menuEvents[e] )
{
return( false );
}
menus.menuEvents[e].locked = false;
return( true );
},
change: function( e , op , c1 , c2 )
{
var e = e || '';
var op = op || '';
var c1 = c1 || '';
var c2 = c2 || '';
if( !e || !op )
{
return( false );
}
if( menus.menuEvents[op].locked )
{
c2 = menus.menuEvents[op].lockColor;
c1 = 'lock';
}
e.style.color = c2;
e = e.parentNode;
if( c1 == 'over' )
{
e.style.backgroundColor = menus.bgStyles.chColor;
}
else if( c1 == 'out' )
{
e.style.backgroundColor = menus.bgStyles.bgColor;
}
else
{
e.style.backgroundColor = menus.bgStyles.lcColor;
}
return( true );
},
about: function( )
{
alert( '感谢zx创造了我,生活从此精彩了!^v^' );
},
regMenu: function( n , s )
{
var s = s || '';
var n = n || menus.menuId;
if( !menus.elements[n] )
{
menus.elements[n] = new menuElementStyle( );
}
if( s != ':split:' )
{
if( menus.elements[n].info.menus.toString( ';' ).indexOf( s ) >= 0 )
{
alert( '注意了:/r/n '+s+'事件已经存在!' );
return( false );
}
}
menus.elements[n].info.menus.push( s );
return( true );
},
realLeft: function( e )
{
var left = parseInt( e.offsetLeft ) || 0;
while( e = e.offsetParent )
{
left += parseInt( e.offsetLeft ) || 0;
}
return( left );
},
realTop: function( e )
{
var top = parseInt( e.offsetTop ) || 0;
while( e = e.offsetParent )
{
top += parseInt( e.offsetTop ) || 0;
}
return( top );
},
childList: function( e , n )
{
var e = e || '';
var newId = e ? menus.getMlid( e ) : false;
if( !newId )
{
return( false );
}
if( !menus.elements[n] )
{
alert( '注意了:/r/n 子菜单'+n+'加载失败!' );
return( false );
}
if( menus.elements[n].info.menus.toString(';').indexOf( e.getAttribute( 'opid' ) ) >= 0 )
{
alert( '菜单加载失败:/r/n 不能调用本身!' );
return( false );
}
var x = menus.realLeft( e ) + e.innerHTML.length*menus.bgStyles.fontSize;
var y = menus.realTop( e );
menus.createMenu( n , x , y );
menus.divStyle( n , "display" , "block" );
return( true );
},
createMenu: function( op , x , y )
{
var o = op || 0;
var x = x || 0;
var y = y || 0;
if( !o )
{
return( false );
}
menus.opend = o;
try
{
menus.elements[o].info.value.style.left = x+'px';
menus.elements[o].info.value.style.top = y+'px';
menus.elements[o].info.value.style.zIndex = ++menus.zIndex;
menus.elements[o].info.value.style.display = 'block';
return( true );
}
catch( e )
{}
var f = menus.div( o );
f.setAttribute( 'menusId' , o );
menus.elements[o].info.value = f;
var sp = 0;
var mW = 0;
var l = 0;
menus.divInit( f );
for( var i = 0 ; i < menus.elements[o].info.menus.length ; i++ )
{
var op = menus.elements[o].info.menus[i];
if( op == ':split:' )
{
var hr = document.createElement( "hr" );
hr.size = menus.slStyles.size;
hr.width = menus.slStyles.width+"%";
hr.color = menus.slStyles.color;
f.appendChild( hr );
sp++;
continue;
}
var opEm = menus.menuEvents[op];
if( !opEm )
{
continue;
}
var div = document.createElement( 'div' );
div.align = 'center';
f.appendChild( div );
var a = document.createElement( 'a' );
div.appendChild( a );
a.style.color = opEm.useColor;
a.href = 'javascript:void(0)';
a.setAttribute( 'opid' , op );
mW = mW < opEm.name.length ? opEm.name.length : mW;
a.font = opEm.font;
a.innerHTML = opEm.name;
if( opEm.locked )
{
var color1 = opEm.lockColor;
var color2 = opEm.lockColor;
}
else
{
var color1 = opEm.useColor;
var color2 = opEm.overColor;
}
if( opEm.listId )
{
a.setAttribute( 'listId' , opEm.listId );
}
a.style.color = color1;
l++;
}
menus.divStyle( o , "left" , x+"px" );
menus.divStyle( o , "top" , y+"px" );
menus.divStyle( o , "zIndex" , ++menus.zIndex );
menus.divStyle( o , "width" , mW*menus.bgStyles.fontSize+menus.bgStyles.bdSize*2+"px" );
menus.divStyle( o , "height" , l*menus.bgStyles.fontSize+menus.bgStyles.fontSize/5+menus.bgStyles.bdSize*2+sp*20+"px" );
menus.divStyle( o , "display" , "none" );
return( true );
},
getMenuList: function( e )
{
var e = e || "";
if( !e )
{
return( false );
}
while( e.nodeType != 9 && !e.getAttribute( "listId" ) )
{
e = e.parentNode;
}
return( e.nodeType == 9 ? false : e.getAttribute( "listId" ) );
},
isDiv: function( e )
{
var e = e || '';
if( !e )
{
return( false );
}
while( e.nodeType != 9 && e.getAttribute( 'menusId' ) != menus.opend )
{
e = e.parentNode;
}
return( e.nodeType == 9 ? false : e );
},
menu: function( e )
{
var e = e || event;
var element = !menus.isIe ? e.target : e.srcElement;
element = menus.getMenuList( element );
id = element ? element : menus.menuId;
menus.freeAll( );
if( menus.elements[id] )
{
menus.elements[id].info.value = '';
}
else
{
return( false );
}
menus.createMenu( id , e.clientX , e.clientY );
menus.divStyle( id , "display" , "block" );
return( false );
}
};
if( !menus.isIe )
{
document.onmouseover = menus.overed;
}
else
{
document.onmousemove = menus.overed;
}
document.onmouseout = menus.outed;
document.onmouseup = menus.clicked;
* 本程序实现常用文件操作的右键菜单
*
* @Author:zx
* @Time:2006年4月20日
* @File:menus.js
* @version:1.0
*/
function menuTypes( )
{
this.name = '';
this.listId = '';
this.attachEvent = new Array();
this.locked = false;
this.useColor = '#CCCCCC';
this.overColor = '#000000';
this.title = '';
this.lockColor = '#BFDAF0';
this.font = 'Arial, Helvetica, sans-serif';
}
function menuDivStyle( )
{
this.bgColor = "#FFFFFF";
this.chColor = "#000000";
this.lcColor = "#CCCCCC";
this.bdColor = "#000000";
this.fontSize = 20;
this.alpha = 100;
this.bdSize = 1;
}
function menuSplitStyle( )
{
this.size = 1;
this.width = 80;
this.color = "#FF0000";
}
function menuMenuStyle( )
{
this.value = '';
this.menus = new Array( );
}
function menuElementStyle( )
{
this.fid = '';
this.cid = new Array( );
this.info = new menuMenuStyle( );
}
var menus =
{
menuEvents: new Array( ),
menuWindow: false,
elements: new Array( ),
opend: 'menusv1.0txzx',
menuId: 'menusv1.0txzx',
bgStyles: new menuDivStyle( ),
slStyles: new menuSplitStyle( ),
zIndex: 0,
isIe:navigator.appVersion.indexOf( "MSIE" )!=-1 ? true : false,
divInit: function( e , id )
{
var e = e || "";
if( !e )
{
return( false );
}
e.id = id;
e.innerHTML = "";
e.style.left = 0;
e.style.top = 0;
e.style.width = 0;
e.style.height =0;
e.style.position = "absolute";
menus.isIe ? e.style.filter = "alpha(opacity="+menus.bgStyles.alpha+")" : e.style.opacity = menus.bgStyles.alpha/100;
e.style.border = menus.bgStyles.bdSize+"px solid "+menus.bgStyles.bdColor;
e.style.backgroundColor = menus.bgStyles.bgColor;
e.style.fontSize = menus.bgStyles.fontSize+"px";
e.style.display = 'none';
return( true );
},
getFile: function( op )
{
if( !menus.menuEvents[op] )
{
menus.menuEvents[op] = new menuTypes( );
}
return( true );
},
regEvent: function( op , name , attachEvent )
{
try
{
menus.getFile( op );
name = name.toLowerCase();
menus.menuEvents[op].attachEvent[name] = attachEvent;
}
catch( e )
{
alert( 'regEvent属性出错!/r/n'+e );
return( false );
}
return( true );
},
opStyle: function( op , prototype , value )
{
var prototype = prototype || "";
var value = value || "";
var op = op || "";
if( !prototype || !op )
{
return( false );
}
menus.getFile( op );
try
{
if( prototype != "attachEvent" )
{
menus.menuEvents[op][prototype] = value;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "属性!");
return( false );
}
return( true );
},
divStyle:function( op , prototype , value )
{
var prototype = prototype || '';
var value = value || '';
try
{
if( prototype != 'alpha' )
{
menus.elements[op].info.value.style[prototype] = value;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
return( true );
},
bgStyle:function( prototype , value )
{
var prototype = prototype || "";
var value = value || "";
try
{
switch( prototype )
{
case "bgColor":
menus.bgStyles.bgColor = value;
break;
case "lcColor":
menus.bgStyles.lcColor = value;
break;
case "chColor":
menus.bgStyles.chColor = value;
break;
case "fontSize":
menus.bgStyles.fontSize = value;
break;
case "bdColor":
menus.bgStyles.bdColor = value;
break;
case "bdSize":
menus.bgStyles.bdSize = value;
break;
case "alpha":
menus.bgStyles.alpha = value;
break;
}
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
return( true );
},
splitStyle: function( prototype , value )
{
var prototype = prototype || "";
var value = value || "";
try
{
menus.slStyles[prototype] = value;
}
catch( e )
{
alert( "没有找到"+prototype+ "这个属性!");
return( false );
}
},
div: function( id )
{
var div = document.getElementById( id );
if( !div )
{
div = document.createElement( 'div' );
document.body.appendChild( div );
menus.divInit( div , id );
}
div.style.display = 'block';
return( div );
},
freeAll: function( )
{
menus.zIndex = 0;
for( var i in menus.elements )
{
try
{
menus.elements[i].info.value.style.display = 'none';
}
catch( e )
{}
}
},
freeChild: function( op )
{
if( !menus.elements[op] )
{
return( false );
}
else
{
for( var i = 0 ; i < menus.elements[op].cid.length ; i++ )
{
menus.freeChild( menus.elements[op].cid[i] );
}
menus.elements[op].info.value.style.display = 'none';
}
return( true );
},
latelyMId: function( e )
{
var mId = menus.getMid( e );
if( mId )
{
return( mId );
}
else
{
return( menus.latelyMId( e.parentNode ) );
}
},
isParent: function( e , id )
{
if( !menus.elements[e] || !id )
{
return( false );
}
if( !menus.elements[e].fid )
{
return( false );
}
while( menus.elements[e].fid != id )
{
e = menus.elements[e].fid;
}
return( e ? true : false );
},
getMid: function( e )
{
var e = e || '';
if( !e || e.nodeType == 9 )
{
return( false );
}
var mId = e.getAttribute( 'menusId' );
if( !mId || !menus.elements[mId] )
{
return( false );
}
return( mId );
},
getMlid: function( e )
{
var e = e || '';
if( !e || e.nodeType == 9 )
{
return( false );
}
var mId = e.getAttribute( 'listId' );
if( !mId || !menus.elements[mId] )
{
return( false );
}
return( mId );
},
clicked: function( e )
{
var e = e || event;
var sel = menus.isIe ? e.srcElement : e.target;
var id = sel.getAttribute( 'opid' );
var mId = menus.getMlid( sel );
if( id && mId )
{
menus.childList( sel , mId );
}
else
{
menus.freeAll( );
}
if( e.button == 2 )
{
return( false );
}
var opEm = menus.menuEvents[ id ];
if( opEm && opEm.locked )
{
return( false );
}
var active = new Array( 'onclick' , 'onmouseup' );
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
eval( opEm.attachEvent[ active[i] ] );
}
}
return( true );
},
overed: function( e )
{
var e = e || event;
var s = menus.isIe ? 'srcElement' : 'target';
var sel = eval( 'e.'+s );
var active = new Array( 'onmouseover' );
var id = sel.getAttribute( 'opid' );
var mId = menus.getMid( sel );
var opEm = menus.menuEvents[ id ];
var el = '';
if( opEm && opEm.locked )
{
return( false );
}
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
el = opEm.attachEvent[ active[i] ].replace( /this/i , 'e.'+s );
eval( el.replace( /event/i , 'e' ) );
}
}
if( id )
{
var lately = menus.latelyMId( sel );
if( lately != menus.opend )
{
menus.freeChild( menus.opend );
}
var mId = menus.getMlid( sel );
if( mId )
{
menus.childList( sel , mId );
}
}
return( true );
},
outed: function( e )
{
var e = e || event;
var s = menus.isIe ? 'srcElement' : 'target';
var sel = eval( 'e.'+s );
var id = sel.getAttribute( 'opid' );
var opEm = menus.menuEvents[ id ];
var active = new Array( 'onmouseout' );
var el = '';
if( opEm && opEm.locked )
{
return( false );
}
for( var i = 0 ; i < active.length ; i++ )
{
if( opEm && opEm.attachEvent[ active[i] ] )
{
el = opEm.attachEvent[ active[i] ].replace( /this/i , 'e.'+s );
eval( el.replace( /event/ , 'e' ) );
}
}
return( true );
},
lockEvent: function( e )
{
var e = e || '';
if( !e || !menus.menuEvents[e] )
{
return( false );
}
menus.menuEvents[e].locked = true;
return( true );
},
unLockEvent: function( e )
{
var e = e || '';
if( !e || !menus.menuEvents[e] )
{
return( false );
}
menus.menuEvents[e].locked = false;
return( true );
},
change: function( e , op , c1 , c2 )
{
var e = e || '';
var op = op || '';
var c1 = c1 || '';
var c2 = c2 || '';
if( !e || !op )
{
return( false );
}
if( menus.menuEvents[op].locked )
{
c2 = menus.menuEvents[op].lockColor;
c1 = 'lock';
}
e.style.color = c2;
e = e.parentNode;
if( c1 == 'over' )
{
e.style.backgroundColor = menus.bgStyles.chColor;
}
else if( c1 == 'out' )
{
e.style.backgroundColor = menus.bgStyles.bgColor;
}
else
{
e.style.backgroundColor = menus.bgStyles.lcColor;
}
return( true );
},
about: function( )
{
alert( '感谢zx创造了我,生活从此精彩了!^v^' );
},
regMenu: function( n , s )
{
var s = s || '';
var n = n || menus.menuId;
if( !menus.elements[n] )
{
menus.elements[n] = new menuElementStyle( );
}
if( s != ':split:' )
{
if( menus.elements[n].info.menus.toString( ';' ).indexOf( s ) >= 0 )
{
alert( '注意了:/r/n '+s+'事件已经存在!' );
return( false );
}
}
menus.elements[n].info.menus.push( s );
return( true );
},
realLeft: function( e )
{
var left = parseInt( e.offsetLeft ) || 0;
while( e = e.offsetParent )
{
left += parseInt( e.offsetLeft ) || 0;
}
return( left );
},
realTop: function( e )
{
var top = parseInt( e.offsetTop ) || 0;
while( e = e.offsetParent )
{
top += parseInt( e.offsetTop ) || 0;
}
return( top );
},
childList: function( e , n )
{
var e = e || '';
var newId = e ? menus.getMlid( e ) : false;
if( !newId )
{
return( false );
}
if( !menus.elements[n] )
{
alert( '注意了:/r/n 子菜单'+n+'加载失败!' );
return( false );
}
if( menus.elements[n].info.menus.toString(';').indexOf( e.getAttribute( 'opid' ) ) >= 0 )
{
alert( '菜单加载失败:/r/n 不能调用本身!' );
return( false );
}
var x = menus.realLeft( e ) + e.innerHTML.length*menus.bgStyles.fontSize;
var y = menus.realTop( e );
menus.createMenu( n , x , y );
menus.divStyle( n , "display" , "block" );
return( true );
},
createMenu: function( op , x , y )
{
var o = op || 0;
var x = x || 0;
var y = y || 0;
if( !o )
{
return( false );
}
menus.opend = o;
try
{
menus.elements[o].info.value.style.left = x+'px';
menus.elements[o].info.value.style.top = y+'px';
menus.elements[o].info.value.style.zIndex = ++menus.zIndex;
menus.elements[o].info.value.style.display = 'block';
return( true );
}
catch( e )
{}
var f = menus.div( o );
f.setAttribute( 'menusId' , o );
menus.elements[o].info.value = f;
var sp = 0;
var mW = 0;
var l = 0;
menus.divInit( f );
for( var i = 0 ; i < menus.elements[o].info.menus.length ; i++ )
{
var op = menus.elements[o].info.menus[i];
if( op == ':split:' )
{
var hr = document.createElement( "hr" );
hr.size = menus.slStyles.size;
hr.width = menus.slStyles.width+"%";
hr.color = menus.slStyles.color;
f.appendChild( hr );
sp++;
continue;
}
var opEm = menus.menuEvents[op];
if( !opEm )
{
continue;
}
var div = document.createElement( 'div' );
div.align = 'center';
f.appendChild( div );
var a = document.createElement( 'a' );
div.appendChild( a );
a.style.color = opEm.useColor;
a.href = 'javascript:void(0)';
a.setAttribute( 'opid' , op );
mW = mW < opEm.name.length ? opEm.name.length : mW;
a.font = opEm.font;
a.innerHTML = opEm.name;
if( opEm.locked )
{
var color1 = opEm.lockColor;
var color2 = opEm.lockColor;
}
else
{
var color1 = opEm.useColor;
var color2 = opEm.overColor;
}
if( opEm.listId )
{
a.setAttribute( 'listId' , opEm.listId );
}
a.style.color = color1;
l++;
}
menus.divStyle( o , "left" , x+"px" );
menus.divStyle( o , "top" , y+"px" );
menus.divStyle( o , "zIndex" , ++menus.zIndex );
menus.divStyle( o , "width" , mW*menus.bgStyles.fontSize+menus.bgStyles.bdSize*2+"px" );
menus.divStyle( o , "height" , l*menus.bgStyles.fontSize+menus.bgStyles.fontSize/5+menus.bgStyles.bdSize*2+sp*20+"px" );
menus.divStyle( o , "display" , "none" );
return( true );
},
getMenuList: function( e )
{
var e = e || "";
if( !e )
{
return( false );
}
while( e.nodeType != 9 && !e.getAttribute( "listId" ) )
{
e = e.parentNode;
}
return( e.nodeType == 9 ? false : e.getAttribute( "listId" ) );
},
isDiv: function( e )
{
var e = e || '';
if( !e )
{
return( false );
}
while( e.nodeType != 9 && e.getAttribute( 'menusId' ) != menus.opend )
{
e = e.parentNode;
}
return( e.nodeType == 9 ? false : e );
},
menu: function( e )
{
var e = e || event;
var element = !menus.isIe ? e.target : e.srcElement;
element = menus.getMenuList( element );
id = element ? element : menus.menuId;
menus.freeAll( );
if( menus.elements[id] )
{
menus.elements[id].info.value = '';
}
else
{
return( false );
}
menus.createMenu( id , e.clientX , e.clientY );
menus.divStyle( id , "display" , "block" );
return( false );
}
};
if( !menus.isIe )
{
document.onmouseover = menus.overed;
}
else
{
document.onmousemove = menus.overed;
}
document.onmouseout = menus.outed;
document.onmouseup = menus.clicked;