var chutil = new CH_UTILITIES();
var GB = {
colors : [
"#FF0000", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFFFFF", "#F5F5F5", "#DCDCDC", "#FFFAFA",
"#D3D3D3", "#C0C0C0", "#A9A9A9", "#808080", "#696969", "#000000", "#2F4F4F", "#708090", "#778899", "#4682B4",
"#4169E1", "#6495ED", "#B0C4DE", "#7B68EE", "#6A5ACD", "#483D8B", "#191970", "#000080", "#00008B", "#0000CD",
"#1E90FF", "#00BFFF", "#87CEFA", "#87CEEB", "#ADD8E6", "#B0E0E6", "#F0FFFF", "#E0FFFF", "#AFEEEE", "#00CED1",
"#5F9EA0", "#48D1CC", "#00FFFF", "#40E0D0", "#20B2AA", "#008B8B", "#008080", "#7FFFD4", "#66CDAA", "#8FBC8F",
"#3CB371", "#2E8B57", "#006400", "#008000", "#228B22", "#32CD32", "#00FF00", "#7FFF00", "#7CFC00", "#ADFF2F",
"#98FB98", "#90EE90", "#00FF7F", "#00FA9A", "#556B2F", "#6B8E23", "#808000", "#BDB76B", "#B8860B", "#DAA520",
"#FFD700", "#F0E68C", "#EEE8AA", "#FFEBCD", "#FFE4B5", "#F5DEB3", "#FFDEAD", "#DEB887", "#D2B48C", "#BC8F8F",
"#A0522D", "#8B4513", "#D2691E", "#CD853F", "#F4A460", "#8B0000", "#800000", "#A52A2A", "#B22222", "#CD5C5C",
"#F08080", "#FA8072", "#E9967A", "#FFA07A", "#FF7F50", "#FF6347", "#FF8C00", "#FFA500", "#FF4500", "#DC143C",
"#FF0000", "#FF1493", "#FF00FF", "#FF69B4", "#FFB6C1", "#FFC0CB", "#DB7093", "#C71585", "#800080", "#8B008B",
"#9370DB", "#8A2BE2", "#4B0082", "#9400D3", "#9932CC", "#BA55D3", "#DA70D6", "#EE82EE", "#DDA0DD", "#D8BFD8",
"#E6E6FA", "#F8F8FF", "#F0F8FF", "#F5FFFA", "#F0FFF0", "#FAFAD2", "#FFFACD", "#FFF8DC", "#FFFFE0", "#FFFFF0",
"#FFFAF0", "#FAF0E6", "#FDF5E6", "#FAEBD7", "#FFE4C4", "#FFDAB9", "#FFEFD5", "#FFF5EE", "#FFF0F5", "#FFE4E1"
],
htmlKey : [
"!doctype", "a", "abbr", "acronym", "address", "applet", "area", "b", "base", "basefont", "bgsound", "bdo",
"big", "blink", "dl", "body", "br", "button", "caption", "center", "cite", "code", "col", "colgroup",
"comment", "dd", "del", "dfn", "dir", "div", "font", "dt", "em", "embed", "fieldset", "blockquote",
"form", "frame", "frameset", "h", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr",
"html", "i", "iframe", "img", "input", "ins", "isindex", "kbd", "label", "legend", "li", "link",
"listing", "map", "marquee", "menu", "meta", "multicol", "nextid", "nobr", "noframes", "noscript", "object", "ol",
"optgroup", "option", "p", "param", "plaintext","pre", "q", "s", "samp", "script", "select", "server",
"small", "sound", "spacer", "span", "strike", "strong", "style", "sub", "sup", "table", "tbody", "td",
"textarea", "title", "tfoot", "th", "thead", "textflow", "tr", "tt", "u", "ul", "var", "wbr", "xmp" ],
MSIE : navigator.userAgent.toLowerCase().indexOf("msie") != -1,
CHROME : navigator.userAgent.toLowerCase().indexOf('chrome') != -1,
GECKO : navigator.userAgent.toLowerCase().indexOf('gecko') != -1,
OPERA : navigator.userAgent.toLowerCase().indexOf('opera') != -1,
editorMode : 'rich',
popupIFrame : ['fontType', 'fontSize', 'paragraph', 'boxStyle', 'foreColor', 'backColor', 'BGColor'],
imageBorder : '#ccc solid',
currentRS : new Object(),
autoHeight : false,
frameFocus : (navigator.userAgent.toLowerCase().indexOf("msie") != -1) ? 'onfocus' : 'onload',
LANG : { toolTip : { btnPrint : 'Àμâ',
btnUndo : '½ÇÇàÃë¼Ò',
btnRedo : 'µÇµ¹¸®±â',
btnCopy : 'º¹»ç',
btnCut : 'À߶󳻱â',
btnPaste : 'ºÙÀ̱â',
btnPasteFromWord : 'MS¿öµå ºÙÀ̱â',
btnSelectAll : 'Àüü ¼±ÅÃ',
btnBold : 'ÁøÇÏ°Ô',
btnUnderline : '¹ØÁÙ',
btnStrike : 'Ãë¼Ò¼±',
btnItalic : '±â¿ïÀÓ',
btnSuperscript : 'À§Ã·ÀÚ',
btnSubscript : '¾Æ·¡Ã·ÀÚ',
btnJustifyLeft : '¿ÞÂÊ Á¤·Ä',
btnJustifyCenter : '°¡¿îµ¥ Á¤·Ä',
btnJustifyRight : '¿À¸¥ÂÊ Á¤·Ä',
btnJustifyFull : '¾çÂÊ Á¤·Ä',
btnOrderedList : '¹®´Ü ¹øÈ£',
btnUnOrderedList : '±Û ¸Ó¸®Ç¥',
btnOutdent : '¿ÞÂÊ¿©¹é ÁÙÀ̱â',
btnIndent : '¿ÞÂÊ¿©¹é ´Ã¸®±â',
btnFontType : '±Û²Ã',
btnParagraph : 'Á¦¸ñ',
btnFontSize : '±Û²Ã Å©±â',
btnBoxStyle : '¹Ú½º',
btnBackColor : 'Çü±¤Ææ',
btnForeColor : '±ÛÀÚ»ö',
btnBGColor : '¹ÙÅÁ»ö',
btnSChar : 'Ư¼ö ¹®ÀÚ',
btnHyperLink : 'ÇÏÀÌÆÛ¸µÅ©',
btnUnLink : 'ÇÏÀÌÆÛ¸µÅ© ÇØÁ¦',
btnFlash : 'Ç÷¡½¬ ¹«ºñ',
btnMedia : '¹Ìµð¾î',
btnUploadImage : '±×¸² ³Ö±â',
btnBGImage : '¹è°æ ±×¸²',
btnEmotion : 'Ç¥Á¤ ¾ÆÀÌÄÜ',
btnHR : '°¡·Î¼±',
btnTable : 'Ç¥',
btnPageBreak : 'Àμâ ÆäÀÌÁö ³ª´®' }
}
}
function CH_UTILITIES()
{
this.oname;
}
function cheditor(oname)
{
if (typeof(document.execCommand) == 'undefined')
return;
if (GB.MSIE) {
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 5.5) {
this.run = function() {
document.write("");
};
return;
}
}
if (GB.GECKO) {
if (navigator.productSub < 20030107) {
this.run = function() {
document.write("");
};
return;
}
}
this.config = {
editorWidth : '100%',
editorHeight : '300px',
editorFontSize : '9pt',
editorFontFace : 'gulim',
editorBorder : '1px solid #ccc',
tabIndex : 0,
lineHeight : '17px',
editorPath : '.',
popupAutoKill : true,
fullHTMLSource : true,
hrefTarget : '_blank',
showTagPath : true,
toolBarSplit : true,
useBR : true,
imgMaxWidth : 400,
imgReSize : true,
includeHostname : true,
editAreaMargin : '7px',
useSource : true,
usePreview : true,
usePrint : true,
useUndo : true,
useRedo : true,
useCopy : true,
useCut : true,
usePaste : true,
usePasteFromWord: true,
useSelectAll : true,
useBold : true,
useUnderline : true,
useStrike : true,
useItalic : true,
useSuperscript : true,
useSubscript : true,
useJustifyLeft : true,
useJustifyCenter: true,
useJustifyRight : true,
useJustifyFull : true,
useOrderedList : true,
useUnOrderedList: true,
useOutdent : true,
useIndent : true,
useFontType : true,
useParagraph : true,
useFontSize : true,
useBackColor : true,
useForeColor : true,
useBGColor : true,
useSChar : true,
useHyperLink : true,
useUnLink : true,
useFlash : true,
useMedia : true,
useUploadImage : true,
useBGImage : true,
useEmotion : true,
useHR : true,
autoHeight : false,
useTable : true,
useBoxStyle : true,
usePageBreak : true
};
this.selectedColor = '#ffc985';
this.editorPopupBgcolor = '#e3efff';
this.oname = oname;
this.editArea = null;
this.editAreaWrapper = null;
this.inputForm = null;
this.selection = null;
this.selectionType = null;
this.displayMode = 'RICH';
this.szTmp = '';
this.undoSteps = 20;
this.undoTimeout = 500;
this.undoQueue = new Array(this.undoSteps);
this.undoPos = -1;
this.customUndo = true;
this.timerUndo = null;
this.images = new Array();
this.toolbarRow1 = new Object();
this.toolbarRow2 = new Object();
this.popupID = null;
this.currentMode = 'rich';
}
cheditor.prototype = {
plainMode : function () {
this.editAreaWrapper.style.display = 'none';
document.getElementById('idToolbar_'+this.oname).style.display = 'none';
document.getElementById('editArea_'+this.oname).style.display = 'none';
document.getElementById('checkBox_'+this.oname).style.display = 'none';
document.getElementById('plainId_'+this.oname).style.display = '';
document.getElementById('plainId_'+this.oname).focus();
if (this.config.showTagPath)
document.getElementById('statusBlock'+this.oname).style.display = 'none';
this.resetData();
},
htmlMode : function () {
document.getElementById('plainId_'+this.oname).style.display = 'none';
this.editAreaWrapper.style.display = '';
document.getElementById('editArea_'+this.oname).style.display = '';
document.getElementById('idToolbar_'+this.oname).style.display = '';
document.getElementById('checkBox_'+this.oname).style.display = '';
if (this.config.showTagPath)
document.getElementById('statusBlock'+this.oname).style.display = '';
this.resetData();
this.editArea.focus();
},
createTextarea : function () {
var wrapper = document.getElementById('container_'+this.oname);
var textarea = document.createElement("textarea");
textarea.style.width = this.config.editorWidth;
textarea.style.height = this.config.editorHeight;
textarea.style.border = this.config.editorBorder;
textarea.style.padding = '10px';
textarea.id = "plainId_"+this.oname;
textarea.style.display = 'none';
textarea.style.fontSize = '9pt';
textarea.style.position = 'relative';
if (this.config.tabIndex) textarea.tabIndex = this.config.tabIndex;
wrapper.appendChild(textarea);
},
useBR : function (el) {
this.editArea.focus();
},
resetData : function () {
if (GB.editorMode == 'rich') {
document.getElementById('plainId_'+this.oname).value = this.outputBodyText();
GB.editorMode = 'plain';
}
else {
var szPlain = document.getElementById('plainId_'+this.oname).value;
szPlain = szPlain.replace(/\n/g,'
');
this.resetEditArea(szPlain);
this.setEditorOpt();
GB.editorMode = 'rich';
}
},
undoSnapshot : function () {
++this.undoPos;
if (this.undoPos >= this.undoSteps) {
this.undoQueue.shift();
--this.undoPos;
}
var take = true;
var txt = this.getContents(false);
if (this.undoPos > 0) take = (this.undoQueue[this.undoPos - 1] != txt);
take ? this.undoQueue[this.undoPos] = txt : this.undoPos--;
},
updateUndoQueue : function () {
if (this.customUndo && !this.timerUndo) {
this.undoSnapshot();
var editor = this;
this.timerUndo = setTimeout(function() { editor.timerUndo = null;}, this.undoTimeout);
}
},
resetEditArea : function (loadContents) {
this.editAreaWrapper.style.visibility = 'hidden';
var oEditor = document.getElementById('id'+this.oname).contentWindow;
oEditor.document.designMode = "on";
if (!GB.MSIE) oEditor.document.execCommand('useCSS', false, false);
oEditor.document.open("text/html", "replace");
oEditor.document.write("
"+loadContents+"");
oEditor.document.close();
this.editAreaWrapper.style.margin = '0px';
this.editAreaWrapper.style.padding = '0px';
this.editAreaWrapper.fontSize = this.config.editorFontSize;
oEditor.document.body.style.fontSize = this.config.editorFontSize;
oEditor.document.body.style.fontFamily = this.config.editorFontFace;
oEditor.document.body.style.margin = this.config.editAreaMargin;
oEditor.document.body.style.lineHeight = this.config.lineHeight;
this.editAreaWrapper.style.visibility = 'visible';
return oEditor;
},
startDrag : function (event) {
GB.currentRS.elNode = this.editAreaWrapper;
var y = GB.MSIE ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop :
event.clientY + window.pageYOffset;
GB.currentRS.cursorStartY = y;
GB.currentRS.elStartTop = parseInt(GB.currentRS.elNode.style.height);
if (isNaN(GB.currentRS.elStartTop)) GB.currentRS.elStartTop = 0;
if (GB.MSIE) {
document.attachEvent("onmousemove", this.dragGo);
document.attachEvent("onmouseup", this.dragStop);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
else {
if (GB.GECKO) GB.currentRS.elNode.style.visibility = 'hidden';
document.addEventListener("mousemove", this.dragGo, true);
document.addEventListener("mouseup", this.dragStop, true);
event.preventDefault();
}
},
dragGo : function (event) {
var y = (GB.MSIE) ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop :
event.clientY + window.pageYOffset;
var h = (GB.currentRS.elStartTop + y - GB.currentRS.cursorStartY);
GB.currentRS.elNode.style.height = (h < 1 ? 1 : h) + 'px';
if (GB.MSIE) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
else
event.preventDefault();
},
dragStop : function () {
if (GB.MSIE) {
document.detachEvent("onmousemove", eval(chutil.oname).dragGo);
document.detachEvent("onmouseup", eval(chutil.oname).dragStop);
}
else {
if (GB.GECKO) GB.currentRS.elNode.style.visibility = 'visible';
document.removeEventListener("mousemove", eval(chutil.oname).dragGo, true);
document.removeEventListener("mouseup", eval(chutil.oname).dragStop, true);
}
},
switchEditorMode : function (which) {
this.editArea.focus();
if (this.currentMode == which) return;
switch (which) {
case 'rich' :
if (this.currentMode == 'preview')
this.previewMode();
else if (this.currentMode == 'code')
this.editMode();
document.getElementById('tabEditModeRich'+this.oname).src = this.config.editorPath+'/icons/edit_mode_rich_a.gif';
if (this.config.useSource) document.getElementById('tabEditModeCode'+this.oname).src = this.config.editorPath+'/icons/edit_mode_code_b.gif';
document.getElementById('tabEditModePreview'+this.oname).src = this.config.editorPath+'/icons/edit_mode_view_b.gif';
break;
case 'code' :
document.getElementById('tabEditModeRich'+this.oname).src = this.config.editorPath+'/icons/edit_mode_rich_b.gif';
document.getElementById('tabEditModeCode'+this.oname).src = this.config.editorPath+'/icons/edit_mode_code_a.gif';
document.getElementById('tabEditModePreview'+this.oname).src = this.config.editorPath+'/icons/edit_mode_view_b.gif';
this.editMode();
break;
case 'preview' :
this.previewMode();
document.getElementById('tabEditModeRich'+this.oname).src = this.config.editorPath+'/icons/edit_mode_rich_b.gif';
if (this.config.useSource) document.getElementById('tabEditModeCode'+this.oname).src = this.config.editorPath+'/icons/edit_mode_code_b.gif';
document.getElementById('tabEditModePreview'+this.oname).src = this.config.editorPath+'/icons/edit_mode_view_a.gif';
break;
default : break;
}
this.currentMode = which;
},
run : function () {
document.write('');
this.drawToolbar();
document.write('
');
document.write('');
document.write('
');
document.write('
');
if (this.config.showTagPath) {
document.write('
');
document.write('
<html> <body>
');
document.write('
');
document.write('
');
}
document.write('
');
document.write('
');
if (this.config.useSource)
document.write('
');
document.write('
');
document.write('
');
var loadContents = '';
if (this.inputForm && document.getElementById(this.inputForm))
loadContents = document.getElementById(this.inputForm).value;
this.editAreaWrapper = document.getElementById("id"+this.oname);
this.editArea = this.resetEditArea(loadContents);
document.write('
');
var tmpeditor = eval("idtmp"+this.oname);
tmpeditor.document.designMode = "on";
tmpeditor.document.open("text/html","replace");
tmpeditor.document.write("");
tmpeditor.document.close();
if (!document.getElementById("foreColor_"+this.oname)) {
htmlOutput = this.createWindow(200, this.setColorTable('fore'));
document.write('
');
var doc = document.getElementById('foreColor_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("backColor_"+this.oname)) {
htmlOutput = this.createWindow(200, this.setColorTable('back'));
document.write('
');
var doc = document.getElementById('backColor_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("BGColor_"+this.oname)) {
htmlOutput = this.createWindow(200, this.setColorTable('bgColor'));
document.write('
');
var doc = document.getElementById('BGColor_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("fontType_"+this.oname)){
htmlOutput = '
' +
"
±Û²Ã ¸ð¾ç
"+
"
" +
"
" +
"
°¡³ª´Ù¶ó¸¶¹Ù»ç (±¼¸²)
" +
"
°¡³ª´Ù¶ó¸¶¹Ù»ç (¹ÙÅÁ)
" +
"
°¡³ª´Ù¶ó¸¶¹Ù»ç (µ¸¿ò)
" +
"
°¡³ª´Ù¶ó¸¶¹Ù»ç (±Ã¼)
" +
"
ABCDEFGHIJK (Arial)
" +
"
ABCDEFGHIJK (Arial Black)
" +
"
ABCDEFGHIJK (Arial Narrow)
" +
"
ABCDEFGHIJK (Comic Sans MS)
" +
"
ABCDEFGHIJK (Courier New)
" +
"
ABCDEFGHIJK (Tahoma)
" +
"
ABCDEFGHIJK (Times New Roman)
" +
"
ABCDEFGHIJK (Verdana)
" +
"
";
htmlOutput = this.createWindow(220, htmlOutput);
document.write('
');
var doc = document.getElementById('fontType_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("paragraph_"+this.oname)) {
htmlOutput = '
' +
"
Á¦¸ñ ¼±ÅÃ
"+
"
" +
"
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 1
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 2
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 3
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 4
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 5
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Á¦¸ñ 6
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
Preformatted
" +
"
')\" align='center' onmouseover='parent."+this.oname+".mouseOver(this)' onmouseout='parent."+this.oname+".mouseOut(this)' class='dropdown' style='padding:3px;margin:1px'>
º¸Åë
" +
"
";
htmlOutput = this.createWindow(200, htmlOutput);
document.write('
');
var doc = document.getElementById('paragraph_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("fontSize_"+this.oname)) {
htmlOutput = '
' +
"
±Û²Ã Å©±â
"+
"
" +
"
" +
"
°¡³ª´Ù¶ó (8pt)
" +
"
°¡³ª´Ù¶ó (9pt)
" +
"
°¡³ª´Ù¶ó (10pt)
" +
"
°¡³ª´Ù¶ó (11pt)
" +
"
°¡³ª´Ù¶ó (12pt)
" +
"
°¡³ª´Ù¶ó (14pt)
" +
"
°¡³ª´Ù¶ó (16pt)
" +
"
°¡³ª´Ù¶ó (18pt)
" +
"
";
htmlOutput = this.createWindow(200, htmlOutput);
document.write('
');
var doc = document.getElementById('fontSize_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
if (!document.getElementById("boxStyle_"+this.oname)){
htmlOutput = '
' +
"
¹Ú½º ½ºÅ¸ÀÏ
"+
"
" +
"
" +
"
°¡³ª´Ù ABC
" +
"
°¡³ª´Ù ABC
" +
"
°¡³ª´Ù ABC
" +
"
°¡³ª´Ù ABC
" +
"
°¡³ª´Ù ABC
" +
"
°¡³ª´Ù ABC
" +
"
";
htmlOutput = this.createWindow(100, htmlOutput);
document.write('
');
var doc = document.getElementById('boxStyle_'+this.oname).contentWindow;
doc.document.open("text/html","replace");
doc.document.write(htmlOutput);
doc.document.close();
}
document.write('
');
document.write('
');
document.write('
');
document.write('
'); //Container
this.popupID = document.getElementById('dwindow_'+this.oname);
GB.autoHeight = this.config.autoHeight;
this.editArea.focus();
this.createTextarea();
this.setEditorOpt();
},
thisTest : function ()
{
alert('hello');
},
setEditorOpt : function () {
var editor = this;
if (GB.MSIE) this.editArea.document.onkeydown = this.doOnKeyPress;
this.addEvent(this.editArea.document, "mouseup");
this.addEvent(this.editArea.document, "keyup");
},
addEvent : function (doc, ev) {
this.updateUndoQueue();
var func = function () { cheditor.setEditorEvent(chutil.oname) };
if (GB.MSIE) {
doc.detachEvent("on"+ev, func);
doc.attachEvent("on"+ev, func);
}
else {
doc.removeEventListener(ev, func, true);
doc.addEventListener(ev, func, false);
}
},
toolbarButtonOut : function (elemButton) {
var nTop = elemButton.style.top.substring(0, elemButton.style.top.length - 2);
elemButton.style.top = nTop * 1 + 22 + 'px';
},
toolbarButtonOver : function (elemButton) {
var nTop = elemButton.style.top.substring(0, elemButton.style.top.length - 2);
elemButton.style.top = nTop - 22 + 'px';
},
preloadToolbar : function () {
var imgTag = '');
}
},
showToolbar : function (tb) {
for (var i in tb) {
if (tb[i].use == false) continue;
this.drawToolbarIcon(tb[i].icon[0],tb[i].icon[1],tb[i].icon[2],
i+this.oname, GB.LANG.toolTip[i], this.oname + tb[i].exec);
}
},
drawToolbar : function () {
this.preloadToolbar();
this.toolbarRow1 = {
//btnPrint : { use : this.config.usePrint, icon : [1,0,22], exec : ".doCmd('print', false)" },
btnUndo : { use : this.config.useUndo, icon : [1,44,22], exec : ".undo()" },
btnRedo : { use : this.config.useRedo, icon : [1,88,22], exec : ".redo()" },
//btnCopy : { use : this.config.useCopy, icon : [1,132,22], exec : ".doCmd('Copy', false)" },
//btnCut : { use : this.config.useCut, icon : [2,0,22], exec : ".doCmd('Cut', false)" },
//btnPaste : { use : this.config.usePaste, icon : [2,44,22], exec : ".doCmd('Paste', false)" },
//btnPasteFromWord : { use : this.config.usePasteFromWord, icon : [10,88,22], exec : ".doCmd('PasteFromWord', false)" },
//btnSelectAll : { use : this.config.useSelectAll, icon : [2,88,22], exec : ".doCmd('SelectAll', false)" },
btnBold : { use : this.config.useBold, icon : [2,132,22], exec : ".doCmd('Bold', false)" },
btnUnderline : { use : this.config.useUnderline, icon : [3,0,22], exec : ".doCmd('Underline', false)" },
btnStrike : { use : this.config.useStrike, icon : [3,44,22], exec : ".doCmd('Strikethrough', false)" },
btnItalic : { use : this.config.useItalic, icon : [3,88,22], exec : ".doCmd('Italic', false)" },
btnSuperscript : { use : this.config.useSuperscript, icon : [3,132,22], exec : ".doCmd('Superscript', false)" },
btnSubscript : { use : this.config.useSubscript, icon : [4,0,22], exec : ".doCmd('Subscript', false)" },
btnJustifyLeft : { use : this.config.useJustifyLeft, icon : [4,44,22], exec : ".doCmd('JustifyLeft', false)" },
btnJustifyCenter : { use : this.config.useJustifyCenter, icon : [4,88,22], exec : ".doCmd('JustifyCenter', false)" },
btnJustifyRight : { use : this.config.useJustifyRight, icon : [4,132,22], exec : ".doCmd('JustifyRight', false)" },
btnJustifyFull : { use : this.config.useJustifyFull, icon : [5,0,22], exec : ".doCmd('JustifyFull', false)" },
btnOrderedList : { use : this.config.useOrderedList, icon : [5,44,22], exec : ".doCmd('InsertOrderedList', false)" },
btnUnOrderedList : { use : this.config.useUnOrderedList, icon : [5,88,22], exec : ".doCmd('InsertUnOrderedList', false)" },
btnOutdent : { use : this.config.useOutdent, icon : [5,132,22], exec : ".doCmd('Outdent', false)" },
btnIndent : { use : this.config.useIndent, icon : [6,0,22], exec : ".doCmd('Indent', false)" }
};
this.toolbarRow2 = {
btnFontType : { use : this.config.useFontType, icon : [8,0,30], exec : ".windowPos(this,'fontType_"+this.oname+"');"+this.oname+".displayWindow('fontType_"+this.oname+"');" },
btnParagraph : { use : this.config.useParagraph, icon : [8,44,30], exec : ".windowPos(this,'paragraph_"+this.oname+"');"+this.oname+".displayWindow('paragraph_"+this.oname+"');" },
btnFontSize : { use : this.config.useFontSize, icon : [8,88,30], exec : ".windowPos(this,'fontSize_"+this.oname+"');"+this.oname+".displayWindow('fontSize_"+this.oname+"');" },
//btnBoxStyle : { use : this.config.useBoxStyle, icon : [11,0,22], exec : ".windowPos(this,'boxStyle_"+this.oname+"');"+this.oname+".displayWindow('boxStyle_"+this.oname+"');" },
btnBackColor : { use : this.config.useBackColor, icon : [9,88,22], exec : ".windowPos(this,'backColor_"+this.oname+"');"+this.oname+".displayWindow('backColor_"+this.oname+"');" },
btnForeColor : { use : this.config.useForeColor, icon : [9,132,22], exec : ".windowPos(this,'foreColor_"+this.oname+"');"+this.oname+".displayWindow('foreColor_"+this.oname+"');" },
//btnBGColor : { use : this.config.useBGColor, icon : [9,44,22], exec : ".windowPos(this,'BGColor_"+this.oname+"');"+this.oname+".displayWindow('BGColor_"+this.oname+"');" },
btnSChar : { use : this.config.useSChar, icon : [7,132,22], exec : ".windowOpen('schar')" },
btnHyperLink : { use : this.config.useHyperLink, icon : [6,44,22], exec : ".windowOpen('hyperLink')" },
btnUnLink : { use : this.config.useUnLink, icon : [6,88,22], exec : ".doCmd('UnLink',false)" },
btnFlash : { use : this.config.useFlash, icon : [9,0,22], exec : ".windowOpen('flash')" },
btnMedia : { use : this.config.useMedia, icon : [6,132,22], exec : ".windowOpen('media')" },
btnUploadImage : { use : this.config.useUploadImage, icon : [7,0,22], exec : ".windowOpen('image')" },
//btnBGImage : { use : this.config.useBGImage, icon : [7,44,22], exec : ".windowOpen('bgimage')" },
btnEmotion : { use : this.config.useEmotion, icon : [7,88,22], exec : ".windowOpen('emotion')" }
//,btnHR : { use : this.config.useHR, icon : [10,0,22], exec : ".doCmd('InsertHorizontalRule')" },
//btnTable : { use : this.config.useTable, icon : [10,44,22], exec : ".windowOpen('table')" }
//,btnPageBreak : { use : this.config.usePageBreak, icon : [10,132,22], exec : ".printPageBreak()" }
};
document.write('');
},
changeFontType : function (val) {
var el = document.getElementById('fontType_'+this.oname).contentWindow;
eval(el.document.getElementById("CHEditor").value).doCmdPopup("fontName",val);
},
setColor : function (color, _which) {
if (_which == 'back') {
var el = document.getElementById('backColor_'+this.oname).contentWindow;
eval(el.document.getElementById("CHEditor").value).doCmdPopup(GB.MSIE ? 'BackColor' : 'HiliteColor', color);
}
else {
var el = document.getElementById('foreColor_'+this.oname).contentWindow;
eval(el.document.getElementById("CHEditor").value).doCmdPopup('ForeColor', color);
}
},
setBgColor : function (color) {
var el = document.getElementById('BGColor_'+this.oname).contentWindow;
if (GB.MSIE)
eval(el.document.getElementById("CHEditor").value).doBgColor(color);
else
eval(el.document.getElementById("CHEditor").value).doCmdPopup("BackColor",color);
},
doBgColor : function (color) {
this.editArea.document.body.style.backgroundColor = color;
this.selection.select();
this.boxHide();
this.editArea.focus();
},
applyParagraph : function (val) {
var el = document.getElementById('paragraph_'+this.oname).contentWindow;
eval(el.document.getElementById("CHEditor").value).doCmdPopup("FormatBlock",val);
},
changeFontSize : function (val) {
var el = document.getElementById('fontSize_'+this.oname).contentWindow;
eval(el.document.getElementById("CHEditor").value).doCmdPopup("fontSize",val);
},
getElement : function (elm, tag) {
while (elm != null && elm.tagName != tag) {
if (elm.id == 'id'+this.oname) return null;
elm = elm.parentElement;
}
return elm;
},
hyperLink: function (szURL, szTarget, szTitle) {
var selection = this.selection;
var selectionType = this.selectionType;
var range, linked, targetEl;
if (GB.MSIE) {
selection.select();
selection = this.fixSelection(selection);
selectionType = this.fixSelectionType(selection, selectionType);
if (selectionType == "None") {
targetEl = document.getElementById('id'+this.oname).document;
}
else {
targetEl = selection;
targetEl.execCommand("UnLink", false);
}
targetEl.execCommand("CreateLink", false, szURL);
linked = selection.parentElement ? selection.parentElement() : this.getElement(selection.item(0),"A");
}
else {
selection = this._getSelection();
if (typeof selection != "undefined") range = selection.getRangeAt(0);
document.getElementById("id"+this.oname).contentDocument.execCommand("CreateLink", false, szURL);
linked = range.startContainer.previousSibling;
}
if (linked) {
if (szTarget) linked.target = szTarget;
if (szTitle) linked.title = szTitle;
}
},
boxStyle: function (el) {
var range = this._getSelection();
if (!GB.MSIE) {
range = (typeof range != "undefined") ?
range.getRangeAt(0) : this.editArea.document.createRange();
}
var newNode = document.createElement("div");
newNode.style.backgroundColor = el.style.backgroundColor;
newNode.style.border = el.style.border;
newNode.style.padding = el.style.padding;
newNode.style.margin = "5px 0px 5px 0px";
if (GB.MSIE) {
var ctx = this.selection.htmlText;
newNode.innerHTML = ctx ? ctx : ' ';
this.doCmdPaste(newNode.outerHTML);
}
else {
var ctx = range != '' ? range.extractContents() : document.createElement('br');
newNode.appendChild(ctx);
range.insertNode(newNode);
range.setEnd(newNode, 0);
range.setStart(newNode, 0);
}
this.boxHide();
this.editArea.focus();
},
insertBgImage: function (img) {
this.editArea.focus();
if (img) {
img = this.config.editorPath + '/' + img;
this.editArea.document.body.style.backgroundImage = "url("+img+")";
}
else {
var s = this.editArea.document.body.style;
GB.MSIE ? s.removeAttribute("backgroundImage") : s.backgroundImage = "none";
}
},
insertTable: function (insertNode) {
if (GB.MSIE) {
this.selection.select();
this.selection.pasteHTML(insertNode.outerHTML);
return;
}
var sel = this._getSelection();
var range = sel.getRangeAt(0);
sel.removeAllRanges();
range.deleteContents();
var container = range.startContainer;
var pos = range.startOffset;
range = document.createRange();
if (container.nodeType==3 && insertNode.nodeType==3) {
container.insertData(pos, insertNode.nodeValue);
range.setEnd(container, pos+insertNode.length);
range.setStart(container, pos+insertNode.length);
}
else {
var afterNode;
if (container.nodeType == 3) {
var textNode = container;
container = textNode.parentNode;
var text = textNode.nodeValue;
var textBefore = text.substr(0,pos);
var textAfter = text.substr(pos);
var beforeNode = document.createTextNode(textBefore);
var afterNode = document.createTextNode(textAfter);
container.insertBefore(afterNode, textNode);
container.insertBefore(insertNode, afterNode);
container.insertBefore(beforeNode, insertNode);
container.removeChild(textNode);
}
else {
afterNode = container.childNodes[pos];
container.insertBefore(insertNode, afterNode);
}
range.setEnd(afterNode, 0);
range.setStart(afterNode, 0);
}
sel.addRange(range);
},
doInsertImage : function (images) {
for (var i=0; i/ig, "");
content = content.replace (//ig, '');
var key = GB.htmlKey.join ("|");
var reg = new RegExp ("(<\/?)(" + key + ")(>)", "ig");
var reg2 = new RegExp ("(<)(" + key + ") (.+?)=(.+?)(>)", "ig");
content = content.replace(//g,'>');
content = content.replace (/\n/g, '
');
content = content.replace (reg, "$1$2$3");
content = content.replace (reg2, "$1$2 $3=$4$5");
this.editArea.document.body.innerHTML = content;
this.editArea.document.body.clearAttributes;
this.editArea.document.body.contentEditable = true;
this.editArea.document.body.style.fontFamily = 'courier new,gulim';
this.editArea.document.body.style.fontSize = '9pt';
this.editArea.document.body.style.color = '#000';
this.editArea.document.body.style.lineHeight = this.config.lineHeight;
this.editArea.document.body.style.background = '#fff';
var tmpHeight = this.editAreaWrapper.offsetHeight + document.getElementById("idToolbar_"+this.oname).offsetHeight;
document.getElementById("idToolbar_"+this.oname).style.display = "none";
this.editAreaWrapper.style.height = tmpHeight + 'px';
this.showTagSelector(false);
}
else {
this.editAreaWrapper.style.visibility = 'hidden';
this.putContents(this.makeHtmlContent());
document.getElementById("idToolbar_"+this.oname).style.display = '';
var tmpHeight = this.editAreaWrapper.offsetHeight - document.getElementById("idToolbar_"+this.oname).offsetHeight;
this.editAreaWrapper.style.height = tmpHeight + 'px';
if (!this.config.fullHTMLSource) this.editArea.document.body.style.cssText = this.szTmp;
this.showTagSelector(true);
this.setEditorOpt();
this.editAreaWrapper.style.visibility = 'visible';
this.editArea.document.body.contentEditable = true;
}
this.editArea.document.body.focus();
},
makeHtmlContent : function () {
if (GB.MSIE) return this.editArea.document.body.innerText;
var content = this.editArea.document.body.innerHTML;
content = content.replace (/
/ig, '\n');
content = content.replace (/<\/font>/ig, '');
content = content.replace (//ig, '');
return content;
},
resetStatusBar : function () {
if (this.config.showTagPath)
document.getElementById('CHstatusBar'+this.oname).innerHTML = '<html> <body> ';
},
previewMode : function () {
this.selection = null;
this.popupWinClose();
this.resetStatusBar();
if (this.config.useSource) {
if (this.currentMode == 'code') {
this.putContents(this.makeHtmlContent());
this.currentMode = 'rich';
}
}
this.editAreaWrapper.style.visibility = 'hidden';
if (this.currentMode=='rich') {
document.getElementById("CHModifyBlock"+this.oname).style.display = 'none';
this.showTagSelector(false);
this.editArea.document.body.contentEditable = false;
if (!GB.MSIE) this.editArea.document.designMode = "off";
var tmpHeight = this.editAreaWrapper.offsetHeight +
document.getElementById("idToolbar_"+this.oname).offsetHeight;
document.getElementById("idToolbar_"+this.oname).style.display = "none";
this.editAreaWrapper.style.height = tmpHeight+'px';
}
else {
this.editArea.document.body.contentEditable = true;
if (!GB.MSIE) this.editArea.document.designMode = "on";
document.getElementById("idToolbar_"+this.oname).style.display = '';
var tmpHeight = this.editAreaWrapper.offsetHeight -
document.getElementById("idToolbar_"+this.oname).offsetHeight;
this.editAreaWrapper.style.height = tmpHeight + 'px';
this.showTagSelector(true);
this.setEditorOpt();
}
this.editAreaWrapper.style.visibility = 'visible';
this.editArea.focus();
},
putContents : function (sContent) {
if (!GB.MSIE)
sContent = sContent.replace(/</g,'<').replace(/>/g,'>');
sContent = (this.config.fullHTMLSource == false) ? sContent : this.docSplit(sContent);
if (GB.MSIE) {
this.editArea.document.open("text/html","replace");
this.editArea.document.write(sContent);
this.editArea.document.close();
this.editArea.document.execCommand("2D-Position", true, true);
this.editArea.document.execCommand("MultipleSelection", true, true);
this.editArea.document.execCommand("LiveResize", true, true);
}
else {
this.editArea.document.body.innerHTML = sContent;
}
this.editArea.document.body.style.cssText = this.szTmp;
this.editArea.document.body.contentEditable = true;
},
getImages : function () {
var img = this.editArea.document.body.getElementsByTagName('img');
var imgNumber = this.images.length;
var imgArr = new Array();
for (i=0; i 0 ? imgArr : false;
},
getContents : function (op) {
if (this.config.hrefTarget != '' || this.config.hrefTarget != null) {
for (var i=0; i < this.editArea.document.links.length; i++) {
if (!this.editArea.document.links[i].target) {
this.editArea.document.links[i].target = this.config.hrefTarget;
}
}
}
this.szTmp = this.editArea.document.body.style.cssText;
this.editArea.document.body.style.border = "";
this.editArea.document.body.removeAttribute("contentEditable", 0);
if (op == true) {
var img = this.editArea.document.body.getElementsByTagName('img');
var hostname = location.hostname;
for (i=0; i