/**
* @file modules/widget/js/widget.js
* @author NHN (developers@xpressengine.com)
* @brief 위젯 관리용 자바스크립트
**/
function getStyle(obj){var style=obj.getAttribute("style");if(!style)style=obj.style;if(typeof (style)=="object")style=style.cssText;style=style.replace(/\burl\s*\(\s*"(.*?)"\s*\)/i,"url('$1')");return style}
function getFloat(obj){return jQuery(obj).css('float')}
function setFloat(obj,fl){jQuery(obj).css('float',fl)}
function getPadding(obj,direct){var padding=obj.getAttribute("widget_padding_"+direct);if(!padding||padding==null)padding=0;return padding};var zonePageObj=null,zoneModuleSrl=0
function doStartPageModify(zoneID,module_srl){zonePageObj=get_by_id(zoneID);zoneModuleSrl=module_srl;jQuery('#tmpPageSizeLayer').appendTo('body').hide().attr('id','pageSizeLayer').css({position:'fixed'}).before('
').find('>form').submit(function(){doApplyWidgetSize(this);return false});xAddEventListener(document.getElementById('zonePageContent'),"click",doCheckWidget);xAddEventListener(document.getElementById('zonePageContent'),"mousedown",doCheckWidgetDrag);xAddEventListener(document.getElementById('zonePageContent'),'mouseover',widgetSetup)}
function removeAllWidget(){if(!confirm(confirm_delete_msg))return;restoreWidgetButtons();jQuery(zonePageObj).html('')}
function getWidgetContent(obj){var html="";if(typeof (obj)=='undefined'||!obj)obj=zonePageObj;var widget=null;jQuery('div.widgetOutput',obj).each(function(){if(jQuery(this).parent().get(0)!=obj)return;widget=jQuery(this).attr('widget');switch(widget){case'widgetBox':html+=getWidgetBoxCode(this,widget);break;case'widgetContent':html+=getContentWidgetCode(this,widget);break;default:html+=getWidgetCode(this,widget);break}});return html}
function getContentWidgetCode(childObj,widget){var cobj=childObj.firstChild,widgetContent=jQuery('div.widgetContent',childObj),body='',attrs='',code='',name,document_srl=0,toIgnore='contenteditable,id,style,src,widget,body,class,widget_width,widget_width_type,xdpx,xdpy,height,document_srl,widget_padding_left,widget_padding_right,widget_padding_top,widget_padding_bottom,hascontent';if(widgetContent.size()>0){document_srl=jQuery(childObj).attr('document_srl');if(document_srl>0){body=''}else body=widgetContent.html();var reIgnore=new RegExp('^('+toIgnore.replace(/,/g,'|')+')$','i'),value;for(var i=0;i'}else return'';return code}
function getWidgetBoxCode(childObj,widget){var attrs="";for(var i=0;i0){o=jQuery('.widget_inner',childObj);o=o.get(0)}else o=jQuery('.nullWidget',childObj).get(0);var body=getWidgetContent(o);return'
'+body+'
'}
function getWidgetCode(childObj,widget){var attrs="",code="";for(var i=0;i'}
function doAddContent(mid){var url=request_uri.setQuery('module','widget').setQuery('act','dispWidgetAdminAddContent').setQuery('module_srl',zoneModuleSrl).setQuery('mid',mid);popopen(url,"addContent")}
function doSyncPageContent(){if(opener&&opener.selectedWidget){var fo_obj=get_by_id("content_fo"),sel_obj=opener.selectedWidget;fo_obj.style.value=getStyle(opener.selectedWidget);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;if(obj&&obj.className=="widgetContent")if(!fo_obj.document_srl||fo_obj.document_srl.value==0)try{var content=Base64.decode(xInnerHtml(obj));content=editorReplacePath(content);get_by_id("content_fo").content.value=content;xe.Editors["1"].exec("SET_IR",[content])}catch(e){}};if(typeof (editorStart)!='undefined')editorStart(1,"module_srl","content",false,400)}
function addContentWidget(fo_obj){var editor_sequence=fo_obj.getAttribute('editor_sequence'),mid=fo_obj.mid.value,module_srl=fo_obj.module_srl.value,document_srl=fo_obj.document_srl.value,content=editorGetContent(editor_sequence),params={editor_sequence:editor_sequence,content:content,module_srl:module_srl,document_srl:document_srl};if(/^\s*