issue 44 : from the multimedia_link editor component

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8496 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-06-16 03:29:56 +00:00
parent db7403c469
commit 35714ac73e
5 changed files with 65 additions and 59 deletions

View file

@ -2,69 +2,60 @@
* popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 멀티미디어 컴포넌트 코드를 체크하여
* 있으면 가져와서 원하는 곳에 삽입
**/
function getMultimedia() {
// 부모 위지윅 에디터에서 선택된 영역이 있는지 확인
if(typeof(opener)=="undefined") return;
jQuery(function($){
var node = opener.editorPrevNode;
if(!node || node.nodeName != "IMG") return;
(function(){
if(!is_def(opener)) return;
var url = node.getAttribute("multimedia_src");
var caption = node.getAttribute("alt");
var width = xWidth(node);
var height = xHeight(node);
var auto_start = node.getAttribute("auto_start");
var wmode = node.getAttribute("wmode");
var $node = $(opener.editorPrevNode).filter('img'), attrs;
if(!$node.length) return;
var fo_obj = xGetElementById('fo');
attrs = {
url : $node.attr('multimedia_src'),
caption : $node.attr('alt'),
width : $node.width() - 4,
height : $node.height() - 4,
wmode : $node.attr('wmode')
};
xGetElementById("multimedia_url").value = url;
xGetElementById("multimedia_caption").value = caption;
xGetElementById("multimedia_width").value = width-4;
xGetElementById("multimedia_height").value = height-4;
if(auto_start=="true") xGetElementById("multimedia_auto_start").checked = true;
$.each(attrs, function(key, val) {
get_by_id('multimedia_'+key).value = val;
});
if(wmode == 'window') fo_obj.multimedia_wmode.selectedIndex = 0;
else if(wmode == 'opaque') fo_obj.multimedia_wmode.selectedIndex = 1;
else fo_obj.multimedia_wmode.selectedIndex = 2;
}
})();
function insertMultimedia(obj) {
if(typeof(opener)=="undefined") return;
$('a._insert').click(function(){
if(!is_def(opener)) return;
var url = xGetElementById("multimedia_url").value;
url = url.replace(request_uri,'');
// url = encodeURI(url);
var fo_obj = xGetElementById('fo');
var el_wmode = get_by_id('fo').elements['multimedia_wmode'];
var attrs = {
alt : get_by_id('multimedia_caption').value,
width : get_by_id('multimedia_width').value || 400,
height : get_by_id('multimedia_height').value || 400,
wmode : el_wmode.value || el_wmode.options[0].value,
auto_start : get_by_id('multimedia_auto_start').checked?'true':'false',
multimedia_src : get_by_id('multimedia_url').value.replace(request_uri, '')
};
var wmode = fo_obj.multimedia_wmode.options[fo_obj.multimedia_wmode.selectedIndex].value;
if(!attrs['multimedia_src']) {
window.close();
return;
}
var caption = xGetElementById("multimedia_caption").value;
var html = '<img src="../../../../common/tpl/images/blank.gif" editor_component="multimedia_link" multimedia_src="" width="" height="" wmode="" style="display:block;width:'+attrs.width+'px;height:'+attrs.height+'px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center" auto_start="" alt="" />';
var width = xGetElementById("multimedia_width").value;
if(!width) width = 400;
html = html.replace(/(\w+)=""/, function(m0,m1) {
return attrs[m1] ? (m1+'="'+attrs[m1]+'"') : '';
});
var height = xGetElementById("multimedia_height").value;
if(!height) height= 400;
opener.editorFocus(opener.editorPrevSrl);
var auto_start = "false";
if(xGetElementById("multimedia_auto_start").checked) auto_start = "true";
var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl)
if(!url) {
window.close();
return;
}
opener.editorReplaceHTML(iframe_obj, html);
opener.editorFocus(opener.editorPrevSrl);
var text = "<img src=\"../../../../common/tpl/images/blank.gif\" editor_component=\"multimedia_link\" multimedia_src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" wmode=\""+wmode+"\" style=\"display:block;width:"+width+"px;height:"+height+"px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;\" auto_start=\""+auto_start+"\" alt=\""+caption+"\" />";
window.close();
});
opener.editorFocus(opener.editorPrevSrl);
var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl)
opener.editorReplaceHTML(iframe_obj, text);
opener.editorFocus(opener.editorPrevSrl);
window.close();
}
xAddEventListener(window, "load", getMultimedia);
});