에디터의 DesignMode를 iframe에 focus가 일어날때 이루어지도록 코드 변경. 페이지 로딩 속도 증가 및 에디터 부분의 display:none일 경우 대비

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2646 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-09-28 03:54:44 +00:00
parent 5a7ab9cd11
commit 1aee7c7b60
2 changed files with 29 additions and 180 deletions

View file

@ -20,7 +20,6 @@ var editor_rel_keys = new Array(); ///< 에디터와 각 모듈과의 연동을
xAddEventListener(window, 'load', _editorSync); ///< 에디터의 동기화를 하는 함수를 window.load시 실행
/**
* 에디터의 상태나 객체를 구하기 위한 함수
**/
@ -148,9 +147,15 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
// iframe내의 document element를 구함
var contentDocument = iframe_obj.contentWindow.document;
/**
* 에디터를 위지윅 모드로 만들기 위해 내용 작성 designMode 활성화
**/
// 크기 변경 불가일 경우 드래그바 숨김
if(resizable == false) xGetElementById("editor_drag_bar_"+editor_sequence).style.display = "none";
else xGetElementById("editor_drag_bar_"+editor_sequence).style.display = "block";
// IE일 경우 ctrl-Enter 안내 문구를 노출
if(xIE4Up && xGetElementById('for_ie_help_'+editor_sequence)) {
xGetElementById('for_ie_help_'+editor_sequence).style.display = "block";
}
var contentHtml = ''+
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
'<html lang="ko" xmlns="http://www.w3.org/1999/xhtml><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/>'+
@ -165,15 +170,31 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
content+
'</body></html>'+
'';
contentDocument.open("text/html","replace");
contentDocument.write(contentHtml);
contentDocument.close();
// editor_mode를 기본으로 설정
editor_mode[editor_sequence] = null;
// iframe에 focus가 될때 에디터 모드로 전환하도록 이벤트 지정
if(xIE4Up) xAddEventListener(iframe_obj, "focus", function() { editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height); } );
else xAddEventListener(iframe_obj.contentWindow, "focus", function() { editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height); } );
}
/**
* 에디터를 위지윅 모드로 만들기 위해 내용 작성 designMode 활성화
**/
var editor_is_started = new Array();
function editorSetDesignMode(iframe_obj, contentDocument, content, fo_obj, editor_sequence, editor_height) {
if(editor_is_started[editor_sequence]) return;
contentDocument.designMode = 'on';
try {
contentDocument.execCommand("undo", false, null);
contentDocument.execCommand("useCSS", false, true);
} catch (e) {
}
contentDocument.open("text/html","replace");
contentDocument.write(contentHtml);
contentDocument.close();
/**
* 더블클릭이나 키눌림등의 각종 이벤트에 대해 listener 추가
@ -189,11 +210,6 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
xAddEventListener(document,'mouseup',editorEventCheck);
xAddEventListener(document,'mousedown',editorHideObject);
// IE일 경우 ctrl-Enter 안내 문구를 노출
if(xIE4Up && xGetElementById('for_ie_help_'+editor_sequence)) {
xGetElementById('for_ie_help_'+editor_sequence).style.display = "block";
}
/**
* 에디터의 내용을 지속적으로 fo_obj.content의 값과 동기화를 시킴.
* 차후 다른 에디터를 사용하더라도 fo_obj.content와 동기화만 된다면 어떤 에디터라도 사용 가능하도록 하기 위해
@ -204,12 +220,7 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
// 자동저장 필드가 있다면 자동 저장 기능 활성화
if(typeof(fo_obj._saved_doc_title)!="undefined" ) editorEnableAutoSave(fo_obj, editor_sequence);
// 크기 변경 불가일 경우 드래그바 숨김
if(resizable == false) xGetElementById("editor_drag_bar_"+editor_sequence).style.display = "none";
else xGetElementById("editor_drag_bar_"+editor_sequence).style.display = "block";
// editor_mode를 기본으로 설정
editor_mode[editor_sequence] = null;
editor_is_started[editor_sequence] = true;
}