#358 editor js minify

This commit is contained in:
bnu 2014-01-22 13:53:49 +09:00
parent a11988e437
commit c503c57477
9 changed files with 464 additions and 422 deletions

View file

@ -65,7 +65,7 @@ function editorGetSelectedNode(editor_sequence) {
/**
* editor 시작 (editor_sequence로 iframe객체를 얻어서 쓰기 모드로 전환)
**/
var _editorFontColor = new Array();
var _editorFontColor = [];
function editorStart(editor_sequence, primary_key, content_key, editor_height, font_color) {
if(typeof(font_color)=='undefined') font_color = '#000';
@ -84,14 +84,13 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
fo_obj.setAttribute('editor_sequence', editor_sequence);
// 모듈 연관 키 값을 세팅
editorRelKeys[editor_sequence] = new Array();
editorRelKeys[editor_sequence]["primary"] = fo_obj[primary_key];
editorRelKeys[editor_sequence]["content"] = fo_obj[content_key];
editorRelKeys[editor_sequence]["func"] = editorGetContent_xe;
editorRelKeys[editor_sequence] = [];
editorRelKeys[editor_sequence].primary = fo_obj[primary_key];
editorRelKeys[editor_sequence].content = fo_obj[content_key];
editorRelKeys[editor_sequence].func = editorGetContent_xe;
// saved document(자동저장 문서)에 대한 확인
if(typeof(fo_obj._saved_doc_title)!="undefined" ) { ///<< _saved_doc_title field가 없으면 자동저장 하지 않음
if(typeof(fo_obj._saved_doc_title)!= "undefined") { ///<< _saved_doc_title field가 없으면 자동저장 하지 않음
var saved_title = fo_obj._saved_doc_title.value;
var saved_content = fo_obj._saved_doc_content.value;
@ -99,12 +98,12 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
// 자동저장된 문서 활용여부를 물은 후 사용하지 않는다면 자동저장된 문서 삭제
if(confirm(fo_obj._saved_doc_message.value)) {
if(typeof(fo_obj.title)!='undefined') fo_obj.title.value = saved_title;
editorRelKeys[editor_sequence]['content'].value = saved_content;
editorRelKeys[editor_sequence].content.value = saved_content;
var param = new Array();
param['editor_sequence'] = editor_sequence;
param['primary_key'] = primary_key;
param['mid'] = current_mid;
var param = [];
param.editor_sequence = editor_sequence;
param.primary_key = primary_key;
param.mid = current_mid;
var response_tags = new Array("error","message","editor_sequence","key","title","content","document_srl");
exec_xml('editor',"procEditorLoadSavedDocument", param, getAutoSavedSrl, response_tags);
} else {
@ -114,7 +113,7 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
}
// 대상 form의 content element에서 데이터를 구함
var content = editorRelKeys[editor_sequence]['content'].value;
var content = editorRelKeys[editor_sequence].content.value;
// IE가 아니고 내용이 없으면 <br /> 추가 (FF등에서 iframe 선택시 focus를 주기 위한 꽁수)
if(!content && !xIE4Up) content = "<br />";
@ -184,13 +183,15 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f
// 좋지는 않으나;; 스타일 변형을 막기 위해 start 할때 html이면 바꿔주자
if (xGetCookie('editor_mode') == 'html'){
var iframe_obj = editorGetIFrame(editor_sequence);
iframe_obj = editorGetIFrame(editor_sequence);
if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block';
textarea_obj = editorGetTextArea(editor_sequence);
textarea_obj.value = content;
xWidth(textarea_obj, xWidth(iframe_obj.parentNode));
xHeight(textarea_obj, xHeight(iframe_obj.parentNode));
editorMode[editor_sequence] = 'html';
if(xGetElementById('xeEditor_'+editor_sequence)) {
xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html';
xGetElementById('use_rich_'+editor_sequence).className = '';
@ -220,6 +221,7 @@ function editorKeyPress(evt) {
var body_obj = null;
if(obj.nodeName == "BODY") body_obj = obj;
else body_obj = obj.firstChild.nextSibling;
if(!body_obj) return;
// editor_sequence는 에디터의 body에 attribute로 정의되어 있음
@ -231,38 +233,35 @@ function editorKeyPress(evt) {
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
obj = contentDocument.selection.createRange();
var contentDocument = iframe_obj.contentWindow.document;
var obj = contentDocument.selection.createRange();
var pTag = obj.parentElement().tagName.toLowerCase();
switch(pTag) {
case 'li' :
return;
break;
return;
default :
obj.pasteHTML("<br />");
obj.pasteHTML("<br />");
break;
}
obj.select();
evt.cancelBubble = true;
evt.returnValue = false;
return;
}
// ctrl-S, alt-S 클릭시 submit하기
if( e.keyCode == 115 && (e.altKey || e.ctrlKey) ) {
// iframe 에디터를 찾음
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
if(!editorGetIFrame(editor_sequence)) return;
// 대상 form을 찾음
var fo_obj = editorGetForm(editor_sequence);
if(!fo_obj) return;
// 데이터 동기화
editorRelKeys[editor_sequence]['content'].value = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence].content.value = editorGetContent(editor_sequence);
// form문 전송
if(fo_obj.onsubmit) fo_obj.onsubmit();
@ -278,8 +277,7 @@ function editorKeyPress(evt) {
// ctrl-b, i, u, s 키에 대한 처리 (파이어폭스에서도 에디터 상태에서 단축키 쓰도록)
if (e.ctrlKey) {
// iframe 에디터를 찾음
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
if(!editorGetIFrame(editor_sequence)) return;
// html 에디터 모드일 경우 이벤트 취소 시킴
if(editorMode[editor_sequence]) {
@ -287,6 +285,7 @@ function editorKeyPress(evt) {
evt.returnValue = false;
xPreventDefault(evt);
xStopPropagation(evt);
return;
}
@ -312,13 +311,16 @@ function editorKeyPress(evt) {
case 13 :
if(xIE4Up) {
if(e.target.parentElement.document.designMode!="On") return;
var obj = e.target.parentElement.document.selection.createRange();
obj = e.target.parentElement.document.selection.createRange();
obj.pasteHTML('<P>');
obj.select();
evt.cancelBubble = true;
evt.returnValue = false;
return;
}
break;
// bold
case 98 :
editorDo('Bold',null,e.target);
@ -425,8 +427,8 @@ function editorChangeHeader(obj,srl) {
**/
function editorChangeMode(mode, editor_sequence) {
if(mode == 'html' || mode ==''){
/* jshint -W041 */
if(mode == 'html' || mode == ''){
var expire = new Date();
expire.setTime(expire.getTime()+ (7000 * 24 * 3600000));
xSetCookie('editor_mode', mode, expire);
@ -450,7 +452,7 @@ function editorChangeMode(mode, editor_sequence) {
// xAddEventListener(xGetElementById('editor_preview_'+editor_sequence), 'load', function(){setPreviewHeight(editor_sequence)});
} else {
html = contentDocument.body.innerHTML;
textarea_obj.value = html
textarea_obj.value = html;
html = html.replace(/<br>/ig,"<br />\n");
html = html.replace(/<br \/>\n\n/ig,"<br />\n");
}
@ -557,10 +559,10 @@ function setPreviewHeight(editor_sequence){
}
function getAutoSavedSrl(ret_obj, response_tags, c) {
var editor_sequence = ret_obj['editor_sequence'];
var primary_key = ret_obj['key'];
var editor_sequence = ret_obj.editor_sequence;
var primary_key = ret_obj.key;
var fo_obj = editorGetForm(editor_sequence);
fo_obj[primary_key].value = ret_obj['document_srl'];
fo_obj[primary_key].value = ret_obj.document_srl;
if(uploadSettingObj[editor_sequence]) editorUploadInit(uploadSettingObj[editor_sequence], true);
}