이미지링크 컴포넌트에 링크를 추가할 수 있도록 기능 추가 및 크기 조절시 비율을 이용하도록 변경

git-svn-id: http://xe-core.googlecode.com/svn/trunk@2231 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-08-07 03:49:30 +00:00
parent 6d0eca6965
commit dce40a2fac
7 changed files with 89 additions and 17 deletions

View file

@ -21,12 +21,20 @@
<th scope="row">{$lang->image_scale}</th>
<td>
<ul>
<li><input type="text" id="width" value="0" size="4" class="inputTypeText" />px </li>
<li><input type="text" id="height" value="0" size="4" class="inputTypeText" />px </li>
<li><input type="text" id="width" value="0" size="4" class="inputTypeText" onblur="setScale('width');return false;" />px </li>
<li><input type="text" id="height" value="0" size="4" class="inputTypeText" onblur="setScale('height');return false;" />px </li>
<li><a href="#" onclick="getImageScale(); return false;" class="button"><span>{$lang->cmd_get_scale}</span></a></li>
</ul>
</td>
</tr>
<tr>
<th scope="row">URL</th>
<td><input type="text" id="link_url" value="" class="inputTypeText w100"/></td>
</tr>
<tr>
<th scope="row">{$lang->urllink_open_window}</th>
<td><input type="checkbox" id="open_window" value="Y" /> {$lang->about_url_link_open_window}</td>
</tr>
<tr>
<th scope="row">{$lang->image_alt}</th>
<td><input type="text" id="image_alt" value="" class="inputTypeText w100"/></td>

View file

@ -2,6 +2,9 @@
* popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 이미지가 있는지 체크하여
* 있으면 가져와서 원하는 곳에 삽입
**/
var orig_width = 0;
var orig_height = 0;
function getImage() {
// 부모 위지윅 에디터에서 선택된 영역이 있는지 확인
if(typeof(opener)=="undefined") return;
@ -23,10 +26,20 @@ function getImage() {
var alt = node.getAttribute("alt");
var width = node.getAttribute("width");
var height = node.getAttribute("height");
orig_width = width;
orig_height = height;
var link_url = node.getAttribute("link_url");
var open_window = node.getAttribute("open_window");
xGetElementById("image_url").value = src;
xGetElementById("image_alt").value = alt;
if(link_url) {
link_url = link_url.replace(/<([^>]*)>/ig,'').replace(/&lt;/ig,'<').replace(/&gt;/ig,'>').replace(/&amp;/ig,'&');
xGetElementById('link_url').value = link_url;
}
if(open_window == 'Y') xGetElementById('open_window').checked = "true";
switch(align) {
case 'left' : xGetElementById("align_left").checked = true; break;
case 'middle' : xGetElementById("align_middle").checked = true; break;
@ -50,11 +63,18 @@ function getImageScale() {
xGetElementById("width").value = img.width;
xGetElementById("height").value = img.height;
orig_width = img.width;
orig_height = img.height;
}
function insertImage(obj) {
if(typeof(opener)=="undefined") return;
var link_url = xGetElementById('link_url').value;
if(link_url) link_url = link_url.replace(/&/ig,'&amp;').replace(/</ig,'&lt;').replace(/>/ig,'&gt;');
var open_window = 'N';
if(xGetElementById('open_window').checked) open_window = 'Y';
var url = xGetElementById("image_url").value;
var alt = xGetElementById("image_alt").value;
var align = "";
@ -75,9 +95,10 @@ function insertImage(obj) {
url = url.replace(request_uri,'');
var text = "<img editor_component=\"image_link\" src=\""+url+"\" border=\""+border+"\" ";
if(alt) text+= " alt=\""+alt+"\"";
if(align) text+= " align=\""+align+"\" ";
if(width) text+= " width=\""+width+"\" ";
if(height) text+= " height=\""+height+"\" ";
if(link_url) text+= " link_url=\""+link_url+"\" ";
if(open_window=='Y') text+= " open_window=\"Y\" ";
text+= " />";
opener.editorFocus(opener.editorPrevSrl);
@ -91,3 +112,23 @@ function insertImage(obj) {
}
xAddEventListener(window, "load", getImage);
function setScale(type) {
switch(type) {
case 'width' :
if(!orig_height) return;
var n_width = xGetElementById('width').value;
var p = n_width/orig_width;
var n_height = parseInt(orig_height * p,10);
xGetElementById('height').value = n_height;
break;
case 'height' :
if(!orig_width) return;
var n_height = xGetElementById('height').value;
var p = n_height/orig_height;
var n_width = parseInt(orig_width * p,10);
xGetElementById('width').value = n_width;
break;
}
}