menu.js
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:8k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. /*
  2. *☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  3. *★                                                                  ★
  4. *☆                eWebEditor - 在线文本编辑器国生修改版2007.5.3     ☆
  5. *★                                                                  ★
  6. *☆  版权所有: gs008.com                                          ☆
  7. *★                                                                  ★
  8. *☆  程序制作: 国生网络                                          ☆
  9. *★            email:gswon@163.com                            ★
  10. *☆            QQ:18087249                                             ☆
  11. *★                                                                  ★
  12. *☆  相关网址: [原版地址]http://www.eWebSoft.com/Product/eWebEditor/ ☆
  13. *★            [支持论坛]http://bbs.eWebSoft.com/                    ★
  14. *☆                                                                  ☆
  15. *★  主页地址: http://www.gs008.com/blog   国生网络-国生博客                       ★
  16. *☆           有什么问题欢迎到博客提出!                         ☆
  17. *★                                                                  ★
  18. *★                                                                  ★
  19. *☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  20. */
  21. // 菜单常量
  22. var sMenuHr="<tr><td align=center valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width=128 height=2><tr><td height=1 class=HrShadow></td></tr><tr><td height=1 class=HrHighLight></td></tr></TABLE></td></tr>";
  23. var sMenu1="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width=150><tr><td width=18 valign=bottom align=center style='background:url(sysimage/contextmenu.gif);background-position:bottom;'></td><td width=132 class=RightBg><TABLE border=0 cellpadding=0 cellspacing=0>";
  24. var sMenu2="</TABLE></td></tr></TABLE>";
  25. // 取菜单行
  26. function getMenuRow(s_Disabled, s_Event, s_Image, s_Html) {
  27. var s_MenuRow = "";
  28. s_MenuRow = "<tr><td align=center valign=middle><TABLE border=0 cellpadding=0 cellspacing=0 width=132><tr "+s_Disabled+"><td valign=middle height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut';";
  29. if (s_Disabled==""){
  30. s_MenuRow += " onclick="parent."+s_Event+";parent.oPopupMenu.hide();"";
  31. }
  32. s_MenuRow += ">"
  33. if (s_Image !=""){
  34. s_MenuRow += "&nbsp;<img border=0 src='buttonimage/"+config.StyleDir+"/"+s_Image+"' width=20 height=20 align=absmiddle "+s_Disabled+">&nbsp;";
  35. }else{
  36. s_MenuRow += "&nbsp;";
  37. }
  38. s_MenuRow += s_Html+"</td></tr></TABLE></td></tr>";
  39. return s_MenuRow;
  40. }
  41. // 取标准的format菜单行
  42. function getFormatMenuRow(menu, html, image){
  43. var s_Disabled = "";
  44. if (!eWebEditor.document.queryCommandEnabled(menu)){
  45. s_Disabled = "disabled";
  46. }
  47. var s_Event = "format('"+menu+"')";
  48. var s_Image = menu+".gif";
  49. if (image){
  50. s_Image = image;
  51. }
  52. return getMenuRow(s_Disabled, s_Event, s_Image, html)
  53. }
  54. // 取表格菜单行
  55. function getTableMenuRow(what){
  56. var s_Menu = "";
  57. var s_Disabled = "disabled";
  58. switch(what){
  59. case "TableInsert":
  60. if (!isTableSelected()) s_Disabled="";
  61. s_Menu += getMenuRow(s_Disabled, "TableInsert()", "tableinsert.gif", "插入表格...")
  62. break;
  63. case "TableProp":
  64. if (isTableSelected()||isCursorInTableCell()) s_Disabled="";
  65. s_Menu += getMenuRow(s_Disabled, "TableProp()", "tableprop.gif", "表格属性...")
  66. break;
  67. case "TableCell":
  68. if (isCursorInTableCell()) s_Disabled="";
  69. s_Menu += getMenuRow(s_Disabled, "TableCellProp()", "tablecellprop.gif", "单元格属性...")
  70. s_Menu += getMenuRow(s_Disabled, "TableCellSplit()", "tablecellsplit.gif", "拆分单元格...")
  71. s_Menu += sMenuHr;
  72. s_Menu += getMenuRow(s_Disabled, "TableRowProp()", "tablerowprop.gif", "表格行属性...")
  73. s_Menu += getMenuRow(s_Disabled, "TableRowInsertAbove()", "tablerowinsertabove.gif", "插入行(在上方)");
  74. s_Menu += getMenuRow(s_Disabled, "TableRowInsertBelow()", "tablerowinsertbelow.gif", "插入行(在下方)");
  75. s_Menu += getMenuRow(s_Disabled, "TableRowMerge()", "tablerowmerge.gif", "合并行(向下方)");
  76. s_Menu += getMenuRow(s_Disabled, "TableRowSplit(2)", "tablerowsplit.gif", "拆分行");
  77. s_Menu += getMenuRow(s_Disabled, "TableRowDelete()", "tablerowdelete.gif", "删除行");
  78. s_Menu += sMenuHr;
  79. s_Menu += getMenuRow(s_Disabled, "TableColInsertLeft()", "tablecolinsertleft.gif", "插入列(在左侧)");
  80. s_Menu += getMenuRow(s_Disabled, "TableColInsertRight()", "tablecolinsertright.gif", "插入列(在右侧)");
  81. s_Menu += getMenuRow(s_Disabled, "TableColMerge()", "tablecolmerge.gif", "合并列(向右侧)");
  82. s_Menu += getMenuRow(s_Disabled, "TableColSplit(2)", "tablecolsplit.gif", "拆分列");
  83. s_Menu += getMenuRow(s_Disabled, "TableColDelete()", "tablecoldelete.gif", "删除列");
  84. break;
  85. }
  86. return s_Menu;
  87. }
  88. // 右键菜单
  89. var oPopupMenu = window.createPopup();
  90. function showContextMenu(event){
  91. if (!bEditMode) return false;
  92. var width = 150;
  93. var height = 0;
  94. var lefter = event.clientX;
  95. var topper = event.clientY;
  96. var oPopDocument = oPopupMenu.document;
  97. var oPopBody = oPopupMenu.document.body;
  98. var sMenu="";
  99. sMenu += getFormatMenuRow("cut", "剪切");
  100. sMenu += getFormatMenuRow("copy", "复制");
  101. sMenu += getFormatMenuRow("paste", "常规粘贴");
  102. sMenu += getFormatMenuRow("delete", "删除");
  103. sMenu += getFormatMenuRow("selectall", "全选");
  104. sMenu += sMenuHr;
  105. height += 102;
  106. if (isCursorInTableCell()){
  107. sMenu += getTableMenuRow("TableProp");
  108. sMenu += getTableMenuRow("TableCell");
  109. sMenu += sMenuHr;
  110. height += 286;
  111. }
  112. if (isControlSelected("TABLE")){
  113. sMenu += getTableMenuRow("TableProp");
  114. sMenu += sMenuHr;
  115. height += 22;
  116. }
  117. if (isControlSelected("IMG")){
  118. sMenu += getMenuRow("", "ShowDialog('dialog/img.htm', 350, 315, true)", "img.gif", "图片属性...");
  119. sMenu += sMenuHr;
  120. sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", "上移一层");
  121. sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", "下移一层");
  122. sMenu += sMenuHr;
  123. height += 64;
  124. }
  125. sMenu += getMenuRow("", "findReplace()", "findreplace.gif", "查找替换...");
  126. height += 20;
  127. sMenu = sMenu1 + sMenu + sMenu2;
  128. oPopDocument.open();
  129. oPopDocument.write(config.StyleMenuHeader+sMenu);
  130. oPopDocument.close();
  131. height+=2;
  132. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  133. //if(topper+height > document.body.clientHeight) topper=topper-height;
  134. oPopupMenu.show(lefter, topper, width, height, eWebEditor.document.body);
  135. return false;
  136. }
  137. // 工具栏菜单
  138. function showToolMenu(menu){
  139. if (!bEditMode) return false;
  140. var sMenu = ""
  141. var width = 150;
  142. var height = 0;
  143. var lefter = event.clientX;
  144. var leftoff = event.offsetX
  145. var topper = event.clientY;
  146. var topoff = event.offsetY;
  147. var oPopDocument = oPopupMenu.document;
  148. var oPopBody = oPopupMenu.document.body;
  149. switch(menu){
  150. case "paste":
  151. break;
  152. case "table": // 表格菜单
  153. sMenu += getTableMenuRow("TableInsert");
  154. sMenu += getTableMenuRow("TableProp");
  155. sMenu += sMenuHr;
  156. sMenu += getTableMenuRow("TableCell");
  157. height = 306;
  158. break;
  159. case "form": // 表单菜单
  160. sMenu += getFormatMenuRow("InsertInputText", "插入输入框", "formtext.gif");
  161. sMenu += getFormatMenuRow("InsertTextArea", "插入输入区", "formtextarea.gif");
  162. sMenu += getFormatMenuRow("InsertInputRadio", "插入单选钮", "formradio.gif");
  163. sMenu += getFormatMenuRow("InsertInputCheckbox", "插入复选钮", "formcheckbox.gif");
  164. sMenu += getFormatMenuRow("InsertSelectDropdown", "插入下拉框", "formdropdown.gif");
  165. sMenu += getFormatMenuRow("InsertButton", "插入按钮", "formbutton.gif");
  166. height = 120;
  167. break;
  168. case "zoom": // 缩放菜单
  169. for (var i=0; i<aZoomSize.length; i++){
  170. if (aZoomSize[i]==nCurrZoomSize){
  171. sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "checked.gif", aZoomSize[i]+"%")
  172. }else{
  173. sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "space.gif", aZoomSize[i]+"%")
  174. }
  175. height += 20;
  176. }
  177. break;
  178. }
  179. sMenu = sMenu1 + sMenu + sMenu2;
  180. oPopDocument.open();
  181. oPopDocument.write(config.StyleMenuHeader+sMenu);
  182. oPopDocument.close();
  183. height+=2;
  184. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  185. //if(topper+height > document.body.clientHeight) topper=topper-height;
  186. oPopupMenu.show(lefter - leftoff - 2, topper - topoff + 22, width, height, document.body);
  187. return false;
  188. }