📄 widget.js
字号:
if(!p_obj.attributes[i].nodeName || !p_obj.attributes[i].nodeValue) continue; var name = p_obj.attributes[i].nodeName.toLowerCase(); var value = p_obj.attributes[i].nodeValue; if(!value) continue; if(value && typeof(value)=="string") value = value.replace(/\"/ig,'"'); dummy.setAttribute(name, value); } if(xIE4Up) dummy.style["cssText"] = p_obj.getAttribute("style")["cssText"]; p_obj.parentNode.insertBefore(dummy, p_obj); } return; // 위젯 사이트/ 여백 조절 } else if(obj.className == 'widgetSize' || obj.className == 'widgetBoxSize') { var p_obj = obj.parentNode; var widget = p_obj.getAttribute("widget"); if(!widget) return; selectedWidget = p_obj; doShowWidgetSizeSetup(evt.pageX, evt.pageY, selectedWidget); return; // 위젯 제거 } else if(obj.className == 'widgetRemove' || obj.className == 'widgetBoxRemove') { var p_obj = obj.parentNode; var widget = p_obj.getAttribute("widget"); if(confirm(confirm_delete_msg)) p_obj.parentNode.removeChild(p_obj); return; } // 내용 클릭 무효화 var p_obj = obj; while(p_obj) { if(p_obj.className == 'widgetOutput') { evt.cancelBubble = true; evt.returnValue = false; xPreventDefault(e); xStopPropagation(e); break; } p_obj = p_obj.parentNode; }}// 마우스 다운 이벤트 발생시 위젯의 이동을 처리function doCheckWidgetDrag(e) { var evt = new xEvent(e); if(!evt.target) return; var obj = evt.target; var pObj = obj.parentNode; while(pObj) { if(pObj.id == "pageSizeLayer") return; pObj = pObj.parentNode; } doHideWidgetSizeSetup(); if(obj.className == 'widgetSetup' || obj.className == 'widgetCopy' || obj.className == 'widgetBoxCopy' || obj.className == 'widgetSize' || obj.className == 'widgetBoxSize' || obj.className == 'widgetRemove' || obj.className == 'widgetBoxRemove') return; p_obj = obj; while(p_obj) { if(p_obj.className == 'widgetOutput' || p_obj.className == 'widgetResize' || p_obj.className == 'widgetResizeLeft' || p_obj.className == 'widgetBoxResize' || p_obj.className == 'widgetBoxResizeLeft') { widgetDragEnable(p_obj, widgetDragStart, widgetDrag, widgetDragEnd); widgetMouseDown(e); return; } p_obj = p_obj.parentNode; }}function _getInt(val) { if(!val || val == "null") return 0; if(parseInt(val,10)==NaN) return 0; return parseInt(val,10);}// 위젯 크기 조절 레이어를 보여줌var selectedSizeWidget = null;function doShowWidgetSizeSetup(px, py, obj) { var layer = xGetElementById("pageSizeLayer"); var formObj = layer.firstChild; while(formObj && formObj.nodeName != "FORM") formObj = formObj.nextSibling; if(!formObj || formObj.nodeName != "FORM") return; selectedSizeWidget = obj; layer.style.display = "block"; formObj.width.value = obj.style.width; formObj.height.value = obj.style.height; 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; else formObj.widget_align.selectedIndex = 1; formObj.border_top_color.value = transRGB2Hex(selectedSizeWidget.style.borderTopColor); formObj.border_top_thick.value = selectedSizeWidget.style.borderTopWidth.replace(/px$/i,''); formObj.border_top_type.selectedIndex = selectedSizeWidget.style.borderTopStyle=='dotted'?1:0; formObj.border_bottom_color.value = transRGB2Hex(selectedSizeWidget.style.borderBottomColor); formObj.border_bottom_thick.value = selectedSizeWidget.style.borderBottomWidth.replace(/px$/i,''); formObj.border_bottom_type.selectedIndex = selectedSizeWidget.style.borderBottomStyle=='dotted'?1:0; formObj.border_right_color.value = transRGB2Hex(selectedSizeWidget.style.borderRightColor); formObj.border_right_thick.value = selectedSizeWidget.style.borderRightWidth.replace(/px$/i,''); formObj.border_right_type.selectedIndex = selectedSizeWidget.style.borderRightStyle=='dotted'?1:0; formObj.border_left_color.value = transRGB2Hex(selectedSizeWidget.style.borderLeftColor); formObj.border_left_thick.value = selectedSizeWidget.style.borderLeftWidth.replace(/px$/i,''); formObj.border_left_type.selectedIndex = selectedSizeWidget.style.borderLeftStyle=='dotted'?1:0; formObj.background_color.value = transRGB2Hex(selectedSizeWidget.style.backgroundColor); formObj.background_image_url.value = selectedSizeWidget.style.backgroundImage.replace(/^url\(/i,'').replace(/\)$/i,''); switch(selectedSizeWidget.style.backgroundRepeat) { case 'no-repeat' : formObj.background_repeat.selectedIndex = 1; break; case 'repeat-x' : formObj.background_repeat.selectedIndex = 2; break; case 'repeat-y' : formObj.background_repeat.selectedIndex = 3; break; default : formObj.background_repeat.selectedIndex = 0; break; } formObj.background_x.value = 0; formObj.background_y.value = 0; var pos = selectedSizeWidget.style.backgroundPosition; if(pos) { pos = pos.split(' '); if(pos.length==2) { formObj.background_x.value = pos[0]; formObj.background_y.value = pos[1]; } } if(px+xWidth(layer)>xPageX(zonePageObj)+xWidth(zonePageObj)) px = xPageX(zonePageObj)+xWidth(zonePageObj)-xWidth(layer)-5; xLeft(layer, px); xTop(layer, py); layer.style.visibility = "visible"; try { formObj.width.focus(); } catch(e) { }}function doHideWidgetSizeSetup() { var layer = xGetElementById("pageSizeLayer"); layer.style.visibility = "hidden"; layer.style.display = "none";}function _getSize(value) { if(!value) return 0; var type = "px"; if(value.lastIndexOf("%")>=0) type = "%"; var num = parseInt(value,10); if(num<1) return 0; if(type == "%" && num > 100) num = 100; return ""+num+type;}function _getBorderStyle(fld_color, fld_thick, fld_type) { var color = fld_color.value; color = color.replace(/^#/,''); if(!color) color = '#FFFFFF'; else color = '#'+color; var width = fld_thick.value; if(!width) width = '0px'; else width = parseInt(width,10)+'px'; var style = fld_type.options[fld_type.selectedIndex].value; if(!style) style = 'solid'; var str = color+' '+width+' '+style; return str;}function _getBGColorStyle(fld_color) { var color = fld_color.replace(/^#/,''); if(!color) color = '#FFFFFF'; else color = '#'+color; return color;}function doApplyWidgetSize(fo_obj) { if(selectedSizeWidget) { if(fo_obj.widget_align.selectedIndex == 1) setFloat(selectedSizeWidget, 'right'); else setFloat(selectedSizeWidget, 'left'); var width = _getSize(fo_obj.width.value); if(width) selectedSizeWidget.style.width = width; var height = _getSize(fo_obj.height.value); if(height && height != "100%") selectedSizeWidget.style.height = height; else { selectedSizeWidget.style.height = ''; var widgetBorder = xGetElementsByClassName('widgetBorder',selectedSizeWidget); for(var i=0;i<widgetBorder.length;i++) { var obj = widgetBorder[i]; obj.style.height = ''; } } selectedSizeWidget.style.borderTop = _getBorderStyle(fo_obj.border_top_color, fo_obj.border_top_thick, fo_obj.border_top_type); 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.value); var image_url = fo_obj.background_image_url.value; if(image_url) selectedSizeWidget.style.backgroundImage = "url("+image_url+")"; else selectedSizeWidget.style.backgroundImage = 'none'; switch(fo_obj.background_repeat.selectedIndex) { case 1 : selectedSizeWidget.style.backgroundRepeat = 'no-repeat'; break; case 2 : selectedSizeWidget.style.backgroundRepeat = 'repeat-x'; break; case 3 : selectedSizeWidget.style.backgroundRepeat = 'repeat-y'; break; default : selectedSizeWidget.style.backgroundRepeat = 'repeat'; break; } selectedSizeWidget.style.backgroundPosition = fo_obj.background_x.value+' '+fo_obj.background_y.value; var borderObj = selectedSizeWidget.firstChild; while(borderObj) { if(borderObj.nodeName == "DIV" && (borderObj.className == "widgetBorder" || borderObj.className == "widgetBoxBorder")) { var contentObj = borderObj.firstChild; while(contentObj) { if(contentObj.nodeName == "DIV") { 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.paddingLeft = ''; selectedSizeWidget.setAttribute('widget_padding_left', ''); } var paddingRight = _getSize(fo_obj.padding_right.value); if(paddingRight) { contentObj.style.paddingRight = paddingRight; selectedSizeWidget.setAttribute('widget_padding_right', paddingRight); } else { contentObj.style.paddingRight = ''; selectedSizeWidget.setAttribute('widget_padding_right', ''); } var paddingTop = _getSize(fo_obj.padding_top.value); if(paddingTop) { contentObj.style.paddingTop = paddingTop; selectedSizeWidget.setAttribute('widget_padding_top', paddingTop); } else { contentObj.style.paddingTop = ''; selectedSizeWidget.setAttribute('widget_padding_top', ''); } var paddingBottom = _getSize(fo_obj.padding_bottom.value); if(paddingBottom) { contentObj.style.paddingBottom = paddingBottom; selectedSizeWidget.setAttribute('widget_padding_bottom', paddingBottom); } else { contentObj.style.paddingBottom = ''; selectedSizeWidget.setAttribute('widget_padding_bottom', ''); } break; } contentObj = contentObj.nextSibling; } break; } borderObj = borderObj.nextSibling; } selectedSizeWidget = null; doFitBorderSize(); } doHideWidgetSizeSetup();}/* 위젯 드래그 */// 드래그 중이라는 상황을 간직할 변수var widgetDragManager = {obj:null, isDrag:false}var widgetTmpObject = new Array();var widgetDisappear = 0;function widgetCreateTmpObject(obj) { var id = obj.getAttribute('id'); tmpObj = xCreateElement('DIV'); tmpObj.id = id + '_tmp'; tmpObj.className = obj.className; tmpObj.style.overflow = 'hidden'; tmpObj.style.margin= '0px'; tmpObj.style.padding = '0px'; tmpObj.style.width = obj.style.width; tmpObj.style.display = 'none'; tmpObj.style.position = 'absolute'; tmpObj.style.opacity = 1; tmpObj.style.filter = 'alpha(opacity=100)'; xLeft(tmpObj, xPageX(obj)); xTop(tmpObj, xPageY(obj)); document.body.appendChild(tmpObj); widgetTmpObject[obj.id] = tmpObj; return tmpObj;}// 기생성된 임시 object를 찾아서 return, 없으면 만들어서 returnvar idStep = 0;function widgetGetTmpObject(obj) { if(!obj.id) obj.id = 'widget_'+idStep++; var tmpObj = widgetTmpObject[obj.id]; if(!tmpObj) tmpObj = widgetCreateTmpObject(obj); return tmpObj;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -