/*
** 프로젝트명: 알디터 (알릭 + wysiwyg 에디터)
**
** 화일명: alditor.js
** 작성자: Alex Suk Hyun Park a.k.a Alik (http://www.alik.info/ | alikong@gmail.com)
** 작성일: 2006-08-19
** 최종 수정일: 2006-11-06
**
**
** 라이센스 정보:
** -------------------------------------------------------------------------
** 소스 수정 및 배포 불가
** 화일의 직접 링크 (개인 유포) 불가
** 개인적인 용도로 사용가능하며 상업적 사용시 상기명시된 작성자에게 연락 요망.
** 소스 배포, 업데이트 및 기능 추가등은 모두 http://www.alik.info 에서 확인 요망.
** 건의사항 및 수정사항 또한 http://www.alik.info 로 문의 요망
** 소스를 제외한 버튼 아이콘등 모든 이미지의 저작권은 이미지 제작자에게 있음.
**
**
** 기능 설명:
** -------------------------------------------------------------------------
** HTML 내부에 있는 Textarea 를 위지윅(WYSIWYG) 에디터로 변환함.
** 한 페이지내 다수의 Textarea 를 선별적(Textarea 태그의 속성에 editable=0 추가시 변환되지 않음)
** 또는 전체 변환(기본 설정) 가능함.
**
**
** 사용법:
** -------------------------------------------------------------------------
** 자세한 설명, 설정방법 및 사용법은 http://www.alik.info/ 방문 요망.
*/
/////////// 사용자 설정 시작 ////////////
function alditorConfig () {
/*
this.alditorPath = 알디터가 삽입된 웹페이지를 기준으로한 알디터 폴더 경로 (끝에 / 필수)
루트로 부터 절대경로를 추천~ ( ./ 가 아닌 / 은 루트를 기준으로 함, 아래 샘플은 현재 루트에 alditor 에 업로드된 상황으로 설정)
this.buttonSet = 사용할 버튼세트의 이름 (buttons 폴더 안에 버튼이미지들이 있는 폴더의 이름)
*/
this.alditorPath = "/alditor/";
this.buttonSet = "alik_nontoxic";
/*
this.uploadLink = 화일을 업로드 할수 있는 서비스제공 페이지의 주소
http://www.imageshack.us/ (외국서버라 살짝 느림.)
http://img.npiza.com/
http://image.widesoccer.com/index.html (부활함)
등등 웹에서 검색하시길... (혹은 본인의 사이트에 회원제 또는 자유 업로드 페이지를 만들어서 연결할수 있음 ^^ .... 차후에 지원합시다!)
*/
this.uploadLink = '/sboard/upload.html';
//this.uploadLink = '/alditor/saveimage.php';
/*
this.spellcheckLink = 맞춤법 검사 서비스제공 페이지의 주소 (종종 변함..ㅜ.ㅜ, 변경시 http://urimal.cs.pusan.ac.kr/ 에서 '한국어 맞춤법/문법검사기' 주소를 찾기 바람)
this.spellcheckAction = 맞춤법 검사를 위한 폼 전송시에 사용될 action 주소 (현재 이름에서 앞의 아이피주소 만 바뀔 가능성이 많음)
*/
this.spellcheckLink = 'http://164.125.36.47/urimal-spellcheck.html';
this.spellcheckAction = 'http://164.125.36.47/WebSpell_ISAPI.dll?Check';
/*
this.runOnLoad = 페이지 로드시 에디터로 시작할까요?
true : false;
참고: false로 지정할경우 에디터 활성화 버튼은 아래 예제를 참고
예제: 에디터 ON
this.setFocus = 페이지 로드시 포커스를 에디터로 이동시킬까요? (에디터가 한페이지에 한개 이상인 상황에서 true 라면 첫번째 에디터로 포커스가 이동됨.)
true : false;
this.useSafeFocus = 위 설정에서 setFocus 를 true 로 했을시, 본 설정도 true 로 한다면 에디터가 화면의 하단(코멘트 입력의 경우)에 있는경우는 포커스를 주지 않음으로서 부적절한 스크롤을 방지한다.
true : false;
*/
this.runOnLoad = true;
this.setFocus = false; //////////// 가볍게
this.useSafeFocus = true;
/*
this.allowStretch = 에디터영역을 내용에 맞게 늘어나게 할까요? (스크롤바가 안생기는다는거죠 ^^) 드레그나 이거나 둘중에 하나만 쓰면 좋을듯...
true : false
*/
this.allowStretch = true;
/*
this.movableToolbar = 툴바를 드레그해서 상/하 위치를 조정할수 있게 할까요?
true : false
*/
this.movableToolbar = false; ////////////// 가볍게
/*
this.allowDrag = 리사이즈 드레그 허용여부
true : false
this.dragMode = 리사이즈 드레그 방향제한
1 = 가로만 늘어나는 모드, 2 = 세로만 늘어나는 모드, 3 = 방향 제한 없는 자유모드
this.minWidth , this.minHeight = 리사이즈 가능한 최소 넓이와 높이 지정 (단위 = 픽셀)
*/
this.allowDrag = false; /////////////////// 가볍게
this.dragMode = 2;
this.minWidth = 200;
this.minHeight = 40;
/*
this.useEnterBR = 엔터 입력시 자동으로 쉬프트+엔터 (
) 형식으로 변환해줄까요? (문단바꿈을 줄바꿈으로 바꿔주는 기능)
true : false
this.useAutoP = 위에 설정한 useEnterBR 이 true 라면 엔터 두번 입력시 자동으로 보통엔터 한번입력으로 변환해줄까요? (한번은 줄바꿈 두번은 문단바꿈)
true : false
*/
this.useEnterBR = true;
this.useAutoP = true;
/*
this.showPath = 에디터 하단의 태그선택기능 허용여부
true : false
this.showPathSafeMode = showPath가 true 일때 너무 느린감이 있다면 showPathSafeMode 를 true로 지정하면 속도가 조금 증가한다
(태그목록이 본문에 내용입력시에서 방형키입력시과 클릭시로 업뎃되게 변경됨, true 권장!)
true : false
*/
this.showPath = true;
this.showPathSafeMode = true;
/*
this.useExtraHTML = 에디터 우측에 다양한 div 상자모음이 나옵니다.
true : false
this.useExtraHTMLwidth = 위에 명시된 div 상자모음의 가로길이 (단위 = 픽셀)
alditor.css 에서 .extraDiv 의width 와 동일하게 지정해줘야함
*/
this.useExtraHTML = true;
this.useExtraHTMLwidth = 120;
/*
this.useExpansion = 툴바에 여러개의 버튼줄이 있는경우 버튼으로 확장하는 형식으로 사용할까요?
true : false
this.minimumRow = 확장하는 형식을 사용하신다면 기본으로 몇줄을 보여줄까요?
true : false
*/
this.useExpansion = true;
this.minimumRow = 1;
/*
this.noSelect = 글꼴과 글자크기 설정을 select 가 아닌 레이어로 표시할까요?
true : false
this.freeFontSize = 글자크기 설정을 select 가 아닌 레이어로 표시할때 기본방식(표준,안정적임,8,10,12,14,18,24,36pt 로 옵션이 제한적임) 을 쓸까요? 아님 원하는데로 (글자 선택후만 변경가능, 관리자가 원하는 사이즈 추가 가능) 바꾸는 방식으로 할까요?
true : false
*/
this.noSelect = true;
this.freeFontSize = false;
/*
this.targetBlank = 에디터안에 삽입된 모든 링크들의 타켓을 새창으로 지정할까요?
true : false
*/
this.targetBlank = true;
/*
this.imgKeepAddress = IE 의 이미지 삽입시 상대경로가 자동으로 절대경로로 바뀌는걸 막을까요? (최종 전송시 변환됨)
true : false
*/
this.imgKeepAddress = true;
/*
this.useCopy = 글 날림 방지용 내용복사 기능의 사용여부
true : false
this.useContentCheck = 글 내용의 길이 체크 기능의 사용여부
true : false
this.minimumContent = 위 체크 기능의 기준 글자수 (몇자 이상 써야 등록이 되는... 그 기능)
1부터 ~ 무한대 (정수)
this.saveRemoteIMG = 본문에 삽입된 이미지들중 외부(다른계정)에 위치한 이미지들을 본인의 서버로 저장할까요?
true : false
*/
this.useCopy = true;
this.useContentCheck = false;
this.minimumContent = 10;
this.saveRemoteIMG = false;
/*
this.killError = 에디터 삽입으로 인해 생기는 각종 에러메세지 출력을 막을까요? (비추천 - 모든 에러가 않나옴...ㅡ.ㅡ)
true : false
*/
this.killError = false;
/*
this.noOnsubmit = 폼전송시에 실행되는 onsubmit 항목을 건드리지 않을까요? true 로 설정시 내용복사를 비롯한 각종기능들이 작동하지 않고 바로 전송됨.(일종의 심플모드, 특히 form 안에서 사용하는 textarea 가 아닐경우 true 로!)
true : false
*/
this.noOnsubmit = false;
/*
툴바에 들어가는 빈공간 가로사이즈 기본값 지정 (단위 = 픽셀) [firefox 에선 실제 픽셀이 아닌 사이즈 5 마다 빈칸을 하나씩 삽입]
*/
this.defaultSpaceWidth = 10;
/*
툴바 버튼 항목
1. 정의하는 순서대로 에디터에 표시됨.
2. 버튼사이의 임의적 공백은 this.toolbarItems.push("space"); 를 추가함으로서 생성가능
2-1. space 만 적을경우 위에서 정의한 defaultSpaceWidth 공백의 사이즈로 이용되며,
2-2. 공백별 사이즈를 지정하고 싶을땐 space_40 처럼 _ 와 함께 적어주면 해당 공백의 넓이를 지정할수 있음 (단위 = 픽셀)
3. 새로운 버튼줄의 경우 this.toolbarItems.push("row"); 를 줄 사이에 넣어주면 생성됨.
4. 필요없는 버튼은 //this.toolbarItems.push("underline"); 처럼 //을 이용하여 주석처리 권장.
5. 설정항목들이 익숙해지길 바라는 마음에 현재 두줄로 설정되어있음. (한줄로 주욱~ 표시하기 권장)
*/
this.toolbarItems = new Array();
this.toolbarItems.push("htmlsource"); //소스창과 에디터창의 전환 버튼
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("fontname"); // 글꼴 변경
this.toolbarItems.push("fontsize"); // 글자크기 변경
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("bold"); // 굵게
this.toolbarItems.push("underline"); // 밑줄
this.toolbarItems.push("italic"); // 기울이기
this.toolbarItems.push("strike"); // 취소선
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("color"); // 글자 색상
this.toolbarItems.push("bgcolor"); // 글자 배경색
this.toolbarItems.push("hilite"); // 강조 (노랑바탕에 검정글씨)
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("link"); // 링크삽입
this.toolbarItems.push("image"); // 이미지 삽입
this.toolbarItems.push("emoticon"); // 이모티콘 삽입
this.toolbarItems.push("specialchars"); // 특수문자 삽입
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("row"); // 새로운 버튼줄
this.toolbarItems.push("unlink"); // 링크취소
this.toolbarItems.push("nohilite"); // 강조 취소 및 각종 글자효과 제거
this.toolbarItems.push("sup"); // 윗첨자
this.toolbarItems.push("sub"); // 아래첨자
//this.toolbarItems.push("space_33"); //공백 사이즈 33 샘플
this.toolbarItems.push("orderedlist"); // 번호매김
this.toolbarItems.push("unorderedlist"); // 점매김
this.toolbarItems.push("indent"); // 들여쓰기
this.toolbarItems.push("outdent"); // 들여쓰기 취소
this.toolbarItems.push("left"); // 왼쪽맞춤
this.toolbarItems.push("center"); // 가운데맞춤
this.toolbarItems.push("right"); // 오른쪽맞춤
this.toolbarItems.push("space"); //기본 공백
this.toolbarItems.push("abs"); // position:absolute
this.toolbarItems.push("hr"); // 줄 삽입
this.toolbarItems.push("simpleDiv"); // 심플박스
this.toolbarItems.push("table"); // 테이블삽입
this.toolbarItems.push("showhide"); // 보이기/감추기
this.toolbarItems.push("spellcheck"); // 맞춤법검사
this.toolbarItems.push("preview"); // 미리보기
// 버튼 끝
/*
위에서 지정한 폰트변경 메뉴에 옵션으로 들어갈 폰트목록
형식 = this.fontOptions.push("execcommand 로 적용되는 정확한 폰트이름", "사용자에게 보여지는 값 - 임의지정 가능");
*/
this.fontOptions = new Array();
if (this.noSelect) // 글꼴선택을 레이어로 했을경우 사용될 항목
{
this.fontOptions.push("굴림", "굴림");
this.fontOptions.push("돋움", "돋움");
this.fontOptions.push("바탕", "바탕");
this.fontOptions.push("궁서", "궁서");
this.fontOptions.push("tahoma", "tahoma");
this.fontOptions.push("verdana", "verdana");
this.fontOptions.push("Courier", "Courier");
}
else // 글꼴선택을 select 로 했을경우 사용될 항목
{
this.fontOptions.push("", "글꼴"); //첫줄 제거 금지!
this.fontOptions.push("굴림", "굴림");
this.fontOptions.push("돋움", "돋움");
this.fontOptions.push("바탕", "바탕");
this.fontOptions.push("궁서", "궁서");
}
/*
위에서 지정한 글자크기 메뉴에 옵션으로 들어갈 사이즈목록
형식 = this.fontOptions.push("실제로 적용되는 사이즈값", "사용자에게 보여지는 값 - 임의지정 가능");
*/
this.fontSizeOptions = new Array();
if (this.noSelect && this.freeFontSize) // 글자크기선택을 레이어로 하면서 크기자유입력시에 사용될 항목 (pt 도 되고 px 도 됨)
{
this.fontSizeOptions.push("7pt", "7pt");
this.fontSizeOptions.push("8pt", "8pt");
this.fontSizeOptions.push("9pt", "9pt");
this.fontSizeOptions.push("10pt", "10pt");
this.fontSizeOptions.push("11pt", "11pt");
this.fontSizeOptions.push("12pt", "12pt");
this.fontSizeOptions.push("14pt", "14pt");
this.fontSizeOptions.push("18pt", "18pt");
this.fontSizeOptions.push("24pt", "24pt");
this.fontSizeOptions.push("36pt", "36pt");
this.fontSizeOptions.push("40pt", "40pt");
}
else // 글자크기선택을 select 로 했을경우 사용될 항목
{
this.fontSizeOptions.push("", "크기"); //첫줄 제거 금지!
this.fontSizeOptions.push("1", "1");
this.fontSizeOptions.push("2", "2");
this.fontSizeOptions.push("3", "3");
this.fontSizeOptions.push("4", "4");
this.fontSizeOptions.push("5", "5");
this.fontSizeOptions.push("6", "6");
this.fontSizeOptions.push("7", "7");
}
if (this.useExtraHTML)
{
this.toolbarItems.push("extraHTML"); // 추가 항목 HTML - 아래 태그내용만 수정하시길. 사용여부는 위의 설정에서...
this.extraHTML = new Array();
this.extraHTML.push("
");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
this.extraHTML.push("");
}
return true;
}
/////////// 설정 끝 //////////// 이하 손델 필요 없음 ///////
//// 필수 변수들
var is_IE = (window.showModelessDialog) ? true : false;
var config = new alditorConfig();
var editorHeight = new Array();
var _1stRun = false;
////
var styleCss=document.createElement('LINK');
styleCss.rel = 'stylesheet';
styleCss.href = config.alditorPath+'buttons/'+config.buttonSet+'/alditor.css';
var styleCssContent=document.createElement('LINK');
styleCssContent.rel = 'stylesheet';
styleCssContent.href = config.alditorPath+'alditorContent.css';
var jsContent=document.createElement('script');
jsContent.type = 'text/javascript';
jsContent.language = 'javascript';
jsContent.src = config.alditorPath+'alditorContent.js';
document.getElementsByTagName('HEAD')[0].appendChild(styleCss);
document.getElementsByTagName('HEAD')[0].appendChild(styleCssContent);
document.getElementsByTagName('HEAD')[0].appendChild(jsContent);
if (config.runOnLoad)
{
addEvent(window,"load", alditorAll);
}
function alditorAll() {
var txtareas = document.getElementsByTagName("TEXTAREA");
for ( i=0 ; i < txtareas.length ; i++ )
{
if (txtareas[i].offsetHeight > 0 && txtareas[i].style.display.toLowerCase() != 'none' && txtareas[i].style.visibility.toLowerCase() != 'hidden' && !txtareas[i].readOnly && !txtareas[i].disabled)
{
var textarea = txtareas[i];
if (!textarea.id) {
if (document.getElementById(textarea.name) && document.getElementById(textarea.name).nodeName != 'TEXTAREA') {
textarea.id = 'text_' + textarea.name ;
} else {
textarea.id = textarea.name ;
}
}
if ( txtareas.length == 1)
{
new alditor(textarea.id);
} else {
setTimeout("new alditor('" + textarea.id + "')", 10 * (i));
}
}
}
}
function killalditorAll() {
var txtareas = document.getElementsByTagName("TEXTAREA");
for ( i=0 ; i < txtareas.length ; i++ )
{
var txtarea = txtareas[i];
if (txtarea.previousSibling && txtarea.previousSibling.id == txtarea.id + '_alditor')
{
var _table = document.getElementById(txtarea.id + '_table');
txtarea.style.display = 'block';
txtarea.className = txtarea.rel;
txtarea.style.cssText = txtarea.oldstyle;
_table.parentNode.replaceChild(txtarea,_table);
var extradiv = document.getElementById(txtarea.id + "_alditorextraDiv");
extradiv.parentNode.removeChild(extradiv);
}
}
}
function alditorById(textareaID) {
_1stRun = false;
var txtarea = document.getElementById(textareaID);
if (!txtarea || txtarea.nodeName != 'TEXTAREA')
{
txtarea = document.getElementsByTagName('TEXTAREA')[textareaID];
if (document.getElementById(txtarea.name) && document.getElementById(txtarea.name).nodeName != 'TEXTAREA') {
txtarea.id = 'text_' + txtarea.name ;
} else {
txtarea.id = txtarea.name ;
}
} else {
if (!txtarea.id)
{
if (document.getElementById(txtarea.name) && document.getElementById(txtarea.name).nodeName != 'TEXTAREA') {
txtarea.id = 'text_' + txtarea.name ;
} else {
txtarea.id = txtarea.name ;
}
}
}
if (!txtarea.previousSibling || (txtarea.previousSibling && txtarea.previousSibling.className !='alditorIframe'))
{
new alditor(txtarea);
}
return true;
}
function killalditor(txtID) {
var txtarea = document.getElementById(txtID);
if (!txtarea || txtarea.nodeName != "TEXTAREA")
{
txtarea = document.getElementsByTagName('TEXTAREA')[txtID];
}
txtID = txtarea.id;
if (txtarea.previousSibling && txtarea.previousSibling.id == txtarea.id + '_alditor')
{
txtarea.style.display = 'block';
txtarea.className = txtarea.rel;
txtarea.style.cssText = txtarea.oldstyle;
var _table = document.getElementById(txtID + "_table");
_table.parentNode.replaceChild(txtarea,_table);
var extradiv = document.getElementById(txtarea.id + "_alditorextraDiv");
extradiv.parentNode.removeChild(extradiv);
}
}
function getAlditor(textareaID) {
var alditorObj = document.getElementById(textareaID + '_alditor');
if (!alditorObj)
{
alditorObj = document.getElementById('text_' + textareaID + '_alditor');
}
if (alditorObj)
{
return alditorObj;
} else {
return false;
}
}
// 알디터 시작
function alditor(textareaObj) {
if (typeof textareaObj == 'string')
{
textareaObj = document.getElementById(textareaObj);
}
if (textareaObj.nodeName != "TEXTAREA" || navigator.userAgent.indexOf('Mac') != -1 || textareaObj.getAttribute("editable") == 0)
{
return true;
}
if ((textareaObj.offsetHeight > 0) && (!textareaObj.previousSibling || textareaObj.previousSibling.id != textareaObj.id + "_alditor"))
{
var self = this;
var tempWidth = textareaObj.offsetWidth;
var tempHeight = textareaObj.offsetHeight;
this._initHeight = tempHeight;
this._textarea = textareaObj;
this._iframe = document.createElement("IFRAME");
this._textarea.rel = this._textarea.className;
this._textarea.oldstyle = this._textarea.style.cssText;
this._textarea.className = "alditorTextarea";
this._textarea.style.display = "none";
this._iframe.id = this._textarea.id + "_alditor";
this._iframe.frameBorder = 0;
this._iframe.marginWidth = 0;
this._iframe.marginHeight = 0;
this._iframe.className = "alditorIframe";
editorHeight[ this._iframe.id ] = tempHeight;
this._table = document.createElement("table");
this._table.setAttribute("border", "0");
this._table.setAttribute("cellPadding", "0");
this._table.setAttribute("cellSpacing", "0");
this._table.style.width = tempWidth + 'px';
this._table.className = "topTable";
this._table.id = this._textarea.id + "_table";
var topTablebody = document.createElement("tbody");
var current_row1 = document.createElement("tr");
current_row1.setAttribute("valign", "middle");
current_row1.setAttribute("align", "left");
this._toolbarTd = document.createElement("td");
this._toolbarTd.id = this._iframe.id + "toolbarTd";
this._toolbarTd.className = "toolbarTd";
this._toolbarTd.unselectable = 'on';
current_row1.appendChild(this._toolbarTd);
this._toolbarDiv = document.createElement("div");
this._toolbarDiv.id = this._iframe.id + "_toolbarDiv";
this._toolbarDiv.className = "toolbarDiv";
this._toolbarDiv.style.backgroundImage = "url('"+config.alditorPath+"buttons/" + config.buttonSet + "/toolbar_bg.gif')";
if (config.movableToolbar)
{
this._toolbarDiv.onmousedown = function (event) {tb_moveStart(event, self._toolbarDiv, self._iframe);};
this._toolbarDiv.className = "toolbarDiv updown";
}
this._toolbarTd.appendChild(this._toolbarDiv);
var current_row2 = document.createElement("tr");
current_row2.setAttribute("valign", "top");
current_row2.setAttribute("align", "left");
this._alditorTd = document.createElement("td");
this._alditorTd.id = this._iframe.id + "alditorTd";
this._alditorTd.className = "alditorTd";
this._alditorTd.width = tempWidth;
this._alditorTd.height = tempHeight;
this._alditorTd.unselectable = 'on';
current_row2.appendChild(this._alditorTd);
var current_row3 = document.createElement("tr");
current_row3.setAttribute("valign", "bottom");
current_row3.setAttribute("align", "left");
var bottomTd = document.createElement("td");
bottomTd.id = this._iframe.id + "bottomTd";
bottomTd.className = "bottomTd";
bottomTd.unselectable = 'on';
var bottomTable = document.createElement("table");
bottomTable.setAttribute("border", "0");
bottomTable.setAttribute("width", "100%");
bottomTable.setAttribute("cellPadding", "0");
bottomTable.setAttribute("cellSpacing", "2");
bottomTable.style.tableLayout = "fixed";
var bottomTablebody = document.createElement("tbody");
var current_row = document.createElement("tr");
current_row.setAttribute("align", "left");
current_row.setAttribute("valign", "bottom");
this._pathTd = document.createElement("td");
this._pathTd.id = this._iframe.id + "pathTd";
this._pathTd.className = "pathTd";
this._pathTd.innerHTML = (config.showPath)? "Tags:" : " ";
this._pathTd.unselectable = 'on';
var current_cell2 = document.createElement("td");
if (config.allowDrag)
{
current_cell2.onmousedown = function (event) {resizeStart(event, self._table, self._iframe); return true;};
current_cell2.className = "resizeHandle";
}
current_cell2.unselectable = "on";
current_row.appendChild(this._pathTd);
current_row.appendChild(current_cell2);
bottomTablebody.appendChild(current_row);
bottomTable.appendChild(bottomTablebody);
current_row3.appendChild(bottomTd);
topTablebody.appendChild(current_row1);
topTablebody.appendChild(current_row2);
topTablebody.appendChild(current_row3);
this._table.appendChild(topTablebody);
this.alditorToolbar();
this._textarea.parentNode.insertBefore(this._table, this._textarea);
this._alditorTd.appendChild(this._iframe);
this._alditorTd.appendChild(this._textarea);
if (config.allowDrag || config.showPath)
{
bottomTd.appendChild(bottomTable);
}
var tools = this._toolbarTd.getElementsByTagName('*');
for (ti=0;ti< tools.length; ti++)
{
tools[ti].unselectable = 'on';
}
this._textarea.style.width = this._alditorTd.clientWidth + 'px';
this._textarea.style.height = this._alditorTd.clientHeight - 2 + 'px';
this.fillContents(this._textarea.value);
if (config.toolbarItems.inArray('color') || config.toolbarItems.inArray('bgcolor'))
{
makeColorset();
}
if (config.toolbarItems.inArray('table'))
{
makeTableset();
}
if (config.toolbarItems.inArray('hilite'))
{
makeHiliteset();
}
if (config.noSelect)
{
makeFontset();
}
setTimeout(function () { self.setDesignMode(); },10);
expanded = false;
rowCnt = 0;
}
return true;
}
var expanded = false;
var rowCnt = 0;
alditor.prototype.alditorToolbar = function (startNo) {
if (!startNo)
{
startNo = 0
}
var self = this;
var tempi = 0;
this._buttonSet = document.createElement("DIV");
this._buttonSet.className = "buttonSet";
this._buttonSet.unselectable = "on";
if (expanded == true)
{
this._buttonSet.style.display = 'none';
}
for (var i = startNo; i < config.toolbarItems.length; i++)
{
switch (config.toolbarItems[i].split("_")[0])
{
case "htmlsource":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/source.gif", "소스 보기", "html");
break;
case "fontname":
if (config.noSelect)
{
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/font.gif", "글꼴", "fontname");
} else {
this.createSelect(config.fontOptions, "fontname");
}
break;
case "fontsize":
if (config.noSelect)
{
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/size.gif", "글자크기", "fontsize");
} else {
this.createSelect(config.fontSizeOptions, "fontsize");
}
break;
case "bold":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/bold.gif", "굵게", "bold");
break;
case "underline":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/underline.gif", "밑줄", "underline");
break;
case "italic":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/italic.gif", "기울이기", "italic");
break;
case "strike":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/strike.gif", "취소선", "StrikeThrough");
break;
case "color":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/fontcolor.gif", "글자 색", "color");
break;
case "bgcolor":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/backcolor.gif", "글자 배경색", "bgcolor");
break;
case "sup":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/super.gif", "위첨자", "Superscript");
break;
case "sub":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/sub.gif", "아래첨자", "Subscript");
break;
case "link":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/link.gif", "링크 삽입", "link");
break;
case "unlink":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/unlink.gif", "링크 제거", "unlink");
break;
case "image":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/image.gif", "이미지/동영상/음악/플래시 삽입", "image");
break;
case "emoticon":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/emoticon.gif", "이모티콘 삽입", "emoticon");
break;
case "specialchars":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/specialchars.gif", "특수문자 삽입", "specialchars");
break;
case "hilite":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/hilite.gif", "글자 강조", "hilite");
break;
case "nohilite":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/nohilite.gif", "강조 취소 및 각종 글자속성 제거", "nohilite");
break;
case "unorderedlist":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/unordered.gif", "점 목록", "insertunorderedlist");
break;
case "orderedlist":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/ordered.gif", "숫자 목록", "insertorderedlist");
break;
case "indent":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/indent.gif", "들여쓰기", "indent");
break;
case "outdent":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/outdent.gif", "들여쓰기 취소", "outdent");
break;
case "left":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/left.gif", "왼쪽 정렬", "justifyleft");
break;
case "center":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/center.gif", "중앙 정렬", "justifycenter");
break;
case "right":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/right.gif", "오른쪽 정렬", "justifyright");
break;
case "hr":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/hr.gif", "가로선 삽입", "inserthorizontalrule");
break;
case "simpleDiv":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/simpleDiv.gif", "단순 상자", "simpleDiv");
break;
case "table":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/table.gif", "테이블 삽입", "table");
break;
case "showhide":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/showhide.gif", "보이기/감추기", "showhide");
break;
case "preview":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/preview.gif", "미리보기", "preview");
break;
case "spellcheck":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/spellcheck.gif", "한글 맞춤법/문법 검사", "spellcheck");
break;
case "space":
var SpaceWidth = (config.toolbarItems[i].split("_")[1])?config.toolbarItems[i].split("_")[1]:config.defaultSpaceWidth;
this.createSpace(SpaceWidth);
break;
case "abs":
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/abs.gif", "position:absolute", "abs");
break;
case "extraHTML":
this.extraDiv = document.createElement("DIV");
this.extraDiv.id = this._iframe.id + "extraDiv";
this.extraDiv.className = "extraDiv";
this.extraDiv.unselectable = "on";
for (xi=0; xi < config.extraHTML.length; xi +=2)
{
var divContent = document.createElement("DIV");
divContent.innerHTML = config.extraHTML[xi] + "..." + config.extraHTML[xi + 1];
divContent.onclick = function () { addExtraTag(self._iframe,this.innerHTML);}
divContent.unselectable = "on";
divContent.firstChild.unselectable = "on";
this.extraDiv.appendChild(divContent);
}
document.body.appendChild(this.extraDiv);
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/extra.gif", "추가 항목 (열기/닫기)", "extraHTML");
break;
}
tempi = i;
if (config.toolbarItems[i] == "row")
{
rowCnt++;
if (config.useExpansion && expanded == false && rowCnt == config.minimumRow)
{
this.createButton(config.alditorPath+"buttons/" + config.buttonSet + "/expand.gif", "입력 도구 확장", "expand");
expanded = true;
}
break;
}
}
this._toolbarDiv.appendChild(this._buttonSet);
if (tempi != config.toolbarItems.length-1)
{
this.addRow(i+1)
}
return true;
}
alditor.prototype.toolbarClick = function(action, buttonObj)
{
var self = this;
var actionIframe = this._iframe;
if (config.toolbarItems.inArray('color') || config.toolbarItems.inArray('bgcolor'))
{
hideColorPicker();
}
if (config.toolbarItems.inArray('table'))
{
hideTableset();
}
if (config.toolbarItems.inArray('hilite'))
{
hideHiliteSelector();
}
if (config.noSelect)
{
hideFontset();
}
actionIframe.contentWindow.focus();
switch (action)
{
case "html":
switchMode(actionIframe);
if (actionIframe.style.display != 'none' && config.allowStretch)
{
self.reHeight(actionIframe.contentWindow.document.body.scrollTop);
}
break;
case "fontname":
if (config.noSelect)
{
getFontName(actionIframe, buttonObj);
} else {
actionIframe.contentWindow.document.execCommand("fontname", false, buttonObj.value);
buttonObj.selectedIndex=0;
}
break;
case "fontsize":
if (config.noSelect)
{
getFontSize(actionIframe, buttonObj);
} else {
actionIframe.contentWindow.document.execCommand("fontsize", false, buttonObj.value);
buttonObj.selectedIndex=0;
}
break;
case "color":
getColor(actionIframe, buttonObj, "ForeColor");
break;
case "bgcolor":
if (is_IE)
{
getColor(actionIframe, buttonObj, "BackColor");
} else {
getColor(actionIframe, buttonObj, "Hilitecolor");
}
break;
case "link":
popWin(config.alditorPath + 'alditorLink.html?id='+this._iframe.id + '&rnd=' + new Date().getTime(), 540,500, actionIframe);
break;
case "image":
popWin(config.alditorPath + 'alditorImage.html?id='+this._iframe.id + '&rnd=' + new Date().getTime() , 500,400, actionIframe, true);
break;
case "emoticon":
popWin(config.alditorPath + 'alditorEmoticons.html?id='+this._iframe.id + '&rnd=' + new Date().getTime(), 540,460, actionIframe);
break;
case "specialchars":
popWin(config.alditorPath + 'alditorSpecialchars.html?id='+this._iframe.id + '&rnd=' + new Date().getTime() ,350,400, actionIframe);
break;
case "hilite":
getHilite(actionIframe, buttonObj);
break;
case "nohilite":
actionIframe.contentWindow.document.execCommand("RemoveFormat",false,null);
break;
case "simpleDiv":
addExtraTag(actionIframe, "...
");
break;
case "table":
showTableset(actionIframe,buttonObj);
break;
case "showhide":
addExtraTag(actionIframe, '...숨겨진 내용...
', "showhide");
break;
case "preview":
alditorPreview (actionIframe);
break;
case "spellcheck":
spellcheck(actionIframe);
break;
case "extraHTML":
this.extraDiv.style.top = getOffsetTop(this._table) + 'px';
if (is_IE)
{
this.extraDiv.style.height = this._table.offsetHeight + 'px';
} else {
this.extraDiv.style.height = this._table.offsetHeight - 2 + 'px';
}
var newLeft = getOffsetLeft(this._table) + this._table.offsetWidth;
if ((newLeft + config.useExtraHTMLwidth) > document.body.clientWidth)
{
newLeft -= config.useExtraHTMLwidth;
}
this.extraDiv.style.left = newLeft + 'px';
if (this.extraDiv.style.display == "none" || !this.extraDiv.style.display){
this.extraDiv.style.display = "block";
} else {
this.extraDiv.style.display = "none";
}
break;
case "expand":
var buttonrows = this._toolbarDiv.childNodes;
for (i=config.minimumRow; i< buttonrows.length; i++)
{
if ( buttonrows[i].style.display != 'none')
{
buttonrows[i].style.display = 'none';
} else {
buttonrows[i].style.display = 'block';
}
}
break;
case "abs":
makeAbs(actionIframe);
break;
default:
try { actionIframe.contentWindow.document.execCommand( action, false, null); } catch (e) {}
}
if (action != "html")
{
updatePath(actionIframe);
}
return true;
}
alditor.prototype.addRow = function (i) {
this.alditorToolbar(i);
return true;
}
alditor.prototype.createButton = function(imgSrc, title, action)
{
var self = this;
var tempButton = document.createElement("IMG");
tempButton.title = title;
tempButton.alt = action;
tempButton.src = imgSrc;
tempButton.align = 'absmiddle';
tempButton.border = 0;
tempButton.onmouseover = function () { window.status = title; } ;
tempButton.onmousedown = toolbarDown;
tempButton.onmouseup = toolbarUp;
tempButton.onmouseout = toolbarUp;
tempButton.onclick = function () { self.toolbarClick(action, this); return true; } ;
this._buttonSet.appendChild(tempButton);
return true;
}
alditor.prototype.createSelect = function(optionList, action)
{
var self = this;
var theSelect = document.createElement("select");
theSelect.onchange = function () { self.toolbarClick(action, this); return true; } ;
for (var i = 0; i < optionList.length; i += 2)
{
var theOption = document.createElement("option");
var theText = document.createTextNode(optionList[i + 1]);
theOption.value = optionList[i];
theOption.appendChild(theText);
theSelect.appendChild(theOption);
}
this._buttonSet.appendChild(theSelect);
return true;
}
alditor.prototype.createSpace = function(width)
{
var tempSpace = document.createElement("SPAN");
tempSpace.style.width = parseInt(width) + "px";
if (!is_IE)
{
for (iii=0;iii@import url(\""+config.alditorPath+"alditorInnerContent.css\");\
\
\
" + text + "\
\