rightmenuscript.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!--
  2. //===================================== 参数设定部分 =======================================================
  3. var strMenu;//菜单信息 Array
  4. var win2; //
  5. var VALUE=19.5; //menuitem is height 20
  6. var omenulayer; //存放菜单对象
  7. //===================================== WEB 页面显示部分 =====================================================
  8. var strFrame; //存放菜单层的HTML代码
  9. document.writeln('<iframe name=rightMenuLayer scrolling="no" Author=wayx frameborder=0 style="color: #000000; position: absolute;width:120px;height:20px;z-index:9999; visibility: hidden;" onblur="parent.closeLayer();"></iframe>');
  10. strFrame=' <style>';
  11. strFrame+=' .RightMenu';
  12. strFrame+=' {';
  13. strFrame+=' font-family:宋体;';
  14. strFrame+=' color:#FFFFFF;';
  15. strFrame+=' font-size:12px;';
  16. strFrame+=' background-color:#EAE8E2;';
  17. strFrame+=' cursor:default;';
  18. strFrame+=' }';
  19. strFrame+=' .RightMenuOver {';
  20. strFrame+=' font-family:宋体;';
  21. strFrame+=' color: #FFFFFF;';
  22. strFrame+=' font-size: 12px;';
  23. strFrame+=' background-color: #316AC5;';
  24. strFrame+=' PADDING-LEFT: 15px;';
  25. strFrame+=' PADDING-RIGHT: 10px;';
  26. strFrame+=' PADDING-TOP: 2px;';
  27. strFrame+=' PADDING-BOTTOM: 2px;';
  28. strFrame+=' cursor:default;';
  29. strFrame+=' }';
  30. strFrame+=' .menuitems {';
  31. strFrame+=' font-family:宋体;';
  32. strFrame+=' color: #000000;';
  33. strFrame+=' font-size: 12px;';
  34. strFrame+=' background-color: #EAE8E2;';
  35. strFrame+=' PADDING-LEFT: 15px;';
  36. strFrame+=' PADDING-RIGHT: 10px;';
  37. strFrame+=' PADDING-TOP: 2px;';
  38. strFrame+=' PADDING-BOTTOM: 2px;';
  39. strFrame+=' cursor:default;';
  40. strFrame+=' }';
  41. strFrame+=' </style>';
  42. strFrame+='<script language="JavaScript" type="text/JavaScript">';
  43. strFrame+='<!--\n';
  44. strFrame+='var pageState = 0;\n';
  45. strFrame+='var display_url = 0;\n';
  46. strFrame+='function highlightie5() { //高亮度鼠标经过的菜单条项目\n';
  47. strFrame+='if (event.srcElement.className == "menuitems") {';
  48. strFrame+='event.srcElement.className="RightMenuOver";';
  49. strFrame+='if (display_url)';
  50. strFrame+='window.status = event.srcElement.url;';
  51. strFrame+='}';
  52. strFrame+='}\n';
  53. strFrame+='';
  54. strFrame+='function lowlightie5() { //恢复菜单条项目的正常显示\n';
  55. strFrame+='if (event.srcElement.className == "RightMenuOver") {';
  56. strFrame+='event.srcElement.className = "menuitems";';
  57. strFrame+='window.status = "";';
  58. strFrame+='}';
  59. strFrame+='}\n';
  60. strFrame+='//-->';
  61. strFrame+='</script>\n';
  62. strFrame+='<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onselectstart="return false;" oncontextmenu="return false;">\n';
  63. strFrame+='<div id="divId" class="RightMenu" style="z-index:9999;" OnMouseover="highlightie5();" OnMouseout="lowlightie5();" OnClick="parent.closeLayer();" spring="yes">';
  64. strFrame+='</div>\n';
  65. strFrame+='</body>\n';
  66. //-------------------------------------------------------------------------------------------------------------------------------
  67. function initMenu(){
  68. window.frames.rightMenuLayer.document.writeln(strFrame);
  69. window.frames.rightMenuLayer.document.close();
  70. omenulayer=window.frames.rightMenuLayer.document;
  71. }
  72. //== WEB 页面显示部分 ==============
  73. function closeLayer() { //这个层的关闭
  74. document.getElementsByName("rightMenuLayer")[0].style.visibility="hidden";
  75. }
  76. function isLayer() {//判断是否显示
  77. if (document.getElementsByName("rightMenuLayer")[0].style.visibility=="hidden") {
  78. return false;
  79. } else {
  80. return true;
  81. }
  82. }
  83. function setMenuTypeWF(aObj,type,win1,x,y){ //主调函数 aObj 为对象; type 为菜单项
  84. closeLayer();
  85. setType(type,aObj);
  86. win2 = win1;
  87. var rightedge = x;
  88. var bottomedge = y;
  89. var strText = "";
  90. var j=0;
  91. if(strMenu.length!=0) {
  92. for (var i = 0;i < strMenu.length;i++) {
  93. if (strMenu[i]!="-") {
  94. var strMenuItem = strMenu[i].split("|");
  95. if ( strMenuItem.length==1)
  96. strText+='<div id="divId'+ i + '" class="menuitems" OnClick="alert(\''+aObj.id+'\');">' + strMenu[i] + '</div>\n';
  97. if ( strMenuItem.length==2)
  98. strText+='<div id="divId'+ i + '" class="menuitems" OnClick="parent.win2.'+ strMenuItem[1] +';">' + strMenuItem[0] + '</div>\n';
  99. if (strMenuItem.length==3)
  100. strText+='<div id="divId'+ i + '" class="menuitems" url="'+ strMenuItem[2]+'" OnClick="parent.win2.'+ strMenuItem[1] +';">' + strMenuItem[0] + '</div>\n';
  101. } else {
  102. strText+='<hr>\n';
  103. j++;
  104. }
  105. }
  106. var dads = document.getElementsByName("rightMenuLayer")[0].style;
  107. if (strMenu.length==1) {
  108. dads.height=(strMenu.length*VALUE)-(strMenu.length*4)+(strMenu.length%2)+3-(j*2)+"px";
  109. } else {
  110. dads.height=(strMenu.length*VALUE)-(strMenu.length*2)+(strMenu.length%2)+3-(j*2)+"px";
  111. }
  112. omenulayer.all.item("divId").innerHTML = strText;
  113. bottomedge = bottomedge + document.body.scrollTop; //定位
  114. rightedge = rightedge + document.body.scrollLeft;
  115. //如果从鼠标位置到窗口下边的空间小于菜单的高度,就定位菜单的上坐标(Top)为当前鼠标位置向上一个菜单高度
  116. if ((bottomedge + parseInt(dads.height)) > window.document.body.scrollHeight + window.document.body.scrollTop)
  117. dads.top = bottomedge - parseInt(dads.height); //否则,就定位菜单的左坐标为当前鼠标位置
  118. else
  119. dads.top = bottomedge;
  120. //如果从鼠标位置到窗口右边的空间小于菜单的宽度,就定位菜单的左坐标(Left)为当前鼠标位置向左一个菜单宽度
  121. if ((rightedge + parseInt(dads.width)) > ( window.document.body.scrollWidth + window.document.body.scrollLeft)) {
  122. dads.left = rightedge - parseInt(dads.width);
  123. }
  124. else{
  125. //否则,就定位菜单的上坐标为当前鼠标位置
  126. dads.left = rightedge
  127. }
  128. //设置菜单可见
  129. dads.visibility="visible";
  130. document.getElementsByName("rightMenuLayer")[0].focus();
  131. }
  132. }
  133. //菜单项类型
  134. function setType(i,aObj){
  135. var nodeId = aObj.nodeId;
  136. var moduletype = aObj.nodeId;
  137. if(moduletype.indexOf(".") != -1) moduletype = moduletype.substring(moduletype.indexOf(".") + 1);
  138. switch(i) {
  139. case 1:
  140. strMenu=new Array();
  141. strMenu[0]="新增模块|add('/nwyj/admin/setup/sysmodel/objmanager/module/edit.jsp?action=0')|2";
  142. strMenu[1]="刷新模块|refreshNode('"+aObj.nodeId+"')|2";
  143. break;
  144. case 10:
  145. strMenu=new Array();
  146. strMenu[0]="修改|edit('"+aObj.href+"')|2";
  147. strMenu[1]="删除|deleteObj('/nwyj/admin/setup/sysmodel/objmanager/module/editExc.jsp?action=del&code="+nodeId+"')|2";
  148. break;
  149. case 2:
  150. strMenu=new Array();
  151. strMenu[0]="新增数据库链接|add('/nwyj/admin/setup/sysmodel/objmanager/DBLink/edit.jsp?action=0')|2";
  152. strMenu[1]="刷新数据库链接|refreshNode('"+aObj.nodeId+"')|2";
  153. break;
  154. case 20:
  155. strMenu=new Array();
  156. strMenu[0]="修改|edit('"+aObj.href+"')|2";
  157. strMenu[1]="删除|deleteObj('/nwyj/admin/setup/sysmodel/objmanager/DBLink/editExc.jsp?action=del&dataSourceid="+nodeId+"')|2";
  158. break;
  159. case 3:
  160. strMenu=new Array();
  161. strMenu[0]="新增常量模版|add('/nwyj/admin/setup/sysmodel/objmanager/constant/template/container.jsp')|2";
  162. strMenu[1]="刷新常量模版|refreshNode('"+aObj.nodeId+"')|2";
  163. break;
  164. case 30:
  165. strMenu=new Array();
  166. strMenu[0]="修改|edit('"+aObj.href+"')|2";
  167. strMenu[1]="删除|deleteObj('/nwyj/admin/setup/sysmodel/objmanager/constant/template/editExc.jsp?action=del&name="+nodeId+"')|2";
  168. break;
  169. case 4:
  170. strMenu=new Array();
  171. strMenu[0]="新增常量|add('/nwyj/admin/setup/sysmodel/objmanager/constant/edit.jsp?action=0&type="+moduletype+"')|2";
  172. strMenu[1]="刷新常量|refreshNode('"+aObj.nodeId+"')|2";
  173. break;
  174. case 40:
  175. strMenu=new Array();
  176. strMenu[0]="修改常量|edit('"+aObj.href+"')|2";
  177. strMenu[1]="删除常量|deleteObj('/nwyj/admin/setup/sysmodel/objmanager/constant/editExc.jsp?action=del&name="+nodeId+"')|2";
  178. strMenu[2]="-";
  179. strMenu[3]="生成表|refreshNode()";
  180. strMenu[4]="更新表|openFileProperty('propertyAdjunctFile.jsp',364,238)";
  181. break;
  182. case 5:
  183. strMenu=new Array();
  184. strMenu[0]="新增表|add('/nwyj/admin/setup/sysmodel/objmanager/table/container.jsp?type="+moduletype+"')|2";
  185. strMenu[1]="刷新表|refreshNode('"+aObj.nodeId+"')|2";
  186. break;
  187. case 50:
  188. strMenu=new Array();
  189. strMenu[0]="修改表|edit('"+aObj.href+"')|2";
  190. strMenu[1]="删除表|deleteObj('/nwyj/admin/setup/sysmodel/objmanager/table/editExc.jsp?action=del&classid="+nodeId+"')|2";
  191. strMenu[2]="-";
  192. strMenu[3]="生成表|creatTable('/nwyj/admin/setup/sysmodel/dbmanager/table/create/createExc.jsp?classid="+nodeId+"&type=1')|2";
  193. strMenu[4]="更新表|openFileProperty('propertyAdjunctFile.jsp',364,238)";
  194. break;
  195. case 6:
  196. strMenu=new Array();
  197. strMenu[0]="新增列表配置|add('/nwyj/admin/setup/listmodel/objmanager/container.html?type="+moduletype+"')|2";
  198. strMenu[1]="刷新列表配置|refreshNode('"+aObj.nodeId+"')|2";
  199. break;
  200. case 60:
  201. strMenu=new Array();
  202. strMenu[0]="修改列表配置|edit('"+aObj.href+"')|2";
  203. strMenu[1]="删除列表配置|deleteObj('/nwyj/admin/setup/listmodel/objmanager/editExc.jsp?action=del&listid="+nodeId+"')|2";
  204. strMenu[2]="-";
  205. strMenu[3]="验证列表配置|edit()";
  206. break;
  207. case 7:
  208. strMenu=new Array();
  209. strMenu[0]="新增采集配置|add('/nwyj/admin/setup/collectmodel/objmanager/container.html?type="+moduletype+"')|2";
  210. strMenu[1]="刷新采集配置|refreshNode('"+aObj.nodeId+"')|2";
  211. break;
  212. case 70:
  213. strMenu=new Array();
  214. strMenu[0]="修改采集配置|edit('"+aObj.href+"')|2";
  215. strMenu[1]="删除采集配置|deleteObj('/nwyj/admin/setup/collectmodel/objmanager/editExc.jsp?Action=del&pagid="+nodeId+"')|2";
  216. strMenu[2]="-";
  217. strMenu[3]="验证采集配置|refreshNode()";
  218. break;
  219. default:
  220. strMenu=new Array();
  221. alert("没有该类型!");
  222. }
  223. }
  224. /*
  225. function document.onkeyup(e) { //按Esc键关闭,切换焦点关闭
  226. if (window.event.keyCode==27) {
  227. closeLayer();
  228. } else if (document.activeElement) {
  229. closeLayer();
  230. }
  231. }
  232. */
  233. // -->