From 318b5f1f566288ce0dd731767adcbcc47348a8b9 Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 19 Mar 2007 08:05:25 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@540 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- common/css/default.css | 23 ++----- .../editor/components/url_link/tpl/popup.css | 5 +- .../editor/components/url_link/tpl/popup.html | 10 ++-- .../editor/components/url_link/tpl/popup.js | 60 +++++++++++++++++++ modules/editor/tpl/js/editor.js | 17 ++++++ 5 files changed, 90 insertions(+), 25 deletions(-) diff --git a/common/css/default.css b/common/css/default.css index db1dda167..9f727e125 100644 --- a/common/css/default.css +++ b/common/css/default.css @@ -21,25 +21,10 @@ a.bold { font-weight:bold; } -a.editor_blue_text:link { color: #145ff9; text-decoration:none; border-bottom:2px solid #4a7fec;} -a.editor_blue_text:visited { color: #145ff9; text-decoration:none; border-bottom:2px solid #4a7fec;} -a.editor_blue_text:active { color: #145ff9; text-decoration:none; border-bottom:2px solid #4a7fec;} -a.editor_blue_text:hover { color: #145ff9; text-decoration:none; border-bottom:2px solid #4a7fec;} - -a.editor_red_text:link { color: #f42126; text-decoration:none; border-bottom:2px solid #e54347; } -a.editor_red_text:visited { color: #f42126; text-decoration:none; border-bottom:2px solid #e54347;} -a.editor_red_text:active { color: #f42126; text-decoration:none; border-bottom:2px solid #e54347;} -a.editor_red_text:hover { color: #f42126; text-decoration:none; border-bottom:2px solid #e54347;} - -a.editor_yellow_text:link { color: #c9bd00; text-decoration:none; border-bottom:2px solid #ece460; } -a.editor_yellow_text:visited { color: #c9bd00; text-decoration:none; border-bottom:2px solid #ece460;} -a.editor_yellow_text:active { color: #c9bd00; text-decoration:none; border-bottom:2px solid #ece460;} -a.editor_yellow_text:hover { color: #c9bd00; text-decoration:none; border-bottom:2px solid #ece460;} - -a.editor_green_text:link { color: #08830B; text-decoration:none; border-bottom:2px solid #08830B;} -a.editor_green_text:visited { color: #08830B; text-decoration:none; border-bottom:2px solid #08830B;} -a.editor_green_text:active { color: #08830B; text-decoration:none; border-bottom:2px solid #08830B;} -a.editor_green_text:hover { color: #08830B; text-decoration:none; border-bottom:2px solid #08830B;} +.editor_blue_text { color: #145ff9; text-decoration:none; border-bottom:2px solid #4a7fec;} +.editor_red_text { color: #f42126; text-decoration:none; border-bottom:2px solid #e54347; } +.editor_yellow_text { color: #c9bd00; text-decoration:none; border-bottom:2px solid #ece460; } +.editor_green_text { color: #08830B; text-decoration:none; border-bottom:2px solid #08830B;} .folder_opener { display: block; } .folder_closer { display: none; } diff --git a/modules/editor/components/url_link/tpl/popup.css b/modules/editor/components/url_link/tpl/popup.css index 710c97a25..f503ea521 100644 --- a/modules/editor/components/url_link/tpl/popup.css +++ b/modules/editor/components/url_link/tpl/popup.css @@ -1,6 +1,8 @@ .editor_window { width:400px; + height:200px; text-align:center; + clear:both; } .header { @@ -37,12 +39,11 @@ } .editor_button_area { - clear:both; - width:100%; text-align:center; background-color:#EEEEEE; padding-top:5px; height:30px; + width:100%; } .editor_button { diff --git a/modules/editor/components/url_link/tpl/popup.html b/modules/editor/components/url_link/tpl/popup.html index e3d7ed9a0..9fd361404 100644 --- a/modules/editor/components/url_link/tpl/popup.html +++ b/modules/editor/components/url_link/tpl/popup.html @@ -19,25 +19,27 @@
- + - + - + - +
+
+ diff --git a/modules/editor/components/url_link/tpl/popup.js b/modules/editor/components/url_link/tpl/popup.js index 68a6bce9a..a8bde3ce1 100644 --- a/modules/editor/components/url_link/tpl/popup.js +++ b/modules/editor/components/url_link/tpl/popup.js @@ -3,8 +3,66 @@ * 있으면 가져와서 원하는 곳에 삽입 **/ function getText() { + // 부모 위지윅 에디터에서 선택된 영역이 있는지 확인 if(typeof(opener)=="undefined") return; var text = opener.editorGetSelectedHtml(opener.editorPrevSrl); + + // 선택된 영역이 A태그인지 확인 + if(text) { + var node = opener.editorGetSelectedNode(opener.editorPrevSrl); + if(node.nodeName == "A") { + var url = node.getAttribute("HREF"); + + var onclick_str = ""; + if(xIE4Up) { + onclick_str = node.outerHTML; + } else { + if(node.getAttribute("onclick")) onclick_str = node.getAttribute("onclick"); + } + + var className = ""; + if(typeof(node.className)) className = node.className; + else className = node.getAttribute("class"); + var open_window = false; + + if(onclick_str) { + open_window = true; + + var s_s = "window.open('"; + var p_s = onclick_str.indexOf(s_s); + url = onclick_str.substr(p_s+s_s.length); + + var e_s = "')"; + var p_e = url.indexOf(e_s); + url = url.substr(0, p_e); + + } + + var bold = false; + var color = ""; + + if(className) { + if(className.indexOf("bold")>-1) bold = true; + + if(className.indexOf("blue")>0) color = "color_blue"; + else if(className.indexOf("red")>0) color = "color_red"; + else if(className.indexOf("yellow")>0) color = "color_yellow"; + else if(className.indexOf("green")>0) color = "color_green"; + } + + var fo_obj = xGetElementById("fo_component"); + + fo_obj.text.value = xInnerHtml(node); + fo_obj.url.value = url; + if(open_window) fo_obj.open_window.checked = true; + if(bold) fo_obj.bold.checked = true; + if(color) xGetElementById(color).checked = true; + + return; + } + } + + // 기본 설정 var fo_obj = xGetElementById("fo_component"); if(fo_obj.text.value) return; fo_obj.text.value = text; @@ -30,6 +88,8 @@ function setText() { return; } + if(!url) url = "#"; + if(fo_obj.open_window.checked) open_window = true; if(fo_obj.bold.checked) bold= true; if(xGetElementById("color_blue").checked) link_class = "editor_blue_text"; diff --git a/modules/editor/tpl/js/editor.js b/modules/editor/tpl/js/editor.js index 465cafa69..3675e043c 100755 --- a/modules/editor/tpl/js/editor.js +++ b/modules/editor/tpl/js/editor.js @@ -138,6 +138,23 @@ function editorGetSelectedHtml(upload_target_srl) { } } +// 에디터 내의 선택된 부분의 NODE를 return +function editorGetSelectedNode(upload_target_srl) { + var iframe_obj = editorGetIFrame(upload_target_srl); + if(xIE4Up) { + var range = iframe_obj.contentWindow.document.selection.createRange(); + var div = xCreateElement('div'); + xInnerHtml(div, range.htmlText); + var node = div.firstChild; + return node; + } else { + var range = iframe_obj.contentWindow.getSelection().getRangeAt(0); + var node = xCreateElement('div'); + node.appendChild(range.cloneContents()); + return node.firstChild; + } +} + // 에디터 내의 선택된 부분의 html코드를 변경 function editorReplaceHTML(iframe_obj, html) {