mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-27 07:09:56 +09:00
xquared 확장콤포넌트 사용가능하도록 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3062 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
61c1c53634
commit
cc46a20754
7 changed files with 260 additions and 226 deletions
|
|
@ -7,7 +7,6 @@
|
|||
/**
|
||||
* 에디터 사용시 사용되는 이벤트 연결 함수 호출
|
||||
**/
|
||||
xAddEventListener(document, 'mouseup', editorEventCheck);
|
||||
|
||||
/**
|
||||
* 에디터의 상태나 객체를 구하기 위한 함수
|
||||
|
|
@ -44,21 +43,6 @@ function editorGetContent_xe(editor_sequence) {
|
|||
return html;
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html 코드를 return
|
||||
function editorGetSelectedHtml(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
var html = range.htmlText;
|
||||
return html;
|
||||
} else {
|
||||
var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
|
||||
var dummy = xCreateElement('div');
|
||||
dummy.appendChild(range.cloneContents());
|
||||
var html = xInnerHtml(dummy);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 NODE를 return
|
||||
function editorGetSelectedNode(editor_sequence) {
|
||||
|
|
@ -193,47 +177,7 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height) {
|
|||
* 에디터의 세부 설정과 데이터 핸들링을 정의한 함수들
|
||||
**/
|
||||
|
||||
// 에디터에 포커스를 줌
|
||||
function editorFocus(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
iframe_obj.contentWindow.focus();
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html코드를 변경
|
||||
function editorReplaceHTML(iframe_obj, html) {
|
||||
// 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화
|
||||
var editor_sequence = iframe_obj.contentWindow.document.body.getAttribute("editor_sequence");
|
||||
|
||||
// iframe 에디터에 포커스를 둠
|
||||
iframe_obj.contentWindow.focus();
|
||||
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
if(range.pasteHTML) {
|
||||
range.pasteHTML(html);
|
||||
} else if(editorPrevNode) {
|
||||
editorPrevNode.outerHTML = html;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
|
||||
var range = iframe_obj.contentDocument.createRange();
|
||||
range.setStart(iframe_obj.contentDocument.body,0);
|
||||
range.setEnd(iframe_obj.contentDocument.body,0);
|
||||
range.insertNode(range.createContextualFragment(html));
|
||||
} else {
|
||||
var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
|
||||
range.deleteContents();
|
||||
range.insertNode(range.createContextualFragment(html));
|
||||
}
|
||||
} catch(e) {
|
||||
xInnerHtml(iframe_obj.contentWindow.document.body, html+xInnerHtml(iframe_obj.contentWindow.document.body));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 키 또는 마우스 이벤트 핸들링 정의 함수
|
||||
|
|
@ -430,161 +374,6 @@ function editorChangeHeader(obj,srl) {
|
|||
obj.selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 에디터 컴포넌트 구현 부분
|
||||
**/
|
||||
|
||||
// 에디터 상단의 컴포넌트 버튼 클릭시 action 처리 (마우스다운 이벤트 발생시마다 요청이 됨)
|
||||
var editorPrevSrl = null;
|
||||
function editorEventCheck(evt) {
|
||||
editorPrevNode = null;
|
||||
|
||||
// 이벤트가 발생한 object의 ID를 구함
|
||||
var e = new xEvent(evt);
|
||||
var target_id = e.target.id;
|
||||
if(!target_id) return;
|
||||
|
||||
// editor_sequence와 component name을 구함 (id가 포맷과 다르면 return)
|
||||
var info = target_id.split('_');
|
||||
if(info[0]!="component") return;
|
||||
var editor_sequence = info[1];
|
||||
var component_name = target_id.replace(/^component_([0-9]+)_/,'');
|
||||
if(!editor_sequence || !component_name) return;
|
||||
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
|
||||
switch(component_name) {
|
||||
|
||||
// 기본 기능에 대한 동작 (바로 실행)
|
||||
case 'Bold' :
|
||||
case 'Italic' :
|
||||
case 'Underline' :
|
||||
case 'StrikeThrough' :
|
||||
case 'undo' :
|
||||
case 'redo' :
|
||||
case 'JustifyLeft' :
|
||||
case 'JustifyCenter' :
|
||||
case 'JustifyRight' :
|
||||
case 'JustifyFull' :
|
||||
case 'Indent' :
|
||||
case 'Outdent' :
|
||||
case 'InsertOrderedList' :
|
||||
case 'InsertUnorderedList' :
|
||||
case 'SaveAs' :
|
||||
case 'Print' :
|
||||
case 'Copy' :
|
||||
case 'Cut' :
|
||||
case 'Paste' :
|
||||
case 'RemoveFormat' :
|
||||
case 'Subscript' :
|
||||
case 'Superscript' :
|
||||
editorDo(component_name, '', editor_sequence);
|
||||
break;
|
||||
|
||||
// 추가 컴포넌트의 경우 서버에 요청을 시도
|
||||
default :
|
||||
openComponent(component_name, editor_sequence);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 컴포넌트 팝업 열기
|
||||
function openComponent(component_name, editor_sequence, manual_url) {
|
||||
editorPrevSrl = editor_sequence;
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
// 더블클릭 이벤트 발생시에 본문내에 포함된 컴포넌트를 찾는 함수
|
||||
var editorPrevNode = null;
|
||||
function editorSearchComponent(evt) {
|
||||
var e = new xEvent(evt);
|
||||
|
||||
editorPrevNode = null;
|
||||
var obj = e.target;
|
||||
|
||||
// 위젯인지 일단 체크
|
||||
if(obj.getAttribute("widget")) {
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
var widget = obj.getAttribute("widget");
|
||||
editorPrevNode = obj;
|
||||
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage');
|
||||
return;
|
||||
}
|
||||
|
||||
// 선택되어진 object부터 상단으로 이동하면서 editor_component attribute가 있는지 검사
|
||||
if(!obj.getAttribute("editor_component")) {
|
||||
while(obj && !obj.getAttribute("editor_component")) {
|
||||
if(obj.parentElement) obj = obj.parentElement;
|
||||
else obj = xParent(obj);
|
||||
}
|
||||
}
|
||||
|
||||
if(!obj) obj = e.target;
|
||||
|
||||
var editor_component = obj.getAttribute("editor_component");
|
||||
|
||||
// editor_component를 찾지 못했을 경우에 이미지/텍스트/링크의 경우 기본 컴포넌트와 연결
|
||||
if(!editor_component) {
|
||||
// 이미지일 경우
|
||||
if(obj.nodeName == "IMG") {
|
||||
editor_component = "image_link";
|
||||
editorPrevNode = obj;
|
||||
|
||||
// 테이블의 td일 경우
|
||||
} else if(obj.nodeName == "TD") {
|
||||
editor_component = "table_maker";
|
||||
editorPrevNode = obj;
|
||||
|
||||
// 링크거나 텍스트인 경우
|
||||
} else if(obj.nodeName == "A" || obj.nodeName == "BODY" || obj.nodeName.indexOf("H")==0 || obj.nodeName == "LI" || obj.nodeName == "P") {
|
||||
editor_component = "url_link";
|
||||
editorPrevNode = obj;
|
||||
}
|
||||
} else {
|
||||
editorPrevNode = obj;
|
||||
}
|
||||
|
||||
// 아무런 editor_component가 없다면 return
|
||||
if(!editor_component) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
|
||||
// 해당 컴포넌트를 찾아서 실행
|
||||
openComponent(editor_component, editor_sequence);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HTML 편집 기능 활성/비활성
|
||||
**/
|
||||
|
|
@ -624,21 +413,6 @@ function editorChangeMode(obj, editor_sequence) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
// Editor Option Button
|
||||
function eOptionOver(obj) {
|
||||
obj.style.marginTop='-21px';
|
||||
obj.style.zIndex='99';
|
||||
}
|
||||
function eOptionOut(obj) {
|
||||
obj.style.marginTop='0';
|
||||
obj.style.zIndex='1';
|
||||
}
|
||||
function eOptionClick(obj) {
|
||||
obj.style.marginTop='-42px';
|
||||
obj.style.zIndex='99';
|
||||
}
|
||||
|
||||
// Editor Info Close
|
||||
function closeEditorInfo(editor_sequence) {
|
||||
xGetElementById('editorInfo_'+editor_sequence).style.display='none';
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ var editorDragObj = {isDrag:false, y:0, obj:null, id:'', det:0, source_height:0}
|
|||
/**
|
||||
* 에디터 사용시 사용되는 이벤트 연결 함수 호출
|
||||
**/
|
||||
xAddEventListener(document, 'mouseup', editorEventCheck);
|
||||
xAddEventListener(document, 'mousedown', editorDragStart);
|
||||
xAddEventListener(document, 'mouseup', editorDragStop);
|
||||
|
||||
|
|
@ -16,6 +17,12 @@ function editorGetContent(editor_sequence) {
|
|||
return editorRelKeys[editor_sequence]["func"](editor_sequence);
|
||||
}
|
||||
|
||||
// 에디터에 포커스를 줌
|
||||
function editorFocus(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
iframe_obj.contentWindow.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 자동 저장 기능
|
||||
**/
|
||||
|
|
@ -141,3 +148,222 @@ function editorDragStop(evt) {
|
|||
editorDragObj.obj = null;
|
||||
editorDragObj.id = '';
|
||||
}
|
||||
|
||||
// Editor Option Button
|
||||
function eOptionOver(obj) {
|
||||
obj.style.marginTop='-21px';
|
||||
obj.style.zIndex='99';
|
||||
}
|
||||
function eOptionOut(obj) {
|
||||
obj.style.marginTop='0';
|
||||
obj.style.zIndex='1';
|
||||
}
|
||||
function eOptionClick(obj) {
|
||||
obj.style.marginTop='-42px';
|
||||
obj.style.zIndex='99';
|
||||
}
|
||||
|
||||
/**
|
||||
* 에디터 컴포넌트 구현 부분
|
||||
**/
|
||||
|
||||
// 에디터 상단의 컴포넌트 버튼 클릭시 action 처리 (마우스다운 이벤트 발생시마다 요청이 됨)
|
||||
var editorPrevSrl = null;
|
||||
function editorEventCheck(evt) {
|
||||
editorPrevNode = null;
|
||||
|
||||
// 이벤트가 발생한 object의 ID를 구함
|
||||
var e = new xEvent(evt);
|
||||
var target_id = e.target.id;
|
||||
if(!target_id) return;
|
||||
|
||||
// editor_sequence와 component name을 구함 (id가 포맷과 다르면 return)
|
||||
var info = target_id.split('_');
|
||||
if(info[0]!="component") return;
|
||||
var editor_sequence = info[1];
|
||||
var component_name = target_id.replace(/^component_([0-9]+)_/,'');
|
||||
if(!editor_sequence || !component_name) return;
|
||||
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
|
||||
switch(component_name) {
|
||||
|
||||
// 기본 기능에 대한 동작 (바로 실행)
|
||||
case 'Bold' :
|
||||
case 'Italic' :
|
||||
case 'Underline' :
|
||||
case 'StrikeThrough' :
|
||||
case 'undo' :
|
||||
case 'redo' :
|
||||
case 'JustifyLeft' :
|
||||
case 'JustifyCenter' :
|
||||
case 'JustifyRight' :
|
||||
case 'JustifyFull' :
|
||||
case 'Indent' :
|
||||
case 'Outdent' :
|
||||
case 'InsertOrderedList' :
|
||||
case 'InsertUnorderedList' :
|
||||
case 'SaveAs' :
|
||||
case 'Print' :
|
||||
case 'Copy' :
|
||||
case 'Cut' :
|
||||
case 'Paste' :
|
||||
case 'RemoveFormat' :
|
||||
case 'Subscript' :
|
||||
case 'Superscript' :
|
||||
editorDo(component_name, '', editor_sequence);
|
||||
break;
|
||||
|
||||
// 추가 컴포넌트의 경우 서버에 요청을 시도
|
||||
default :
|
||||
openComponent(component_name, editor_sequence);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 컴포넌트 팝업 열기
|
||||
function openComponent(component_name, editor_sequence, manual_url) {
|
||||
editorPrevSrl = editor_sequence;
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
// 더블클릭 이벤트 발생시에 본문내에 포함된 컴포넌트를 찾는 함수
|
||||
var editorPrevNode = null;
|
||||
function editorSearchComponent(evt) {
|
||||
var e = new xEvent(evt);
|
||||
|
||||
editorPrevNode = null;
|
||||
var obj = e.target;
|
||||
|
||||
// 위젯인지 일단 체크
|
||||
if(obj.getAttribute("widget")) {
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
var widget = obj.getAttribute("widget");
|
||||
editorPrevNode = obj;
|
||||
|
||||
if(editorMode[editor_sequence]=='html') return;
|
||||
popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage');
|
||||
return;
|
||||
}
|
||||
|
||||
// 선택되어진 object부터 상단으로 이동하면서 editor_component attribute가 있는지 검사
|
||||
if(!obj.getAttribute("editor_component")) {
|
||||
while(obj && !obj.getAttribute("editor_component")) {
|
||||
if(obj.parentElement) obj = obj.parentElement;
|
||||
else obj = xParent(obj);
|
||||
}
|
||||
}
|
||||
|
||||
if(!obj) obj = e.target;
|
||||
|
||||
var editor_component = obj.getAttribute("editor_component");
|
||||
|
||||
// editor_component를 찾지 못했을 경우에 이미지/텍스트/링크의 경우 기본 컴포넌트와 연결
|
||||
if(!editor_component) {
|
||||
// 이미지일 경우
|
||||
if(obj.nodeName == "IMG") {
|
||||
editor_component = "image_link";
|
||||
editorPrevNode = obj;
|
||||
|
||||
// 테이블의 td일 경우
|
||||
} else if(obj.nodeName == "TD") {
|
||||
editor_component = "table_maker";
|
||||
editorPrevNode = obj;
|
||||
|
||||
// 링크거나 텍스트인 경우
|
||||
} else if(obj.nodeName == "A" || obj.nodeName == "BODY" || obj.nodeName.indexOf("H")==0 || obj.nodeName == "LI" || obj.nodeName == "P") {
|
||||
editor_component = "url_link";
|
||||
editorPrevNode = obj;
|
||||
}
|
||||
} else {
|
||||
editorPrevNode = obj;
|
||||
}
|
||||
|
||||
// 아무런 editor_component가 없다면 return
|
||||
if(!editor_component) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// editor_sequence을 찾음
|
||||
var tobj = obj;
|
||||
while(tobj && tobj.nodeName != "BODY") {
|
||||
tobj = xParent(tobj);
|
||||
}
|
||||
if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
|
||||
editorPrevNode = null;
|
||||
return;
|
||||
}
|
||||
var editor_sequence = tobj.getAttribute("editor_sequence");
|
||||
|
||||
// 해당 컴포넌트를 찾아서 실행
|
||||
openComponent(editor_component, editor_sequence);
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html코드를 변경
|
||||
function editorReplaceHTML(iframe_obj, html) {
|
||||
// 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화
|
||||
var editor_sequence = iframe_obj.contentWindow.document.body.getAttribute("editor_sequence");
|
||||
|
||||
// iframe 에디터에 포커스를 둠
|
||||
iframe_obj.contentWindow.focus();
|
||||
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
if(range.pasteHTML) {
|
||||
range.pasteHTML(html);
|
||||
} else if(editorPrevNode) {
|
||||
editorPrevNode.outerHTML = html;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
|
||||
var range = iframe_obj.contentDocument.createRange();
|
||||
range.setStart(iframe_obj.contentDocument.body,0);
|
||||
range.setEnd(iframe_obj.contentDocument.body,0);
|
||||
range.insertNode(range.createContextualFragment(html));
|
||||
} else {
|
||||
var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
|
||||
range.deleteContents();
|
||||
range.insertNode(range.createContextualFragment(html));
|
||||
}
|
||||
} catch(e) {
|
||||
xInnerHtml(iframe_obj.contentWindow.document.body, html+xInnerHtml(iframe_obj.contentWindow.document.body));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 에디터 내의 선택된 부분의 html 코드를 return
|
||||
function editorGetSelectedHtml(editor_sequence) {
|
||||
var iframe_obj = editorGetIFrame(editor_sequence);
|
||||
if(xIE4Up) {
|
||||
var range = iframe_obj.contentWindow.document.selection.createRange();
|
||||
var html = range.htmlText;
|
||||
return html;
|
||||
} else {
|
||||
var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
|
||||
var dummy = xCreateElement('div');
|
||||
dummy.appendChild(range.cloneContents());
|
||||
var html = xInnerHtml(dummy);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue