From 3144756e6fbd4edf641106ce2daa7996715875a9 Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 19 Nov 2007 03:05:20 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9C=84=EC=A0=AF=EC=9D=98=20=EB=82=B4?= =?UTF-8?q?=EB=B6=80=EC=97=AC=EB=B0=B1=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2993 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/widget/WidgetHandler.class.php | 38 +++---- common/js/common.js | 2 +- modules/widget/lang/en.lang.php | 3 +- modules/widget/lang/es.lang.php | 3 +- modules/widget/lang/jp.lang.php | 3 +- modules/widget/lang/ko.lang.php | 5 +- modules/widget/lang/zh-CN.lang.php | 3 +- modules/widget/tpl/add_content_widget.html | 8 +- modules/widget/tpl/js/widget.js | 98 ++++++++++--------- modules/widget/tpl/js/widget_admin.js | 23 ++++- .../tpl/widget_generate_code_in_page.html | 8 +- modules/widget/tpl/widget_layer.html | 11 +++ modules/widget/widget.controller.php | 14 +-- 13 files changed, 129 insertions(+), 90 deletions(-) diff --git a/classes/widget/WidgetHandler.class.php b/classes/widget/WidgetHandler.class.php index 365f84a86..48fd65729 100644 --- a/classes/widget/WidgetHandler.class.php +++ b/classes/widget/WidgetHandler.class.php @@ -54,28 +54,28 @@ if($widget == 'widgetContent') { $style = $args->style; $body = base64_decode($args->body); - $widget_margin_left = $args->widget_margin_left; - $widget_margin_right = $args->widget_margin_right; - $widget_margin_top = $args->widget_margin_top; - $widget_margin_bottom = $args->widget_margin_bottom; + $widget_padding_left = $args->widget_padding_left; + $widget_padding_right = $args->widget_padding_right; + $widget_padding_top = $args->widget_padding_top; + $widget_padding_bottom = $args->widget_padding_bottom; if($include_info) { $oWidgetController = &getController('widget'); $tpl = $oWidgetController->transEditorContent($body, $args); } else { - $tpl = sprintf('
%s
', $style, $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left, $body); + $tpl = sprintf('
%s
', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $body); } return $tpl; // widget Box일 경우 간단히 변경만 시도함 } else if($widget == 'widgetBox') { $style = $args->style; - $widget_margin_left = $args->widget_margin_left; - $widget_margin_right = $args->widget_margin_right; - $widget_margin_top = $args->widget_margin_top; - $widget_margin_bottom = $args->widget_margin_bottom; + $widget_padding_left = $args->widget_padding_left; + $widget_padding_right = $args->widget_padding_right; + $widget_padding_top = $args->widget_padding_top; + $widget_padding_bottom = $args->widget_padding_bottom; if($include_info) { - $tpl = sprintf('
', $style, $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left, $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left); + $tpl = sprintf('
', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left); } else { - $tpl = sprintf('
%s', $style, $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left, $body); + $tpl = sprintf('
%s', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $body); } return $tpl; } @@ -91,12 +91,12 @@ if(!$oWidget) return; // 위젯 output을 생성하기 위한 변수 설정 - $widget_margin_top = $args->widget_margin_top; - $widget_margin_bottom = $args->widget_margin_bottom; - $widget_margin_left = $args->widget_margin_left; - $widget_margin_right = $args->widget_margin_right; + $widget_padding_top = $args->widget_padding_top; + $widget_padding_bottom = $args->widget_padding_bottom; + $widget_padding_left = $args->widget_padding_left; + $widget_padding_right = $args->widget_padding_right; - $inner_style = sprintf("margin:%dpx %dpx %dpx %dpx !important; padding:none !important;", $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left); + $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important; padding:none !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left); /** * 출력을 위해 위젯 내용을 div로 꾸밈 @@ -143,8 +143,8 @@ if(!$html) $html = ' '; $output = sprintf( - ''. - '
'. + '
'. + '
'. '
'. '
'. '
'. @@ -159,7 +159,7 @@ '
', $css_header, $args->style, - $widget_margin_top, $widget_margin_right, $widget_margin_bottom, $widget_margin_left, + $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget, implode(' ',$attribute), $inner_style, $html diff --git a/common/js/common.js b/common/js/common.js index 968fce532..86c331be5 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -780,7 +780,7 @@ function transRGB2Hex(value) { var color = parseInt(value_list[i],10).toString(16); hex += color; } - return hex; + return '#'+hex; } /** diff --git a/modules/widget/lang/en.lang.php b/modules/widget/lang/en.lang.php index caef1fc5c..bf0d72918 100644 --- a/modules/widget/lang/en.lang.php +++ b/modules/widget/lang/en.lang.php @@ -49,7 +49,8 @@ $lang->cmd_widget_align = "위젯 정렬"; $lang->cmd_widget_align_left = "왼쪽"; $lang->cmd_widget_align_right = "오른쪽"; - $lang->cmd_widget_margin = "위젯 여백"; + $lang->cmd_widget_margin = "외부 여백"; + $lang->cmd_widget_padding = "내부 여백"; $lang->cmd_widget_border = "위젯 테두리"; $lang->cmd_widget_border_solid = "실선"; $lang->cmd_widget_border_dotted = "점선"; diff --git a/modules/widget/lang/es.lang.php b/modules/widget/lang/es.lang.php index eaa46c161..b0f3a52fc 100644 --- a/modules/widget/lang/es.lang.php +++ b/modules/widget/lang/es.lang.php @@ -49,7 +49,8 @@ $lang->cmd_widget_align = "위젯 정렬"; $lang->cmd_widget_align_left = "왼쪽"; $lang->cmd_widget_align_right = "오른쪽"; - $lang->cmd_widget_margin = "위젯 여백"; + $lang->cmd_widget_margin = "외부 여백"; + $lang->cmd_widget_padding = "내부 여백"; $lang->cmd_widget_border = "위젯 테두리"; $lang->cmd_widget_border_solid = "실선"; $lang->cmd_widget_border_dotted = "점선"; diff --git a/modules/widget/lang/jp.lang.php b/modules/widget/lang/jp.lang.php index 38612c6f5..f15c143b7 100644 --- a/modules/widget/lang/jp.lang.php +++ b/modules/widget/lang/jp.lang.php @@ -49,7 +49,8 @@ $lang->cmd_widget_align = "위젯 정렬"; $lang->cmd_widget_align_left = "왼쪽"; $lang->cmd_widget_align_right = "오른쪽"; - $lang->cmd_widget_margin = "위젯 여백"; + $lang->cmd_widget_margin = "외부 여백"; + $lang->cmd_widget_padding = "내부 여백"; $lang->cmd_widget_border = "위젯 테두리"; $lang->cmd_widget_border_solid = "실선"; $lang->cmd_widget_border_dotted = "점선"; diff --git a/modules/widget/lang/ko.lang.php b/modules/widget/lang/ko.lang.php index cc72e9cdd..1b0d4ede3 100644 --- a/modules/widget/lang/ko.lang.php +++ b/modules/widget/lang/ko.lang.php @@ -20,7 +20,7 @@ $lang->widget_position_none = '줄바꿈'; $lang->widget_position_left = '왼쪽'; $lang->widget_position_right = '오른쪽'; - $lang->widget_margin = '여백'; + $lang->widget_margin = '외부 여백'; $lang->widget_margin_top = '위'; $lang->widget_margin_right = '오른쪽'; $lang->widget_margin_bottom = '아래 '; @@ -49,7 +49,8 @@ $lang->cmd_widget_align = "위젯 정렬"; $lang->cmd_widget_align_left = "왼쪽"; $lang->cmd_widget_align_right = "오른쪽"; - $lang->cmd_widget_margin = "위젯 여백"; + $lang->cmd_widget_margin = "외부 여백"; + $lang->cmd_widget_padding = "내부 여백"; $lang->cmd_widget_border = "위젯 테두리"; $lang->cmd_widget_border_solid = "실선"; $lang->cmd_widget_border_dotted = "점선"; diff --git a/modules/widget/lang/zh-CN.lang.php b/modules/widget/lang/zh-CN.lang.php index e9fcf535e..6f0f2e083 100644 --- a/modules/widget/lang/zh-CN.lang.php +++ b/modules/widget/lang/zh-CN.lang.php @@ -49,7 +49,8 @@ $lang->cmd_widget_align = "위젯 정렬"; $lang->cmd_widget_align_left = "왼쪽"; $lang->cmd_widget_align_right = "오른쪽"; - $lang->cmd_widget_margin = "위젯 여백"; + $lang->cmd_widget_margin = "외부 여백"; + $lang->cmd_widget_padding = "내부 여백"; $lang->cmd_widget_border = "위젯 테두리"; $lang->cmd_widget_border_solid = "실선"; $lang->cmd_widget_border_dotted = "점선"; diff --git a/modules/widget/tpl/add_content_widget.html b/modules/widget/tpl/add_content_widget.html index a342f0a69..74e08c898 100644 --- a/modules/widget/tpl/add_content_widget.html +++ b/modules/widget/tpl/add_content_widget.html @@ -8,10 +8,10 @@ - - - - + + + +
{$editor} diff --git a/modules/widget/tpl/js/widget.js b/modules/widget/tpl/js/widget.js index 193c8b937..4fc220c59 100644 --- a/modules/widget/tpl/js/widget.js +++ b/modules/widget/tpl/js/widget.js @@ -23,11 +23,11 @@ function setFloat(obj, fl) { else obj.style.cssFloat = fl; } -// margin값을 구하는 함수 (없을 경우 0으로 세팅), zbxe의 위젯에서만 사용 -function getMargin(obj, direct) { - var margin = obj.getAttribute("widget_margin_"+direct); - if(!margin || margin == null) margin = 0; - return margin; +// padding값을 구하는 함수 (없을 경우 0으로 세팅), zbxe의 위젯에서만 사용 +function getPadding(obj, direct) { + var padding = obj.getAttribute("widget_padding_"+direct); + if(!padding || padding == null) padding = 0; + return padding; } @@ -102,7 +102,7 @@ function getContentWidgetCode(childObj, widget) { while(cobj) { if(cobj.nodeName == "DIV" && cobj.className == "widgetContent") { var body = xInnerHtml(cobj); - return ''; + return ''; } cobj = cobj.nextSibling; } @@ -117,7 +117,7 @@ function getWidgetBoxCode(childObj, widget) { while(c2obj) { if(c2obj.className == "nullWidget") { var body = getWidgetContent(c2obj); - return '
'+body+'
'; + return '
'+body+'
'; } c2obj = c2obj.nextSibling; } @@ -158,10 +158,10 @@ function doSyncPageContent() { var fo_obj = xGetElementById("content_fo"); var sel_obj = opener.selectedWidget; fo_obj.style.value = getStyle(opener.selectedWidget); - fo_obj.widget_margin_left.value = getMargin(sel_obj, 'left'); - fo_obj.widget_margin_right.value = getMargin(sel_obj,'right'); - fo_obj.widget_margin_bottom.value = getMargin(sel_obj,'bottom'); - fo_obj.widget_margin_top.value = getMargin(sel_obj,'top'); + fo_obj.widget_padding_left.value = getPadding(sel_obj, 'left'); + fo_obj.widget_padding_right.value = getPadding(sel_obj,'right'); + fo_obj.widget_padding_bottom.value = getPadding(sel_obj,'bottom'); + fo_obj.widget_padding_top.value = getPadding(sel_obj,'top'); var obj = sel_obj.firstChild; while(obj && obj.className != "widgetContent") obj = obj.nextSibling; @@ -365,10 +365,14 @@ function doShowWidgetSizeSetup(px, py, obj) { formObj.width.value = obj.style.width; formObj.height.value = obj.style.height; - formObj.margin_left.value = _getInt(selectedSizeWidget.getAttribute('widget_margin_left')); - formObj.margin_right.value = _getInt(selectedSizeWidget.getAttribute('widget_margin_right')); - formObj.margin_top.value = _getInt(selectedSizeWidget.getAttribute('widget_margin_top')); - formObj.margin_bottom.value = _getInt(selectedSizeWidget.getAttribute('widget_margin_bottom')); + formObj.padding_left.value = _getInt(selectedSizeWidget.getAttribute('widget_padding_left')); + formObj.padding_right.value = _getInt(selectedSizeWidget.getAttribute('widget_padding_right')); + formObj.padding_top.value = _getInt(selectedSizeWidget.getAttribute('widget_padding_top')); + formObj.padding_bottom.value = _getInt(selectedSizeWidget.getAttribute('widget_padding_bottom')); + formObj.margin_left.value = _getInt(selectedSizeWidget.style.marginLeft); + formObj.margin_right.value = _getInt(selectedSizeWidget.style.marginRight); + formObj.margin_top.value = _getInt(selectedSizeWidget.style.marginTop); + formObj.margin_bottom.value = _getInt(selectedSizeWidget.style.marginBottom); var widget_align = getFloat(selectedSizeWidget); if(widget_align == "left") formObj.widget_align.selectedIndex = 0; @@ -431,11 +435,11 @@ function doHideWidgetSizeSetup() { } function _getSize(value) { - if(!value) return; + if(!value) return 0; var type = "px"; if(value.lastIndexOf("%")>=0) type = "%"; var num = parseInt(value,10); - if(num<1) return; + if(num<1) return 0; if(type == "%" && num > 100) num = 100; return ""+num+type; } @@ -455,7 +459,7 @@ function _getBorderStyle(fld_color, fld_thick, fld_type) { } function _getBGColorStyle(fld_color) { - var color = fld_color.value; + var color = fld_color.replace(/^#/,''); if(!color) color = '#FFFFFF'; else color = '#'+color; return color; @@ -476,9 +480,13 @@ function doApplyWidgetSize(fo_obj) { selectedSizeWidget.style.borderBottom = _getBorderStyle(fo_obj.border_bottom_color, fo_obj.border_bottom_thick, fo_obj.border_bottom_type); selectedSizeWidget.style.borderLeft = _getBorderStyle(fo_obj.border_left_color, fo_obj.border_left_thick, fo_obj.border_left_type); selectedSizeWidget.style.borderRight = _getBorderStyle(fo_obj.border_right_color, fo_obj.border_right_thick, fo_obj.border_right_type); + selectedSizeWidget.style.marginTop = _getSize(fo_obj.margin_top.value); + selectedSizeWidget.style.marginRight = _getSize(fo_obj.margin_right.value); + selectedSizeWidget.style.marginBottom = _getSize(fo_obj.margin_bottom.value); + selectedSizeWidget.style.marginLeft = _getSize(fo_obj.margin_left.value); if(!fo_obj.background_color.value || fo_obj.background_color.value == 'transparent') selectedSizeWidget.style.backgroundColor = 'transparent'; - else selectedSizeWidget.style.backgroundColor = _getBGColorStyle(fo_obj.background_color); + else selectedSizeWidget.style.backgroundColor = _getBGColorStyle(fo_obj.background_color.value); var image_url = fo_obj.background_image_url.value; if(image_url) selectedSizeWidget.style.backgroundImage = "url("+image_url+")"; @@ -500,41 +508,41 @@ function doApplyWidgetSize(fo_obj) { var contentObj = borderObj.firstChild; while(contentObj) { if(contentObj.nodeName == "DIV") { - contentObj.style.margin = ""; - var marginLeft = _getSize(fo_obj.margin_left.value); - if(marginLeft) { - contentObj.style.marginLeft = marginLeft; - selectedSizeWidget.setAttribute('widget_margin_left', marginLeft); + contentObj.style.padding = ""; + var paddingLeft = _getSize(fo_obj.padding_left.value); + if(paddingLeft) { + contentObj.style.paddingLeft = paddingLeft; + selectedSizeWidget.setAttribute('widget_padding_left', paddingLeft); } else { - contentObj.style.marginLeft = ''; - selectedSizeWidget.setAttribute('widget_margin_left', ''); + contentObj.style.paddingLeft = ''; + selectedSizeWidget.setAttribute('widget_padding_left', ''); } - var marginRight = _getSize(fo_obj.margin_right.value); - if(marginRight) { - contentObj.style.marginRight = marginRight; - selectedSizeWidget.setAttribute('widget_margin_right', marginRight); + var paddingRight = _getSize(fo_obj.padding_right.value); + if(paddingRight) { + contentObj.style.paddingRight = paddingRight; + selectedSizeWidget.setAttribute('widget_padding_right', paddingRight); } else { - contentObj.style.marginRight = ''; - selectedSizeWidget.setAttribute('widget_margin_right', ''); + contentObj.style.paddingRight = ''; + selectedSizeWidget.setAttribute('widget_padding_right', ''); } - var marginTop = _getSize(fo_obj.margin_top.value); - if(marginTop) { - contentObj.style.marginTop = marginTop; - selectedSizeWidget.setAttribute('widget_margin_top', marginTop); + var paddingTop = _getSize(fo_obj.padding_top.value); + if(paddingTop) { + contentObj.style.paddingTop = paddingTop; + selectedSizeWidget.setAttribute('widget_padding_top', paddingTop); } else { - contentObj.style.marginTop = ''; - selectedSizeWidget.setAttribute('widget_margin_top', ''); + contentObj.style.paddingTop = ''; + selectedSizeWidget.setAttribute('widget_padding_top', ''); } - var marginBottom = _getSize(fo_obj.margin_bottom.value); - if(marginBottom) { - contentObj.style.marginBottom = marginBottom; - selectedSizeWidget.setAttribute('widget_margin_bottom', marginBottom); + var paddingBottom = _getSize(fo_obj.padding_bottom.value); + if(paddingBottom) { + contentObj.style.paddingBottom = paddingBottom; + selectedSizeWidget.setAttribute('widget_padding_bottom', paddingBottom); } else { - contentObj.style.marginBottom = ''; - selectedSizeWidget.setAttribute('widget_margin_bottom', ''); + contentObj.style.paddingBottom = ''; + selectedSizeWidget.setAttribute('widget_padding_bottom', ''); } break; @@ -567,8 +575,8 @@ function widgetCreateTmpObject(obj) { tmpObj.id = id + '_tmp'; tmpObj.className = obj.className; tmpObj.style.overflow = 'hidden'; + tmpObj.style.margin= '0px'; tmpObj.style.padding = '0px'; - tmpObj.style.margin = '0px'; tmpObj.style.width = obj.style.width; tmpObj.style.display = 'none'; diff --git a/modules/widget/tpl/js/widget_admin.js b/modules/widget/tpl/js/widget_admin.js index 366f950b0..419303d17 100644 --- a/modules/widget/tpl/js/widget_admin.js +++ b/modules/widget/tpl/js/widget_admin.js @@ -19,6 +19,21 @@ function completeGenerateCodeInPage(ret_obj,response_tags,params,fo_obj) { window.close(); return; } + + var dummy = xCreateElement("DIV"); + xInnerHtml(dummy, widget_code); + + var cobj = dummy.firstChild; + while(cobj) { + if(cobj.className == 'widgetClass') { + opener.document.body.insertBefore(cobj, opener.document.body.firstChild); + break; + } + cobj = cobj.nextSibling; + } + + widget_code = xInnerHtml(dummy); + if(selected_node && selected_node.getAttribute("widget")) { selected_node = replaceOuterHTML(selected_node, widget_code); if(opener.doFitBorderSize) opener.doFitBorderSize(); @@ -88,10 +103,10 @@ function doFillWidgetVars() { if(typeof(style)=="object") style = style["cssText"]; fo_obj.style.value = style; - fo_obj.widget_margin_left.value = selected_node.getAttribute("widget_margin_left"); - fo_obj.widget_margin_right.value = selected_node.getAttribute("widget_margin_right"); - fo_obj.widget_margin_bottom.value = selected_node.getAttribute("widget_margin_bottom"); - fo_obj.widget_margin_top.value = selected_node.getAttribute("widget_margin_top"); + fo_obj.widget_padding_left.value = selected_node.getAttribute("widget_padding_left"); + fo_obj.widget_padding_right.value = selected_node.getAttribute("widget_padding_right"); + fo_obj.widget_padding_bottom.value = selected_node.getAttribute("widget_padding_bottom"); + fo_obj.widget_padding_top.value = selected_node.getAttribute("widget_padding_top"); for(var name in fo_obj) { var node = fo_obj[name]; diff --git a/modules/widget/tpl/widget_generate_code_in_page.html b/modules/widget/tpl/widget_generate_code_in_page.html index 0e6f22298..fea7d0f41 100644 --- a/modules/widget/tpl/widget_generate_code_in_page.html +++ b/modules/widget/tpl/widget_generate_code_in_page.html @@ -8,10 +8,10 @@ - - - - + + + +

{$lang->cmd_generate_code}

diff --git a/modules/widget/tpl/widget_layer.html b/modules/widget/tpl/widget_layer.html index 5b3669774..05070289e 100644 --- a/modules/widget/tpl/widget_layer.html +++ b/modules/widget/tpl/widget_layer.html @@ -28,6 +28,17 @@ + + {$lang->cmd_widget_padding} + + + + + + + + + {$lang->cmd_widget_border} diff --git a/modules/widget/widget.controller.php b/modules/widget/widget.controller.php index 44788b609..969da8b97 100644 --- a/modules/widget/widget.controller.php +++ b/modules/widget/widget.controller.php @@ -134,7 +134,7 @@ **/ function procWidgetAddContent() { $content = Context::get('content'); - $args = Context::getRequestVars('style','widget_margin_left','widget_margin_right','widget_margin_bottom','widget_margin_top'); + $args = Context::getRequestVars('style','widget_padding_left','widget_padding_right','widget_padding_bottom','widget_padding_top'); $tpl = $this->transEditorContent($content, $args); @@ -152,8 +152,8 @@ $none_widget_code = preg_replace('!]*)widget=([^\>]*?)\>!is', '', $content); $oPageAdminController = &getAdminController('page'); if(trim($none_widget_code)) { - $args->style = "float:left;overflow:hidden;padding:none;margin:none"; - $args->widget_margin_left = $args->widget_margin_top = $args->widget_margin_right = $args->widget_margin_bottom = 0; + $args->style = "float:left;overflow:hidden;padding:none;padding:none"; + $args->widget_padding_left = $args->widget_padding_top = $args->widget_padding_right = $args->widget_padding_bottom = 0; $none_widget_content = $oPageAdminController->transEditorContent($none_widget_code, $args); } */ @@ -247,7 +247,7 @@ $tpl = sprintf( ''. - '
'. + '
'. '
'. '
'. '
'. @@ -255,7 +255,7 @@ '
'. '
'. '
'. - '
'. + '
'. '%s'. '
'. '
'. @@ -263,8 +263,8 @@ '
', $css_header, $args->style, - $args->widget_margin_left, $args->widget_margin_right, $args->widget_margin_top, $args->widget_margin_bottom, - $args->widget_margin_top, $args->widget_margin_right, $args->widget_margin_bottom, $args->widget_margin_left, + $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, + $args->widget_padding_top, $args->widget_padding_right, $args->widget_padding_bottom, $args->widget_padding_left, $content, base64_encode($code) );