editor2.js
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:121k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. // JavaScript Document
  2. /***********************************************************
  3. InnovaStudio WYSIWYG Editor 2.2
  4. Copyright ?2003-2005, INNOVA STUDIO (www.InnovaStudio.com). All rights reserved.
  5. ************************************************************/
  6. /*** UTILITY OBJECT ***/
  7. var oUtil=new InnovaEditorUtil();
  8. function InnovaEditorUtil()
  9. {
  10. /*** Localization ***/
  11. this.langDir="english";
  12. try{if(LanguageDirectory)this.langDir=LanguageDirectory;}catch(e){;}
  13. var oScripts=document.getElementsByTagName("script");
  14. for(var i=0;i<oScripts.length;i++)
  15. {
  16. var sSrc=oScripts[i].src.toLowerCase();
  17. if(sSrc.indexOf("scripts/editor.js")!=-1) this.scriptPath=oScripts[i].src.replace(/editor.js/ig,"");
  18. }
  19. this.scriptPathLang=this.scriptPath+"language/"+this.langDir+"/";
  20. if(this.langDir=="english")
  21. document.write("<scr"+"ipt src='"+this.scriptPathLang+"editor_lang.js'></scr"+"ipt>");
  22. /*** /Localization ***/
  23. this.oName;this.oEditor;this.obj;
  24. this.oSel;
  25. this.sType;
  26. this.bInside=bInside;
  27. this.useSelection=true;
  28. this.arrEditor=[];
  29. this.onSelectionChanged=function(){return true;};
  30. this.activeElement;
  31. }
  32. /*** FOCUS STUFF ***/
  33. function bInside(oElement)
  34. {
  35. while(oElement!=null)
  36. {
  37. if(oElement.contentEditable=="true")return true;
  38. oElement=oElement.parentElement;
  39. }
  40. return false;
  41. }
  42. function checkFocus()
  43. {
  44. var oEditor=eval("idContent"+this.oName);
  45. var oSel=oEditor.document.selection.createRange();
  46. var sType=oEditor.document.selection.type;
  47. if(oSel.parentElement!=null)
  48. {
  49. if(!bInside(oSel.parentElement()))return false;
  50. }
  51. else
  52. {
  53. if(!bInside(oSel.item(0)))return false;
  54. }
  55. return true;
  56. }
  57. function iwe_focus()
  58. {
  59. var oEditor=eval("idContent"+this.oName);
  60. oEditor.focus()
  61. }
  62. /*********************
  63. EDITOR OBJECT
  64. **********************/
  65. function InnovaEditor(oName)
  66. {
  67. this.oName=oName;
  68. this.RENDER=RENDER;
  69. this.IsSecurityRestricted=false;
  70. this.loadHTML=loadHTML;
  71. this.getHTMLBody=getHTMLBody;
  72. this.getXHTMLBody=getXHTMLBody;
  73. this.getHTML=getHTML;
  74. this.getXHTML=getXHTML;
  75. this.putHTML=putHTML;//source dialog
  76. this.css="";
  77. this.initialRefresh=false;
  78. this.bInside=bInside;
  79. this.checkFocus=checkFocus;
  80. this.focus=iwe_focus;
  81. this.doCmd=doCmd;
  82. this.applyParagraph=applyParagraph;
  83. this.applyFontName=applyFontName;
  84. this.applyFontSize=applyFontSize;
  85. this.applyBullets=applyBullets;
  86. this.applyNumbering=applyNumbering;
  87. this.applyJustifyLeft=applyJustifyLeft;
  88. this.applyJustifyCenter=applyJustifyCenter;
  89. this.applyJustifyRight=applyJustifyRight;
  90. this.applyJustifyFull=applyJustifyFull;
  91. this.applyBlockDirLTR=applyBlockDirLTR;
  92. this.applyBlockDirRTL=applyBlockDirRTL;
  93. this.doPaste=doPaste;
  94. this.doPasteText=doPasteText;
  95. this.applySpan=applySpan;
  96. this.makeAbsolute=makeAbsolute;
  97. this.insertHTML=insertHTML;
  98. this.clearAll=clearAll;
  99. this.spellcheckDialogShow=spellcheckDialogShow;
  100. this.insertCustomTag=insertCustomTag;
  101. this.selectParagraph=selectParagraph;
  102. this.doOnPaste=doOnPaste;
  103. this.isAfterPaste=false;
  104. this.doClean=doClean;
  105. this.hide=hide;
  106. this.dropShow=dropShow;
  107. this.width="663";
  108. this.height="250";
  109. this.publishingPath="";//ex."http://localhost/InnovaStudio/"
  110. var oScripts=document.getElementsByTagName("script");
  111. for(var i=0;i<oScripts.length;i++)
  112. {
  113. var sSrc=oScripts[i].src.toLowerCase();
  114. if(sSrc.indexOf("scripts/editor.js")!=-1) this.scriptPath=sSrc.replace(/editor.js/,"");
  115. }
  116. this.iconPath="icons/";
  117. this.iconWidth=25;this.iconHeight=24;
  118. this.writeIconToggle=writeIconToggle;
  119. this.writeIconStandard=writeIconStandard;
  120. this.writeDropDown=writeDropDown;
  121. this.writeBreakSpace=writeBreakSpace;
  122. this.dropTopAdjustment=1;
  123. this.runtimeBorder=runtimeBorder;
  124. this.runtimeBorderOn=runtimeBorderOn;
  125. this.runtimeBorderOff=runtimeBorderOff;
  126. this.IsRuntimeBorderOn=true;
  127. this.runtimeStyles=runtimeStyles;
  128. this.applyColor=applyColor;
  129. this.customColors=[];//["#ff4500","#ffa500","#808000","#4682b4","#1e90ff","#9400d3","#ff1493","#a9a9a9"];
  130. this.oColor1 = new ColorPicker("oColor1",this.oName);//to call: oEdit1.oColor1
  131. this.oColor2 = new ColorPicker("oColor2",this.oName);//rendered id: ...oColor1oEdit1
  132. this.expandSelection=expandSelection;
  133. this.fullScreen=fullScreen;
  134. this.stateFullScreen=false;
  135. this.onFullScreen=function(){return true;};
  136. this.onNormalScreen=function(){return true;};
  137. this.arrElm=new Array(300);
  138. this.getElm=iwe_getElm;
  139. this.features=[];
  140. this.buttonMap=["Save","FullScreen","Preview","Print","Search","SpellCheck","|",
  141. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  142. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  143. "CustomTag","Image","Flash","Media","ContentBlock","InternalLink","CustomObject","|",
  144. "Table","Guidelines","Absolute","|","Characters","Line",
  145. "Form","Clean","HTMLFullSource","HTMLSource","XHTMLFullSource",
  146. "XHTMLSource","ClearAll","BRK",
  147. "StyleAndFormatting","|","Paragraph","FontName","FontSize","|",
  148. "Bold","Italic","Underline","Strikethrough","Superscript","Subscript","|",
  149. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|",
  150. "Numbering","Bullets","|","Indent","Outdent","LTR","RTL"];//complete, default
  151. this.btnSave=false;this.btnPreview=true;this.btnFullScreen=true;this.btnPrint=false;this.btnSearch=true;
  152. this.btnSpellCheck=false;this.btnTextFormatting=true;
  153. this.btnListFormatting=true;this.btnBoxFormatting=true;this.btnParagraphFormatting=true;this.btnCssText=true;
  154. this.btnStyles=false;this.btnParagraph=true;this.btnFontName=true;this.btnFontSize=true;
  155. this.btnCut=true;this.btnCopy=true;this.btnPaste=true;this.btnPasteText=false;this.btnUndo=true;this.btnRedo=true;
  156. this.btnBold=true;this.btnItalic=true;this.btnUnderline=true;
  157. this.btnStrikethrough=false;this.btnSuperscript=false;this.btnSubscript=false;
  158. this.btnJustifyLeft=true;this.btnJustifyCenter=true;this.btnJustifyRight=true;this.btnJustifyFull=true;
  159. this.btnNumbering=true;this.btnBullets=true;this.btnIndent=true;this.btnOutdent=true;
  160. this.btnLTR=false;this.btnRTL=false;this.btnForeColor=true;this.btnBackColor=true;
  161. this.btnHyperlink=true;this.btnBookmark=true;this.btnCharacters=true;this.btnCustomTag=false;
  162. this.btnImage=true;this.btnFlash=false;this.btnMedia=false;
  163. this.btnTable=true;this.btnGuidelines=true;
  164. this.btnAbsolute=true;this.btnPasteWord=true;this.btnLine=true;
  165. this.btnForm=true;this.btnClean=true;
  166. this.btnHTMLFullSource=false;this.btnHTMLSource=false;
  167. this.btnXHTMLFullSource=false;this.btnXHTMLSource=true;
  168. this.btnClearAll=false;
  169. //*** CMS Features ***
  170. this.cmdAssetManager="";
  171. this.btnContentBlock=false;
  172. this.cmdContentBlock=";";//needs ;
  173. this.btnInternalLink=false;
  174. this.cmdInternalLink=";";//needs ;
  175. this.insertLink=insertLink;
  176. this.btnCustomObject=false;
  177. this.cmdCustomObject=";";//needs ;
  178. //*****
  179. this.arrStyle=[];
  180. this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText.htm',360,380)");
  181. this.addonCSSBuilder=addonCSSBuilder;
  182. this.arrParagraph=[[getText("Heading 1"),"H1"],
  183. [getText("Heading 2"),"H2"],
  184. [getText("Heading 3"),"H3"],
  185. [getText("Heading 4"),"H4"],
  186. [getText("Heading 5"),"H5"],
  187. [getText("Heading 6"),"H6"],
  188. [getText("Preformatted"),"PRE"],
  189. [getText("Normal (P)"),"P"],
  190. [getText("Normal (DIV)"),"DIV"]];
  191. this.arrFontName=["u5B8Bu4F53","u9ED1u4F53","u96B6u4E66","Arial","Arial Black","Arial Narrow",
  192. "Book Antiqua","Bookman Old Style",
  193. "Century Gothic","Comic Sans MS","Courier New",
  194. "Franklin Gothic Medium","Garamond","Georgia",
  195. "Impact","Lucida Console","Lucida Sans","Lucida Unicode",
  196. "Modern","Monotype Corsiva","Palatino Linotype",
  197. "Roman","Script","Small Fonts","Symbol",
  198. "Tahoma","Times New Roman","Trebuchet MS",
  199. "Verdana","Webdings","Wingdings","Wingdings 2","Wingdings 3",
  200. "serif","sans-serif","cursive","fantasy","monoscape"];
  201. this.arrFontSize=[[getText("Size 1"),"1"],
  202. [getText("Size 2"),"2"],
  203. [getText("Size 3"),"3"],
  204. [getText("Size 4"),"4"],
  205. [getText("Size 5"),"5"],
  206. [getText("Size 6"),"6"],
  207. [getText("Size 7"),"7"]];
  208. this.arrCustomTag=[];//eg.[["Full Name","{%full_name%}"],["Email","{%email%}"]];
  209. this.docType="";
  210. this.html="<html>";
  211. this.headContent="";
  212. this.preloadHTML="";
  213. this.onSave=function(){return true;};
  214. this.useBR=false;
  215. this.useDIV=true;
  216. this.doUndo=doUndo;
  217. this.doRedo=doRedo;
  218. this.saveForUndo=saveForUndo;
  219. this.arrUndoList=[];
  220. this.arrRedoList=[];
  221. this.useTagSelector=true;
  222. this.TagSelectorPosition="bottom";
  223. this.moveTagSelector=moveTagSelector;
  224. this.selectElement=selectElement;
  225. this.removeTag=removeTag;
  226. this.doClick_TabCreate=doClick_TabCreate;
  227. this.doRefresh_TabCreate=doRefresh_TabCreate;
  228. this.arrCustomButtons = [["CustomName1","alert(0)","caption here","btnSave.gif"],
  229. ["CustomName2","alert(0)","caption here","btnSave.gif"]];
  230. this.onSelectionChanged=function(){return true;};
  231. }
  232. /*********************
  233. ADD-ONS
  234. **********************/
  235. function addonCSSBuilder(bEnabled)
  236. {
  237. if(bEnabled)
  238. this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText2.htm',430,462)");
  239. else
  240. this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText.htm',360,380)");
  241. }
  242. /*********************
  243. UNDO/REDO
  244. **********************/
  245. function saveForUndo()
  246. {
  247. var oEditor=eval("idContent"+this.oName);
  248. var obj=eval(this.oName);
  249. if(obj.arrUndoList[0])
  250. if(oEditor.document.body.innerHTML==obj.arrUndoList[0][0])return;
  251. for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
  252. obj.focus();
  253. var oSel=oEditor.document.selection.createRange();
  254. var sType=oEditor.document.selection.type;
  255. if(sType=="None")
  256. obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
  257. oEditor.document.selection.createRange().getBookmark(),"None"];
  258. else if(sType=="Text")
  259. obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
  260. oEditor.document.selection.createRange().getBookmark(),"Text"];
  261. else if(sType=="Control")
  262. {
  263. oSel.item(0).selThis="selThis";
  264. obj.arrUndoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
  265. oSel.item(0).removeAttribute("selThis",0);
  266. }
  267. this.arrRedoList=[];//clear redo list
  268. if(this.btnUndo) makeEnableNormal(eval("document.all.btnUndo"+this.oName));
  269. if(this.btnRedo) makeDisabled(eval("document.all.btnRedo"+this.oName));
  270. }
  271. function doUndo()
  272. {
  273. var oEditor=eval("idContent"+this.oName);
  274. var obj=eval(this.oName);
  275. if(!obj.arrUndoList[0])return;
  276. //~~~~
  277. for(var i=20;i>1;i--)obj.arrRedoList[i-1]=obj.arrRedoList[i-2];
  278. var oSel=oEditor.document.selection.createRange();
  279. var sType=oEditor.document.selection.type;
  280. if(sType=="None")
  281. this.arrRedoList[0]=[oEditor.document.body.innerHTML,
  282. oEditor.document.selection.createRange().getBookmark(),"None"];
  283. else if(sType=="Text")
  284. this.arrRedoList[0]=[oEditor.document.body.innerHTML,
  285. oEditor.document.selection.createRange().getBookmark(),"Text"];
  286. else if(sType=="Control")
  287. {
  288. oSel.item(0).selThis="selThis";
  289. this.arrRedoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
  290. oSel.item(0).removeAttribute("selThis",0);
  291. }
  292. //~~~~
  293. sHTML=obj.arrUndoList[0][0];
  294. var arrA = String(sHTML).match(/<A[^>]*>/ig);
  295. if(arrA)
  296. for(var i=0;i<arrA.length;i++)
  297. {
  298. sTmp = arrA[i].replace(/href=/,"href_iwe=");
  299. sHTML=String(sHTML).replace(arrA[i],sTmp);
  300. }
  301. var arrB = String(sHTML).match(/<IMG[^>]*>/ig);
  302. if(arrB)
  303. for(var i=0;i<arrB.length;i++)
  304. {
  305. sTmp = arrB[i].replace(/src=/,"src_iwe=");
  306. sHTML=String(sHTML).replace(arrB[i],sTmp);
  307. }
  308. var arrC = String(sHTML).match(/<AREA[^>]*>/ig);
  309. if(arrC)
  310. for(var i=0;i<arrC.length;i++)
  311. {
  312. sTmp = arrC[i].replace(/href=/,"href_iwe=");
  313. sHTML=String(sHTML).replace(arrC[i],sTmp);
  314. }
  315. oEditor.document.body.innerHTML=sHTML;
  316. for(var i=0;i<oEditor.document.all.length;i++)
  317. {
  318. if(oEditor.document.all[i].getAttribute("href_iwe"))
  319. {
  320. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  321. oEditor.document.all[i].removeAttribute("href_iwe",0);
  322. }
  323. if(oEditor.document.all[i].getAttribute("src_iwe"))
  324. {
  325. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  326. oEditor.document.all[i].removeAttribute("src_iwe",0);
  327. }
  328. }
  329. //*** RUNTIME STYLES ***
  330. this.runtimeBorder(false);
  331. this.runtimeStyles();
  332. //***********************
  333. var oRange=oEditor.document.body.createTextRange();
  334. if(obj.arrUndoList[0][2]=="None")
  335. {
  336. oRange.moveToBookmark(obj.arrUndoList[0][1]);
  337. oRange.select(); //di-disable, spy tdk select all? tdk perlu utk undo
  338. }
  339. else if(obj.arrUndoList[0][2]=="Text")
  340. {
  341. oRange.moveToBookmark(obj.arrUndoList[0][1]);
  342. oRange.select();
  343. }
  344. else if(obj.arrUndoList[0][2]=="Control")
  345. {
  346. for(var i=0;i<oEditor.document.all.length;i++)
  347. {
  348. if(oEditor.document.all[i].selThis=="selThis")
  349. {
  350. var oSelRange=oEditor.document.body.createControlRange();
  351. oSelRange.add(oEditor.document.all[i]);
  352. oSelRange.select();
  353. oEditor.document.all[i].removeAttribute("selThis",0);
  354. }
  355. }
  356. }
  357. //~~~~
  358. for(var i=0;i<19;i++)obj.arrUndoList[i]=obj.arrUndoList[i+1];
  359. obj.arrUndoList[19]=null;
  360. realTime(this.oName);
  361. }
  362. function doRedo()
  363. {
  364. var oEditor=eval("idContent"+this.oName);
  365. var obj=eval(this.oName);
  366. if(!obj.arrRedoList[0])return;
  367. //~~~~
  368. for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
  369. var oSel=oEditor.document.selection.createRange();
  370. var sType=oEditor.document.selection.type;
  371. if(sType=="None")
  372. obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
  373. oEditor.document.selection.createRange().getBookmark(),"None"];
  374. else if(sType=="Text")
  375. obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
  376. oEditor.document.selection.createRange().getBookmark(),"Text"];
  377. else if(sType=="Control")
  378. {
  379. oSel.item(0).selThis="selThis";
  380. this.arrUndoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
  381. oSel.item(0).removeAttribute("selThis",0);
  382. }
  383. //~~~~
  384. sHTML=obj.arrRedoList[0][0];
  385. var arrA = String(sHTML).match(/<A[^>]*>/ig);
  386. if(arrA)
  387. for(var i=0;i<arrA.length;i++)
  388. {
  389. sTmp = arrA[i].replace(/href=/,"href_iwe=");
  390. sHTML=String(sHTML).replace(arrA[i],sTmp);
  391. }
  392. var arrB = String(sHTML).match(/<IMG[^>]*>/ig);
  393. if(arrB)
  394. for(var i=0;i<arrB.length;i++)
  395. {
  396. sTmp = arrB[i].replace(/src=/,"src_iwe=");
  397. sHTML=String(sHTML).replace(arrB[i],sTmp);
  398. }
  399. var arrC = String(sHTML).match(/<AREA[^>]*>/ig);
  400. if(arrC)
  401. for(var i=0;i<arrC.length;i++)
  402. {
  403. sTmp = arrC[i].replace(/href=/,"href_iwe=");
  404. sHTML=String(sHTML).replace(arrC[i],sTmp);
  405. }
  406. oEditor.document.body.innerHTML=sHTML;
  407. for(var i=0;i<oEditor.document.all.length;i++)
  408. {
  409. if(oEditor.document.all[i].getAttribute("href_iwe"))
  410. {
  411. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  412. oEditor.document.all[i].removeAttribute("href_iwe",0);
  413. }
  414. if(oEditor.document.all[i].getAttribute("src_iwe"))
  415. {
  416. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  417. oEditor.document.all[i].removeAttribute("src_iwe",0);
  418. }
  419. }
  420. //*** RUNTIME STYLES ***
  421. this.runtimeBorder(false);
  422. this.runtimeStyles();
  423. //***********************
  424. var oRange=oEditor.document.body.createTextRange();
  425. if(obj.arrRedoList[0][2]=="None")
  426. {
  427. oRange.moveToBookmark(obj.arrRedoList[0][1]);
  428. //oRange.select(); //di-disable, sph tdk select all, utk redo perlu
  429. }
  430. else if(obj.arrRedoList[0][2]=="Text")
  431. {
  432. oRange.moveToBookmark(obj.arrRedoList[0][1]);
  433. oRange.select();
  434. }
  435. else if(obj.arrRedoList[0][2]=="Control")
  436. {
  437. for(var i=0;i<oEditor.document.all.length;i++)
  438. {
  439. if(oEditor.document.all[i].selThis=="selThis")
  440. {
  441. var oSelRange = oEditor.document.body.createControlRange();
  442. oSelRange.add(oEditor.document.all[i]);
  443. oSelRange.select();
  444. oEditor.document.all[i].removeAttribute("selThis",0);
  445. }
  446. }
  447. }
  448. //~~~~
  449. for(var i=0;i<19;i++)obj.arrRedoList[i]=obj.arrRedoList[i+1];
  450. obj.arrRedoList[19]=null;
  451. realTime(this.oName);
  452. }
  453. /*********************
  454. RENDER
  455. **********************/
  456. function RENDER(sPreloadHTML)
  457. {
  458. /*** Tetap Ada (For downgrade compatibility) ***/
  459. if(sPreloadHTML.substring(0,4)=="<!--" &&
  460. sPreloadHTML.substring(sPreloadHTML.length-3)=="-->")
  461. sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-3);
  462. if(sPreloadHTML.substring(0,4)=="<!--" &&
  463. sPreloadHTML.substring(sPreloadHTML.length-6)=="--&gt;")
  464. sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-6);
  465. /*** Converting back HTML-encoded content (kalau tdk encoded tdk masalah) ***/
  466. sPreloadHTML=sPreloadHTML.replace(/&lt;/g,"<");
  467. sPreloadHTML=sPreloadHTML.replace(/&gt;/g,">");
  468. sPreloadHTML=sPreloadHTML.replace(/&amp;/g,"&");
  469. sPreloadHTML=sPreloadHTML.replace(/&quot;/g,""");
  470. /*** features ***/
  471. var bUseFeature=false;
  472. if(this.features.length>0)
  473. {
  474. bUseFeature=true;
  475. for(var i=0;i<this.buttonMap.length;i++)
  476. eval(this.oName+".btn"+this.buttonMap[i]+"=true");//ex: oEdit1.btnStyleAndFormatting=true (no problem), oEdit1.btn|=true (no problem), oEdit1.btnBRK=true (no problem)
  477. this.btnTextFormatting=false;this.btnListFormatting=false;
  478. this.btnBoxFormatting=false;this.btnParagraphFormatting=false;
  479. this.btnCssText=false;this.btnStyles=false;
  480. for(var j=0;j<this.features.length;j++)
  481. eval(this.oName+".btn"+this.features[j]+"=true");//ex: oEdit1.btnTextFormatting=true
  482. for(var i=0;i<this.buttonMap.length;i++)
  483. {
  484. sButtonName=this.buttonMap[i];
  485. bBtnExists=false;
  486. for(var j=0;j<this.features.length;j++)
  487. if(sButtonName==this.features[j])bBtnExists=true;//ada;
  488. if(!bBtnExists)//tdk ada; set false
  489. eval(this.oName+".btn"+sButtonName+"=false");//ex: oEdit1.btnBold=false, oEdit1.btn|=false (no problem), oEdit1.btnBRK=false (no problem)
  490. }
  491. //Remove:"TextFormatting","ListFormatting",dst.=>tdk perlu(krn diabaikan)
  492. this.buttonMap=this.features;
  493. }
  494. /*** /features ***/
  495. this.preloadHTML=sPreloadHTML;
  496. var sHTMLDropMenus="";
  497. var sHTMLIcons="";
  498. var sTmp="";
  499. for(var i=0;i<this.buttonMap.length;i++)
  500. {
  501. sButtonName=this.buttonMap[i];
  502. switch(sButtonName)
  503. {
  504. case "|":
  505. sHTMLIcons+=this.writeBreakSpace();
  506. break;
  507. case "BRK":
  508. sHTMLIcons+="</td></tr></table><table cellpadding=0 cellspacing=0><tr><td dir=ltr>";
  509. break;
  510. case "Save":
  511. if(this.btnSave)sHTMLIcons+=this.writeIconStandard("btnSave"+this.oName,this.oName+".onSave()","btnSave.gif",getText("Save"));
  512. break;
  513. case "Preview":
  514. if(this.btnPreview)
  515. {
  516. sHTMLIcons+=this.writeIconStandard("btnPreview"+this.oName,this.oName+".dropShow(this,dropPreview"+this.oName+")","btnPreview.gif",getText("Preview"));
  517. var arrPreviewSize=[[640,480],[800,600],[1024,768]];
  518. sTmp="";
  519. for(var j=0;j<arrPreviewSize.length;j++)
  520. {
  521. sTmp+= "<tr><td onclick="dropPreview"+this.oName+".style.display='none';setActiveEditor('"+this.oName+"');modalDialogShow('"+this.scriptPath+"preview.htm',"+arrPreviewSize[j][0]+","+arrPreviewSize[j][1]+");" "+
  522. "style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  523. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  524. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+arrPreviewSize[j][0]+"x"+arrPreviewSize[j][1]+"</td></tr>";
  525. }
  526. sHTMLDropMenus+="<table id=dropPreview"+this.oName+" cellpadding=0 cellspacing=0 "+
  527. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  528. "cursor:default;background-color:#fdfdfd;' unselectable=on>"+
  529. sTmp+"</table>";
  530. }
  531. break;
  532. case "FullScreen":
  533. if(this.btnFullScreen)sHTMLIcons+=this.writeIconStandard("btnFullScreen"+this.oName,this.oName+".fullScreen()","btnFullScreen.gif",getText("Full Screen"));
  534. break;
  535. case "Print":
  536. if(this.btnPrint)sHTMLIcons+=this.writeIconStandard("btnPrint"+this.oName,this.oName+".focus();"+this.oName+".doCmd('Print')","btnPrint.gif",getText("Print"));
  537. break;
  538. case "Search":
  539. if(this.btnSearch)sHTMLIcons+=this.writeIconStandard("btnSearch"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"search.htm',375,163)","btnSearch.gif",getText("Search"));
  540. break;
  541. case "SpellCheck":
  542. if(this.btnSpellCheck)sHTMLIcons+=this.writeIconStandard("btnSpellCheck"+this.oName,this.oName+".hide();"+this.oName+".spellcheckDialogShow()","btnSpellCheck.gif",getText("Check Spelling"));
  543. break;
  544. case "StyleAndFormatting":
  545. sTmp="";
  546. if(this.btnTextFormatting)
  547. sTmp+="<tr><td onclick="modelessDialogShow('"+this.scriptPath+"text1.htm',511,534);"+
  548. "dropStyle"+this.oName+".style.display='none'""+
  549. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  550. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  551. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("Text Formatting")+"</td></tr>";
  552. if(this.btnParagraphFormatting)
  553. sTmp+="<tr><td onclick="modelessDialogShow('"+this.scriptPath+"paragraph.htm',440,284);"+
  554. "dropStyle"+this.oName+".style.display='none'""+
  555. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  556. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  557. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("Paragraph Formatting")+"</td></tr>";
  558. if(this.btnListFormatting)
  559. sTmp+="<tr><td onclick="modelessDialogShow('"+this.scriptPath+"list.htm',270,335);"+
  560. "dropStyle"+this.oName+".style.display='none'""+
  561. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  562. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  563. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("List Formatting")+"</td></tr>";
  564. if(this.btnBoxFormatting)
  565. sTmp+="<tr><td onclick="modelessDialogShow('"+this.scriptPath+"box.htm',438,380);"+
  566. "dropStyle"+this.oName+".style.display='none'""+
  567. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  568. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  569. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("Box Formatting")+"</td></tr>";
  570. if(this.btnStyles)
  571. sTmp+="<tr><td onclick="modelessDialogShow('"+this.scriptPath+"styles.htm',360,347);"+
  572. "dropStyle"+this.oName+".style.display='none'""+
  573. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  574. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  575. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("Styles")+"</td></tr>";
  576. if(this.btnCssText)
  577. sTmp+= "<tr><td onclick=""+this.oName+".onCustomCssShow();"+
  578. "dropStyle"+this.oName+".style.display='none'""+
  579. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  580. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  581. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+getText("Custom CSS")+"</td></tr>";
  582. if(this.btnTextFormatting||this.btnParagraphFormatting||this.btnListFormatting||this.btnBoxFormatting||this.btnStyles||this.btnCssText)
  583. {
  584. sHTMLIcons+=this.writeIconStandard("btnStyleAndFormat"+this.oName,this.oName+".dropShow(this,dropStyle"+this.oName+")","btnStyle.gif",getText("Styles & Formatting"));
  585. sHTMLDropMenus+="<table id=dropStyle"+this.oName+" cellpadding=0 cellspacing=0 "+
  586. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  587. "cursor:default;background-color:#fdfdfd;' unselectable=on>"+
  588. sTmp+"</table>";
  589. }
  590. break;
  591. case "Paragraph":
  592. if(this.btnParagraph)
  593. {
  594. sHTMLDropMenus+="<table id=dropParagraph"+this.oName+" cellpadding=0 cellspacing=0 "+
  595. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  596. "cursor:default;background-color:#fdfdfd;' unselectable=on>";
  597. for(var j=0;j<this.arrParagraph.length;j++)
  598. {
  599. sHTMLDropMenus+="<tr><td onclick=""+this.oName+".applyParagraph('<"+this.arrParagraph[j][1]+">')" "+
  600. "style="padding:0;padding-left:5px;padding-right:5px;font-family:tahoma;color:black;" "+
  601. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  602. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on align=center>"+
  603. "<"+this.arrParagraph[j][1]+" style="margin-bottom:4px"  unselectable=on> "+
  604. this.arrParagraph[j][0]+"</"+this.arrParagraph[j][1]+"></td></tr>";
  605. }
  606. sHTMLDropMenus+="</table>";
  607. sHTMLIcons+=this.writeDropDown("btnParagraph"+this.oName,this.oName+".selectParagraph();"+this.oName+".dropShow(this,dropParagraph"+this.oName+")","btnParagraph.gif",getText("Paragraph"),77);
  608. }
  609. break;
  610. case "FontName":
  611. if(this.btnFontName)
  612. {
  613. sHTMLDropMenus+="<table id=dropFontName"+this.oName+" cellpadding=0 cellspacing=0 "+
  614. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  615. "cursor:default;background-color:#fdfdfd;' unselectable=on><tr><td>";
  616. //~~~~ up to 120 fonts
  617. var numOfFonts=0;
  618. for(var j=0;j<this.arrFontName.length;j++)
  619. {
  620. //if(this.arrFontName[j].length==1)
  621. if(this.arrFontName[j].toString().indexOf(",")==-1)
  622. {
  623. if(this.arrFontName[j]!="serif" &&
  624. this.arrFontName[j]!="sans-serif" &&
  625. this.arrFontName[j]!="cursive" &&
  626. this.arrFontName[j]!="fantasy" &&
  627. this.arrFontName[j]!="monoscape")numOfFonts++;
  628. }
  629. else numOfFonts++;
  630. }
  631. sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
  632. for(var j=0;j<this.arrFontName.length;j++)
  633. {
  634. //if(this.arrFontName[j].length==1)
  635. if(this.arrFontName[j].toString().indexOf(",")==-1)
  636. {
  637. if(this.arrFontName[j]!="serif" &&
  638. this.arrFontName[j]!="sans-serif" &&
  639. this.arrFontName[j]!="cursive" &&
  640. this.arrFontName[j]!="fantasy" &&
  641. this.arrFontName[j]!="monoscape")
  642. sHTMLDropMenus+="<tr><td onclick=""+this.oName+".applyFontName('"+this.arrFontName[j]+"')" "+
  643. "style="padding:2px;padding-top:1px;font-family:"+ this.arrFontName[j] +";font-size:11px;color:black;" "+
  644. "onmouseover="if(this.style.backgroundColor=='#708090')this.sel='true';this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  645. "onmouseout="if(this.sel=='true'){this.sel='false'}else{this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on>"+
  646. this.arrFontName[j]+" <span unselectable=on style='font-family:tahoma'>("+ this.arrFontName[j] +")</span></td></tr>";
  647. }
  648. else
  649. {
  650. sHTMLDropMenus+="<tr><td onclick=""+this.oName+".applyFontName('"+this.arrFontName[j][0]+"')" "+
  651. "style="padding:2px;padding-top:1px;font-family:"+ this.arrFontName[j][0] +";font-size:11px;color:black;" "+
  652. "onmouseover="if(this.style.backgroundColor=='#708090')this.sel='true';this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  653. "onmouseout="if(this.sel=='true'){this.sel='false'}else{this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on>"+
  654. this.arrFontName[j][1]+" <span unselectable=on style='font-family:tahoma'>("+ this.arrFontName[j][1] +")</span></td></tr>";
  655. }
  656. if(j==14||j==29||j==44||j==59||j==74||j==89||j==104)
  657. {
  658. if(j!=numOfFonts-1)
  659. {
  660. sHTMLDropMenus+="</table>";
  661. sHTMLDropMenus+="</td><td valign=top style='border-left:#716f64 1 solid'>";//main
  662. sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
  663. }
  664. }
  665. }
  666. sHTMLDropMenus+="</table>";
  667. //~~~~
  668. sHTMLDropMenus+="</td></tr></table>";
  669. sHTMLIcons+=this.writeDropDown("btnFontName"+this.oName,this.oName+".expandSelection();"+this.oName+".dropShow(this,dropFontName"+this.oName+");realtimeFontSelect('"+this.oName+"')","btnFontName.gif",getText("Font Name"),77);
  670. }
  671. break;
  672. case "FontSize":
  673. if(this.btnFontSize)
  674. {
  675. sHTMLDropMenus+="<table id=dropFontSize"+this.oName+" cellpadding=0 cellspacing=0 "+
  676. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  677. "cursor:default;background-color:#fdfdfd;' unselectable=on>";
  678. for(var j=0;j<this.arrFontSize.length;j++)
  679. {
  680. sHTMLDropMenus+="<tr><td onclick=""+this.oName+".applyFontSize('"+this.arrFontSize[j][1]+"')" "+
  681. "style="padding:0;padding-left:5px;padding-right:5px;font-family:tahoma;color:black;" "+
  682. "onmouseover="if(this.style.backgroundColor=='#708090')this.sel='true';this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  683. "onmouseout="if(this.sel=='true'){this.sel='false'}else{this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on align=center>"+
  684. "<font unselectable=on size=""+this.arrFontSize[j][1]+"">"+
  685. this.arrFontSize[j][0]+"</font></td></tr>";
  686. }
  687. sHTMLDropMenus+="</table>";
  688. sHTMLIcons+=this.writeDropDown("btnFontSize"+this.oName,this.oName+".expandSelection();"+this.oName+".dropShow(this,dropFontSize"+this.oName+");realtimeSizeSelect('"+this.oName+"')","btnFontSize.gif",getText("Font Size"),60);
  689. }
  690. break;
  691. case "Cut":
  692. if(this.btnCut)sHTMLIcons+=this.writeIconStandard("btnCut"+this.oName,this.oName+".doCmd('Cut')","btnCut.gif",getText("Cut"));
  693. break;
  694. case "Copy":
  695. if(this.btnCopy)sHTMLIcons+=this.writeIconStandard("btnCopy"+this.oName,this.oName+".doCmd('Copy')","btnCopy.gif",getText("Copy"));
  696. break;
  697. case "Paste":
  698. if(this.btnPaste)sHTMLIcons+=this.writeIconStandard("btnPaste"+this.oName,this.oName+".doPaste()","btnPaste.gif",getText("Paste"));
  699. break;
  700. case "PasteWord":
  701. if(this.btnPasteWord)sHTMLIcons+=this.writeIconStandard("btnPasteWord"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"paste_word.htm',400,280)","btnPasteWord.gif",getText("Paste from Word"));
  702. break;
  703. case "PasteText":
  704. if(this.btnPasteText)sHTMLIcons+=this.writeIconStandard("btnPasteText"+this.oName,this.oName+".doPasteText()","btnPasteText.gif",getText("Paste Text"));
  705. break;
  706. case "Undo":
  707. if(this.btnUndo)sHTMLIcons+=this.writeIconStandard("btnUndo"+this.oName,this.oName+".doUndo()","btnUndo.gif",getText("Undo"));
  708. break;
  709. case "Redo":
  710. if(this.btnRedo)sHTMLIcons+=this.writeIconStandard("btnRedo"+this.oName,this.oName+".doRedo()","btnRedo.gif",getText("Redo"));
  711. break;
  712. case "Bold":
  713. if(this.btnBold)sHTMLIcons+=this.writeIconToggle("btnBold"+this.oName,this.oName+".doCmd('Bold')","btnBold.gif",getText("Bold"));
  714. break;
  715. case "Italic":
  716. if(this.btnItalic)sHTMLIcons+=this.writeIconToggle("btnItalic"+this.oName,this.oName+".doCmd('Italic')","btnItalic.gif",getText("Italic"));
  717. break;
  718. case "Underline":
  719. if(this.btnUnderline)sHTMLIcons+=this.writeIconToggle("btnUnderline"+this.oName,this.oName+".doCmd('Underline')","btnUnderline.gif",getText("Underline"));
  720. break;
  721. case "Strikethrough":
  722. if(this.btnStrikethrough)sHTMLIcons+=this.writeIconToggle("btnStrikethrough"+this.oName,this.oName+".doCmd('Strikethrough')","btnStrikethrough.gif",getText("Strikethrough"));
  723. break;
  724. case "Superscript":
  725. if(this.btnSuperscript)sHTMLIcons+=this.writeIconToggle("btnSuperscript"+this.oName,this.oName+".doCmd('Superscript')","btnSuperscript.gif",getText("Superscript"));
  726. break;
  727. case "Subscript":
  728. if(this.btnSubscript)sHTMLIcons+=this.writeIconToggle("btnSubscript"+this.oName,this.oName+".doCmd('Subscript')","btnSubscript.gif",getText("Subscript"));
  729. break;
  730. case "JustifyLeft":
  731. if(this.btnJustifyLeft)sHTMLIcons+=this.writeIconToggle("btnJustifyLeft"+this.oName,this.oName+".applyJustifyLeft()","btnLeft.gif",getText("Justify Left"));
  732. break;
  733. case "JustifyCenter":
  734. if(this.btnJustifyCenter)sHTMLIcons+=this.writeIconToggle("btnJustifyCenter"+this.oName,this.oName+".applyJustifyCenter()","btnCenter.gif",getText("Justify Center"));
  735. break;
  736. case "JustifyRight":
  737. if(this.btnJustifyRight)sHTMLIcons+=this.writeIconToggle("btnJustifyRight"+this.oName,this.oName+".applyJustifyRight()","btnRight.gif",getText("Justify Right"));
  738. break;
  739. case "JustifyFull":
  740. if(this.btnJustifyFull)sHTMLIcons+=this.writeIconToggle("btnJustifyFull"+this.oName,this.oName+".applyJustifyFull()","btnFull.gif",getText("Justify Full"));
  741. break;
  742. case "Numbering":
  743. if(this.btnNumbering)sHTMLIcons+=this.writeIconToggle("btnNumbering"+this.oName,this.oName+".applyNumbering()","btnNumber.gif",getText("Numbering"));
  744. break;
  745. case "Bullets":
  746. if(this.btnBullets)sHTMLIcons+=this.writeIconToggle("btnBullets"+this.oName,this.oName+".applyBullets()","btnList.gif",getText("Bullets"));
  747. break;
  748. case "Indent":
  749. if(this.btnIndent)sHTMLIcons+=this.writeIconStandard("btnIndent"+this.oName,this.oName+".doCmd('Indent')","btnIndent.gif",getText("Indent"));
  750. break;
  751. case "Outdent":
  752. if(this.btnOutdent)sHTMLIcons+=this.writeIconStandard("btnOutdent"+this.oName,this.oName+".doCmd('Outdent')","btnOutdent.gif",getText("Outdent"));
  753. break;
  754. case "LTR":
  755. if(this.btnLTR)sHTMLIcons+=this.writeIconToggle("btnLTR"+this.oName,this.oName+".applyBlockDirLTR()","btnLTR.gif",getText("Left To Right"));
  756. break;
  757. case "RTL":
  758. if(this.btnRTL)sHTMLIcons+=this.writeIconToggle("btnRTL"+this.oName,this.oName+".applyBlockDirRTL()","btnRTL.gif",getText("Right To Left"));
  759. break;
  760. case "ForeColor":
  761. if(this.btnForeColor)sHTMLIcons+=this.writeIconStandard("btnForeColor"+this.oName,this.oName+".expandSelection();"+this.oName+".oColor1.show(this)","btnForeColor.gif",getText("Foreground Color"));
  762. break;
  763. case "BackColor":
  764. if(this.btnBackColor)sHTMLIcons+=this.writeIconStandard("btnBackColor"+this.oName,this.oName+".expandSelection();"+this.oName+".oColor2.show(this)","btnBackColor.gif",getText("Background Color"));
  765. break;
  766. case "Bookmark":
  767. if(this.btnBookmark)sHTMLIcons+=this.writeIconStandard("btnBookmark"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"bookmark.htm',245,216)","btnBookmark.gif",getText("Bookmark"));
  768. break;
  769. case "Hyperlink":
  770. if(this.btnHyperlink)sHTMLIcons+=this.writeIconStandard("btnHyperlink"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"hyperlink.htm',380,200)","btnHyperlink.gif",getText("Hyperlink"));
  771. break;
  772. case "CustomTag":
  773. if(this.btnCustomTag)
  774. {
  775. sHTMLDropMenus+="<table id=dropCustomTag"+this.oName+" cellpadding=0 cellspacing=0 "+
  776. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  777. "cursor:default;background-color:#fdfdfd;' unselectable=on><tr><td valign=top>";
  778. //~~~~ up to 120 tags
  779. sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
  780. for(var j=0;j<this.arrCustomTag.length;j++)
  781. {
  782. sHTMLDropMenus+="<tr><td onclick=""+this.oName+".insertCustomTag('"+this.arrCustomTag[j][1]+"')" "+
  783. "style="padding:1px;padding-left:5px;padding-right:5px;font-family:tahoma;font-size:11px;color:black;" "+
  784. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  785. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on align=center>"+
  786. this.arrCustomTag[j][0]+"</td></tr>";
  787. if(j==14||j==29||j==44||j==59||j==74||j==89||j==104)
  788. {
  789. if(j!=this.arrCustomTag.length-1)
  790. {
  791. sHTMLDropMenus+="</table>";
  792. sHTMLDropMenus+="</td><td valign=top style='border-left:#716f64 1 solid'>";//main
  793. sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
  794. }
  795. }
  796. }
  797. sHTMLDropMenus+="</table>";
  798. //~~~~
  799. sHTMLDropMenus+="</td></tr></table>";
  800. sHTMLIcons+=this.writeDropDown("btnCustomTag"+this.oName,this.oName+".dropShow(this,dropCustomTag"+this.oName+")","btnCustomTag.gif",getText("Tags"),60);
  801. }
  802. break;
  803. case "Image":
  804. if(this.btnImage)sHTMLIcons+=this.writeIconStandard("btnImage"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"image.htm',440,351)","btnImage.gif",getText("Image"));
  805. break;
  806. case "Flash":
  807. if(this.btnFlash)sHTMLIcons+=this.writeIconStandard("btnFlash"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"flash.htm',340,275)","btnFlash.gif",getText("Flash"));
  808. break;
  809. case "Media":
  810. if(this.btnMedia)sHTMLIcons+=this.writeIconStandard("btnMedia"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"media.htm',340,272)","btnMedia.gif",getText("Media"));
  811. break;
  812. case "ContentBlock":
  813. if(this.btnContentBlock)sHTMLIcons+=this.writeIconStandard("btnContentBlock"+this.oName,this.oName+".hide();"+this.cmdContentBlock,"btnContentBlock.gif",getText("Content Block"));
  814. break;
  815. case "InternalLink":
  816. if(this.btnInternalLink)sHTMLIcons+=this.writeIconStandard("btnInternalLink"+this.oName,this.oName+".hide();"+this.cmdInternalLink,"btnInternalLink.gif",getText("Internal Link"));
  817. break;
  818. case "CustomObject":
  819. if(this.btnCustomObject)sHTMLIcons+=this.writeIconStandard("btnCustomObject"+this.oName,this.oName+".hide();"+this.cmdCustomObject,"btnCustomObject.gif",getText("Object"));
  820. break;
  821. case "Table":
  822. if(this.btnTable)
  823. {
  824. sHTMLDropMenus+="<table id=dropTable"+this.oName+" cellpadding=0 cellspacing=0 "+
  825. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  826. "cursor:default;background-color:#fdfdfd;' unselectable=on>"+
  827. "<tr><td id="mnuTableSize"+this.oName+"" onclick="if(this.style.color!='gray'){modelessDialogShow('"+this.scriptPath+"table_size.htm',240,262);"+
  828. " dropTable"+this.oName+".style.display='none'}""+
  829. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black""+
  830. " onmouseover="if(this.style.color!='gray'){this.style.backgroundColor='#708090';this.style.color='#FFFFFF';}""+
  831. " onmouseout="if(this.style.color!='gray'){this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on>"+getText("Table Size")+" </td></tr>"+
  832. "<tr><td id="mnuTableEdit"+this.oName+"" onclick="if(this.style.color!='gray'){modelessDialogShow('"+this.scriptPath+"table_edit.htm',358,360);"+
  833. " dropTable"+this.oName+".style.display='none'}""+
  834. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black""+
  835. " onmouseover="if(this.style.color!='gray'){this.style.backgroundColor='#708090';this.style.color='#FFFFFF';}""+
  836. " onmouseout="if(this.style.color!='gray'){this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on>"+getText("Edit Table")+" </td></tr>"+
  837. "<tr><td id="mnuCellEdit"+this.oName+"" onclick="if(this.style.color!='gray'){modelessDialogShow('"+this.scriptPath+"table_editCell.htm',427,440);"+
  838. " dropTable"+this.oName+".style.display='none'}""+
  839. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black""+
  840. " onmouseover="if(this.style.color!='gray'){this.style.backgroundColor='#708090';this.style.color='#FFFFFF';}""+
  841. " onmouseout="if(this.style.color!='gray'){this.style.backgroundColor='';this.style.color='#000000';}" unselectable=on>"+getText("Edit Cell")+" </td></tr>"+
  842. "</table>";
  843. sHTMLDropMenus+="<table width=195 id=dropTableCreate"+this.oName+" onmouseout='doOut_TabCreate();event.cancelBubble=true' style='position:absolute;display:none;cursor:default;background:#f3f3f3;border:#8a867a 1px solid;' cellpadding=0 cellspacing=2 border=0 unselectable=on>";
  844. for(var m=0;m<8;m++)
  845. {
  846. sHTMLDropMenus+="<tr>";
  847. for(var n=0;n<8;n++)
  848. {
  849. sHTMLDropMenus+="<td onclick='"+this.oName+".doClick_TabCreate()' onmouseover='doOver_TabCreate()' style='background:#ffffff;font-size:1px;border:#8a867a 1px solid;width:20px;height:20px;' unselectable=on>&nbsp;</td>";
  850. }
  851. sHTMLDropMenus+="</tr>";
  852. }
  853. sHTMLDropMenus+="<tr><td colspan=8 onclick=""+this.oName+".hide();modelessDialogShow('"+this.scriptPath+"table_insert.htm',300,322);" onmouseover="this.innerText='"+getText("Advanced Table Insert")+"';this.style.border='#777777 1px solid';this.style.backgroundColor='#8d9aa7';this.style.color='#ffffff'" onmouseout="this.style.border='#f3f3f3 1px solid';this.style.backgroundColor='#f3f3f3';this.style.color='#000000'" align=center style='font-family:verdana;font-size:10px;font-color:black;border:#f3f3f3 1px solid;' unselectable=on>"+getText("Advanced Table Insert")+"</td></tr>";
  854. sHTMLDropMenus+="</table>";
  855. sHTMLIcons+=this.writeIconStandard("btnTable"+this.oName,this.oName+".dropShow(this,dropTableCreate"+this.oName+")","btnTable.gif",getText("Insert Table"));
  856. sHTMLIcons+=this.writeIconStandard("btnTableEdit"+this.oName,this.oName+".dropShow(this,dropTable"+this.oName+")","btnTableEdit.gif",getText("Edit Table/Cell"));
  857. }
  858. break;
  859. case "Guidelines":
  860. if(this.btnGuidelines)sHTMLIcons+=this.writeIconStandard("btnGuidelines"+this.oName,this.oName+".runtimeBorder(true)","btnGuideline.gif",getText("Show/Hide Guidelines"));
  861. break;
  862. case "Absolute":
  863. if(this.btnAbsolute)sHTMLIcons+=this.writeIconStandard("btnAbsolute"+this.oName,this.oName+".makeAbsolute()","btnAbsolute.gif",getText("Absolute"));
  864. break;
  865. case "Characters":
  866. if(this.btnCharacters)sHTMLIcons+=this.writeIconStandard("btnCharacters"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"characters.htm',495,162)","btnSymbol.gif",getText("Special Characters"));
  867. break;
  868. case "Line":
  869. if(this.btnLine)sHTMLIcons+=this.writeIconStandard("btnLine"+this.oName,this.oName+".doCmd('InsertHorizontalRule')","btnLine.gif",getText("Line"));
  870. break;
  871. case "Form":
  872. if(this.btnForm)
  873. {
  874. var arrFormMenu = [[getText("Form"),"form_form.htm","280","177"],
  875. [getText("Text Field"),"form_text.htm","285","289"],
  876. [getText("List"),"form_list.htm","295","332"],
  877. [getText("Checkbox"),"form_check.htm","235","174"],
  878. [getText("Radio Button"),"form_radio.htm","235","177"],
  879. [getText("Hidden Field"),"form_hidden.htm","235","152"],
  880. [getText("File Field"),"form_file.htm","235","132"],
  881. [getText("Button"),"form_button.htm","235","174"]];
  882. sHTMLIcons+=this.writeIconStandard("btnForm"+this.oName,this.oName+".dropShow(this,dropForm"+this.oName+")","btnForm.gif",getText("Form Editor"));
  883. sHTMLDropMenus+="<table id=dropForm"+this.oName+" cellpadding=0 cellspacing=0 "+
  884. "style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;"+
  885. "cursor:default;background-color:#fdfdfd;' unselectable=on>";
  886. for(var j=0;j<arrFormMenu.length;j++)
  887. {
  888. sHTMLDropMenus+="<tr><td onclick="modelessDialogShow('"+this.scriptPath + arrFormMenu[j][1]+"',"+arrFormMenu[j][2]+","+arrFormMenu[j][3]+");"+
  889. "dropForm"+this.oName+".style.display='none'""+
  890. " style="padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;" "+
  891. "onmouseover="this.style.backgroundColor='#708090';this.style.color='#FFFFFF';" "+
  892. "onmouseout="this.style.backgroundColor='';this.style.color='#000000';" unselectable=on>"+arrFormMenu[j][0]+"</td></tr>";
  893. }
  894. sHTMLDropMenus+="</table>";
  895. }
  896. break;
  897. case "Clean":
  898. if(this.btnClean)sHTMLIcons+=this.writeIconStandard("btnClean"+this.oName,this.oName+".doClean()","btnRemoveFormat.gif",getText("Clean"));
  899. break;
  900. case "HTMLFullSource":
  901. if(this.btnHTMLFullSource)sHTMLIcons+=this.writeIconStandard("btnHTMLFullSource"+this.oName,"setActiveEditor('"+this.oName+"');"+this.oName+".hide();modalDialogShow('"+this.scriptPath+"source_html_full.htm',600,450);","btnSource.gif",getText("View/Edit Source"));
  902. break;
  903. case "HTMLSource":
  904. if(this.btnHTMLSource)sHTMLIcons+=this.writeIconStandard("btnHTMLSource"+this.oName,"setActiveEditor('"+this.oName+"');"+this.oName+".hide();modalDialogShow('"+this.scriptPath+"source_html.htm',600,450);","btnSource.gif",getText("View/Edit Source"));
  905. break;
  906. case "XHTMLFullSource":
  907. if(this.btnXHTMLFullSource)sHTMLIcons+=this.writeIconStandard("btnXHTMLFullSource"+this.oName,"setActiveEditor('"+this.oName+"');"+this.oName+".hide();modalDialogShow('"+this.scriptPath+"source_xhtml_full.htm',600,450);","btnSource.gif",getText("View/Edit Source"));
  908. break;
  909. case "XHTMLSource":
  910. if(this.btnXHTMLSource)sHTMLIcons+=this.writeIconStandard("btnXHTMLSource"+this.oName,"setActiveEditor('"+this.oName+"');"+this.oName+".hide();modalDialogShow('"+this.scriptPath+"source_xhtml.htm',600,450);","btnSource.gif",getText("View/Edit Source"));
  911. break;
  912. case "ClearAll":
  913. if(this.btnClearAll)sHTMLIcons+=this.writeIconStandard("btnClearAll"+this.oName,this.oName+".clearAll()","btnDelete.gif",getText("Clear All"));
  914. break;
  915. default:
  916. for(j=0;j<this.arrCustomButtons.length;j++)
  917. {
  918. if(sButtonName==this.arrCustomButtons[j][0])
  919. {
  920. sCbName=this.arrCustomButtons[j][0];
  921. //sCbCommand=this.arrCustomButtons[j][1];
  922. sCbCaption=this.arrCustomButtons[j][2];
  923. sCbImage=this.arrCustomButtons[j][3];
  924. sHTMLIcons+=this.writeIconStandard("btn"+sCbName+this.oName,"eval("+this.oName+".arrCustomButtons["+j+"][1])",sCbImage,sCbCaption);
  925. }
  926. }
  927. break;
  928. }
  929. }
  930. var sHTML="";
  931. if(!document.getElementById("id_refresh_z_index"))
  932. sHTML+="<div id=id_refresh_z_index style='margin:0'></div>";
  933. sHTML+="<table id=idArea"+this.oName+" name=idArea"+this.oName+" border=0 "+
  934. "cellpadding=0 cellspacing=0 width='"+this.width+"' height='"+this.height+"'>"+
  935. //"<tr><td colspan=2 bgcolor=#ffffff style="padding:1px;border:#cfcfcf 1px solid;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff,endColorstr=#ebebeb);">"+
  936. "<tr><td colspan=2 style="padding:1px;border:#cfcfcf 1px solid;background:url('"+this.scriptPath+"icons/bg.gif')">"+
  937. "<table cellpadding=0 cellspacing=0><tr><td dir=ltr>"+
  938. sHTMLIcons+
  939. "</td></tr></table>"+
  940. "</td></tr>"+
  941. "<tr id=idTagSelTopRow"+this.oName+"><td colspan=2 id=idTagSelTop"+this.oName+" height=0></td></tr>";
  942. sHTML+="<tr><td colspan=2 valign=top height=100% style='background:white'>";
  943. if(this.IsSecurityRestricted)
  944. sHTML+="<iframe security='restricted' style='width:100%;height:100%;margin-top:1px;' src='"+this.scriptPath+"blank.gif'"+
  945. " name=idContent"+ this.oName + " id=idContent"+this.oName+
  946. " contentEditable=true></iframe>";//prohibit running ActiveX controls
  947. else
  948. sHTML+="<iframe style='width:100%;height:100%;margin-top:1px;' src='"+this.scriptPath+"blank.gif'"+
  949. " name=idContent"+ this.oName + " id=idContent"+this.oName+
  950. " contentEditable=true></iframe>";
  951. //Paste From Word
  952. sHTML+="<iframe style='width:1px;height:1px;overflow:auto;' src='"+this.scriptPath+"blank.gif'"+
  953. " name=idContentWord"+ this.oName +" id=idContentWord"+ this.oName+
  954. " contentEditable=true onfocus='"+this.oName+".hide()'></iframe>";
  955. if(this.css!="")
  956. {
  957. document.write("<iframe id="myStyle"+this.oName+"" name="myStyle"+this.oName+"" src='"+this.scriptPath+"blank.gif' style="display:none"></iframe>");
  958. }
  959. sHTML+="</td></tr>";
  960. sHTML+="<tr id=idTagSelBottomRow"+this.oName+"><td colspan=2 id=idTagSelBottom"+this.oName+"></td></tr>";
  961. sHTML+="</table>";
  962. sHTML+=sHTMLDropMenus;//dropdown
  963. document.write(sHTML);
  964. //Render Color Picker (forecolor)
  965. this.oColor1.url=this.scriptPath+"color_picker_fg.htm";
  966. this.oColor1.onShow = new Function(this.oName+".hide()");
  967. this.oColor1.onMoreColor = new Function(this.oName+".hide()");
  968. this.oColor1.onPickColor = new Function(this.oName+".applyColor('ForeColor',eval('"+this.oName+"').oColor1.color)");
  969. this.oColor1.onRemoveColor = new Function(this.oName+".applyColor('ForeColor','')");
  970. this.oColor1.txtCustomColors=getText("Custom Colors");
  971. this.oColor1.txtMoreColors=getText("More Colors...");
  972. this.oColor1.RENDER();
  973. //Render Color Picker (backcolor)
  974. this.oColor2.url=this.scriptPath+"color_picker_bg.htm";
  975. this.oColor2.onShow = new Function(this.oName+".hide()");
  976. this.oColor2.onMoreColor = new Function(this.oName+".hide()");
  977. this.oColor2.onPickColor = new Function(this.oName+".applyColor('BackColor',eval('"+this.oName+"').oColor2.color)");
  978. this.oColor2.onRemoveColor = new Function(this.oName+".applyColor('BackColor','')");
  979. this.oColor2.txtCustomColors=getText("Custom Colors");
  980. this.oColor2.txtMoreColors=getText("More Colors...");
  981. this.oColor2.RENDER();
  982. if(this.useTagSelector)
  983. {
  984. if(this.TagSelectorPosition=="bottom")this.TagSelectorPosition="top";
  985. else this.TagSelectorPosition="bottom";
  986. this.moveTagSelector()
  987. }
  988. //paste from word temp storage
  989. var oWord=eval("idContentWord"+this.oName);
  990. oWord.document.designMode="on";
  991. oWord.document.open("text/html","replace");
  992. oWord.document.write("<html><head></head><body></body></html>");
  993. oWord.document.close();
  994. oWord.document.body.contentEditable=true;
  995. oUtil.oName=this.oName;//default active editor
  996. oUtil.oEditor=eval("idContent"+this.oName);
  997. oUtil.obj=eval(this.oName);
  998. oUtil.arrEditor.push(this.oName);
  999. var arrA = String(this.preloadHTML).match(/<HTML[^>]*>/ig);
  1000. if(arrA)
  1001. {//full html
  1002. this.loadHTML("");
  1003. //this.preloadHTML is required here. Can't use sPreloadHTML as in:
  1004. //window.setTimeout(this.oName+".putHTML("+sPreloadHTML+")",0);
  1005. window.setTimeout(this.oName+".putHTML("+this.oName+".preloadHTML)",0);
  1006. //window.setTimeout utk fix swf loading.
  1007. //Utk loadHTML & putHTML yg di SourceEditor tdk masalah
  1008. }
  1009. else
  1010. {
  1011. this.loadHTML(sPreloadHTML)
  1012. }
  1013. if(this.btnTable)
  1014. {
  1015. this.arrElm[0]=this.getElm("btnTableEdit");
  1016. this.arrElm[1]=this.getElm("mnuTableSize");
  1017. this.arrElm[2]=this.getElm("mnuTableEdit");
  1018. this.arrElm[3]=this.getElm("mnuCellEdit");
  1019. }
  1020. if(this.btnParagraph)this.arrElm[4]=this.getElm("btnParagraph");
  1021. if(this.btnFontName)this.arrElm[5]=this.getElm("btnFontName");
  1022. if(this.btnFontSize)this.arrElm[6]=this.getElm("btnFontSize");
  1023. if(this.btnCut)this.arrElm[7]=this.getElm("btnCut");
  1024. if(this.btnCopy)this.arrElm[8]=this.getElm("btnCopy");
  1025. if(this.btnPaste)this.arrElm[9]=this.getElm("btnPaste");
  1026. if(this.btnPasteWord)this.arrElm[10]=this.getElm("btnPasteWord");
  1027. if(this.btnPasteText)this.arrElm[11]=this.getElm("btnPasteText");
  1028. if(this.btnUndo)this.arrElm[12]=this.getElm("btnUndo");
  1029. if(this.btnRedo)this.arrElm[13]=this.getElm("btnRedo");
  1030. if(this.btnBold)this.arrElm[14]=this.getElm("btnBold");
  1031. if(this.btnItalic)this.arrElm[15]=this.getElm("btnItalic");
  1032. if(this.btnUnderline)this.arrElm[16]=this.getElm("btnUnderline");
  1033. if(this.btnStrikethrough)this.arrElm[17]=this.getElm("btnStrikethrough");
  1034. if(this.btnSuperscript)this.arrElm[18]=this.getElm("btnSuperscript");
  1035. if(this.btnSubscript)this.arrElm[19]=this.getElm("btnSubscript");
  1036. if(this.btnNumbering)this.arrElm[20]=this.getElm("btnNumbering");
  1037. if(this.btnBullets)this.arrElm[21]=this.getElm("btnBullets");
  1038. if(this.btnJustifyLeft)this.arrElm[22]=this.getElm("btnJustifyLeft");
  1039. if(this.btnJustifyCenter)this.arrElm[23]=this.getElm("btnJustifyCenter");
  1040. if(this.btnJustifyRight)this.arrElm[24]=this.getElm("btnJustifyRight");
  1041. if(this.btnJustifyFull)this.arrElm[25]=this.getElm("btnJustifyFull");
  1042. if(this.btnIndent)this.arrElm[26]=this.getElm("btnIndent");
  1043. if(this.btnOutdent)this.arrElm[27]=this.getElm("btnOutdent");
  1044. if(this.btnLTR)this.arrElm[28]=this.getElm("btnLTR");
  1045. if(this.btnRTL)this.arrElm[29]=this.getElm("btnRTL");
  1046. if(this.btnForeColor)this.arrElm[30]=this.getElm("btnForeColor");
  1047. if(this.btnBackColor)this.arrElm[31]=this.getElm("btnBackColor");
  1048. if(this.btnLine)this.arrElm[32]=this.getElm("btnLine");
  1049. }
  1050. function iwe_getElm(s)
  1051. {
  1052. return document.getElementById(s+this.oName)
  1053. }
  1054. /*********************
  1055. COLOR PICKER
  1056. **********************/
  1057. var arrColorPickerObjects=[];
  1058. function ColorPicker(sName,sParent)
  1059. {
  1060. this.oParent=sParent;
  1061. if(sParent)
  1062. {
  1063. this.oName=sParent+"."+sName;
  1064. this.oRenderName=sName+sParent;
  1065. }
  1066. else
  1067. {
  1068. this.oName=sName;
  1069. this.oRenderName=sName;
  1070. }
  1071. arrColorPickerObjects.push(this.oName);
  1072. this.url="color_picker.htm";
  1073. this.onShow=function(){return true;};
  1074. this.onHide=function(){return true;};
  1075. this.onPickColor=function(){return true;};
  1076. this.onRemoveColor=function(){return true;};
  1077. this.onMoreColor=function(){return true;};
  1078. this.show=showColorPicker;
  1079. this.hide=hideColorPicker;
  1080. this.hideAll=hideColorPickerAll;
  1081. this.color;
  1082. this.customColors=[];
  1083. this.refreshCustomColor=refreshCustomColor;
  1084. this.isActive=false;
  1085. this.txtCustomColors="Custom Colors";
  1086. this.txtMoreColors="More Colors...";
  1087. this.align="left";
  1088. this.currColor="#ffffff";//default current color
  1089. this.RENDER=drawColorPicker;
  1090. }
  1091. function drawColorPicker()
  1092. {
  1093. var arrColors=[["#800000","#8b4513","#006400","#2f4f4f","#000080","#4b0082","#800080","#000000"],
  1094. ["#ff0000","#daa520","#6b8e23","#708090","#0000cd","#483d8b","#c71585","#696969"],
  1095. ["#ff4500","#ffa500","#808000","#4682b4","#1e90ff","#9400d3","#ff1493","#a9a9a9"],
  1096. ["#ff6347","#ffd700","#32cd32","#87ceeb","#00bfff","#9370db","#ff69b4","#dcdcdc"],
  1097. ["#ffdab9","#ffffe0","#98fb98","#e0ffff","#87cefa","#e6e6fa","#dda0dd","#ffffff"]];
  1098. var sHTMLColor="<table id=dropColor"+this.oRenderName+" style="z-index:1;display:none;position:absolute;border:#716F64 1px solid;cursor:default;background-color:#f3f3f3;padding:2px" unselectable=on cellpadding=0 cellspacing=0 width=143 height=109><tr><td unselectable=on>";
  1099. sHTMLColor+="<table align=center cellpadding=0 cellspacing=0 border=0 unselectable=on>";
  1100. for(var i=0;i<arrColors.length;i++)
  1101. {
  1102. sHTMLColor+="<tr>";
  1103. for(var j=0;j<arrColors[i].length;j++)
  1104. sHTMLColor+="<td onclick=""+this.oName+".color='"+arrColors[i][j]+"';"+this.oName+".onPickColor();"+this.oName+".currColor='"+arrColors[i][j]+"';"+this.oName+".hideAll()" onmouseover="this.style.border='#777777 1px solid'" onmouseout="this.style.border='#efefef 1px solid'" style="cursor:default;padding:1px;border:#efefef 1px solid;" unselectable=on>"+
  1105. "<table style='margin:0;width:13px;height:13px;background:"+arrColors[i][j]+";border:white 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  1106. "<tr><td unselectable=on></td></tr>"+
  1107. "</table></td>";
  1108. sHTMLColor+="</tr>";
  1109. }
  1110. //~~~ custom colors ~~~~
  1111. sHTMLColor+="<tr><td colspan=8 id=idCustomColor"+this.oRenderName+"></td></tr>";
  1112. //~~~ remove color & more colors ~~~~
  1113. sHTMLColor+= "<tr>";
  1114. sHTMLColor+= "<td unselectable=on>"+
  1115. "<table style='margin-left:1px;width:14px;height:14px;background:#f3f3f3;' cellpadding=0 cellspacing=0 unselectable=on>"+
  1116. "<tr><td onclick=""+this.oName+".onRemoveColor();"+this.oName+".currColor='';"+this.oName+".hideAll()" onmouseover="this.style.border='#777777 1px solid'" onmouseout="this.style.border='white 1px solid'" style="cursor:default;padding:1px;border:white 1px solid;font-family:verdana;font-size:10px;font-color:black;line-height:9px;" align=center valign=top unselectable=on>x</td></tr>"+
  1117. "</table></td>";
  1118. sHTMLColor+= "<td colspan=7 unselectable=on>"+
  1119. "<table style='margin:1px;width:117px;height:16px;background:#f3f3f3;border:#f3f3f3 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  1120. "<tr><td onclick=""+this.oName+".onMoreColor();"+this.oName+".hideAll();window.showModelessDialog('"+this.url+"',[window,'"+this.oName+"'],'dialogWidth:432px;dialogHeight:427px;edge:Raised;center:1;help:0;resizable:1;')" onmouseover="this.style.border='#777777 1px solid';this.style.background='#8d9aa7';this.style.color='#ffffff'" onmouseout="this.style.border='#efefef 1px solid';this.style.background='#f3f3f3';this.style.color='#000000'" style="cursor:default;padding:1px;border:#efefef 1px solid" style="font-family:verdana;font-size:9px;font-color:black;line-height:9px;padding:1px" align=center valign=top nowrap unselectable=on>"+this.txtMoreColors+"</td></tr>"+
  1121. "</table></td>";
  1122. sHTMLColor+= "</tr>";
  1123. sHTMLColor+= "</table>";
  1124. sHTMLColor+="</td></tr></table>";
  1125. document.write(sHTMLColor);
  1126. }
  1127. function refreshCustomColor()
  1128. {
  1129. this.customColors=eval(this.oParent).customColors;//[CUSTOM] (Get from public definition)
  1130. if(this.customColors.length==0)
  1131. {
  1132. eval("idCustomColor"+this.oRenderName).innerHTML="";
  1133. return;
  1134. }
  1135. sHTML="<table cellpadding=0 cellspacing=0 width=100%><tr><td colspan=8 style="font-family:verdana;font-size:9px;font-color:black;line-height:9px;padding:1">"+this.txtCustomColors+":</td></tr></table>";
  1136. sHTML+="<table cellpadding=0 cellspacing=0><tr>";
  1137. for(var i=0;i<this.customColors.length;i++)
  1138. {
  1139. if(i<22)
  1140. {
  1141. if(i==8||i==16||i==24||i==32)sHTML+="</tr></table><table cellpadding=0 cellspacing=0><tr>";
  1142. sHTML+="<td onclick=""+this.oName+".color='"+this.customColors[i]+"';"+this.oName+".onPickColor()" onmouseover="this.style.border='#777777 1px solid'" onmouseout="this.style.border='#efefef 1px solid'" style="cursor:default;padding:1px;border:#efefef 1px solid;" unselectable=on>"+
  1143. " <table  style='margin:0;width:13;height:13;background:"+this.customColors[i]+";border:white 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  1144. " <tr><td unselectable=on></td></tr>"+
  1145. " </table>"+
  1146. "</td>";
  1147. }
  1148. }
  1149. sHTML+="</tr></table>";
  1150. eval("idCustomColor"+this.oRenderName).innerHTML=sHTML;
  1151. }
  1152. function showColorPicker(oEl)
  1153. {
  1154. this.onShow();
  1155. this.hideAll();
  1156. var box=eval("dropColor"+this.oRenderName);
  1157. box.style.display="block";
  1158. var nTop=0;
  1159. var nLeft=0;
  1160. oElTmp=oEl;
  1161. while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  1162. {
  1163. if(oElTmp.style.top!="")
  1164. nTop+=oElTmp.style.top.substring(1,oElTmp.style.top.length-2)*1;
  1165. else nTop+=oElTmp.offsetTop;
  1166. oElTmp = oElTmp.offsetParent;
  1167. }
  1168. oElTmp=oEl;
  1169. while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  1170. {
  1171. if(oElTmp.style.left!="")
  1172. nLeft+=oElTmp.style.left.substring(1,oElTmp.style.left.length-2)*1;
  1173. else nLeft+=oElTmp.offsetLeft;
  1174. oElTmp=oElTmp.offsetParent;
  1175. }
  1176. if(this.align=="left") box.style.left=nLeft;
  1177. else box.style.left=nLeft-143+oEl.offsetWidth;
  1178. box.style.top=nTop+1+oUtil.obj.dropTopAdjustment;//[CUSTOM]
  1179. //box.style.top=nTop+1+oEl.offsetHeight;//[CUSTOM]
  1180. this.isActive=true;
  1181. this.refreshCustomColor();
  1182. }
  1183. function hideColorPicker()
  1184. {
  1185. this.onHide();
  1186. var box=eval("dropColor"+this.oRenderName);
  1187. box.style.display="none";
  1188. this.isActive=false;
  1189. }
  1190. function hideColorPickerAll()
  1191. {
  1192. for(var i=0;i<arrColorPickerObjects.length;i++)
  1193. {
  1194. var box=eval("dropColor"+eval(arrColorPickerObjects[i]).oRenderName);
  1195. box.style.display="none";
  1196. eval(arrColorPickerObjects[i]).isActive=false;
  1197. }
  1198. }
  1199. /*********************
  1200. CONTENT
  1201. **********************/
  1202. function loadHTML(sHTML)//hanya utk first load.
  1203. {
  1204. var oEditor=eval("idContent"+this.oName);
  1205. var oDoc=oEditor.document.open("text/html","replace");
  1206. if(this.publishingPath!="")
  1207. {
  1208. var arrA = String(this.preloadHTML).match(/<base[^>]*>/ig);
  1209. if(!arrA)
  1210. {//if no <base> found
  1211. sHTML=this.docType+"<HTML><HEAD><BASE HREF=""+this.publishingPath+""/>"+this.headContent+"</HEAD><BODY contentEditable=true>" + sHTML + "</BODY></HTML>";
  1212. //kalau cuma tambah <HTML><HEAD></HEAD><BODY.. tdk apa2.
  1213. }
  1214. }
  1215. else
  1216. {
  1217. sHTML=this.docType+"<HTML><HEAD>"+this.headContent+"</HEAD><BODY contentEditable=true>"+sHTML+"</BODY></HTML>";
  1218. }
  1219. oDoc.write(sHTML);
  1220. oDoc.close();
  1221. oEditor.document.body.contentEditable=true;
  1222. oEditor.document.execCommand("2D-Position", true, true);//make focus
  1223. oEditor.document.execCommand("MultipleSelection", true, true);//make focus
  1224. oEditor.document.execCommand("LiveResize", true, true);//make focus
  1225. //RealTime
  1226. oEditor.document.body.onkeydown = new Function("editorDoc_onkeydown('"+this.oName+"')");
  1227. oEditor.document.body.onkeyup = new Function("editorDoc_onkeyup('"+this.oName+"')");
  1228. oEditor.document.body.onmouseup = new Function("editorDoc_onmouseup('"+this.oName+"')");
  1229. //Save for Undo
  1230. oEditor.document.body.onpaste = new Function(this.oName+".doOnPaste()");
  1231. oEditor.document.body.oncut = new Function(this.oName+".saveForUndo()");
  1232. //Styles
  1233. if(this.arrStyle.length>0)
  1234. {
  1235. var oElement=oEditor.document.createElement("<STYLE>");
  1236. oEditor.document.documentElement.childNodes[0].appendChild(oElement);
  1237. for(var i=0;i<this.arrStyle.length;i++)
  1238. {
  1239. selector=this.arrStyle[i][0];
  1240. style=this.arrStyle[i][3];
  1241. oEditor.document.styleSheets(0).addRule(selector,style);
  1242. }
  1243. }
  1244. //*** RUNTIME STYLES ***
  1245. this.runtimeBorder(false);
  1246. this.runtimeStyles();
  1247. //***********************
  1248. //fix undisplayed content
  1249. if(this.initialRefresh)
  1250. {
  1251. oEditor.document.execCommand("SelectAll");
  1252. window.setTimeout("eval('idContentWord"+this.oName+"').document.execCommand('SelectAll');",0);
  1253. }
  1254. oEditor.document.body.style.width=50;
  1255. oEditor.document.body.style.height=50;
  1256. oEditor.document.body.style.width="";
  1257. oEditor.document.body.style.height="";
  1258. //oEditor.document.body.style.cssText="overflow-x:scroll;overflow-y:scroll";
  1259. if(this.css!="")
  1260. {
  1261. eval("myStyle"+this.oName).document.open("text/html","replace");
  1262. eval("myStyle"+this.oName).document.write("<html><head><link href=""+this.css+"" rel="stylesheet" type="text/css"></head><body onload="parent.ApplyExternalStyle('"+this.oName+"')"></body></html>");
  1263. eval("myStyle"+this.oName).document.close();
  1264. try{ApplyExternalStyle(this.oName)}
  1265. catch(e){;}
  1266. }
  1267. //<br> or <p>
  1268. oEditor.document.body.onkeydown=new Function("doKeyPress(eval('idContent"+this.oName+"').event,'"+this.oName+"')");
  1269. }
  1270. function doOnPaste()
  1271. {
  1272. this.isAfterPaste=true;
  1273. eval(this.oName).saveForUndo();//Save for Undo
  1274. }
  1275. function putHTML(sHTML)//used by source editor
  1276. {
  1277. var oEditor=eval("idContent"+this.oName);
  1278. //save doctype (if any/if not body only)
  1279. var arrA=String(sHTML).match(/<!DOCTYPE[^>]*>/ig);
  1280. if(arrA)
  1281. for(var i=0;i<arrA.length;i++)
  1282. {
  1283. this.docType=arrA[i];
  1284. }
  1285. else this.docType="";//back to default value
  1286. //save html (if any/if not body only)
  1287. var arrB=String(sHTML).match(/<HTML[^>]*>/ig);
  1288. if(arrB)
  1289. for(var i=0;i<arrB.length;i++)
  1290. {
  1291. s=arrB[i];
  1292. s=s.replace(/"[^"]*"/ig,function(x){
  1293. x=x.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/[s+]/ig,"#_#");
  1294. return x});
  1295. s=s.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()});
  1296. s=s.replace(/ ([^=]+)=([^" >]+)/ig," $1="$2"");
  1297. s=s.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
  1298. s=s.replace(/#_#/ig," ");
  1299. this.html=s;
  1300. }
  1301. else this.html="<html>";//back to default value
  1302. //Dalam pengeditan jangan pakai doctype,
  1303. //membuat mouse tdk bisa di-klik di empty area
  1304. /* sHTML=String(sHTML).replace(/<!DOCTYPE[^>]*>/ig,"");
  1305. */
  1306. if(this.publishingPath!="")
  1307. {
  1308. var arrA = sHTML.match(/<base[^>]*>/ig);
  1309. if(!arrA)
  1310. {
  1311. sHTML="<BASE HREF=""+this.publishingPath+""/>"+sHTML;
  1312. }
  1313. }
  1314. var oDoc=oEditor.document.open("text/html","replace");
  1315. oDoc.write(sHTML);
  1316. oDoc.close();
  1317. oEditor.document.body.contentEditable=true;
  1318. oEditor.document.execCommand("2D-Position",true,true);
  1319. oEditor.document.execCommand("MultipleSelection",true,true);
  1320. oEditor.document.execCommand("LiveResize",true,true);
  1321. //RealTime
  1322. oEditor.document.body.onkeydown=new Function("editorDoc_onkeydown('"+this.oName+"')");
  1323. oEditor.document.body.onkeyup=new Function("editorDoc_onkeyup('"+this.oName+"')");
  1324. oEditor.document.body.onmouseup=new Function("editorDoc_onmouseup('"+this.oName+"')");
  1325. //*** RUNTIME STYLES ***
  1326. this.runtimeBorder(false);
  1327. this.runtimeStyles();
  1328. //***********************
  1329. //<br> or <p>
  1330. oEditor.document.body.onkeydown=new Function("doKeyPress(eval('idContent"+this.oName+"').event,'"+this.oName+"')");
  1331. }
  1332. function getHTML()
  1333. {
  1334. var oEditor=eval("idContent"+this.oName);
  1335. sHTML=oEditor.document.documentElement.outerHTML;
  1336. sHTML=String(sHTML).replace(/ contentEditable=true/g,"");
  1337. sHTML = String(sHTML).replace(/<PARAM NAME="Play" VALUE="0">/ig,"<PARAM NAME="Play" VALUE="-1">");
  1338. sHTML=this.docType+sHTML;//restore doctype (if any)
  1339. return sHTML;
  1340. }
  1341. function getHTMLBody()
  1342. {
  1343. var oEditor=eval("idContent"+this.oName);
  1344. sHTML=oEditor.document.body.innerHTML;
  1345. sHTML=String(sHTML).replace(/ contentEditable=true/g,"");
  1346. sHTML = String(sHTML).replace(/<PARAM NAME="Play" VALUE="0">/ig,"<PARAM NAME="Play" VALUE="-1">");
  1347. return sHTML;
  1348. }
  1349. var sBaseHREF="";
  1350. function getXHTML()
  1351. {
  1352. var oEditor=eval("idContent"+this.oName);
  1353. //base handling
  1354. sHTML=oEditor.document.documentElement.outerHTML;
  1355. var arrTmp=sHTML.match(/<BASE([^>]*)>/ig);
  1356. if(arrTmp!=null)sBaseHREF=arrTmp[0];
  1357. for(var i=0;i<oEditor.document.all.length;i++)
  1358. if(oEditor.document.all[i].tagName=="BASE")oEditor.document.all[i].removeNode();
  1359. for(var i=0;i<oEditor.document.all.length;i++)
  1360. if(oEditor.document.all[i].tagName=="BASE")oEditor.document.all[i].removeNode();
  1361. //~~~~~~~~~~~~~
  1362. sBaseHREF=sBaseHREF.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()});
  1363. sBaseHREF=sBaseHREF.replace(/ [^=]+="[^"]+"/ig,function(x){
  1364. x=x.replace(/[s+]/ig,"#_#");
  1365. x=x.replace(/^#_#/," ");
  1366. return x});
  1367. sBaseHREF=sBaseHREF.replace(/ ([^=]+)=([^" >]+)/ig," $1="$2"");
  1368. sBaseHREF=sBaseHREF.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
  1369. sBaseHREF=sBaseHREF.replace(/#_#/ig," ");
  1370. sBaseHREF=sBaseHREF.replace(/>$/ig," />").replace(// />$/ig,"/>");
  1371. //~~~~~~~~~~~~~
  1372. sHTML=recur(oEditor.document.documentElement,"");
  1373. sHTML=this.docType+this.html+sHTML+"n</html>";//restore doctype (if any) & html
  1374. sHTML=sHTML.replace(/</title>/,"</title>"+sBaseHREF);//restore base href
  1375. return sHTML;
  1376. }
  1377. function getXHTMLBody()
  1378. {
  1379. var oEditor=eval("idContent"+this.oName);
  1380. //base handling
  1381. sHTML=oEditor.document.documentElement.outerHTML;
  1382. var arrTmp=sHTML.match(/<BASE([^>]*)>/ig);
  1383. if(arrTmp!=null)sBaseHREF=arrTmp[0];
  1384. for(var i=0;i<oEditor.document.all.length;i++)
  1385. if(oEditor.document.all[i].tagName=="BASE")oEditor.document.all[i].removeNode();
  1386. for(var i=0;i<oEditor.document.all.length;i++)
  1387. if(oEditor.document.all[i].tagName=="BASE")oEditor.document.all[i].removeNode();
  1388. //~~~~~~~~~~~~~
  1389. sHTML=recur(oEditor.document.body,"");
  1390. return sHTML;
  1391. }
  1392. function ApplyExternalStyle(oName)
  1393. {
  1394. var sTmp="";
  1395. var myStyle=eval("myStyle"+oName);
  1396. for(var i=0;i<myStyle.document.styleSheets(0).rules.length;i++)
  1397. {
  1398. sSelector=myStyle.document.styleSheets(0).rules.item(i).selectorText;
  1399. sCssText=myStyle.document.styleSheets(0).rules.item(i).style.cssText.replace(/"/g,"&quot;");
  1400. var itemCount = sSelector.split(".").length;
  1401. if(itemCount>1) sTmp+=",[""+sSelector+"",true,""+sSelector+"",""+ sCssText + ""]";
  1402. else sTmp+=",[""+sSelector+"",false,"",""+ sCssText + ""]";
  1403. }
  1404. var arrStyle = eval("["+sTmp.substr(1)+"]");
  1405. if(arrStyle.length>0)
  1406. {
  1407. var oEditor=eval("idContent"+oName);
  1408. var oElement=oEditor.document.createElement("<STYLE>");
  1409. oEditor.document.documentElement.childNodes[0].appendChild(oElement);
  1410. for(var i=0;i<arrStyle.length;i++)
  1411. {
  1412. selector=arrStyle[i][0];
  1413. style=arrStyle[i][3].replace(/&quot;/g,""");
  1414. if(style!="")
  1415. {
  1416. if(selector=="")selector="*";
  1417. oEditor.document.styleSheets(0).addRule(selector,style);
  1418. }
  1419. }
  1420. }
  1421. eval(oName).arrStyle=arrStyle;
  1422. }
  1423. /*********************
  1424. REALTIME
  1425. **********************/
  1426. function editorDoc_onkeydown(oName)
  1427. {
  1428. realTime(oName);
  1429. }
  1430. function editorDoc_onkeyup(oName)
  1431. {
  1432. if(eval(oName).isAfterPaste)
  1433. {
  1434. //*** RUNTIME STYLES ***
  1435. eval(oName).runtimeBorder(false);
  1436. eval(oName).runtimeStyles();
  1437. //***********************
  1438. eval(oName).isAfterPaste=false;
  1439. }
  1440. realTime(oName);
  1441. }
  1442. function editorDoc_onmouseup(oName)
  1443. {
  1444. oUtil.activeElement=null;//focus ke editor, jgn pakai selection dari tag selector
  1445. oUtil.oName=oName;oUtil.oEditor=eval("idContent"+oName);oUtil.obj=eval(oName);eval(oName).hide();//pengganti onfocus
  1446. realTime(oName);
  1447. }
  1448. function setActiveEditor(oName)
  1449. {
  1450. //eval(oName).focus();//focus first
  1451. oUtil.oName=oName;
  1452. oUtil.oEditor=eval("idContent"+oName);
  1453. oUtil.obj=eval(oName);
  1454. }
  1455. var arrTmp=[];
  1456. function GetElement(oElement,sMatchTag)//Used in realTime() only.
  1457. {
  1458. while (oElement!=null&&oElement.tagName!=sMatchTag)
  1459. {
  1460. if(oElement.tagName=="BODY")return null;
  1461. oElement=oElement.parentElement;
  1462. }
  1463. return oElement;
  1464. }
  1465. var arrTmp2=[];//TAG SELECTOR
  1466. function realTime(oName)
  1467. {
  1468. //Focus stuff
  1469. if(!eval(oName).checkFocus())return;
  1470. var oEditor=eval("idContent"+oName);
  1471. var oSel=oEditor.document.selection.createRange();
  1472. var obj=eval(oName);
  1473. //Enable/Disable Table Edit & Cell Edit Menu
  1474. if(obj.btnTable)
  1475. {
  1476. obj.arrElm[1].style.color="gray";
  1477. obj.arrElm[2].style.color="gray";
  1478. obj.arrElm[3].style.color="gray";
  1479. var oTable=(oSel.parentElement!=null?GetElement(oSel.parentElement(),"TABLE"):GetElement(oSel.item(0),"TABLE"));
  1480. if (oTable)
  1481. {
  1482. obj.arrElm[1].style.color="black";
  1483. obj.arrElm[2].style.color="black";
  1484. obj.arrElm[3].style.color="gray";
  1485. makeEnableNormal(obj.arrElm[0]);
  1486. }
  1487. else makeDisabled(obj.arrElm[0]);
  1488. var oTD=(oSel.parentElement!=null?GetElement(oSel.parentElement(),"TD"):GetElement(oSel.item(0),"TD"));
  1489. if (oTD)
  1490. {
  1491. obj.arrElm[1].style.color="black";
  1492. obj.arrElm[2].style.color="black";
  1493. obj.arrElm[3].style.color="black";
  1494. }
  1495. }
  1496. //REALTIME BUTTONS HERE
  1497. if(obj.btnParagraph)
  1498. {
  1499. if(oEditor.document.queryCommandEnabled("FormatBlock"))
  1500. makeEnableNormal(obj.arrElm[4]);
  1501. else makeDisabled(obj.arrElm[4]);
  1502. }
  1503. if(obj.btnFontName)
  1504. {
  1505. if(oEditor.document.queryCommandEnabled("FontName"))
  1506. makeEnableNormal(obj.arrElm[5]);
  1507. else makeDisabled(obj.arrElm[5]);
  1508. }
  1509. if(obj.btnFontSize)
  1510. {
  1511. if(oEditor.document.queryCommandEnabled("FontSize"))
  1512. makeEnableNormal(obj.arrElm[6]);
  1513. else makeDisabled(obj.arrElm[6]);
  1514. }
  1515. if(obj.btnCut)
  1516. {
  1517. if(oEditor.document.queryCommandEnabled("Cut"))
  1518. makeEnableNormal(obj.arrElm[7]);
  1519. else makeDisabled(obj.arrElm[7]);
  1520. }
  1521. if(obj.btnCopy)
  1522. {
  1523. if(oEditor.document.queryCommandEnabled("Copy"))
  1524. makeEnableNormal(obj.arrElm[8]);
  1525. else makeDisabled(obj.arrElm[8]);
  1526. }
  1527. if(obj.btnPaste)
  1528. {
  1529. if(oEditor.document.queryCommandEnabled("Paste"))
  1530. makeEnableNormal(obj.arrElm[9]);
  1531. else makeDisabled(obj.arrElm[9]);
  1532. }
  1533. if(obj.btnPasteWord)
  1534. {
  1535. if(oEditor.document.queryCommandEnabled("Paste"))
  1536. makeEnableNormal(obj.arrElm[10]);
  1537. else makeDisabled(obj.arrElm[10]);
  1538. }
  1539. if(obj.btnPasteText)
  1540. {
  1541. if(oEditor.document.queryCommandEnabled("Paste"))
  1542. makeEnableNormal(obj.arrElm[11]);
  1543. else makeDisabled(obj.arrElm[11]);
  1544. }
  1545. if(obj.btnUndo)
  1546. {
  1547. if(!obj.arrUndoList[0])makeDisabled(obj.arrElm[12]);
  1548. else makeEnableNormal(obj.arrElm[12]);
  1549. }
  1550. if(obj.btnRedo)
  1551. {
  1552. if(!obj.arrRedoList[0])makeDisabled(obj.arrElm[13]);
  1553. else makeEnableNormal(obj.arrElm[13]);
  1554. }
  1555. if(obj.btnBold)
  1556. {
  1557. if(oEditor.document.queryCommandEnabled("Bold"))
  1558. {
  1559. if(oEditor.document.queryCommandState("Bold"))
  1560. makeEnablePushed(obj.arrElm[14]);
  1561. else makeEnableNormal(obj.arrElm[14]);
  1562. }
  1563. else makeDisabled(obj.arrElm[14]);
  1564. }
  1565. if(obj.btnItalic)
  1566. {
  1567. if(oEditor.document.queryCommandEnabled("Italic"))
  1568. {
  1569. if(oEditor.document.queryCommandState("Italic"))
  1570. makeEnablePushed(obj.arrElm[15]);
  1571. else makeEnableNormal(obj.arrElm[15]);
  1572. }
  1573. else makeDisabled(obj.arrElm[15]);
  1574. }
  1575. if(obj.btnUnderline)
  1576. {
  1577. if(oEditor.document.queryCommandEnabled("Underline"))
  1578. {
  1579. if(oEditor.document.queryCommandState("Underline"))
  1580. makeEnablePushed(obj.arrElm[16]);
  1581. else makeEnableNormal(obj.arrElm[16]);
  1582. }
  1583. else makeDisabled(obj.arrElm[16]);
  1584. }
  1585. if(obj.btnStrikethrough)
  1586. {
  1587. if(oEditor.document.queryCommandEnabled("Strikethrough"))
  1588. {
  1589. if(oEditor.document.queryCommandState('Strikethrough'))
  1590. makeEnablePushed(obj.arrElm[17]);
  1591. else makeEnableNormal(obj.arrElm[17]);
  1592. }
  1593. else makeDisabled(obj.arrElm[17]);
  1594. }
  1595. if(obj.btnSuperscript)
  1596. {
  1597. if(oEditor.document.queryCommandEnabled("Superscript"))
  1598. {
  1599. if(oEditor.document.queryCommandState("Superscript"))
  1600. makeEnablePushed(obj.arrElm[18]);
  1601. else makeEnableNormal(obj.arrElm[18]);
  1602. }
  1603. else makeDisabled(obj.arrElm[18]);
  1604. }
  1605. if(obj.btnSubscript)
  1606. {
  1607. if(oEditor.document.queryCommandEnabled("Subscript"))
  1608. {
  1609. if(oEditor.document.queryCommandState("Subscript"))
  1610. makeEnablePushed(obj.arrElm[19]);
  1611. else makeEnableNormal(obj.arrElm[19]);
  1612. }
  1613. else makeDisabled(obj.arrElm[19]);
  1614. }
  1615. if(obj.btnNumbering)
  1616. {
  1617. if(oEditor.document.queryCommandEnabled("InsertOrderedList"))
  1618. {
  1619. if(oEditor.document.queryCommandState("InsertOrderedList"))
  1620. makeEnablePushed(obj.arrElm[20]);
  1621. else makeEnableNormal(obj.arrElm[20]);
  1622. }
  1623. else makeDisabled(obj.arrElm[20]);
  1624. }
  1625. if(obj.btnBullets)
  1626. {
  1627. if(oEditor.document.queryCommandEnabled("InsertUnorderedList"))
  1628. {
  1629. if(oEditor.document.queryCommandState("InsertUnorderedList"))
  1630. makeEnablePushed(obj.arrElm[21]);
  1631. else makeEnableNormal(obj.arrElm[21]);
  1632. }
  1633. else makeDisabled(obj.arrElm[21]);
  1634. }
  1635. if(obj.btnJustifyLeft)
  1636. {
  1637. if(oEditor.document.queryCommandEnabled("JustifyLeft"))
  1638. {
  1639. if(oEditor.document.queryCommandState("JustifyLeft"))
  1640. makeEnablePushed(obj.arrElm[22]);
  1641. else makeEnableNormal(obj.arrElm[22]);
  1642. }
  1643. else makeDisabled(obj.arrElm[22]);
  1644. }
  1645. if(obj.btnJustifyCenter)
  1646. {
  1647. if(oEditor.document.queryCommandEnabled("JustifyCenter"))
  1648. {
  1649. if(oEditor.document.queryCommandState("JustifyCenter"))
  1650. makeEnablePushed(obj.arrElm[23]);
  1651. else makeEnableNormal(obj.arrElm[23]);
  1652. }
  1653. else makeDisabled(obj.arrElm[23]);
  1654. }
  1655. if(obj.btnJustifyRight)
  1656. {
  1657. if(oEditor.document.queryCommandEnabled("JustifyRight"))
  1658. {
  1659. if(oEditor.document.queryCommandState("JustifyRight"))
  1660. makeEnablePushed(obj.arrElm[24]);
  1661. else makeEnableNormal(obj.arrElm[24]);
  1662. }
  1663. else makeDisabled(obj.arrElm[24]);
  1664. }
  1665. if(obj.btnJustifyFull)
  1666. {
  1667. if(oEditor.document.queryCommandEnabled("JustifyFull"))
  1668. {
  1669. if(oEditor.document.queryCommandState("JustifyFull"))
  1670. makeEnablePushed(obj.arrElm[25]);
  1671. else makeEnableNormal(obj.arrElm[25]);
  1672. }
  1673. else makeDisabled(obj.arrElm[25]);
  1674. }
  1675. if(obj.btnIndent)
  1676. {
  1677. if(oEditor.document.queryCommandEnabled("Indent"))
  1678. makeEnableNormal(obj.arrElm[26]);
  1679. else makeDisabled(obj.arrElm[26]);
  1680. }
  1681. if(obj.btnOutdent)
  1682. {
  1683. if(oEditor.document.queryCommandEnabled("Outdent"))
  1684. makeEnableNormal(obj.arrElm[27]);
  1685. else makeDisabled(obj.arrElm[27]);
  1686. }
  1687. if(obj.btnLTR)
  1688. {
  1689. if(oEditor.document.queryCommandEnabled("BlockDirLTR"))
  1690. {
  1691. if(oEditor.document.queryCommandState("BlockDirLTR"))
  1692. makeEnablePushed(obj.arrElm[28]);
  1693. else makeEnableNormal(obj.arrElm[28]);
  1694. }
  1695. else makeDisabled(obj.arrElm[28]);
  1696. }
  1697. if(obj.btnRTL)
  1698. {
  1699. if(oEditor.document.queryCommandEnabled("BlockDirRTL"))
  1700. {
  1701. if(oEditor.document.queryCommandState("BlockDirRTL"))
  1702. makeEnablePushed(obj.arrElm[29]);
  1703. else makeEnableNormal(obj.arrElm[29]);
  1704. }
  1705. else makeDisabled(obj.arrElm[29]);
  1706. }
  1707. if(oSel.parentElement)
  1708. {
  1709. if(obj.btnForeColor)makeEnableNormal(obj.arrElm[30]);
  1710. if(obj.btnBackColor)makeEnableNormal(obj.arrElm[31]);
  1711. if(obj.btnLine)makeEnableNormal(obj.arrElm[32]);
  1712. }
  1713. else
  1714. {
  1715. if(obj.btnForeColor)makeDisabled(obj.arrElm[30]);
  1716. if(obj.btnBackColor)makeDisabled(obj.arrElm[31]);
  1717. if(obj.btnLine)makeDisabled(obj.arrElm[32]);
  1718. }
  1719. try{oUtil.onSelectionChanged()}catch(e){;}
  1720. try{obj.onSelectionChanged()}catch(e){;}
  1721. //TAG SELECTOR ~~~~~~~~~~~~~~~~~~
  1722. if(obj.useTagSelector)
  1723. {
  1724. if (oSel.parentElement) oElement=oSel.parentElement();
  1725. else oElement=oSel.item(0);
  1726. var sHTML="";var i=0;
  1727. arrTmp2=[];//clear
  1728. while (oElement!=null && oElement.tagName!="BODY")
  1729. {
  1730. arrTmp2[i]=oElement;
  1731. var sTagName = oElement.tagName;
  1732. sHTML = "&nbsp; &lt;<span id=tag"+oName+i+" unselectable=on style='text-decoration:underline;cursor:hand' onclick=""+oName+".selectElement("+i+")">" + sTagName + "</span>&gt;" + sHTML;
  1733. oElement = oElement.parentElement;
  1734. i++;
  1735. }
  1736. sHTML = "&nbsp;&lt;BODY&gt;" + sHTML;
  1737. eval("idElNavigate"+oName).innerHTML = sHTML;
  1738. eval("idElCommand"+oName).style.display="none";
  1739. }
  1740. }
  1741. function realtimeFontSelect(oName)
  1742. {
  1743. var oEditor=eval("idContent"+oName);
  1744. var sFontName = oEditor.document.queryCommandValue("FontName");
  1745. var iCols = eval("dropFontName"+oName).rows[0].childNodes.length;
  1746. for(var i=0;i<iCols;i++)
  1747. {
  1748. var oFontTable=eval("dropFontName"+oName).rows[0].childNodes[i].childNodes[0];
  1749. var rowFonts = oFontTable.rows;
  1750. for(var j=0;j<rowFonts.length;j++)
  1751. {
  1752. if(sFontName+")"==rowFonts[j].innerText.split("(")[1])
  1753. {
  1754. rowFonts[j].childNodes[0].style.backgroundColor="#708090";
  1755. rowFonts[j].childNodes[0].style.color="#FFFFFF";
  1756. }
  1757. else
  1758. {
  1759. rowFonts[j].childNodes[0].style.backgroundColor="";
  1760. rowFonts[j].childNodes[0].style.color="#000000";
  1761. }
  1762. }
  1763. }
  1764. }
  1765. function realtimeSizeSelect(oName)
  1766. {
  1767. var oEditor=eval("idContent"+oName);
  1768. var sFontSize=oEditor.document.queryCommandValue("FontSize");
  1769. var rowFonts=eval("dropFontSize"+oName).rows;
  1770. for(var i=0;i<rowFonts.length;i++)
  1771. {
  1772. if("Size "+sFontSize==rowFonts[i].innerText)
  1773. {
  1774. rowFonts[i].childNodes[0].style.backgroundColor="#708090";
  1775. rowFonts[i].childNodes[0].style.color="#FFFFFF";
  1776. }
  1777. else
  1778. {
  1779. rowFonts[i].childNodes[0].style.backgroundColor="";
  1780. rowFonts[i].childNodes[0].style.color="#000000";
  1781. }
  1782. }
  1783. }
  1784. /*********************
  1785. TAG SELECTOR
  1786. **********************/
  1787. function moveTagSelector()
  1788. {
  1789. var sTagSelTop="<table unselectable=on ondblclick='"+this.oName+".moveTagSelector()' width='100%' cellpadding=0 cellspacing=0><tr style='background:#e7e7e7;font-family:arial;font-size:10px;color:black;'>"+
  1790. "<td id=idElNavigate"+ this.oName +" style='padding:1px;width:100%' valign=top>&nbsp;</td>"+
  1791. "<td align=right valign=top nowrap>"+
  1792. "<span id=idElCommand"+ this.oName +" unselectable=on style='display:none;text-decoration:underline;cursor:hand;padding-right:5;' onclick='"+this.oName+".removeTag()'>"+getText("Remove Tag")+"</span>"+
  1793. "</td></tr></table>";
  1794. var sTagSelBottom="<table unselectable=on ondblclick='"+this.oName+".moveTagSelector()' width='100%' cellpadding=0 cellspacing=0><tr style='background:#e7e7e7;font-family:arial;font-size:10px;color:black;'>"+
  1795. "<td id=idElNavigate"+ this.oName +" style='padding:1px;width:100%' valign=top>&nbsp;</td>"+
  1796. "<td align=right valign=top nowrap>"+
  1797. "<span id=idElCommand"+ this.oName +" unselectable=on style='display:none;text-decoration:underline;cursor:hand;padding-right:5;' onclick='"+this.oName+".removeTag()'>"+getText("Remove Tag")+"</span>"+
  1798. "</td></tr></table>";
  1799. if(this.TagSelectorPosition=="top")
  1800. {
  1801. eval("idTagSelTop"+this.oName).innerHTML="";
  1802. eval("idTagSelBottom"+this.oName).innerHTML=sTagSelBottom;
  1803. eval("idTagSelTopRow"+this.oName).style.display="none";
  1804. eval("idTagSelBottomRow"+this.oName).style.display="block";
  1805. this.TagSelectorPosition="bottom"
  1806. }
  1807. else//if(this.TagSelectorPosition=="bottom")
  1808. {
  1809. eval("idTagSelTop"+this.oName).innerHTML=sTagSelTop;
  1810. eval("idTagSelBottom"+this.oName).innerHTML="";
  1811. eval("idTagSelTopRow"+this.oName).style.display="block";
  1812. eval("idTagSelBottomRow"+this.oName).style.display="none";
  1813. this.TagSelectorPosition="top"
  1814. }
  1815. }
  1816. function selectElement(i)
  1817. {
  1818. var oEditor=eval("idContent"+this.oName);
  1819. var oSelRange = oEditor.document.body.createControlRange();
  1820. var oActiveElement;
  1821. try
  1822. {
  1823. oSelRange.add(arrTmp2[i]);
  1824. oSelRange.select();
  1825. realTime(this.oName);
  1826. oActiveElement = arrTmp2[i];
  1827. if(oActiveElement.tagName!="TD"&&
  1828. oActiveElement.tagName!="TR"&&
  1829. oActiveElement.tagName!="TBODY"&&
  1830. oActiveElement.tagName!="LI")
  1831. eval("idElCommand"+this.oName).style.display="block";
  1832. }
  1833. catch(e)
  1834. {
  1835. try//utk multiple instance, kalau select tag tapi tdk focus atau select list & content lain di luar list lalu set color
  1836. {
  1837. var oSelRange = oEditor.document.body.createTextRange();
  1838. oSelRange.moveToElementText(arrTmp2[i]);
  1839. oSelRange.select();
  1840. realTime(this.oName);
  1841. oActiveElement = arrTmp2[i];
  1842. if(oActiveElement.tagName!="TD"&&
  1843. oActiveElement.tagName!="TR"&&
  1844. oActiveElement.tagName!="TBODY"&&
  1845. oActiveElement.tagName!="LI")
  1846. eval("idElCommand"+this.oName).style.display="block";
  1847. }
  1848. catch(e){return;}
  1849. }
  1850. for(var j=0;j<arrTmp2.length;j++)eval("tag"+this.oName+j).style.background="";
  1851. eval("tag"+this.oName+i).style.background="DarkGray";
  1852. if(oActiveElement)
  1853. oUtil.activeElement=oActiveElement;//Set active element in the Editor
  1854. }
  1855. function removeTag()
  1856. {
  1857. if(!this.checkFocus())return;//Focus stuff
  1858. eval(this.oName).saveForUndo();//Save for Undo
  1859. var oEditor=eval("idContent"+this.oName);
  1860. var oSel=oEditor.document.selection.createRange();
  1861. var sType=oEditor.document.selection.type;
  1862. if(sType=="Control")
  1863. {
  1864. oSel.item(0).outerHTML="";
  1865. this.focus();
  1866. realTime(this.oName);
  1867. return;
  1868. }
  1869. var oActiveElement=oUtil.activeElement;
  1870. var oSelRange = oEditor.document.body.createTextRange();
  1871. oSelRange.moveToElementText(oActiveElement);
  1872. oSel.setEndPoint("StartToStart",oSelRange);
  1873. oSel.setEndPoint("EndToEnd",oSelRange);
  1874. oSel.select();
  1875. sHTML=oActiveElement.innerHTML;
  1876. var arrA = String(sHTML).match(/<A[^>]*>/g);
  1877. if(arrA)
  1878. for(var i=0;i<arrA.length;i++)
  1879. {
  1880. sTmp = arrA[i].replace(/href=/,"href_iwe=");
  1881. sHTML=String(sHTML).replace(arrA[i],sTmp);
  1882. }
  1883. var arrB = String(sHTML).match(/<IMG[^>]*>/g);
  1884. if(arrB)
  1885. for(var i=0;i<arrB.length;i++)
  1886. {
  1887. sTmp = arrB[i].replace(/src=/,"src_iwe=");
  1888. sHTML=String(sHTML).replace(arrB[i],sTmp);
  1889. }
  1890. var oTmp=oActiveElement.parentElement;
  1891. if(oTmp.innerHTML==oActiveElement.outerHTML)//<b><u>TEXT</u><b> (<u> is selected)
  1892. {//oTmp=<b> , oActiveElement=<u>
  1893. oTmp.innerHTML=sHTML;
  1894. for(var i=0;i<oEditor.document.all.length;i++)
  1895. {
  1896. if(oEditor.document.all[i].getAttribute("href_iwe"))
  1897. {
  1898. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  1899. oEditor.document.all[i].removeAttribute("href_iwe",0);
  1900. }
  1901. if(oEditor.document.all[i].getAttribute("src_iwe"))
  1902. {
  1903. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  1904. oEditor.document.all[i].removeAttribute("src_iwe",0);
  1905. }
  1906. }
  1907. var oSelRange = oEditor.document.body.createTextRange();
  1908. oSelRange.moveToElementText(oTmp);
  1909. oSel.setEndPoint("StartToStart",oSelRange);
  1910. oSel.setEndPoint("EndToEnd",oSelRange);
  1911. oSel.select();
  1912. realTime(this.oName);
  1913. this.selectElement(0);
  1914. return;
  1915. }
  1916. else
  1917. {
  1918. oActiveElement.outerHTML="";
  1919. oSel.pasteHTML(sHTML);
  1920. for(var i=0;i<oEditor.document.all.length;i++)
  1921. {
  1922. if(oEditor.document.all[i].getAttribute("href_iwe"))
  1923. {
  1924. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  1925. oEditor.document.all[i].removeAttribute("href_iwe",0);
  1926. }
  1927. if(oEditor.document.all[i].getAttribute("src_iwe"))
  1928. {
  1929. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  1930. oEditor.document.all[i].removeAttribute("src_iwe",0);
  1931. }
  1932. }
  1933. this.focus();
  1934. realTime(this.oName);
  1935. }
  1936. //*** RUNTIME STYLES ***
  1937. this.runtimeBorder(false);
  1938. this.runtimeStyles();
  1939. //***********************
  1940. }
  1941. /*********************
  1942. RUNTIME BORDERS
  1943. **********************/
  1944. function runtimeBorderOn()
  1945. {
  1946. this.runtimeBorderOff();//reset
  1947. var oEditor=eval("idContent"+this.oName);
  1948. var oTables=oEditor.document.getElementsByTagName("TABLE");
  1949. for(i=0;i<oTables.length;i++)
  1950. {
  1951. if(oTables[i].border==0)
  1952. {
  1953. for(j=0;j<oTables[i].getElementsByTagName("TD").length;j++)
  1954. {
  1955. if(oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth=="0px"||
  1956. oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth==""||
  1957. oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth=="medium")
  1958. {
  1959. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftWidth=1;
  1960. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftColor="#BCBCBC";
  1961. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftStyle="dotted";
  1962. }
  1963. if(oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth=="0px"||
  1964. oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth==""||
  1965. oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth=="medium")
  1966. {
  1967. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightWidth=1;
  1968. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightColor="#BCBCBC";
  1969. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightStyle="dotted";
  1970. }
  1971. if(oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth=="0px"||
  1972. oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth==""||
  1973. oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth=="medium")
  1974. {
  1975. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopWidth=1;
  1976. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopColor="#BCBCBC";
  1977. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopStyle="dotted";
  1978. }
  1979. if(oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth=="0px"||
  1980. oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth==""||
  1981. oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth=="medium")
  1982. {
  1983. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomWidth=1;
  1984. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomColor="#BCBCBC";
  1985. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomStyle="dotted";
  1986. }
  1987. }
  1988. }
  1989. }
  1990. }
  1991. function runtimeBorderOff()
  1992. {
  1993. var oEditor=eval("idContent"+this.oName);
  1994. var oTables=oEditor.document.getElementsByTagName("TABLE");
  1995. for(i=0;i<oTables.length;i++)
  1996. {
  1997. if(oTables[i].border==0)
  1998. {
  1999. for(j=0;j<oTables[i].getElementsByTagName("TD").length;j++)
  2000. {
  2001. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderWidth="";
  2002. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderColor="";
  2003. oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderStyle="";
  2004. }
  2005. }
  2006. }
  2007. }
  2008. function runtimeBorder(bToggle)
  2009. {
  2010. if(bToggle)
  2011. {
  2012. if(this.IsRuntimeBorderOn)
  2013. {
  2014. this.runtimeBorderOff();
  2015. this.IsRuntimeBorderOn=false;
  2016. }
  2017. else
  2018. {
  2019. this.runtimeBorderOn();
  2020. this.IsRuntimeBorderOn=true;
  2021. }
  2022. }
  2023. else
  2024. {//refresh based on the current status
  2025. if(this.IsRuntimeBorderOn) this.runtimeBorderOn();
  2026. else this.runtimeBorderOff();
  2027. }
  2028. }
  2029. /*********************
  2030. RUNTIME STYLES
  2031. **********************/
  2032. function runtimeStyles()
  2033. {
  2034. var oEditor=eval("idContent"+this.oName);
  2035. var oForms=oEditor.document.getElementsByTagName("FORM");
  2036. for (i=0;i<oForms.length;i++) oForms[i].runtimeStyle.border="#7bd158 1px dotted";
  2037. var oBookmarks=oEditor.document.getElementsByTagName("A");
  2038. for (i=0;i<oBookmarks.length;i++)
  2039. {
  2040. if(oBookmarks[i].name||oBookmarks[i].NAME)
  2041. {
  2042. if(oBookmarks[i].innerHTML=="")oBookmarks[i].runtimeStyle.width="1px";
  2043. oBookmarks[i].runtimeStyle.padding="0px";
  2044. oBookmarks[i].runtimeStyle.paddingLeft="1px";
  2045. oBookmarks[i].runtimeStyle.paddingRight="1px";
  2046. oBookmarks[i].runtimeStyle.border="#888888 1 dotted";
  2047. oBookmarks[i].runtimeStyle.borderLeft="#cccccc 10 solid";
  2048. }
  2049. }
  2050. }
  2051. /*********************
  2052. OTHERS
  2053. **********************/
  2054. function doCmd(sCmd,sOption)
  2055. {
  2056. if(!this.checkFocus())return;//Focus stuff
  2057. eval(this.oName).saveForUndo();//Save for Undo
  2058. var oEditor=eval("idContent"+this.oName);
  2059. var oSel=oEditor.document.selection.createRange();
  2060. var sType=oEditor.document.selection.type;
  2061. var oTarget=(sType=="None"?oEditor.document:oSel);
  2062. oTarget.execCommand(sCmd,false,sOption);
  2063. realTime(this.oName);
  2064. }
  2065. function applyColor(sType,sColor)
  2066. {
  2067. this.hide();
  2068. this.focus();//Focus stuff
  2069. var oEditor=eval("idContent"+this.oName);
  2070. var oSel=oEditor.document.selection.createRange();
  2071. this.saveForUndo();
  2072. oSel.execCommand(sType,false,sColor);
  2073. realTime(this.oName);
  2074. if(sColor=="")return;
  2075. this.selectElement(0);
  2076. }
  2077. function applyParagraph(val)
  2078. {
  2079. var oEditor=eval("idContent"+this.oName);
  2080. var oSel=oEditor.document.selection.createRange();
  2081. this.hide();
  2082. oSel.select();
  2083. this.doCmd("FormatBlock",val);
  2084. }
  2085. function applyFontName(val)
  2086. {
  2087. var oEditor=eval("idContent"+this.oName);
  2088. var oSel=oEditor.document.selection.createRange();
  2089. this.hide();//ini menyebabkan text yg ter-select menjadi tdk ter-select di framed-page.
  2090. //Solusi: oSel di select lagi
  2091. oSel.select();
  2092. this.doCmd("fontname",val);
  2093. }
  2094. function applyFontSize(val)
  2095. {
  2096. var oEditor=eval("idContent"+this.oName);
  2097. var oSel=oEditor.document.selection.createRange();
  2098. this.hide();
  2099. oSel.select();
  2100. this.doCmd("fontsize",val);
  2101. }
  2102. function applyBullets()
  2103. {
  2104. this.doCmd("InsertUnOrderedList");
  2105. makeEnableNormal(eval("document.all.btnNumbering"+this.oName));
  2106. var oEditor=eval("idContent"+this.oName);
  2107. var oSel=oEditor.document.selection.createRange();
  2108. var oElement=oSel.parentElement();
  2109. while (oElement!=null&&oElement.tagName!="OL"&&oElement.tagName!="UL")
  2110. {
  2111. if(oElement.tagName=="BODY")return;
  2112. oElement=oElement.parentElement;
  2113. }
  2114. oElement.removeAttribute("type",0);
  2115. oElement.style.listStyleImage="";
  2116. }
  2117. function applyNumbering()
  2118. {
  2119. this.doCmd("InsertOrderedList");
  2120. makeEnableNormal(eval("document.all.btnBullets"+this.oName));
  2121. var oEditor=eval("idContent"+this.oName);
  2122. var oSel=oEditor.document.selection.createRange();
  2123. var oElement=oSel.parentElement();
  2124. while (oElement!=null&&oElement.tagName!="OL"&&oElement.tagName!="UL")
  2125. {
  2126. if(oElement.tagName=="BODY")return;
  2127. oElement=oElement.parentElement;
  2128. }
  2129. oElement.removeAttribute("type",0);
  2130. oElement.style.listStyleImage="";
  2131. }
  2132. function applyJustifyLeft()
  2133. {
  2134. this.doCmd("JustifyLeft");
  2135. if(this.btnJustifyCenter) makeEnableNormal(eval("document.all.btnJustifyCenter"+this.oName));
  2136. if(this.btnJustifyRight) makeEnableNormal(eval("document.all.btnJustifyRight"+this.oName));
  2137. if(this.btnJustifyFull) makeEnableNormal(eval("document.all.btnJustifyFull"+this.oName));
  2138. }
  2139. function applyJustifyCenter()
  2140. {
  2141. this.doCmd("JustifyCenter");
  2142. if(this.btnJustifyLeft) makeEnableNormal(eval("document.all.btnJustifyLeft"+this.oName));
  2143. if(this.btnJustifyRight) makeEnableNormal(eval("document.all.btnJustifyRight"+this.oName));
  2144. if(this.btnJustifyFull) makeEnableNormal(eval("document.all.btnJustifyFull"+this.oName));
  2145. }
  2146. function applyJustifyRight()
  2147. {
  2148. this.doCmd("JustifyRight");
  2149. if(this.btnJustifyLeft) makeEnableNormal(eval("document.all.btnJustifyLeft"+this.oName));
  2150. if(this.btnJustifyCenter) makeEnableNormal(eval("document.all.btnJustifyCenter"+this.oName));
  2151. if(this.btnJustifyFull) makeEnableNormal(eval("document.all.btnJustifyFull"+this.oName));
  2152. }
  2153. function applyJustifyFull()
  2154. {
  2155. this.doCmd("JustifyFull");
  2156. if(this.btnJustifyLeft) makeEnableNormal(eval("document.all.btnJustifyLeft"+this.oName));
  2157. if(this.btnJustifyCenter) makeEnableNormal(eval("document.all.btnJustifyCenter"+this.oName));
  2158. if(this.btnJustifyRight) makeEnableNormal(eval("document.all.btnJustifyRight"+this.oName));
  2159. }
  2160. function applyBlockDirLTR()
  2161. {
  2162. this.doCmd("BlockDirLTR");
  2163. if(this.btnRTL) makeEnableNormal(eval("document.all.btnRTL"+this.oName));
  2164. }
  2165. function applyBlockDirRTL()
  2166. {
  2167. this.doCmd("BlockDirRTL");
  2168. if(this.btnLTR) makeEnableNormal(eval("document.all.btnLTR"+this.oName));
  2169. }
  2170. function doPaste()
  2171. {
  2172. this.doCmd("Paste");
  2173. //*** RUNTIME BORDERS ***
  2174. this.runtimeBorder(false);
  2175. //***********************
  2176. }
  2177. function doPasteText()
  2178. {
  2179. if(!this.checkFocus())return;//Focus stuff
  2180. var oEditor=eval("idContent"+this.oName);
  2181. var oSel=oEditor.document.selection.createRange();
  2182. this.saveForUndo();
  2183. var oWord = eval("idContentWord"+this.oName);
  2184. oWord.focus();
  2185. oWord.document.execCommand("SelectAll");
  2186. oWord.document.execCommand("Paste");
  2187. oSel.pasteHTML(oWord.document.body.innerText);
  2188. }
  2189. function insertCustomTag(sTag)
  2190. {
  2191. this.insertHTML(sTag);
  2192. this.hide();
  2193. this.focus();
  2194. }
  2195. function expandSelection()
  2196. {
  2197. if(!this.checkFocus())return;//Focus stuff
  2198. var oEditor=eval("idContent"+this.oName);
  2199. var oSel=oEditor.document.selection.createRange();
  2200. if(oSel.text!="")return;
  2201. /*
  2202. var oElement = oSel.parentElement();
  2203. if(oElement.tagName!="BODY")
  2204. {
  2205. var oSelRange=oEditor.document.body.createTextRange();
  2206. oSelRange.moveToElementText(oElement);
  2207. oSel.setEndPoint("StartToStart",oSelRange);
  2208. oSel.setEndPoint("EndToEnd",oSelRange);
  2209. oSel.select();
  2210. return;
  2211. }*/
  2212. oSel.expand("word");
  2213. oSel.select();
  2214. if(oSel.text.substr(oSel.text.length*1-1,oSel.text.length)==" ")
  2215. {
  2216. oSel.moveEnd("character",-1);
  2217. oSel.select();
  2218. }
  2219. }
  2220. function selectParagraph()
  2221. {
  2222. if(!this.checkFocus())return;//Focus stuff
  2223. var oEditor=eval("idContent"+this.oName);
  2224. var oSel=oEditor.document.selection.createRange();
  2225. if(oSel.parentElement)
  2226. {
  2227. if(oSel.text=="")
  2228. {
  2229. var oElement=oSel.parentElement();
  2230. while (oElement!=null&&
  2231. oElement.tagName!="H1"&&oElement.tagName!="H2"&&
  2232. oElement.tagName!="H3"&&oElement.tagName!="H4"&&
  2233. oElement.tagName!="H5"&&oElement.tagName!="H6"&&
  2234. oElement.tagName!="PRE"&&oElement.tagName!="P"&&
  2235. oElement.tagName!="DIV")
  2236. {
  2237. if(oElement.tagName=="BODY")return;
  2238. oElement=oElement.parentElement;
  2239. }
  2240. var oSelRange = oEditor.document.body.createControlRange();
  2241. try
  2242. {
  2243. oSelRange.add(oElement);
  2244. oSelRange.select();
  2245. }
  2246. catch(e)
  2247. {
  2248. var oSelRange = oEditor.document.body.createTextRange();
  2249. try{oSelRange.moveToElementText(oElement);
  2250. oSelRange.select()
  2251. }catch(e){;}
  2252. }
  2253. }
  2254. }
  2255. }
  2256. function insertHTML(sHTML)
  2257. {
  2258. this.focus();
  2259. //if(!this.checkFocus())return;//Focus stuff
  2260. var oEditor=eval("idContent"+this.oName);
  2261. var oSel=oEditor.document.selection.createRange();
  2262. var arrA = String(sHTML).match(/<A[^>]*>/ig);
  2263. if(arrA)
  2264. for(var i=0;i<arrA.length;i++)
  2265. {
  2266. sTmp = arrA[i].replace(/href=/,"href_iwe=");
  2267. sHTML=String(sHTML).replace(arrA[i],sTmp);
  2268. }
  2269. var arrB = String(sHTML).match(/<IMG[^>]*>/ig);
  2270. if(arrB)
  2271. for(var i=0;i<arrB.length;i++)
  2272. {
  2273. sTmp = arrB[i].replace(/src=/,"src_iwe=");
  2274. sHTML=String(sHTML).replace(arrB[i],sTmp);
  2275. }
  2276. if(oSel.parentElement)oSel.pasteHTML(sHTML);
  2277. else oSel.item(0).outerHTML=sHTML;
  2278. for(var i=0;i<oEditor.document.all.length;i++)
  2279. {
  2280. if(oEditor.document.all[i].getAttribute("href_iwe"))
  2281. {
  2282. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  2283. oEditor.document.all[i].removeAttribute("href_iwe",0);
  2284. }
  2285. if(oEditor.document.all[i].getAttribute("src_iwe"))
  2286. {
  2287. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  2288. oEditor.document.all[i].removeAttribute("src_iwe",0);
  2289. }
  2290. }
  2291. }
  2292. function insertLink(url,title,target)
  2293. {
  2294. this.focus();//Focus stuff
  2295. var oEditor=eval("idContent"+this.oName);
  2296. var oSel=oEditor.document.selection.createRange();
  2297. if(oSel.parentElement)
  2298. {
  2299. if(oSel.text=="")
  2300. {
  2301. var oSelTmp=oSel.duplicate();
  2302. if(title!="" && title!=undefined) oSel.text=title;
  2303. else oSel.text=url;
  2304. oSel.setEndPoint("StartToStart",oSelTmp);
  2305. oSel.select();
  2306. }
  2307. }
  2308. oSel.execCommand("CreateLink",false,url);
  2309. if (oSel.parentElement) oEl=GetElement(oSel.parentElement(),"A");
  2310. else oEl=GetElement(oSel.item(0),"A");
  2311. if(oEl)
  2312. {
  2313. if(target!="" && target!=undefined)oEl.target=target;
  2314. }
  2315. }
  2316. function clearAll()
  2317. {
  2318. if(confirm(getText("Are you sure you wish to delete all contents?"))==true)
  2319. {
  2320. var oEditor=eval("idContent"+this.oName);
  2321. oEditor.document.body.innerHTML="";
  2322. }
  2323. }
  2324. function spellcheckDialogShow()
  2325. {
  2326. window.open(this.scriptPath+"spellcheck.htm","","width=500,height=222;toolbar=no,menubar=no,location=no,directories=no,status=yes")
  2327. }
  2328. function doClean()
  2329. {
  2330. if(!this.checkFocus())return;//Focus stuff
  2331. eval(this.oName).saveForUndo();//Save for Undo
  2332. if(oUtil.activeElement)
  2333. {
  2334. var oActiveElement=oUtil.activeElement;
  2335. oActiveElement.removeAttribute("className",0);
  2336. oActiveElement.removeAttribute("style",0);
  2337. if(oActiveElement.tagName=="H1"||oActiveElement.tagName=="H2"||
  2338. oActiveElement.tagName=="H3"||oActiveElement.tagName=="H4"||
  2339. oActiveElement.tagName=="H5"||oActiveElement.tagName=="H6"||
  2340. oActiveElement.tagName=="PRE"||oActiveElement.tagName=="P"||
  2341. oActiveElement.tagName=="DIV")
  2342. {
  2343. if(this.useDIV)this.doCmd('FormatBlock','<DIV>');
  2344. else this.doCmd('FormatBlock','<P>');
  2345. }
  2346. }
  2347. else
  2348. {
  2349. var oEditor=eval("idContent"+this.oName);
  2350. var oSel=oEditor.document.selection.createRange();
  2351. var sType=oEditor.document.selection.type;
  2352. if (oSel.parentElement)
  2353. {
  2354. oEl=oSel.parentElement();
  2355. if(oEl.outerHTML==oSel.htmlText)
  2356. {
  2357. oEl.removeAttribute("className",0);
  2358. oEl.removeAttribute("style",0);
  2359. if(oEl.tagName=="H1"||oEl.tagName=="H2"||
  2360. oEl.tagName=="H3"||oEl.tagName=="H4"||
  2361. oEl.tagName=="H5"||oEl.tagName=="H6"||
  2362. oEl.tagName=="PRE"||oEl.tagName=="P"||oEl.tagName=="DIV")
  2363. {
  2364. if(this.useDIV)this.doCmd('FormatBlock','<DIV>');
  2365. else this.doCmd('FormatBlock','<P>');
  2366. }
  2367. }
  2368. }
  2369. else
  2370. {
  2371. oEl=oSel.item(0);
  2372. oEl.removeAttribute("className",0);
  2373. oEl.removeAttribute("style",0);
  2374. }
  2375. }
  2376. this.doCmd('RemoveFormat');
  2377. realTime(this.oName);
  2378. }
  2379. function applySpan()
  2380. {
  2381. if(!this.checkFocus())return;//Focus stuff
  2382. var oEditor=eval("idContent"+this.oName);
  2383. var oSel=oEditor.document.selection.createRange();
  2384. var sType=oEditor.document.selection.type;
  2385. if(sType=="Control"||sType=="None")return;
  2386. sHTML=oSel.htmlText;
  2387. var oParent=oSel.parentElement();
  2388. if(oParent.tagName=="SPAN")
  2389. {
  2390. idSpan=oParent;
  2391. return idSpan;
  2392. }
  2393. var arrA = String(sHTML).match(/<A[^>]*>/ig);
  2394. if(arrA)
  2395. for(var i=0;i<arrA.length;i++)
  2396. {
  2397. sTmp = arrA[i].replace(/href=/,"href_iwe=");
  2398. sHTML=String(sHTML).replace(arrA[i],sTmp);
  2399. }
  2400. var arrB = String(sHTML).match(/<IMG[^>]*>/ig);
  2401. if(arrB)
  2402. for(var i=0;i<arrB.length;i++)
  2403. {
  2404. sTmp = arrB[i].replace(/src=/,"src_iwe=");
  2405. sHTML=String(sHTML).replace(arrB[i],sTmp);
  2406. }
  2407. oSel.pasteHTML("<span id='idSpan__abc'>"+sHTML+"</span>");
  2408. var idSpan=oEditor.document.all.idSpan__abc;
  2409. var oSelRange=oEditor.document.body.createTextRange();
  2410. oSelRange.moveToElementText(idSpan);
  2411. oSel.setEndPoint("StartToStart",oSelRange);
  2412. oSel.setEndPoint("EndToEnd",oSelRange);
  2413. oSel.select();
  2414. for(var i=0;i<oEditor.document.all.length;i++)
  2415. {
  2416. if(oEditor.document.all[i].getAttribute("href_iwe"))
  2417. {
  2418. oEditor.document.all[i].href=oEditor.document.all[i].getAttribute("href_iwe");
  2419. oEditor.document.all[i].removeAttribute("href_iwe",0);
  2420. }
  2421. if(oEditor.document.all[i].getAttribute("src_iwe"))
  2422. {
  2423. oEditor.document.all[i].src=oEditor.document.all[i].getAttribute("src_iwe");
  2424. oEditor.document.all[i].removeAttribute("src_iwe",0);
  2425. }
  2426. }
  2427. idSpan.removeAttribute("id",0);
  2428. return idSpan;
  2429. }
  2430. function makeAbsolute()
  2431. {
  2432. if(!this.checkFocus())return;//Focus stuff
  2433. var oEditor=eval("idContent"+this.oName);
  2434. var oSel=oEditor.document.selection.createRange();
  2435. if(oSel.parentElement)
  2436. {
  2437. var oElement=oSel.parentElement();
  2438. oElement.style.position="absolute";
  2439. }
  2440. else
  2441. this.doCmd("AbsolutePosition");
  2442. }
  2443. function doKeyPress(evt,oName)
  2444. {
  2445. if(!eval(oName).arrUndoList[0]){eval(oName).saveForUndo();}//pengganti saveForUndo_First
  2446. if(evt.ctrlKey)
  2447. {
  2448. if(evt.keyCode==89)
  2449. {//CTRL-Y (Redo)
  2450. eval(oName).doRedo();
  2451. }
  2452. if(evt.keyCode==90)
  2453. {//CTRL-Z (Undo)
  2454. eval(oName).doUndo();
  2455. }
  2456. if(evt.keyCode==65) 
  2457. {//CTRL-A (Select All) => spy jalan di modal dialog
  2458. eval(oName).doCmd("SelectAll");
  2459. }
  2460. }
  2461. if(evt.keyCode==37||evt.keyCode==38||evt.keyCode==39||evt.keyCode==40)//Arrow
  2462. {
  2463. eval(oName).saveForUndo();//Save for Undo
  2464. }
  2465. if(evt.keyCode==13)
  2466. {
  2467. if(eval(oName).useDIV && !eval(oName).useBR)
  2468. {
  2469. var oSel=document.selection.createRange();
  2470. if(oSel.parentElement)
  2471. {
  2472. eval(oName).saveForUndo();//Save for Undo
  2473. if(GetElement(oSel.parentElement(),"FORM"))
  2474. {
  2475. var oSel=document.selection.createRange();
  2476. oSel.pasteHTML('<br>');
  2477. evt.cancelBubble=true;
  2478. evt.returnValue=false;
  2479. oSel.select();
  2480. oSel.moveEnd("character", 1);
  2481. oSel.moveStart("character", 1);
  2482. oSel.collapse(false);
  2483. return false;
  2484. }
  2485. else
  2486. {
  2487. var oEl = GetElement(oSel.parentElement(),"H1");
  2488. if(!oEl) oEl = GetElement(oSel.parentElement(),"H2");
  2489. if(!oEl) oEl = GetElement(oSel.parentElement(),"H3");
  2490. if(!oEl) oEl = GetElement(oSel.parentElement(),"H4");
  2491. if(!oEl) oEl = GetElement(oSel.parentElement(),"H5");
  2492. if(!oEl) oEl = GetElement(oSel.parentElement(),"H6");
  2493. if(!oEl) oEl = GetElement(oSel.parentElement(),"PRE");
  2494. if(!oEl)eval(oName).doCmd("FormatBlock","<div>");
  2495. return true;
  2496. }
  2497. }
  2498. }
  2499. if((eval(oName).useDIV && eval(oName).useBR)||
  2500. (!eval(oName).useDIV && eval(oName).useBR))
  2501. {
  2502. var oSel=document.selection.createRange();
  2503. oSel.pasteHTML('<br>');
  2504. evt.cancelBubble=true;
  2505. evt.returnValue=false;
  2506. oSel.select();
  2507. oSel.moveEnd("character", 1);
  2508. oSel.moveStart("character", 1);
  2509. oSel.collapse(false);
  2510. return false;
  2511. }
  2512. eval(oName).saveForUndo();//Save for Undo
  2513. }
  2514. }
  2515. function fullScreen()
  2516. {
  2517. this.hide();
  2518. var oEditor=eval("idContent"+this.oName);
  2519. if(this.stateFullScreen)
  2520. {
  2521. this.onNormalScreen();
  2522. this.stateFullScreen=false;
  2523. document.body.style.overflow="";
  2524. document.all.id_refresh_z_index.style.margin="0px";
  2525. eval("idArea"+this.oName).style.position="";
  2526. eval("idArea"+this.oName).style.top="0";
  2527. eval("idArea"+this.oName).style.left="0";
  2528. eval("idArea"+this.oName).style.width=this.width;
  2529. eval("idArea"+this.oName).style.height=this.height;
  2530. //fix undisplayed content
  2531. if(this.initialRefresh)
  2532. {
  2533. oEditor.document.execCommand("SelectAll");
  2534. window.setTimeout("eval('idContentWord"+this.oName+"').document.execCommand('SelectAll');",0);
  2535. }
  2536. for(var i=0;i<oUtil.arrEditor.length;i++)
  2537. {
  2538. if(oUtil.arrEditor[i]!=this.oName)eval("idArea"+oUtil.arrEditor[i]).style.display="block";
  2539. }
  2540. }
  2541. else
  2542. {
  2543. this.onFullScreen();
  2544. this.stateFullScreen=true;
  2545. scroll(0,0);
  2546. document.body.style.overflow="hidden";
  2547. document.all.id_refresh_z_index.style.margin="70px";
  2548. eval("idArea"+this.oName).style.position="absolute";
  2549. eval("idArea"+this.oName).style.top="0";
  2550. eval("idArea"+this.oName).style.left="0";
  2551. //fix undisplayed content
  2552. if(this.initialRefresh)
  2553. {
  2554. oEditor.document.execCommand("SelectAll");
  2555. window.setTimeout("eval('idContentWord"+this.oName+"').document.execCommand('SelectAll');",0);
  2556. }
  2557. var numOfBrk=0;
  2558. for(var j=0;j<this.buttonMap.length;j++)if(this.buttonMap[j]=="BRK")numOfBrk++;
  2559. nToolbarHeight=(numOfBrk+1)*27;
  2560. if (document.compatMode && document.compatMode!="BackCompat")
  2561. {
  2562. //using doctype
  2563. try
  2564. {
  2565. var tes=dialogArguments;
  2566. w=(document.body.offsetWidth);
  2567. document.body.style.height="100%";
  2568. h=document.body.offsetHeight-nToolbarHeight;
  2569. document.body.style.height="";
  2570. }
  2571. catch(e)
  2572. {
  2573. w=(document.body.offsetWidth+20);
  2574. document.body.style.height="100%";
  2575. h=document.body.offsetHeight-nToolbarHeight;
  2576. document.body.style.height="";
  2577. }
  2578. }
  2579. else
  2580. {
  2581. if(document.body.style.overflow=="hidden")
  2582. {
  2583. w=document.body.offsetWidth;
  2584. }
  2585. else
  2586. {
  2587. w=document.body.offsetWidth-22;
  2588. }
  2589. h=document.body.offsetHeight-4;
  2590. }
  2591. eval("idArea"+this.oName).style.width=w;
  2592. eval("idArea"+this.oName).style.height=h;
  2593. for(var i=0;i<oUtil.arrEditor.length;i++)
  2594. {
  2595. if(oUtil.arrEditor[i]!=this.oName)eval("idArea"+oUtil.arrEditor[i]).style.display="none";
  2596. }
  2597. var oEditor=eval("idContent"+this.oName);
  2598. oEditor.focus();
  2599. }
  2600. }
  2601. /*********************
  2602. Table Insert Dropdown
  2603. **********************/
  2604. function doOver_TabCreate()
  2605. {
  2606. var oTD=event.srcElement;
  2607. var oTable=oTD.parentElement.parentElement.parentElement;
  2608. var nRow=oTD.parentElement.rowIndex;
  2609. var nCol=oTD.cellIndex;
  2610. var rows=oTable.rows;
  2611. rows[rows.length-1].childNodes[0].innerHTML="<div align=right>"+(nRow*1+1) + " x " + (nCol*1+1) + " Table ...  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='text-decoration:underline'>Advanced</span>&nbsp;</div>";
  2612. for(var i=0;i<rows.length-1;i++)
  2613. {
  2614. var oRow=rows[i];
  2615. for(var j=0;j<oRow.childNodes.length;j++)
  2616. {
  2617. var oCol=oRow.childNodes[j];
  2618. if(i<=nRow&&j<=nCol)oCol.style.backgroundColor="#316ac5";
  2619. else oCol.style.backgroundColor="#ffffff";
  2620. }
  2621. }
  2622. event.cancelBubble=true;
  2623. }
  2624. function doOut_TabCreate()
  2625. {
  2626. var oTable=event.srcElement;
  2627. if(oTable.tagName!="TABLE")return;
  2628. var rows=oTable.rows;
  2629. rows[rows.length-1].childNodes[0].innerText=getText("Advanced Table Insert");
  2630. for(var i=0;i<rows.length-1;i++)
  2631. {
  2632. var oRow=rows[i];
  2633. for(var j=0;j<oRow.childNodes.length;j++)
  2634. {
  2635. var oCol=oRow.childNodes[j];
  2636. oCol.style.backgroundColor="#ffffff";
  2637. }
  2638. }
  2639. event.cancelBubble=true;
  2640. }
  2641. function doRefresh_TabCreate()
  2642. {
  2643. var oTable=eval("dropTableCreate"+this.oName);
  2644. var rows=oTable.rows;
  2645. rows[rows.length-1].childNodes[0].innerText=getText("Advanced Table Insert");
  2646. for(var i=0;i<rows.length-1;i++)
  2647. {
  2648. var oRow=rows[i];
  2649. for(var j=0;j<oRow.childNodes.length;j++)
  2650. {
  2651. var oCol=oRow.childNodes[j];
  2652. oCol.style.backgroundColor="#ffffff";
  2653. }
  2654. }
  2655. }
  2656. function doClick_TabCreate()
  2657. {
  2658. this.hide();
  2659. if(!this.checkFocus())return;//Focus stuff
  2660. var oEditor=eval("idContent"+this.oName);
  2661. var oSel=oEditor.document.selection.createRange();
  2662. var oTD=event.srcElement;
  2663. var nRow=oTD.parentElement.rowIndex+1;
  2664. var nCol=oTD.cellIndex+1;
  2665. this.saveForUndo();
  2666. var sHTML="<table style='border-collapse:collapse;width:100%;'>";
  2667. for(var i=1;i<=nRow;i++)
  2668. {
  2669. sHTML+="<tr>";
  2670. for(var j=1;j<=nCol;j++)
  2671. {
  2672. sHTML+="<td></td>";
  2673. }
  2674. sHTML+="</tr>";
  2675. }
  2676. sHTML+="</table>";
  2677. if(oSel.parentElement)
  2678. oSel.pasteHTML(sHTML);
  2679. else
  2680. oSel.item(0).outerHTML = sHTML;
  2681. realTime(this.oName);
  2682. //*** RUNTIME STYLES ***
  2683. this.runtimeBorder(false);
  2684. this.runtimeStyles();
  2685. //***********************
  2686. }
  2687. /*********************
  2688. Show/Hide Dropdown
  2689. **********************/
  2690. function dropShow(oEl,box)
  2691. {
  2692. this.hide();
  2693. box.style.display="block";
  2694. var nTop=0;
  2695. var nLeft=0;
  2696. oElTmp=oEl;
  2697. while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  2698. {
  2699. if(oElTmp.style.top!="")
  2700. nTop+=oElTmp.style.top.substring(1,oElTmp.style.top.length-2)*1;
  2701. else nTop+=oElTmp.offsetTop;
  2702. oElTmp = oElTmp.offsetParent;
  2703. }
  2704. oElTmp=oEl;
  2705. while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  2706. {
  2707. if(oElTmp.style.left!="")
  2708. nLeft+=oElTmp.style.left.substring(1,oElTmp.style.left.length-2)*1;
  2709. else nLeft+=oElTmp.offsetLeft;
  2710. oElTmp=oElTmp.offsetParent;
  2711. }
  2712. box.style.left=nLeft;
  2713. box.style.top=nTop+1+this.dropTopAdjustment;
  2714. }
  2715. function hide()
  2716. {
  2717. if(this.btnPreview)eval("dropPreview"+this.oName).style.display="none";
  2718. if(this.btnTextFormatting||this.btnParagraphFormatting||this.btnListFormatting||this.btnBoxFormatting||this.btnStyles||this.btnCssText)eval("dropStyle"+this.oName).style.display="none";
  2719. if(this.btnParagraph)eval("dropParagraph"+this.oName).style.display="none";
  2720. if(this.btnFontName)eval("dropFontName"+this.oName).style.display="none";
  2721. if(this.btnFontSize)eval("dropFontSize"+this.oName).style.display="none";
  2722. if(this.btnTable)eval("dropTable"+this.oName).style.display="none";
  2723. if(this.btnTable)eval("dropTableCreate"+this.oName).style.display="none";
  2724. if(this.btnForm)eval("dropForm"+this.oName).style.display="none";
  2725. if(this.btnCustomTag)eval("dropCustomTag"+this.oName).style.display="none";
  2726. this.oColor1.hide();
  2727. this.oColor2.hide();
  2728. //additional
  2729. if(this.btnTable)this.doRefresh_TabCreate();
  2730. }
  2731. /*********************
  2732. Open Dialog
  2733. **********************/
  2734. function modelessDialogShow(url,width,height)
  2735. {
  2736. window.showModelessDialog(url,window,
  2737. "dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:1;help:0;resizable:1;");
  2738. }
  2739. function modalDialogShow(url,width,height)
  2740. {
  2741. window.showModalDialog(url,window,
  2742. "dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:1;help:0;resizable:1;maximize:1");
  2743. }
  2744. /*********************
  2745. HTML to XHTML
  2746. **********************/
  2747. function lineBreak1(tag) //[0]<TAG>[1]text[2]</TAG>
  2748. {
  2749. arrReturn = ["n","",""];
  2750. if( tag=="A"||tag=="B"||tag=="CITE"||tag=="CODE"||tag=="EM"||
  2751. tag=="FONT"||tag=="I"||tag=="SMALL"||tag=="STRIKE"||tag=="BIG"||
  2752. tag=="STRONG"||tag=="SUB"||tag=="SUP"||tag=="U"||tag=="SAMP"||
  2753. tag=="S"||tag=="VAR"||tag=="BASEFONT"||tag=="KBD"||tag=="TT")
  2754. arrReturn=["","",""];
  2755. if( tag=="TEXTAREA"||tag=="TABLE"||tag=="THEAD"||tag=="TBODY"||
  2756. tag=="TR"||tag=="OL"||tag=="UL"||tag=="DIR"||tag=="MENU"||
  2757. tag=="FORM"||tag=="SELECT"||tag=="MAP"||tag=="DL"||tag=="HEAD"||
  2758. tag=="BODY"||tag=="HTML")
  2759. arrReturn=["n","","n"];
  2760. if( tag=="STYLE"||tag=="SCRIPT")
  2761. arrReturn=["n","",""];
  2762. if(tag=="BR"||tag=="HR")
  2763. arrReturn=["","n",""];
  2764. return arrReturn;
  2765. }
  2766. function fixAttr(s)
  2767. {
  2768. s = String(s).replace(/&/g, "&amp;");
  2769. s = String(s).replace(/</g, "&lt;");
  2770. s = String(s).replace(/"/g, "&quot;");
  2771. return s;
  2772. }
  2773. function fixVal(s)
  2774. {
  2775. s = String(s).replace(/&/g, "&amp;");
  2776. s = String(s).replace(/</g, "&lt;");
  2777. return s;
  2778. }
  2779. function recur(oEl,sTab)
  2780. {
  2781. var sHTML="";
  2782. for(var i=0;i<oEl.childNodes.length;i++)
  2783. {
  2784. var oNode=oEl.childNodes(i);
  2785. if(oNode.nodeType==1)//tag
  2786. {
  2787. var sTagName = oNode.nodeName;
  2788. var bDoNotProcess=false;
  2789. if(sTagName.substring(0,1)=="/")
  2790. {
  2791. bDoNotProcess=true;//do not process
  2792. }
  2793. else
  2794. {
  2795. /*** tabs ***/
  2796. var sT= sTab;
  2797. sHTML+= lineBreak1(sTagName)[0];
  2798. if(lineBreak1(sTagName)[0] !="") sHTML+= sT;//If new line, use base Tabs
  2799. /************/
  2800. }
  2801. if(bDoNotProcess)
  2802. {
  2803. ;//do not process
  2804. }
  2805. else if(sTagName=="OBJECT" || sTagName=="EMBED")
  2806. {
  2807. s=oNode.outerHTML;
  2808. s=s.replace(/"[^"]*"/ig,function(x){
  2809. x=x.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/[s+]/ig,"#_#");
  2810. return x});
  2811. s=s.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()});
  2812. s=s.replace(/ ([^=]+)=([^"' >]+)/ig," $1="$2"");//new
  2813. s=s.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
  2814. s=s.replace(/#_#/ig," ");
  2815. s=s.replace(/<param([^>]*)>/ig,"n<param$1 />").replace(// />$/ig," />");//no closing tag
  2816. if(sTagName=="EMBED")
  2817. if(oNode.innerHTML=="")
  2818. s=s.replace(/>$/ig," />").replace(// />$/ig,"/>");//no closing tag
  2819. s=s.replace(/<param name="Play" value="0" />/,"<param name="Play" value="-1" />");
  2820. sHTML+=s;
  2821. }
  2822. else if(sTagName=="TITLE")
  2823. {
  2824. sHTML+="<title>"+oNode.innerHTML+"</title>";
  2825. }
  2826. else
  2827. {
  2828. if(sTagName=="AREA")
  2829. {
  2830. var sCoords=oNode.coords;
  2831. var sShape=oNode.shape;
  2832. }
  2833. var oNode2=oNode.cloneNode();
  2834. s=oNode2.outerHTML.replace(/</[^>]*>/,"");
  2835. if(sTagName=="STYLE")
  2836. {
  2837. var arrTmp=s.match(/<[^>]*>/ig);
  2838. s=arrTmp[0];
  2839. }
  2840. s=s.replace(/"[^"]*"/ig,function(x){
  2841. //x=x.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/[s+]/ig,"#_#");
  2842. //x=x.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/[s+]/ig,"#_#");
  2843. x=x.replace(/&/g, "&amp;").replace(/&amp;amp;/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/[s+]/ig,"#_#");
  2844. return x});
  2845. //info ttg: .replace(/&amp;amp;/g, "&amp;")
  2846. //ini karena '&' di (hanya) '&amp;' selalu di-replace lagi dgn &amp;.
  2847. //tapi kalau &lt; , &gt; tdk (no problem) => default behaviour
  2848. s=s.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()});
  2849. s=s.replace(/ ([^=]+)=([^" >]+)/ig," $1="$2"");
  2850. s=s.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
  2851. s=s.replace(/#_#/ig," ");
  2852. //single attribute
  2853. s=s.replace(/[<hr]?(noshade)/ig,"noshade="noshade"");
  2854. s=s.replace(/[<input]?(checked)/ig,"checked="checked"");
  2855. s=s.replace(/[<select]?(multiple)/ig,"multiple="multiple"");
  2856. s=s.replace(/[<option]?(selected)/ig,"selected="true"");
  2857. s=s.replace(/[<input]?(readonly)/ig,"readonly="readonly"");
  2858. s=s.replace(/[<input]?(disabled)/ig,"checked="disabled"");
  2859. s=s.replace(/[<td]?(nowrap )/ig,"nowrap="nowrap" ");
  2860. s=s.replace(/[<td]?(nowrap>)/ig,"nowrap="nowrap">");
  2861. s=s.replace(/ contenteditable="true"/ig,"");
  2862. if(sTagName=="AREA")
  2863. {
  2864. s=s.replace(/ coords="0,0,0,0"/ig," coords=""+sCoords+""");
  2865. s=s.replace(/ shape="RECT"/ig," shape=""+sShape+""");
  2866. }
  2867. var bClosingTag=true;
  2868. if(sTagName=="IMG"||sTagName=="BR"||
  2869. sTagName=="AREA"||sTagName=="HR"||
  2870. sTagName=="INPUT"||sTagName=="BASE"||
  2871. sTagName=="LINK")//no closing tag
  2872. {
  2873. s=s.replace(/>$/ig," />").replace(// />$/ig,"/>");//no closing tag
  2874. bClosingTag=false;
  2875. }
  2876. sHTML+=s;
  2877. /*** tabs ***/
  2878. if(sTagName!="TEXTAREA")sHTML+= lineBreak1(sTagName)[1];
  2879. if(sTagName!="TEXTAREA")if(lineBreak1(sTagName)[1] !="") sHTML+= sT;//If new line, use base Tabs
  2880. /************/
  2881. if(bClosingTag)
  2882. {
  2883. /*** CONTENT ***/
  2884. s=oNode.outerHTML;
  2885. if(sTagName=="SCRIPT")
  2886. {
  2887. s = s.replace(/<script([^>]*)>[n+s+t+]*/ig,"<script$1>");//clean spaces
  2888. s = s.replace(/[n+s+t+]*</script>/ig,"</script>");//clean spaces
  2889. s = s.replace(/<script([^>]*)>//<![CDATA[/ig,"");
  2890. s = s.replace(///]]></script>/ig,"");
  2891. s = s.replace(/<script([^>]*)>/ig,"");
  2892. s = s.replace(/</script>/ig,"");
  2893. s = s.replace(/^s+/,'').replace(/s+$/,'');
  2894. sHTML+="n"+
  2895. sT + "//<![CDATA[n"+
  2896. sT + s + "n"+
  2897. sT + "//]]>n"+sT;
  2898. }
  2899. if(sTagName=="STYLE")
  2900. {
  2901. s = s.replace(/<style([^>]*)>[n+s+t+]*/ig,"<style$1>");//clean spaces
  2902. s = s.replace(/[n+s+t+]*</style>/ig,"</style>");//clean spaces
  2903. s = s.replace(/<style([^>]*)><!--/ig,"");
  2904. s = s.replace(/--></style>/ig,"");
  2905. s = s.replace(/<style([^>]*)>/ig,"");
  2906. s = s.replace(/</style>/ig,"");
  2907. s = s.replace(/^s+/,"").replace(/s+$/,"");
  2908. sHTML+="n"+
  2909. sT + "<!--n"+
  2910. sT + s + "n"+
  2911. sT + "-->n"+sT;
  2912. }
  2913. if(sTagName=="DIV"||sTagName=="P")
  2914. {
  2915. if(oNode.innerHTML==""||oNode.innerHTML=="&nbsp;")
  2916. {
  2917. sHTML+="&nbsp;";
  2918. }
  2919. else sHTML+=recur(oNode,sT+"t");
  2920. }
  2921. else
  2922. {
  2923. sHTML+=recur(oNode,sT+"t");
  2924. }
  2925. /*** tabs ***/
  2926. if(sTagName!="TEXTAREA")sHTML+=lineBreak1(sTagName)[2];
  2927. if(sTagName!="TEXTAREA")if(lineBreak1(sTagName)[2] !="")sHTML+=sT;//If new line, use base Tabs
  2928. /************/
  2929. sHTML+="</" + sTagName.toLowerCase() + ">";
  2930. }
  2931. }
  2932. }
  2933. else if(oNode.nodeType==3)//text
  2934. {
  2935. sHTML+= fixVal(oNode.nodeValue);
  2936. }
  2937. else if(oNode.nodeType==8)
  2938. {
  2939. if(oNode.outerHTML.substring(0,2)=="<"+"%")
  2940. {//server side script
  2941. sTmp=(oNode.outerHTML.substring(2));
  2942. sTmp=sTmp.substring(0,sTmp.length-2);
  2943. sTmp = sTmp.replace(/^s+/,"").replace(/s+$/,"");
  2944. /*** tabs ***/
  2945. var sT= sTab;
  2946. /************/
  2947. sHTML+="n" +
  2948. sT + "<%n"+
  2949. sT + sTmp + "n" +
  2950. sT + "%>n"+sT;
  2951. }
  2952. else
  2953. {//comments
  2954. sTmp=oNode.nodeValue;
  2955. sTmp = sTmp.replace(/^s+/,"").replace(/s+$/,"");
  2956. sHTML+="n" +
  2957. sT + "<!--n"+
  2958. sT + sTmp + "n" +
  2959. sT + "-->n"+sT;
  2960. }
  2961. }
  2962. else
  2963. {
  2964. ;//Not Processed
  2965. }
  2966. }
  2967. return sHTML;
  2968. }
  2969. /*********************
  2970. TOOLBAR ICONS
  2971. **********************/
  2972. var buttonArrays=[];
  2973. var buttonArraysCount=0;
  2974. function writeIconToggle(id,command,img,title)
  2975. {
  2976. w=this.iconWidth;
  2977. h=this.iconHeight;
  2978. imgPath=this.scriptPath+this.iconPath+img;
  2979. sHTML=""+
  2980. "<td unselectable='on' style='padding-right:1px;VERTICAL-ALIGN: top;margin-left:0;margin-right:1px;margin-bottom:1px;width:"+w+"px;height:"+h+"px;'>"+
  2981. "<span unselectable='on' style='position:absolute;clip: rect(0 "+w+"px "+h+"px 0)'>"+
  2982. "<img name=""+id+"" id=""+id+"" btnIndex=""+buttonArraysCount+"" unselectable='on' src='"+imgPath+"' style='position:absolute;top:-0;width:"+w+"px'"+
  2983. "onmouseover='doOver(this)' "+
  2984. "onmouseout='doOut(this)' "+
  2985. "onmousedown='doDown(this)' "+
  2986. "onmouseup="if(doUpToggle(this)){"+command+"}" alt=""+title+"">"+
  2987. "</span></td>";
  2988. sHTML="<table align=left cellpadding=0 cellspacing=0 style='table-layout:fixed;'><tr>"+sHTML+"</tr></table>";
  2989. buttonArrays.push(["inactive"]);
  2990. buttonArraysCount++;
  2991. return sHTML;
  2992. }
  2993. function writeIconStandard(id,command,img,title)
  2994. {
  2995. w=this.iconWidth;
  2996. h=this.iconHeight;
  2997. imgPath=this.scriptPath+this.iconPath+img;
  2998. sHTML=""+
  2999. "<td unselectable='on' style='padding-right:1px;VERTICAL-ALIGN: top;margin-left:0;margin-right:1px;margin-bottom:1px;width:"+w+"px;height:"+h+"px;'>"+
  3000. "<span unselectable='on' style='position:absolute;clip: rect(0 "+w+"px "+h+"px 0)'>"+
  3001. "<img name=""+id+"" id=""+id+"" btnIndex=""+buttonArraysCount+"" unselectable='on' src='"+imgPath+"' style='position:absolute;top:-0;width:"+w+"px'"+
  3002. "onmouseover='doOver(this)' "+
  3003. "onmouseout='doOut(this)' "+
  3004. "onmousedown='doDown(this)' "+
  3005. "onmouseup="if(doUp(this)){"+command+"}" alt=""+title+"">"+
  3006. "</span></td>";
  3007. sHTML="<table align=left cellpadding=0 cellspacing=0 style='table-layout:fixed;'><tr>"+sHTML+"</tr></table>";
  3008. buttonArrays.push(["inactive"]);
  3009. buttonArraysCount++;
  3010. return sHTML;
  3011. }
  3012. function writeBreakSpace()
  3013. {
  3014. w=this.iconWidth;
  3015. h=this.iconHeight;
  3016. imgPath=this.scriptPath+this.iconPath+"brkspace.gif";
  3017. sHTML=""+
  3018. "<td unselectable='on' style='padding-left:0px;padding-right:0px;VERTICAL-ALIGN:top;margin-bottom:1px;width:5px;height:"+h+"px;'>"+
  3019. "<img unselectable='on' src='"+imgPath+"'></td>";
  3020. sHTML="<table align=left cellpadding=0 cellspacing=0 style='table-layout:fixed;'><tr>"+sHTML+"</tr></table>";
  3021. return sHTML;
  3022. }
  3023. function writeDropDown(id,command,img,title,width)
  3024. {
  3025. w=width;
  3026. h=this.iconHeight;
  3027. /*** Localization ***/
  3028. imgPath=this.scriptPath+this.iconPath+oUtil.langDir+"/"+img;
  3029. /*** /Localization ***/
  3030. sHTML=""+
  3031. "<td unselectable='on' style='padding-right:1px;VERTICAL-ALIGN: top;margin-left:0;margin-right:1px;margin-bottom:1px;width:"+w+"px;height:"+h+"px;'>"+
  3032. "<span unselectable='on' style='position:absolute;clip: rect(0 "+w+"px "+h+"px 0)'>"+
  3033. "<img name=""+id+"" id=""+id+"" btnIndex=""+buttonArraysCount+"" unselectable='on' src='"+imgPath+"' style='position:absolute;top:-0;width:"+w+"px'"+
  3034. "onmouseover='doOver(this)' "+
  3035. "onmouseout='doOut(this)' "+
  3036. "onmousedown='doDown(this)' "+
  3037. "onmouseup="if(doUp(this)){"+command+"}" alt=""+title+"">"+
  3038. "</span></td>";
  3039. sHTML="<table align=left cellpadding=0 cellspacing=0 style='table-layout:fixed;'><tr>"+sHTML+"</tr></table>";
  3040. buttonArrays.push(["inactive"]);
  3041. buttonArraysCount++;
  3042. return sHTML;
  3043. }
  3044. function doOver(btn)
  3045. {
  3046. btnArr=buttonArrays[btn.btnIndex];
  3047. if(btnArr[0]=="inactive")btn.style.top=-24;//no.2
  3048. }
  3049. function doDown(btn)
  3050. {
  3051. btnArr=buttonArrays[btn.btnIndex];
  3052. if(btnArr[0]!="disabled")btn.style.top=-48;//no.3
  3053. }
  3054. var bCancel=false;
  3055. function doOut(btn)
  3056. {
  3057. if(btn.style.top=="-48px")
  3058. {//lagi pushed tapi mouseout (cancel)
  3059. bCancel=true;
  3060. }
  3061. btnArr=buttonArrays[btn.btnIndex];
  3062. if(btnArr[0]=="active")btn.style.top=-72;//no.4 (remain active/pushed)
  3063. if(btnArr[0]=="inactive")btn.style.top=0;//no.1 (remain inactive)
  3064. }
  3065. function doUpToggle(btn)
  3066. {
  3067. if(bCancel)
  3068. {//lagi pushed tapi mouseout (cancel)
  3069. bCancel=false;btn.style.top=0;
  3070. return false;
  3071. }
  3072. btnArr = buttonArrays[btn.btnIndex];
  3073. if(btnArr[0]=="inactive")
  3074. {
  3075. btn.style.top=-72;//no.4
  3076. btnArr[0]="active";
  3077. return true;
  3078. }
  3079. if(btnArr[0]=="active")
  3080. {
  3081. btn.style.top=-24;//no.2
  3082. btnArr[0]="inactive";
  3083. return true;
  3084. }
  3085. }
  3086. function doUp(btn)//return true/false
  3087. {
  3088. if(bCancel)
  3089. {//lagi pushed tapi mouseout (cancel)
  3090. bCancel=false;btn.style.top=0;
  3091. return false;
  3092. }
  3093. btnArr=buttonArrays[btn.btnIndex];
  3094. if(btnArr[0]=="disabled") return false;
  3095. btn.style.top=-24;//no.2
  3096. return true;
  3097. }
  3098. function makeEnablePushed(btn)
  3099. {
  3100. btnArr=buttonArrays[btn.btnIndex];
  3101. btnArr[0]="active";
  3102. btn.style.top=-72;//no.4
  3103. }
  3104. function makeEnableNormal(btn)
  3105. {
  3106. btnArr=buttonArrays[btn.btnIndex];
  3107. btnArr[0]="inactive";
  3108. btn.style.top=0;//no.1
  3109. }
  3110. function makeDisabled(btn)
  3111. {
  3112. btnArr=buttonArrays[btn.btnIndex];
  3113. btnArr[0]="disabled";
  3114. btn.style.top=-96;//no.5
  3115. }