mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-25 22:29:55 +09:00
#77. 에디터에서 파일 업로드 행동을 하였을 경우에만 getNextSequence() 를 호출하도록 하여 DB 부하를 대폭 감소.
블로그 모듈의 기본 스킨들에서 댓글의 에디터도 위지윅 에디터로 대체하였음.
기본 board모듈의 스킨은 filter/insert.xml에서 document_srl을 제거해야 함.
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2572 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
86670c07c5
commit
9a9e86f1fa
58 changed files with 857 additions and 620 deletions
|
|
@ -4,193 +4,57 @@
|
|||
* @brief 에디터 관련 스크립트
|
||||
**/
|
||||
|
||||
// iframe의 id prefix
|
||||
var iframe_id = 'editor_iframe_';
|
||||
var textarea_id = 'editor_textarea_';
|
||||
/**
|
||||
* 에디터에서 사용하는 iframe, textarea의 prefix
|
||||
**/
|
||||
var iframe_id = 'editor_iframe_'; ///< 에디터로 사용하는 iframe의 prefix
|
||||
var textarea_id = 'editor_textarea_'; ///< 에디터의 html편집 모드에서 사용하는 textarea의 prefix
|
||||
var editor_mode = new Array(); ///<< 에디터의 html편집 모드 flag 세팅 변수
|
||||
var _editorSyncList = new Array(); ///< 에디터와 form 동기화를 위한 동기화 대상 목록
|
||||
var _autoSaveObj = {fo_obj:null, editor_sequence:0, title:'', content:'', locked:false} ///< 자동저장을 위한 정보를 가진 object
|
||||
var editor_rel_keys = new Array(); ///< 에디터와 각 모듈과의 연동을 위한 key 값을 보관하는 변수
|
||||
|
||||
// upload_target_srl에 대한 form문을 객체로 보관함
|
||||
var editor_form_list = new Array();
|
||||
/**
|
||||
* 에디터 사용시 사용되는 이벤트 연결 함수 호출
|
||||
**/
|
||||
xAddEventListener(window, 'load', _editorSync); ///< 에디터의 동기화를 하는 함수를 window.load시 실행
|
||||
|
||||
// 편집 상태에 대한 체크
|
||||
var editor_mode = new Array();
|
||||
|
||||
// upload_target_srl값에 해당하는 iframe의 object를 return
|
||||
function editorGetIFrame(upload_target_srl) {
|
||||
var obj_id = iframe_id+upload_target_srl;
|
||||
|
||||
/**
|
||||
* 에디터의 상태나 객체를 구하기 위한 함수
|
||||
**/
|
||||
|
||||
// editor_sequence값에 해당하는 iframe의 object를 return
|
||||
function editorGetIFrame(editor_sequence) {
|
||||
var obj_id = iframe_id + editor_sequence;
|
||||
return xGetElementById(obj_id);
|
||||
}
|
||||
|
||||
// upload_target_srl값에 해당하는 textarea object를 return
|
||||
function editorGetTextArea(upload_target_srl) {
|
||||
var obj_id = textarea_id+upload_target_srl;
|
||||
// editor_sequence값에 해당하는 textarea object를 return
|
||||
function editorGetTextArea(editor_sequence) {
|
||||
var obj_id = textarea_id + editor_sequence;
|
||||
return xGetElementById(obj_id);
|
||||
}
|
||||
|
||||
// editor 시작 (upload_target_srl로 iframe객체를 얻어서 쓰기 모드로 전환)
|
||||
function editorStart(upload_target_srl, resizable, editor_height) {
|
||||
if(typeof(resizable)=="undefined"||!resizable) resizable = false;
|
||||
else resizable = true;
|
||||
|
||||
// iframe obj를 찾음
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
// editor_sequence에 해당하는 form문 구함
|
||||
function editorGetForm(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
iframe_obj.style.width = '100%';
|
||||
|
||||
// 현 에디터를 감싸고 있는 form문을 찾아서 content object를 찾아서 내용 sync
|
||||
var fo_obj = iframe_obj.parentNode;
|
||||
while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
|
||||
|
||||
// saved document에 대한 체크
|
||||
if(typeof(fo_obj._saved_doc_title)!="undefined" ) {
|
||||
var saved_title = fo_obj._saved_doc_title.value;
|
||||
var saved_content = fo_obj._saved_doc_content.value;
|
||||
if(saved_title || saved_content) {
|
||||
if(confirm(fo_obj._saved_doc_message.value)) {
|
||||
fo_obj.title.value = saved_title;
|
||||
fo_obj.content.value = saved_content;
|
||||
} else {
|
||||
editorRemoveSavedDoc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 구해진 form 객체를 저장
|
||||
editor_form_list[upload_target_srl] = fo_obj;
|
||||
|
||||
// 대상 form의 content object에서 데이터를 구함
|
||||
var content = fo_obj.content.value;
|
||||
if(!content && !xIE4Up) content = "<br />";
|
||||
|
||||
// iframe내의 document object
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
|
||||
// 기본 내용 작성
|
||||
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"/>'+
|
||||
'<base href="'+request_uri+'" />'+
|
||||
'<link rel="stylesheet" href="'+request_uri+'/common/css/default.css" type="text/css" />'+
|
||||
'<link rel="stylesheet" href="'+request_uri+editor_path+'/css/editor.css" type="text/css" />'+
|
||||
'<style style="text/css">'+
|
||||
'body {margin:0px; height:'+editor_height+'px;}'+
|
||||
'</style>'+
|
||||
'</head><body upload_target_srl="'+upload_target_srl+'">'+
|
||||
content+
|
||||
'</body></html>'+
|
||||
'';
|
||||
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();
|
||||
|
||||
// 작성시 필요한 이벤트 체크
|
||||
if(xIE4Up) xAddEventListener(contentDocument, 'keydown',editorKeyPress);
|
||||
else xAddEventListener(contentDocument, 'keypress',editorKeyPress);
|
||||
xAddEventListener(contentDocument,'mousedown',editorHideObject);
|
||||
|
||||
// 위젯 감시를 위한 더블클릭 이벤트 걸기 (오페라에 대한 처리는 차후에.. 뭔가 이상함)
|
||||
xAddEventListener(contentDocument,'dblclick',editorSearchComponent);
|
||||
xAddEventListener(document,'dblclick',editorSearchComponent);
|
||||
|
||||
xAddEventListener(document,'mouseup',editorEventCheck);
|
||||
xAddEventListener(document,'mousedown',editorHideObject);
|
||||
|
||||
if(xIE4Up && xGetElementById('for_ie_help_'+upload_target_srl)) {
|
||||
xGetElementById('for_ie_help_'+upload_target_srl).style.display = "block";
|
||||
}
|
||||
|
||||
// 에디터의 내용을 지속적으로 fo_obj.content.value에 입력
|
||||
editorSyncContent(fo_obj.content, upload_target_srl);
|
||||
|
||||
if(typeof(fo_obj._saved_doc_title)!="undefined" ) editorEnableAutoSave(fo_obj, upload_target_srl);
|
||||
|
||||
// 크기 변경 불가일 경우 드래그바 숨김
|
||||
if(resizable == false) xGetElementById("editor_drag_bar_"+upload_target_srl).style.display = "none";
|
||||
|
||||
if(fo_obj.nodeName == 'FORM') return fo_obj;
|
||||
return;
|
||||
}
|
||||
|
||||
// 여러개의 편집기를 예상하여 전역 배열 변수에 form, iframe의 정보를 넣음
|
||||
var _editorSyncList = new Array();
|
||||
function editorSyncContent(obj, upload_target_srl) {
|
||||
_editorSyncList[_editorSyncList.length] = {field:obj, upload_target_srl:upload_target_srl}
|
||||
}
|
||||
|
||||
// 편집기와 폼의 정보를 주기적으로 동기화 시킴
|
||||
function _editorSync() {
|
||||
for(var i=0;i<_editorSyncList.length;i++) {
|
||||
var field = _editorSyncList[i].field;
|
||||
var upload_target_srl = _editorSyncList[i].upload_target_srl;
|
||||
var content = editorGetContent(upload_target_srl);
|
||||
if(typeof(content)=='undefined') continue;
|
||||
field.value = content;
|
||||
}
|
||||
setTimeout(_editorSync, 1000);
|
||||
}
|
||||
xAddEventListener(window, 'load', _editorSync);
|
||||
|
||||
// 자동 저장 기능
|
||||
var _autoSaveObj = {fo_obj:null, upload_target_srl:0, title:'', content:''}
|
||||
function editorEnableAutoSave(fo_obj, upload_target_srl) {
|
||||
var title = fo_obj.title.value;
|
||||
var content = fo_obj.content.value;
|
||||
_autoSaveObj = {"fo_obj":fo_obj, "upload_target_srl":upload_target_srl, "title":title, "content":content};
|
||||
setTimeout(_editorAutoSave, 5000);
|
||||
}
|
||||
|
||||
function _editorAutoSave() {
|
||||
var fo_obj = _autoSaveObj.fo_obj;
|
||||
var upload_target_srl = _autoSaveObj.upload_target_srl;
|
||||
|
||||
if(fo_obj && upload_target_srl) {
|
||||
var title = fo_obj.title.value;
|
||||
var content = editorGetContent(upload_target_srl);
|
||||
if((fo_obj.title && title.trim() != _autoSaveObj.title.trim()) || content.trim() != _autoSaveObj.content.trim()) {
|
||||
var params = new Array();
|
||||
params["document_srl"] = upload_target_srl;
|
||||
params["title"] = title;
|
||||
params["content"] = content;
|
||||
|
||||
_autoSaveObj.title = title;
|
||||
_autoSaveObj.content = content;
|
||||
|
||||
var obj = xGetElementById("editor_autosaved_message_"+upload_target_srl);
|
||||
var oDate = new Date();
|
||||
html = oDate.getHours()+':'+oDate.getMinutes()+' '+auto_saved_msg;
|
||||
xInnerHtml(obj, html);
|
||||
obj.style.display = "block";
|
||||
|
||||
show_waiting_message = false;
|
||||
exec_xml("editor","procEditorSaveDoc", params, _editorAutoSaved);
|
||||
show_waiting_message = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(_editorAutoSave, 15000);
|
||||
}
|
||||
|
||||
function _editorAutoSaved(ret_obj) {
|
||||
setTimeout(_editorAutoSave, 15000);
|
||||
return null;
|
||||
}
|
||||
|
||||
function editorRemoveSavedDoc() {
|
||||
exec_xml("editor","procEditorRemoveSavedDoc");
|
||||
}
|
||||
|
||||
// 에디터의 전체 내용 return
|
||||
function editorGetContent(upload_target_srl) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
// 에디터의 전체 내용 return, HTML 편집모드일 경우에 데이터를 이전후 값 return
|
||||
function editorGetContent(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return null;
|
||||
|
||||
var html = null;
|
||||
if(editor_mode[upload_target_srl]=='html') {
|
||||
var textarea_obj = editorGetTextArea(upload_target_srl);
|
||||
if(editor_mode[editor_sequence]=='html') {
|
||||
var textarea_obj = editorGetTextArea(editor_sequence);
|
||||
var html = textarea_obj.value;
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
contentDocument.body.innerHTML = html;
|
||||
|
|
@ -202,8 +66,8 @@ function editorGetContent(upload_target_srl) {
|
|||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html 코드를 return
|
||||
function editorGetSelectedHtml(upload_target_srl) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
function editorGetSelectedHtml(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
var html = range.htmlText;
|
||||
|
|
@ -219,8 +83,8 @@ function editorGetSelectedHtml(upload_target_srl) {
|
|||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 NODE를 return
|
||||
function editorGetSelectedNode(upload_target_srl) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
function editorGetSelectedNode(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
var div = xCreateElement('div');
|
||||
|
|
@ -235,6 +99,217 @@ function editorGetSelectedNode(upload_target_srl) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* editor 시작 (editor_sequence로 iframe객체를 얻어서 쓰기 모드로 전환)
|
||||
**/
|
||||
function editorStart(editor_sequence, primary_key, content_key, resizable, editor_height) {
|
||||
// resize 가/불가에 대한 체크
|
||||
if(typeof(resizable)=="undefined"||!resizable) resizable = false;
|
||||
else resizable = true;
|
||||
|
||||
// iframe obj를 찾음
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
iframe_obj.style.width = '100%'; ///<< iframe_obj의 가로 크기를 100%로 고정
|
||||
|
||||
// 현 에디터를 감싸고 있는 form문을 찾아서 content object를 찾아서 내용 sync
|
||||
var fo_obj = editorGetForm(editor_sequence);
|
||||
if(!fo_obj) return;
|
||||
|
||||
// 모듈 연관 키 값을 세팅
|
||||
editor_rel_keys[editor_sequence] = new Array();
|
||||
editor_rel_keys[editor_sequence]["primary"] = fo_obj[primary_key];
|
||||
editor_rel_keys[editor_sequence]["content"] = fo_obj[content_key];
|
||||
|
||||
// saved document(자동저장 문서)에 대한 확인
|
||||
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;
|
||||
|
||||
if(saved_title || saved_content) {
|
||||
// 자동저장된 문서 활용여부를 물은 후 사용하지 않는다면 자동저장된 문서 삭제
|
||||
if(confirm(fo_obj._saved_doc_message.value)) {
|
||||
if(typeof(fo_obj.title)!='undefined') fo_obj.title.value = saved_title;
|
||||
editor_rel_keys[editor_sequence]['content'].value = saved_content;
|
||||
} else {
|
||||
editorRemoveSavedDoc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 대상 form의 content element에서 데이터를 구함
|
||||
var content = editor_rel_keys[editor_sequence]['content'].value;
|
||||
|
||||
// IE가 아니고 내용이 없으면 <br /> 추가 (FF등에서 iframe 선택시 focus를 주기 위한 꽁수)
|
||||
if(!content && !xIE4Up) content = "<br />";
|
||||
|
||||
// iframe내의 document element를 구함
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
|
||||
/**
|
||||
* 에디터를 위지윅 모드로 만들기 위해 내용 작성 후 designMode 활성화
|
||||
**/
|
||||
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"/>'+
|
||||
'<base href="'+request_uri+'" />'+
|
||||
'<link rel="stylesheet" href="'+request_uri+'/common/css/default.css" type="text/css" />'+
|
||||
'<link rel="stylesheet" href="'+request_uri+editor_path+'/css/editor.css" type="text/css" />'+
|
||||
'<style style="text/css">'+
|
||||
'body {font-size:9pt;margin:0px; height:'+editor_height+'px;}'+
|
||||
'</style>'+
|
||||
'</head><body editor_sequence="'+editor_sequence+'">'+
|
||||
content+
|
||||
'</body></html>'+
|
||||
'';
|
||||
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 추가
|
||||
**/
|
||||
// 작성시 필요한 이벤트 체크
|
||||
if(xIE4Up) xAddEventListener(contentDocument, 'keydown',editorKeyPress);
|
||||
else xAddEventListener(contentDocument, 'keypress',editorKeyPress);
|
||||
xAddEventListener(contentDocument,'mousedown',editorHideObject);
|
||||
|
||||
// 위젯 감시를 위한 더블클릭 이벤트 걸기 (오페라에 대한 처리는 차후에.. 뭔가 이상함)
|
||||
xAddEventListener(contentDocument,'dblclick',editorSearchComponent);
|
||||
xAddEventListener(document,'dblclick',editorSearchComponent);
|
||||
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와 동기화만 된다면 어떤 에디터라도 사용 가능하도록 하기 위해
|
||||
* 별도의 동기화 루틴을 이용함
|
||||
**/
|
||||
editorSyncContent(editor_rel_keys[editor_sequence]['content'], editor_sequence);
|
||||
|
||||
// 자동저장 필드가 있다면 자동 저장 기능 활성화
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 에디터와 form문의 동기화를 위한 함수들
|
||||
**/
|
||||
// 여러개의 편집기를 예상하여 전역 배열 변수에 form, iframe의 정보를 넣음
|
||||
function editorSyncContent(obj, editor_sequence) {
|
||||
_editorSyncList[_editorSyncList.length] = {field:obj, editor_sequence:editor_sequence}
|
||||
}
|
||||
|
||||
// 편집기와 폼의 정보를 주기적으로 동기화 시킴
|
||||
function _editorSync() {
|
||||
// 등록된 모든 에디터에 대해 동기화를 시킴
|
||||
for(var i=0;i<_editorSyncList.length;i++) {
|
||||
var field = _editorSyncList[i].field;
|
||||
var editor_sequence = _editorSyncList[i].editor_sequence;
|
||||
var content = editorGetContent(editor_sequence);
|
||||
if(typeof(content)=='undefined') continue;
|
||||
field.value = content;
|
||||
}
|
||||
|
||||
// 1.5초마다 계속 동기화 시킴
|
||||
setTimeout(_editorSync, 1500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 자동 저장 기능
|
||||
**/
|
||||
// 자동 저장 활성화 시키는 함수 (5초마다 자동저장)
|
||||
function editorEnableAutoSave(fo_obj, editor_sequence) {
|
||||
var title = fo_obj.title.value;
|
||||
var content = editor_rel_keys[editor_sequence]['content'].value;
|
||||
_autoSaveObj = {"fo_obj":fo_obj, "editor_sequence":editor_sequence, "title":title, "content":content, locked:false};
|
||||
setTimeout(_editorAutoSave, 5000);
|
||||
}
|
||||
|
||||
// ajax를 이용하여 editor.procEditorSaveDoc 호출하여 자동 저장시킴
|
||||
function _editorAutoSave() {
|
||||
var fo_obj = _autoSaveObj.fo_obj;
|
||||
var editor_sequence = _autoSaveObj.editor_sequence;
|
||||
|
||||
// 현재 자동저장중이면 중지
|
||||
if(_autoSaveObj.locked == true) return;
|
||||
|
||||
// 대상이 없으면 자동저장 시키는 기능 자체를 중지
|
||||
if(!fo_obj || typeof(fo_obj.title)=='undefined' || !editor_sequence) return;
|
||||
|
||||
// 자동저장을 위한 준비
|
||||
var title = fo_obj.title.value;
|
||||
var content = editorGetContent(editor_sequence);
|
||||
|
||||
// 내용이 이전에 저장하였던 것과 다르면 자동 저장을 함
|
||||
if(title != _autoSaveObj.title || content != _autoSaveObj.content ) {
|
||||
var params = new Array();
|
||||
|
||||
params["title"] = title;
|
||||
params["content"] = content;
|
||||
params["document_srl"] = editor_rel_keys[editor_sequence]['primary'].value;
|
||||
|
||||
_autoSaveObj.title = title;
|
||||
_autoSaveObj.content = content;
|
||||
|
||||
var obj = xGetElementById("editor_autosaved_message_"+editor_sequence);
|
||||
var oDate = new Date();
|
||||
html = oDate.getHours()+':'+oDate.getMinutes()+' '+auto_saved_msg;
|
||||
xInnerHtml(obj, html);
|
||||
obj.style.display = "block";
|
||||
|
||||
// 현재 자동저장중임을 설정
|
||||
_autoSaveObj.locked = true;
|
||||
|
||||
// 서버 호출 (서버와 교신중이라는 메세지를 보이지 않도록 함)
|
||||
show_waiting_message = false;
|
||||
exec_xml("editor","procEditorSaveDoc", params, function() { _autoSaveObj.locked = false; } );
|
||||
show_waiting_message = true;
|
||||
}
|
||||
|
||||
// 10초마다 동기화를 시킴
|
||||
setTimeout(_editorAutoSave, 10000);
|
||||
}
|
||||
|
||||
// 자동저장된 모든 메세지를 삭제하는 루틴
|
||||
function editorRemoveSavedDoc() {
|
||||
exec_xml("editor","procEditorRemoveSavedDoc");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 에디터의 세부 설정과 데이터 핸들링을 정의한 함수들
|
||||
**/
|
||||
|
||||
// 에디터에 포커스를 줌
|
||||
function editorFocus(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
iframe_obj.contentWindow.focus();
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html코드를 변경
|
||||
function editorReplaceHTML(iframe_obj, html) {
|
||||
iframe_obj.contentWindow.focus();
|
||||
|
|
@ -259,33 +334,32 @@ function editorReplaceHTML(iframe_obj, html) {
|
|||
}
|
||||
}
|
||||
|
||||
// 에디터에 포커스를 줌
|
||||
function editorFocus(upload_target_srl) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
iframe_obj.contentWindow.focus();
|
||||
}
|
||||
/**
|
||||
* 키 또는 마우스 이벤트 핸들링 정의 함수
|
||||
**/
|
||||
|
||||
// 입력 키에 대한 이벤트 체크
|
||||
function editorKeyPress(evt) {
|
||||
var e = new xEvent(evt);
|
||||
|
||||
// 대상을 구함
|
||||
var obj = e.target;
|
||||
var body_obj = null;
|
||||
if(obj.nodeName == "BODY") body_obj = obj;
|
||||
else body_obj = obj.firstChild.nextSibling;
|
||||
if(!body_obj) return;
|
||||
|
||||
var upload_target_srl = body_obj.getAttribute("upload_target_srl");
|
||||
if(!upload_target_srl) return;
|
||||
// editor_sequence는 에디터의 body에 attribute로 정의되어 있음
|
||||
var editor_sequence = body_obj.getAttribute("editor_sequence");
|
||||
if(!editor_sequence) return;
|
||||
|
||||
// IE에서 enter키를 눌렀을때 P 태그 대신 BR 태그 입력
|
||||
if (xIE4Up && !e.ctrlKey && !e.shiftKey && e.keyCode == 13 && editor_mode[upload_target_srl]!='html') {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
if (xIE4Up && !e.ctrlKey && !e.shiftKey && e.keyCode == 13 && editor_mode[editor_sequence]!='html') {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
|
||||
var obj = contentDocument.selection.createRange();
|
||||
obj.pasteHTML('<br />');
|
||||
obj.pasteHTML("<br />\n");
|
||||
obj.select();
|
||||
evt.cancelBubble = true;
|
||||
evt.returnValue = false;
|
||||
|
|
@ -294,14 +368,21 @@ function editorKeyPress(evt) {
|
|||
|
||||
// ctrl-S, alt-S 클릭시 submit하기
|
||||
if( e.keyCode == 115 && (e.altKey || e.ctrlKey) ) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
// iframe 에디터를 찾음
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
|
||||
var fo_obj = iframe_obj.parentNode;
|
||||
while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
|
||||
// 대상 form을 찾음
|
||||
var fo_obj = editorGetForm(editor_sequence);
|
||||
if(!fo_obj) return;
|
||||
|
||||
// 데이터 동기화
|
||||
editor_rel_keys[editor_sequence]['content'].value = editorGetContent(editor_sequence);
|
||||
|
||||
// form문 전송
|
||||
if(fo_obj.onsubmit) fo_obj.onsubmit();
|
||||
|
||||
// 이벤트 중단
|
||||
evt.cancelBubble = true;
|
||||
evt.returnValue = false;
|
||||
xPreventDefault(evt);
|
||||
|
|
@ -311,12 +392,12 @@ function editorKeyPress(evt) {
|
|||
|
||||
// ctrl-b, i, u, s 키에 대한 처리 (파이어폭스에서도 에디터 상태에서 단축키 쓰도록)
|
||||
if (e.ctrlKey) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
// iframe 에디터를 찾음
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
var contentDocument = iframe_obj.contentWindow.document;
|
||||
|
||||
// html 에디터 모드일 경우 이벤트 취소 시킴
|
||||
if(editor_mode[upload_target_srl]=='html') {
|
||||
if(editor_mode[editor_sequence]=='html') {
|
||||
evt.cancelBubble = true;
|
||||
evt.returnValue = false;
|
||||
xPreventDefault(evt);
|
||||
|
|
@ -384,7 +465,64 @@ function editorKeyPress(evt) {
|
|||
}
|
||||
}
|
||||
|
||||
// 에디터 상단의 버튼 클릭시 action 처리 (마우스다운 이벤트 발생시마다 요청이 됨)
|
||||
// 편집 기능 실행
|
||||
function editorDo(command, value, target) {
|
||||
|
||||
var doc = null;
|
||||
|
||||
// target이 object인지 editor_sequence인지에 따라 document를 구함
|
||||
if(typeof(target)=="object") {
|
||||
if(xIE4Up) doc = target.parentElement.document;
|
||||
else doc = target.parentNode;
|
||||
} else {
|
||||
var iframe_obj = editorGetIFrame(target);
|
||||
doc = iframe_obj.contentWindow.document;
|
||||
}
|
||||
|
||||
var editor_sequence = doc.body.getAttribute('editor_sequence');
|
||||
if(editor_mode[editor_sequence]=='html') return;
|
||||
|
||||
// 포커스
|
||||
if(typeof(target)=="object") target.focus();
|
||||
else editorFocus(target);
|
||||
|
||||
// 실행
|
||||
doc.execCommand(command, false, value);
|
||||
|
||||
// 포커스
|
||||
if(typeof(target)=="object") target.focus();
|
||||
else editorFocus(target);
|
||||
}
|
||||
|
||||
// 폰트를 변경
|
||||
function editorChangeFontName(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
editorDo('FontName',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function editorChangeFontSize(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
editorDo('FontSize',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function editorChangeHeader(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
value = "<"+value+">";
|
||||
editorDo('formatblock',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 에디터 컴포넌트 구현 부분
|
||||
**/
|
||||
|
||||
// 에디터 상단의 컴포넌트 버튼 클릭시 action 처리 (마우스다운 이벤트 발생시마다 요청이 됨)
|
||||
var editorPrevObj = null;
|
||||
var editorPrevSrl = null;
|
||||
function editorEventCheck(evt) {
|
||||
|
|
@ -395,14 +533,14 @@ function editorEventCheck(evt) {
|
|||
var target_id = e.target.id;
|
||||
if(!target_id) return;
|
||||
|
||||
// upload_target_srl와 component name을 구함 (id가 포맷과 다르면 return)
|
||||
// editor_sequence와 component name을 구함 (id가 포맷과 다르면 return)
|
||||
var info = target_id.split('_');
|
||||
if(info[0]!="component") return;
|
||||
var upload_target_srl = info[1];
|
||||
var editor_sequence = info[1];
|
||||
var component_name = target_id.replace(/^component_([0-9]+)_/,'');
|
||||
if(!upload_target_srl || !component_name) return;
|
||||
if(!editor_sequence || !component_name) return;
|
||||
|
||||
if(editor_mode[upload_target_srl]=='html') return;
|
||||
if(editor_mode[editor_sequence]=='html') return;
|
||||
|
||||
switch(component_name) {
|
||||
|
||||
|
|
@ -420,12 +558,12 @@ function editorEventCheck(evt) {
|
|||
case 'outdent' :
|
||||
case 'insertorderedlist' :
|
||||
case 'insertunorderedlist' :
|
||||
editorDo(component_name, '', upload_target_srl);
|
||||
editorDo(component_name, '', editor_sequence);
|
||||
break;
|
||||
|
||||
// 추가 컴포넌트의 경우 서버에 요청을 시도
|
||||
default :
|
||||
openComponent(component_name, upload_target_srl);
|
||||
openComponent(component_name, editor_sequence);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -433,11 +571,11 @@ function editorEventCheck(evt) {
|
|||
}
|
||||
|
||||
// 컴포넌트 팝업 열기
|
||||
function openComponent(component_name, upload_target_srl, manual_url) {
|
||||
editorPrevSrl = upload_target_srl;
|
||||
if(editor_mode[upload_target_srl]=='html') return;
|
||||
function openComponent(component_name, editor_sequence, manual_url) {
|
||||
editorPrevSrl = editor_sequence;
|
||||
if(editor_mode[editor_sequence]=='html') return;
|
||||
|
||||
var popup_url = request_uri+"?module=editor&act=dispEditorPopup&upload_target_srl="+upload_target_srl+"&component="+component_name;
|
||||
var popup_url = request_uri+"?module=editor&act=dispEditorPopup&editor_sequence="+editor_sequence+"&component="+component_name;
|
||||
if(typeof(manual_url)!="undefined" && manual_url) popup_url += "&manual_url="+escape(manual_url);
|
||||
|
||||
popopen(popup_url, 'editorComponent');
|
||||
|
|
@ -453,21 +591,21 @@ function editorSearchComponent(evt) {
|
|||
|
||||
// 위젯인지 일단 체크
|
||||
if(obj.getAttribute("widget")) {
|
||||
// upload_target_srl을 찾음
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("upload_target_srl")) {
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var upload_target_srl = tobj.getAttribute("upload_target_srl");
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
var widget = obj.getAttribute("widget");
|
||||
editorPrevNode = obj;
|
||||
|
||||
if(editor_mode[upload_target_srl]=='html') return;
|
||||
popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+upload_target_srl,'GenerateCodeInPage');
|
||||
if(editor_mode[editor_sequence]=='html') return;
|
||||
popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -510,19 +648,19 @@ function editorSearchComponent(evt) {
|
|||
return;
|
||||
}
|
||||
|
||||
// upload_target_srl을 찾음
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("upload_target_srl")) {
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var upload_target_srl = tobj.getAttribute("upload_target_srl");
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
|
||||
// 해당 컴포넌트를 찾아서 실행
|
||||
openComponent(editor_component, upload_target_srl);
|
||||
openComponent(editor_component, editor_sequence);
|
||||
}
|
||||
|
||||
// 마우스 클릭시 이전 object정보를 숨김
|
||||
|
|
@ -541,14 +679,15 @@ function editorHideObject(evt) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HTML 편집 기능
|
||||
* HTML 편집 기능 활성/비활성
|
||||
**/
|
||||
function editorChangeMode(obj, upload_target_srl) {
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
function editorChangeMode(obj, editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(!iframe_obj) return;
|
||||
|
||||
var textarea_obj = editorGetTextArea(upload_target_srl);
|
||||
var textarea_obj = editorGetTextArea(editor_sequence);
|
||||
xWidth(textarea_obj, xWidth(iframe_obj.parentNode));
|
||||
xHeight(textarea_obj, xHeight(iframe_obj.parentNode));
|
||||
|
||||
|
|
@ -564,9 +703,9 @@ function editorChangeMode(obj, upload_target_srl) {
|
|||
|
||||
iframe_obj.parentNode.style.display = "none";
|
||||
textarea_obj.style.display = "block";
|
||||
xGetElementById('xeEditorOption_'+upload_target_srl).style.display = "none";
|
||||
xGetElementById('xeEditorOption_'+editor_sequence).style.display = "none";
|
||||
|
||||
editor_mode[upload_target_srl] = 'html';
|
||||
editor_mode[editor_sequence] = 'html';
|
||||
|
||||
// 위지윅 모드 사용시
|
||||
} else {
|
||||
|
|
@ -574,68 +713,12 @@ function editorChangeMode(obj, upload_target_srl) {
|
|||
contentDocument.body.innerHTML = html;
|
||||
iframe_obj.parentNode.style.display = "block";
|
||||
textarea_obj.style.display = "none";
|
||||
xGetElementById('xeEditorOption_'+upload_target_srl).style.display = "block";
|
||||
editor_mode[upload_target_srl] = null;
|
||||
xGetElementById('xeEditorOption_'+editor_sequence).style.display = "block";
|
||||
editor_mode[editor_sequence] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 편집기능 실행
|
||||
*/
|
||||
|
||||
// 편집 기능 실행
|
||||
function editorDo(command, value, target) {
|
||||
|
||||
var doc = null;
|
||||
|
||||
// target이 object인지 upload_target_srl인지에 따라 document를 구함
|
||||
if(typeof(target)=="object") {
|
||||
if(xIE4Up) doc = target.parentElement.document;
|
||||
else doc = target.parentNode;
|
||||
} else {
|
||||
var iframe_obj = editorGetIFrame(target);
|
||||
doc = iframe_obj.contentWindow.document;
|
||||
}
|
||||
|
||||
var upload_target_srl = doc.body.getAttribute('upload_target_srl');
|
||||
if(editor_mode[upload_target_srl]=='html') return;
|
||||
|
||||
// 포커스
|
||||
if(typeof(target)=="object") target.focus();
|
||||
else editorFocus(target);
|
||||
|
||||
// 실행
|
||||
doc.execCommand(command, false, value);
|
||||
|
||||
// 포커스
|
||||
if(typeof(target)=="object") target.focus();
|
||||
else editorFocus(target);
|
||||
}
|
||||
|
||||
// 폰트를 변경
|
||||
function editorChangeFontName(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
editorDo('FontName',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function editorChangeFontSize(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
editorDo('FontSize',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function editorChangeHeader(obj,srl) {
|
||||
var value = obj.options[obj.selectedIndex].value;
|
||||
if(!value) return;
|
||||
value = "<"+value+">";
|
||||
editorDo('formatblock',value,srl);
|
||||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* iframe 세로 크기 조절 드래그 관련
|
||||
**/
|
||||
|
|
@ -708,8 +791,8 @@ function eOptionClick(obj) {
|
|||
}
|
||||
|
||||
// Editor Info Close
|
||||
function closeEditorInfo(upload_target_srl) {
|
||||
xGetElementById('editorInfo_'+upload_target_srl).style.display='none';
|
||||
function closeEditorInfo(editor_sequence) {
|
||||
xGetElementById('editorInfo_'+editor_sequence).style.display='none';
|
||||
var expire = new Date();
|
||||
expire.setTime(expire.getTime()+ (7000 * 24 * 3600000));
|
||||
xSetCookie('EditorInfo', '1', expire);
|
||||
|
|
|
|||
|
|
@ -3,51 +3,40 @@
|
|||
* @version 0.1
|
||||
* @brief 파일 업로드 관련
|
||||
*
|
||||
***********************************************************************************************************************************************
|
||||
*****************************************************************************************************************************
|
||||
* 제로보드XE의 게시물 파일업로드 컴포넌트는 "mmSWFUpload 1.0: Flash upload dialog - http://swfupload.mammon.se/" 를 사용합니다.
|
||||
* - SWFUpload is (c) 2006 Lars Huring and Mammon Media and is released under the MIT License:http://www.opensource.org/licenses/mit-license.php
|
||||
***********************************************************************************************************************************************
|
||||
*****************************************************************************************************************************
|
||||
|
||||
* 감사합니다.
|
||||
**/
|
||||
var uploading_file = false;
|
||||
var uploaded_files = new Array();
|
||||
|
||||
// 업로드를 하기 위한 준비 시작
|
||||
function editor_upload_init(upload_target_srl) {
|
||||
xAddEventListener(window,'load',function() {editor_upload_form_set(upload_target_srl);} );
|
||||
/**
|
||||
* 업로드를 하기 위한 준비 시작
|
||||
* 이 함수는 editor.html 에서 파일 업로드 가능할 경우 호출됨
|
||||
**/
|
||||
// window.load 이벤트일 경우 && 문서 번호가 가상의 번호가 아니면 기존에 저장되어 있을지도 모르는 파일 목록을 가져옴
|
||||
function editor_upload_init(editor_sequence) {
|
||||
xAddEventListener(window,'load',function() { editor_upload_start(editor_sequence);} );
|
||||
}
|
||||
|
||||
// upload_target_srl에 해당하는 form의 action을 iframe으로 변경
|
||||
function editor_upload_form_set(upload_target_srl) {
|
||||
try {
|
||||
document.execCommand('BackgroundImageCache',false,true);
|
||||
} catch(e) { }
|
||||
function editor_upload_get_target_srl(editor_sequence) {
|
||||
return editor_rel_keys[editor_sequence]['primary'].value;
|
||||
}
|
||||
|
||||
// SWFUploader load
|
||||
var uploader_name = "swf_uploader_"+upload_target_srl;
|
||||
var embed_html = "";
|
||||
var flashVars = 'uploadProgressCallback=editor_upload_progress&uploadFileErrorCallback=editor_upload_error_handle&allowedFiletypesDescription='+uploader_setting["allowed_filetypes_description"]+'&autoUpload=true&allowedFiletypes='+uploader_setting["allowed_filetypes"]+'&maximumFilesize='+uploader_setting["allowed_filesize"]+'&uploadQueueCompleteCallback=editor_display_uploaded_file&uploadScript='+escape(request_uri+'?mid='+current_url.getQuery('mid')+'&act=procFileUpload&upload_target_srl='+upload_target_srl+'&PHPSESSID='+xGetCookie(zbxe_session_name));
|
||||
function editor_upload_get_uploader_name(editor_sequence) {
|
||||
return "swf_uploader_"+editor_sequence;
|
||||
|
||||
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length) {
|
||||
embed_html = '<embed type="application/x-shockwave-flash" src="'+request_uri+'/modules/editor/tpl/images/SWFUpload.swf" width="1" height="1" id="'+uploader_name+'" name="'+uploader_name+'" quality="high" wmode="transparent" menu="false" flashvars="'+flashVars+'" />';
|
||||
} else {
|
||||
embed_html = '<object id="'+uploader_name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1"><param name="movie" value="'+request_uri+'./modules/editor/tpl/images/SWFUpload.swf" /><param name="bgcolor" value="#000000" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><param name="flashvars" value="'+flashVars+'" /></object>';
|
||||
}
|
||||
}
|
||||
|
||||
if(xIE4Up) {
|
||||
window.document.body.insertAdjacentHTML("afterEnd", "<div style='width:1px;height:1px;position:absolute;top:0px;left:0px'>"+embed_html+"</div>");
|
||||
} else {
|
||||
var dummy = xCreateElement("div");
|
||||
dummy.style.width = "1px";
|
||||
dummy.style.height = "1px";
|
||||
dummy.style.position="absolute";
|
||||
dummy.style.top="0px";
|
||||
dummy.style.left="0px";
|
||||
xInnerHtml(dummy, embed_html);
|
||||
window.document.body.appendChild(dummy);
|
||||
}
|
||||
// 파일 업로드를 위한 기본 준비를 함
|
||||
function editor_upload_start(editor_sequence) {
|
||||
// 캐시 삭제
|
||||
try { document.execCommand('BackgroundImageCache',false,true); } catch(e) { }
|
||||
|
||||
// 임시 iframe을 생성
|
||||
// 임시 iframe을 생성 (공통으로 사용)
|
||||
if(!xGetElementById('tmp_upload_iframe')) {
|
||||
if(xIE4Up) {
|
||||
window.document.body.insertAdjacentHTML("afterEnd", "<iframe id='tmp_upload_iframe' name='tmp_upload_iframe' style='display:none;width:1px;height:1px;position:absolute;top:-10px;left:-10px'></iframe>");
|
||||
|
|
@ -64,41 +53,54 @@ function editor_upload_form_set(upload_target_srl) {
|
|||
}
|
||||
}
|
||||
|
||||
// form의 action 을 변경
|
||||
var field_obj = xGetElementById("uploaded_file_list_"+upload_target_srl);
|
||||
// 첨부파일 목록을 출력하는 select element 구함
|
||||
var field_obj = xGetElementById("uploaded_file_list_"+editor_sequence);
|
||||
if(!field_obj) return;
|
||||
|
||||
var fo_obj = field_obj.parentNode;
|
||||
while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
|
||||
// 에디터를 감싸는 form을 구해 submit target을 임시 iframe으로 변경
|
||||
var fo_obj = editorGetForm(editor_sequence);
|
||||
fo_obj.target = 'tmp_upload_iframe';
|
||||
|
||||
// upload_target_srl에 해당하는 첨부파일 목록을 로드 (procDeleteFile에 file_srl을 보내주지 않으면 삭제시도는 없이 목록만 갱신할 수 있음)
|
||||
var module = "";
|
||||
if(fo_obj["module"]) module = fo_obj.module.value;
|
||||
var mid = "";
|
||||
if(fo_obj["mid"]) mid = fo_obj.mid.value;
|
||||
var document_srl = "";
|
||||
if(fo_obj["document_srl"]) document_srl = fo_obj.document_srl.value;
|
||||
// SWF uploader 생성
|
||||
var uploader_name = editor_upload_get_uploader_name(editor_sequence);
|
||||
var embed_html = "";
|
||||
|
||||
// 기 등록된 파일 표시
|
||||
editor_display_uploaded_file(upload_target_srl);
|
||||
}
|
||||
// 업로드와 관련된 변수 설정 (이 변수들이 그대로 zbxe에 전달됨)
|
||||
var flashVars = ''+
|
||||
'uploadProgressCallback=editor_upload_progress'+
|
||||
'&uploadFileErrorCallback=editor_upload_error_handle'+
|
||||
'&allowedFiletypesDescription='+uploader_setting["allowed_filetypes_description"]+
|
||||
'&autoUpload=true&allowedFiletypes='+uploader_setting["allowed_filetypes"]+
|
||||
'&maximumFilesize='+uploader_setting["allowed_filesize"]+
|
||||
'&uploadQueueCompleteCallback=editor_display_uploaded_file'+
|
||||
'&uploadScript='+escape( request_uri+'?mid='+current_url.getQuery('mid')+
|
||||
'&act=procFileUpload'+
|
||||
'&editor_sequence='+editor_sequence+
|
||||
'&PHPSESSID='+xGetCookie(zbxe_session_name)
|
||||
);
|
||||
|
||||
// upload_target_srl에 등록된 파일 표시
|
||||
var _prev_upload_target_srl = 0;
|
||||
function editor_display_uploaded_file(upload_target_srl) {
|
||||
if(typeof(upload_target_srl)=='undefined'||!upload_target_srl) {
|
||||
if(_prev_upload_target_srl) {
|
||||
upload_target_srl = _prev_upload_target_srl;
|
||||
_prev_upload_target_srl = 0;
|
||||
} else return;
|
||||
// 객체 생성 코드
|
||||
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length) {
|
||||
embed_html = '<embed type="application/x-shockwave-flash" src="'+request_uri+'/modules/editor/tpl/images/SWFUpload.swf" width="1" height="1" id="'+uploader_name+'" name="'+uploader_name+'" quality="high" wmode="transparent" menu="false" flashvars="'+flashVars+'" />';
|
||||
} else {
|
||||
embed_html = '<object id="'+uploader_name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1"><param name="movie" value="'+request_uri+'./modules/editor/tpl/images/SWFUpload.swf" /><param name="bgcolor" value="#000000" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><param name="flashvars" value="'+flashVars+'" /></object>';
|
||||
}
|
||||
var url = request_uri + "?act=procFileDelete&upload_target_srl="+upload_target_srl+"&mid="+current_url.getQuery('mid');
|
||||
|
||||
// iframe에 url을 보내버림
|
||||
var iframe_obj = xGetElementById('tmp_upload_iframe');
|
||||
if(!iframe_obj) return;
|
||||
iframe_obj.contentWindow.document.location.href=url;
|
||||
// div dummy 객체를 만들고 SWFUploader 코드를 추가하여 객체 생성
|
||||
var dummy = xCreateElement("div");
|
||||
dummy.style.width = "1px";
|
||||
dummy.style.height = "1px";
|
||||
dummy.style.position="absolute";
|
||||
dummy.style.top="0px";
|
||||
dummy.style.left="0px";
|
||||
window.document.body.appendChild(dummy);
|
||||
xInnerHtml(dummy, embed_html);
|
||||
|
||||
/**
|
||||
* upload_target_srl값이 실제 문서 번호일 경우 이미 등록되 있을지도 모르는 첨부파일 목록을 로드
|
||||
* procDeleteFile에 file_srl을 보내주지 않으면 삭제시도는 없이 목록만 갱신할 수 있음
|
||||
**/
|
||||
editor_display_uploaded_file(editor_sequence);
|
||||
}
|
||||
|
||||
// 파일 업로드 에러 핸들링
|
||||
|
|
@ -122,18 +124,29 @@ function editor_upload_error_handle(errcode,file,msg) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 업로드 관련 함수들
|
||||
**/
|
||||
|
||||
// 파일 업로드
|
||||
function editor_upload_file(upload_target_srl) {
|
||||
var swf_uploader = xGetElementById("swf_uploader_"+upload_target_srl);
|
||||
if(!swf_uploader) return;
|
||||
swf_uploader.browse();
|
||||
_prev_upload_target_srl = upload_target_srl;
|
||||
var _prev_editor_sequence; ///< 진행 상태를 표시하기 위해 바로 이전의 에디터 sequence값을 가지고 있음
|
||||
function editor_upload_file(editor_sequence) {
|
||||
// 업로더 객체를 구함
|
||||
var uploader_name = editor_upload_get_uploader_name(editor_sequence);
|
||||
var swf_uploader = xGetElementById(uploader_name);
|
||||
|
||||
try {
|
||||
swf_uploader.browse();
|
||||
_prev_editor_sequence = editor_sequence;
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 업로드 진행상태 표시
|
||||
var _progress_start = false;
|
||||
function editor_upload_progress(file, bytesLoaded) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+_prev_upload_target_srl);
|
||||
var obj = xGetElementById('uploaded_file_list_'+_prev_editor_sequence);
|
||||
if(!_progress_start) {
|
||||
while(obj.options.length) {
|
||||
obj.remove(0);
|
||||
|
|
@ -143,7 +156,7 @@ function editor_upload_progress(file, bytesLoaded) {
|
|||
|
||||
var percent = Math.ceil((bytesLoaded / file.size) * 100);
|
||||
var filename = file.name;
|
||||
if(filename.length>15) filename = filename.substr(0,15)+'...';
|
||||
if(filename.length>20) filename = filename.substr(0,20)+'...';
|
||||
|
||||
var text = filename + ' ('+percent+'%)';
|
||||
if(!obj.options.length || obj.options[obj.options.length-1].value != file.id) {
|
||||
|
|
@ -154,34 +167,54 @@ function editor_upload_progress(file, bytesLoaded) {
|
|||
}
|
||||
}
|
||||
|
||||
// 업로드된 파일 목록 비움
|
||||
function editor_upload_clear_list(upload_target_srl) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+upload_target_srl);
|
||||
// upload_target_srl 에 등록된 파일 표시
|
||||
function editor_display_uploaded_file(editor_sequence) {
|
||||
if(typeof(editor_sequence)=='undefined'||!editor_sequence) editor_sequence = _prev_editor_sequence;
|
||||
if(!editor_sequence) return;
|
||||
|
||||
// upload_target_srl이 없으면 무시
|
||||
var upload_target_srl = editor_rel_keys[editor_sequence]['primary'].value;
|
||||
|
||||
// 이미 등록된 전체 파일 목록을 구해옴
|
||||
var url = request_uri + "?act=procFileDelete&editor_sequence="+editor_sequence+"&mid="+current_url.getQuery('mid');
|
||||
|
||||
// iframe에 url을 보내버림
|
||||
var iframe_obj = xGetElementById('tmp_upload_iframe');
|
||||
if(!iframe_obj) return;
|
||||
iframe_obj.contentWindow.document.location.href=url;
|
||||
}
|
||||
|
||||
|
||||
// 업로드된 파일 목록 비움 (단순히 select 객체의 내용을 지우고 미리보기를 제거함)
|
||||
function editor_upload_clear_list(editor_sequence, upload_target_srl) {
|
||||
if(!upload_target_srl || upload_target_srl<1) return;
|
||||
editor_rel_keys[editor_sequence]['primary'].value = upload_target_srl;
|
||||
|
||||
var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
|
||||
while(obj.options.length) {
|
||||
obj.remove(0);
|
||||
}
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+upload_target_srl);
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
|
||||
xInnerHtml(preview_obj,'')
|
||||
}
|
||||
|
||||
// 업로드된 파일 정보를 목록에 추가
|
||||
function editor_insert_uploaded_file(upload_target_srl, file_srl, filename, file_size, disp_file_size, uploaded_filename, sid) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+upload_target_srl);
|
||||
if(filename.length>15) filename = filename.substr(0,15)+'...';
|
||||
var text = filename+' ('+disp_file_size+')';
|
||||
// 업로드된 파일 정보를 select 목록에 추가
|
||||
function editor_insert_uploaded_file(editor_sequence, file_srl, filename, file_size, disp_file_size, uploaded_filename, sid) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
|
||||
var text = disp_file_size+' - '+filename;
|
||||
var opt_obj = new Option(text, file_srl, true, true);
|
||||
obj.options[obj.options.length] = opt_obj;
|
||||
|
||||
var file_obj = {file_srl:file_srl, filename:filename, file_size:file_size, uploaded_filename:uploaded_filename, sid:sid}
|
||||
uploaded_files[file_srl] = file_obj;
|
||||
|
||||
editor_preview(obj, upload_target_srl);
|
||||
editor_preview(obj, editor_sequence);
|
||||
_progress_start = false;
|
||||
}
|
||||
|
||||
// 파일 목록창에서 클릭 되었을 경우 미리 보기
|
||||
function editor_preview(sel_obj, upload_target_srl) {
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+upload_target_srl);
|
||||
function editor_preview(sel_obj, editor_sequence) {
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
|
||||
if(!sel_obj.options.length) {
|
||||
xInnerHtml(preview_obj, '');
|
||||
return;
|
||||
|
|
@ -220,8 +253,8 @@ function editor_preview(sel_obj, upload_target_srl) {
|
|||
}
|
||||
|
||||
// 업로드된 파일 삭제
|
||||
function editor_remove_file(upload_target_srl) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+upload_target_srl);
|
||||
function editor_remove_file(editor_sequence) {
|
||||
var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
|
||||
if(obj.options.length<1) return;
|
||||
|
||||
// 삭제하려는 파일의 정보를 챙김;;
|
||||
|
|
@ -233,6 +266,10 @@ function editor_remove_file(upload_target_srl) {
|
|||
var iframe_obj = xGetElementById('tmp_upload_iframe');
|
||||
if(!iframe_obj) return;
|
||||
|
||||
// upload_target_srl이 가상 번호일 경우 아무 동작 하지 않음
|
||||
var upload_target_srl = editor_rel_keys[editor_sequence]['primary'].value;
|
||||
if(upload_target_srl<1) return;
|
||||
|
||||
for(var i=0;i<obj.options.length;i++) {
|
||||
var sel_obj = obj.options[i];
|
||||
if(!sel_obj.selected) continue;
|
||||
|
|
@ -240,24 +277,25 @@ function editor_remove_file(upload_target_srl) {
|
|||
var file_srl = sel_obj.value;
|
||||
if(!file_srl) continue;
|
||||
|
||||
var url = request_uri+"/?act=procFileDelete&upload_target_srl="+upload_target_srl+"&file_srl="+file_srl+"&mid="+current_url.getQuery('mid');
|
||||
var url = request_uri+"/?act=procFileDelete&editor_sequence="+editor_sequence+"&upload_target_srl="+upload_target_srl+"&file_srl="+file_srl+"&mid="+current_url.getQuery('mid');
|
||||
|
||||
iframe_obj.contentWindow.document.location.href=url;
|
||||
|
||||
xSleep(100);
|
||||
}
|
||||
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+upload_target_srl);
|
||||
var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
|
||||
xInnerHtml(preview_obj, "");
|
||||
}
|
||||
|
||||
// 업로드 목록의 선택된 파일을 내용에 추가
|
||||
function editor_insert_file(upload_target_srl) {
|
||||
if(editor_mode[upload_target_srl]=='html') return;
|
||||
var obj = xGetElementById('uploaded_file_list_'+upload_target_srl);
|
||||
function editor_insert_file(editor_sequence) {
|
||||
if(editor_mode[editor_sequence]=='html') return;
|
||||
var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
|
||||
if(obj.options.length<1) return;
|
||||
|
||||
var iframe_obj = editorGetIFrame(upload_target_srl);
|
||||
editorFocus(upload_target_srl);
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
editorFocus(editor_sequence);
|
||||
|
||||
var fo_obj = obj;
|
||||
while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue