editor.js
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:122k
源码类别:

数据库编程

开发平台:

ASP/ASPX

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