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

Jsp/Servlet

开发平台:

Java

  1. /*
  2. *######################################
  3. * eWebEditor v4.00 - Advanced online web based WYSIWYG HTML editor.
  4. * Copyright (c) 2003-2007 eWebSoft.com
  5. *
  6. * For further information go to http://www.ewebsoft.com/
  7. * This copyright notice MUST stay intact for use.
  8. *######################################
  9. */
  10. var sMenuHr="<tr><td align=center valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width="+(lang["UIMenuWidth"]-22)+" height=2><tr><td height=1 class=HrShadow></td></tr><tr><td height=1 class=HrHighLight></td></tr></TABLE></td></tr>";
  11. var sMenu1="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width="+lang["UIMenuWidth"]+"><tr><td width=18 valign=bottom align=center style='background:url(sysimage/contextmenu.gif);background-position:bottom;'></td><td width="+(lang["UIMenuWidth"]-18)+" class=RightBg><TABLE border=0 cellpadding=0 cellspacing=0>";
  12. var sMenu2="</TABLE></td></tr></TABLE>";
  13. var oPopupMenu = null;
  14. if (BrowserInfo.IsIE55OrMore){
  15. oPopupMenu = window.createPopup();
  16. }
  17. function getMenuRow(s_Disabled, s_Event, s_Image, s_Html) {
  18. var s_MenuRow = "";
  19. s_MenuRow = "<tr><td align=center valign=middle><TABLE border=0 cellpadding=0 cellspacing=0 width="+(lang["UIMenuWidth"]-18)+"><tr "+s_Disabled+"><td valign=middle height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut';";
  20. if (s_Disabled==""){
  21. s_MenuRow += " onclick="parent."+s_Event+";parent.oPopupMenu.hide();"";
  22. }
  23. s_MenuRow += ">"
  24. if (s_Image !=""){
  25. s_MenuRow += "&nbsp;<img border=0 src='buttonimage/"+config.ButtonDir+"/"+s_Image+"' width=20 height=20 align=absmiddle "+s_Disabled+">&nbsp;";
  26. }else{
  27. s_MenuRow += "&nbsp;";
  28. }
  29. s_MenuRow += s_Html+"</td></tr></TABLE></td></tr>";
  30. return s_MenuRow;
  31. }
  32. function getFormatMenuRow(menu, html, image){
  33. var s_Disabled = "";
  34. if (!eWebEditor.document.queryCommandEnabled(menu)){
  35. s_Disabled = "disabled";
  36. }
  37. var s_Event = "format('"+menu+"')";
  38. var s_Image = menu+".gif";
  39. if (image){
  40. s_Image = image;
  41. }
  42. return getMenuRow(s_Disabled, s_Event, s_Image, html)
  43. }
  44. function getTableMenuRow(what){
  45. var s_Menu = "";
  46. var s_Disabled = "disabled";
  47. switch(what){
  48. case "TableInsert":
  49. if (!isTableSelected()) s_Disabled="";
  50. s_Menu += getMenuRow(s_Disabled, "TableInsert()", "tableinsert.gif", lang["TableInsert"])
  51. break;
  52. case "TableProp":
  53. if (isTableSelected()||isCursorInTableCell()) s_Disabled="";
  54. s_Menu += getMenuRow(s_Disabled, "TableProp()", "tableprop.gif", lang["TableProp"])
  55. break;
  56. case "TableCell":
  57. if (isCursorInTableCell()) s_Disabled="";
  58. s_Menu += getMenuRow(s_Disabled, "TableCellProp()", "tablecellprop.gif", lang["TableCellProp"])
  59. s_Menu += getMenuRow(s_Disabled, "TableCellSplit()", "tablecellsplit.gif", lang["TableCellSplit"])
  60. s_Menu += sMenuHr;
  61. s_Menu += getMenuRow(s_Disabled, "TableRowProp()", "tablerowprop.gif", lang["TableRowProp"])
  62. s_Menu += getMenuRow(s_Disabled, "TableRowInsertAbove()", "tablerowinsertabove.gif", lang["TableRowInsertAbove"]);
  63. s_Menu += getMenuRow(s_Disabled, "TableRowInsertBelow()", "tablerowinsertbelow.gif", lang["TableRowInsertBelow"]);
  64. s_Menu += getMenuRow(s_Disabled, "TableRowMerge()", "tablerowmerge.gif", lang["TableRowMerge"]);
  65. s_Menu += getMenuRow(s_Disabled, "TableRowSplit(2)", "tablerowsplit.gif", lang["TableRowSplit"]);
  66. s_Menu += getMenuRow(s_Disabled, "TableRowDelete()", "tablerowdelete.gif", lang["TableRowDelete"]);
  67. s_Menu += sMenuHr;
  68. s_Menu += getMenuRow(s_Disabled, "TableColInsertLeft()", "tablecolinsertleft.gif", lang["TableColInsertLeft"]);
  69. s_Menu += getMenuRow(s_Disabled, "TableColInsertRight()", "tablecolinsertright.gif", lang["TableColInsertRight"]);
  70. s_Menu += getMenuRow(s_Disabled, "TableColMerge()", "tablecolmerge.gif", lang["TableColMerge"]);
  71. s_Menu += getMenuRow(s_Disabled, "TableColSplit(2)", "tablecolsplit.gif", lang["TableColSplit"]);
  72. s_Menu += getMenuRow(s_Disabled, "TableColDelete()", "tablecoldelete.gif", lang["TableColDelete"]);
  73. break;
  74. }
  75. return s_Menu;
  76. }
  77. function showContextMenu(event){
  78. if (!bEditMode) return false;
  79. var width = lang["UIMenuWidth"];
  80. var height = 0;
  81. var lefter = event.clientX;
  82. var topper = event.clientY;
  83. var oPopDocument = oPopupMenu.document;
  84. var oPopBody = oPopupMenu.document.body;
  85. var sMenu="";
  86. sMenu += getFormatMenuRow("cut", lang["Cut"]);
  87. sMenu += getFormatMenuRow("copy", lang["Copy"]);
  88. sMenu += getFormatMenuRow("paste", lang["Paste"]);
  89. sMenu += getFormatMenuRow("delete", lang["Delete"]);
  90. sMenu += getFormatMenuRow("selectall", lang["SelectAll"]);
  91. sMenu += sMenuHr;
  92. height += 102;
  93. if (isCursorInTableCell()){
  94. sMenu += getTableMenuRow("TableProp");
  95. sMenu += getTableMenuRow("TableCell");
  96. sMenu += sMenuHr;
  97. height += 286;
  98. }
  99. if (isControlSelected("TABLE")){
  100. sMenu += getTableMenuRow("TableProp");
  101. sMenu += sMenuHr;
  102. height += 22;
  103. }
  104. if (isControlSelected("IMG")){
  105. sMenu += getMenuRow("", "showDialog('img.htm', true)", "img.gif", lang["CMenuImg"]);
  106. sMenu += sMenuHr;
  107. sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", lang["zIndexForward"]);
  108. sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", lang["zIndexBackward"]);
  109. sMenu += sMenuHr;
  110. height += 64;
  111. }
  112. if (tagInSelection("P")){
  113. sMenu += getMenuRow("", "showDialog('paragraph.htm', true)", "paragraph.gif", lang["CMenuParagraph"]);
  114. sMenu += sMenuHr;
  115. height += 22;
  116. }
  117. sMenu += getMenuRow("", "findReplace()", "findreplace.gif", lang["FindReplace"]);
  118. height += 20;
  119. sMenu = sMenu1 + sMenu + sMenu2;
  120. oPopDocument.open();
  121. oPopDocument.write(config.StyleMenuHeader+sMenu);
  122. oPopDocument.close();
  123. height+=2;
  124. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  125. //if(topper+height > document.body.clientHeight) topper=topper-height;
  126. oPopupMenu.show(lefter, topper, width, height, eWebEditor.document.body);
  127. return false;
  128. }
  129. function showToolMenu(menu){
  130. if (!bEditMode) return false;
  131. var sMenu = ""
  132. var width = lang["UIMenuWidth"];
  133. var height = 0;
  134. var lefter = event.clientX;
  135. var leftoff = event.offsetX
  136. var topper = event.clientY;
  137. var topoff = event.offsetY;
  138. var oPopDocument = oPopupMenu.document;
  139. var oPopBody = oPopupMenu.document.body;
  140. switch(menu){
  141. case "font":
  142. sMenu += getFormatMenuRow("bold", lang["Bold"], "bold.gif");
  143. sMenu += getFormatMenuRow("italic", lang["Italic"], "italic.gif");
  144. sMenu += getFormatMenuRow("underline", lang["UnderLine"], "underline.gif");
  145. sMenu += getFormatMenuRow("strikethrough", lang["StrikeThrough"], "strikethrough.gif");
  146. sMenu += sMenuHr;
  147. sMenu += getFormatMenuRow("superscript", lang["SuperScript"], "superscript.gif");
  148. sMenu += getFormatMenuRow("subscript", lang["SubScript"], "subscript.gif");
  149. sMenu += sMenuHr;
  150. sMenu += getMenuRow("", "showDialog('selcolor.htm?action=forecolor', true)", "forecolor.gif", lang["ForeColor"]);
  151. sMenu += getMenuRow("", "showDialog('selcolor.htm?action=backcolor', true)", "backcolor.gif", lang["BackColor"]);
  152. sMenu += sMenuHr;
  153. sMenu += getMenuRow("", "insert('big')", "tobig.gif", lang["Big"]);
  154. sMenu += getMenuRow("", "insert('small')", "tosmall.gif", lang["Small"]);
  155. height = 206;
  156. break;
  157. case "paragraph":
  158. sMenu += getFormatMenuRow("JustifyLeft", lang["JustifyLeft"], "justifyleft.gif");
  159. sMenu += getFormatMenuRow("JustifyCenter", lang["JustifyCenter"], "justifycenter.gif");
  160. sMenu += getFormatMenuRow("JustifyRight", lang["JustifyRight"], "justifyright.gif");
  161. sMenu += getFormatMenuRow("JustifyFull", lang["JustifyFull"], "justifyfull.gif");
  162. sMenu += sMenuHr;
  163. sMenu += getFormatMenuRow("insertorderedlist", lang["OrderedList"], "insertorderedlist.gif");
  164. sMenu += getFormatMenuRow("insertunorderedlist", lang["UnOrderedList"], "insertunorderedlist.gif");
  165. sMenu += getFormatMenuRow("indent", lang["Indent"], "indent.gif");
  166. sMenu += getFormatMenuRow("outdent", lang["Outdent"], "outdent.gif");
  167. sMenu += sMenuHr;
  168. sMenu += getFormatMenuRow("insertparagraph", lang["Paragraph"], "insertparagraph.gif");
  169. sMenu += getMenuRow("", "insert('br')", "br.gif", lang["BR"]);
  170. sMenu += sMenuHr;
  171. sMenu += getMenuRow((tagInSelection("P")) ? "" : "disabled", "showDialog('paragraph.htm', true)", "paragraph.gif", lang["CMenuParagraph"]);
  172. height = 226;
  173. break;
  174. case "edit":
  175. var s_Disabled = "";
  176. if (history.data.length <= 1 || history.position <= 0) s_Disabled = "disabled";
  177. sMenu += getMenuRow(s_Disabled, "goHistory(-1)", "undo.gif", lang["UnDo"])
  178. if (history.position >= history.data.length-1 || history.data.length == 0) s_Disabled = "disabled";
  179. sMenu += getMenuRow(s_Disabled, "goHistory(1)", "redo.gif", lang["ReDo"])
  180. sMenu += sMenuHr;
  181. sMenu += getFormatMenuRow("Cut", lang["Cut"], "cut.gif");
  182. sMenu += getFormatMenuRow("Copy", lang["Copy"], "copy.gif");
  183. sMenu += getFormatMenuRow("Paste", lang["Paste"], "paste.gif");
  184. sMenu += getMenuRow("", "PasteText()", "pastetext.gif", lang["PasteText"]);
  185. sMenu += getMenuRow("", "PasteWord()", "pasteword.gif", lang["PasteWord"]);
  186. sMenu += sMenuHr;
  187. sMenu += getFormatMenuRow("delete", lang["Delete"], "delete.gif");
  188. sMenu += getFormatMenuRow("RemoveFormat", lang["RemoveFormat"], "removeformat.gif");
  189. sMenu += sMenuHr;
  190. sMenu += getFormatMenuRow("SelectAll", lang["SelectAll"], "selectall.gif");
  191. sMenu += getFormatMenuRow("Unselect", lang["UnSelect"], "unselect.gif");
  192. sMenu += sMenuHr;
  193. sMenu += getMenuRow("", "findReplace()", "findreplace.gif", lang["FindReplace"]);
  194. height = 248;
  195. break;
  196. case "object":
  197. sMenu += getMenuRow("", "showDialog('selcolor.htm?action=bgcolor', true)", "bgcolor.gif", lang["BgColor"]);
  198. sMenu += getMenuRow("", "showDialog('backimage.htm', true)", "bgpic.gif", lang["BackImage"]);
  199. sMenu += sMenuHr;
  200. sMenu += getMenuRow("", "absolutePosition()", "abspos.gif", lang["absolutePosition"]);
  201. sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", lang["zIndexForward"]);
  202. sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", lang["zIndexBackward"]);
  203. sMenu += sMenuHr;
  204. sMenu += getMenuRow("", "showBorders()", "showborders.gif", lang["ShowBorders"]);
  205. sMenu += sMenuHr;
  206. sMenu += getMenuRow("", "insert('quote')", "quote.gif", lang["Quote"]);
  207. sMenu += getMenuRow("", "insert('code')", "code.gif", lang["Code"]);
  208. height = 166;
  209. break;
  210. case "component":
  211. sMenu += getMenuRow("", "showDialog('img.htm', true)", "img.gif", lang["Image"]);
  212. sMenu += getMenuRow("", "showDialog('flash.htm', true)", "flash.gif", lang["Flash"]);
  213. sMenu += getMenuRow("", "showDialog('media.htm', true)", "media.gif", lang["Media"]);
  214. sMenu += getMenuRow("", "showDialog('file.htm', true)", "file.gif", lang["File"]);
  215. sMenu += sMenuHr;
  216. sMenu += getMenuRow("", "showDialog('fieldset.htm', true)", "fieldset.gif", lang["Fieldset"]);
  217. sMenu += getMenuRow("", "showDialog('iframe.htm', true)", "iframe.gif", lang["Iframe"]);
  218. sMenu += getFormatMenuRow("InsertHorizontalRule", lang["HorizontalRule"], "inserthorizontalrule.gif");
  219. sMenu += getMenuRow("", "showDialog('marquee.htm', true)", "marquee.gif", lang["Marquee"]);
  220. sMenu += sMenuHr;
  221. sMenu += getMenuRow("", "createLink()", "createlink.gif", lang["CreateLink"]);
  222. sMenu += getMenuRow("", "showDialog('anchor.htm', true)", "anchor.gif", lang["Anchor"]);
  223. sMenu += getMenuRow("", "mapEdit()", "map.gif", lang["Map"]);
  224. sMenu += getFormatMenuRow("UnLink", lang["Unlink"], "unlink.gif");
  225. height = 244;
  226. break;
  227. case "tool":
  228. sMenu += getMenuRow("", "showDialog('symbol.htm', true)", "symbol.gif", lang["Symbol"]);
  229. sMenu += getMenuRow("", "insert('excel')", "excel.gif", lang["Excel"]);
  230. sMenu += getMenuRow("", "showDialog('emot.htm', true)", "emot.gif", lang["Emot"]);
  231. sMenu += sMenuHr;
  232. sMenu += getMenuRow("", "showDialog('art.htm', true)", "art.gif", lang["Art"]);
  233. sMenu += sMenuHr;
  234. sMenu += getMenuRow("", "insert('nowdate')", "date.gif", lang["NowDate"]);
  235. sMenu += getMenuRow("", "insert('nowtime')", "time.gif", lang["NowTime"]);
  236. height = 124;
  237. break;
  238. case "file":
  239. sMenu += getMenuRow("", "format('Refresh')", "refresh.gif", lang["Refresh"]);
  240. sMenu += sMenuHr;
  241. sMenu += getMenuRow("", "setMode('CODE')", "modecodebtn.gif", lang["ModeCode"]);
  242. sMenu += getMenuRow("", "setMode('EDIT')", "modeeditbtn.gif", lang["ModeEdit"]);
  243. sMenu += getMenuRow("", "setMode('TEXT')", "modetextbtn.gif", lang["ModeText"]);
  244. sMenu += getMenuRow("", "setMode('VIEW')", "modeviewbtn.gif", lang["ModeView"]);
  245. sMenu += sMenuHr;
  246. sMenu += getMenuRow("", "sizeChange(300)", "sizeplus.gif", lang["SizePlus"]);
  247. sMenu += getMenuRow("", "sizeChange(-300)", "sizeminus.gif", lang["SizeMinus"]);
  248. sMenu += sMenuHr;
  249. sMenu += getMenuRow("", "format('Print')", "print.gif", lang["Print"]);
  250. sMenu += sMenuHr;
  251. sMenu += getMenuRow("", "showDialog('about.htm')", "about.gif", lang["About"]);
  252. sMenu += getMenuRow("", "window.open('http://www.ewebeditor.net')", "site.gif", lang["Site"]);
  253. height = 208;
  254. break;
  255. case "table":
  256. sMenu += getTableMenuRow("TableInsert");
  257. sMenu += getTableMenuRow("TableProp");
  258. sMenu += sMenuHr;
  259. sMenu += getTableMenuRow("TableCell");
  260. height = 306;
  261. break;
  262. case "form":
  263. sMenu += getFormatMenuRow("InsertInputText", lang["FormText"], "formtext.gif");
  264. sMenu += getFormatMenuRow("InsertTextArea", lang["FormTextArea"], "formtextarea.gif");
  265. sMenu += getFormatMenuRow("InsertInputRadio", lang["FormRadio"], "formradio.gif");
  266. sMenu += getFormatMenuRow("InsertInputCheckbox", lang["FormCheckbox"], "formcheckbox.gif");
  267. sMenu += getFormatMenuRow("InsertSelectDropdown", lang["FormDropdown"], "formdropdown.gif");
  268. sMenu += getFormatMenuRow("InsertButton", lang["FormButton"], "formbutton.gif");
  269. height = 120;
  270. break;
  271. case "zoom":
  272. for (var i=0; i<aZoomSize.length; i++){
  273. if (aZoomSize[i]==nCurrZoomSize){
  274. sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "checked.gif", aZoomSize[i]+"%");
  275. }else{
  276. sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "space.gif", aZoomSize[i]+"%");
  277. }
  278. height += 20;
  279. }
  280. break;
  281. }
  282. sMenu = sMenu1 + sMenu + sMenu2;
  283. oPopDocument.open();
  284. oPopDocument.write(config.StyleMenuHeader+sMenu);
  285. oPopDocument.close();
  286. height+=2;
  287. if(lefter+width > document.body.clientWidth) lefter=lefter-width+22;
  288. oPopupMenu.show(lefter - leftoff - 2, topper - topoff + 22, width, height, document.body);
  289. return false;
  290. }