/** * @file modules/widget/js/widget.js * @author NAVER (developers@xpressengine.com) * @brief 위젯 관리용 자바스크립트 **/ /* DOM 속성을 구하기 위한 몇가지 함수들.. */ // style의 값을 구하는게 IE랑 그외가 다름. 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; } // float: 값을 구하는게 IE랑 그외가 다름 function getFloat(obj) { return jQuery(obj).css('float'); } function setFloat(obj, fl) { jQuery(obj).css('float', fl); } // padding값을 구하는 함수 (없을 경우 0으로 세팅), zbxe의 위젯에서만 사용 function getPadding(obj, direct) { var padding = obj.getAttribute("widget_padding_"+direct); if(!padding || padding === null) padding = 0; return padding; } /* 위젯 핸들링 시작 */ var zonePageObj = null; var 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; }); // 드래그와 리사이즈와 관련된 이벤트 리스너 생성 jQuery('#zonePageContent') .on('click', doCheckWidget) .on('mousedown', doCheckWidgetDrag) .on('mouseover', widgetSetup); } // 내용 모두 삭제 function removeAllWidget() { if(!confirm(confirm_delete_msg)) return; restoreWidgetButtons(); jQuery(zonePageObj).html(''); } /** * 특정 영역에 편집된 위젯들을 약속된 태그로 변환하여 return **/ 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; var widgetContent = jQuery('div.widgetContent',childObj); var body = '', attrs = '', code = '', name; var document_srl = 0; var 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'); var value; for(var i=0;i.*<\/p>\s*$/i.test(params.content)) { // get count of paragraphs var lowerContent = params.content.toLowerCase(); var idx = lowerContent.indexOf('
'); var last_idx = lowerContent.lastIndexOf(''); if(idx > 0 && last_idx > 0 && idx == last_idx) { params.content = content = params.content.replace(/^\s*|<\/p>\s*$/ig, ''); } } exec_xml( 'widget', 'procWidgetInsertDocument', params, function(ret_obj, response_tags) { if(!ret_obj || ret_obj.error != '0') return; var document_srl = ret_obj.document_srl; var contentWidget = opener.jQuery('div.widgetOutput[widget=widgetContent][document_srl='+document_srl+']'), attr = []; if(contentWidget.size() > 0) { attr = contentWidget.get(0).attributes; } var tpl = ''+ '
'; var $tpl = jQuery(tpl); for(var i=0,l=attr.length; i < l; i++) { if(!$tpl.attr(attr[i].name)) $tpl.attr(attr[i].name, attr[i].value); } tpl = jQuery('