123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- function HtmlLib ()
- {
- };
- /**
- * Xml Node style 값을 얻어 온다.
- */
- HtmlLib.getStyle = function (xnHtmlNode, strStyleName)
- {
- if (null != xnHtmlNode && null != strStyleName && 0 < strStyleName.length)
- {
- switch (strStyleName)
- {
- case "left" : return xnHtmlNode.style.left;
- case "right" : return xnHtmlNode.style.right;
- case "top" : return xnHtmlNode.style.top;
- case "bottom" : return xnHtmlNode.style.bottom;
- case "width" : return xnHtmlNode.style.width;
- case "height" : return xnHtmlNode.style.height;
- case "font-family" : return xnHtmlNode.style.fontFamily;
- case "font-size" : return xnHtmlNode.style.fontSize;
- case "font-weight" : return xnHtmlNode.style.fontWeight;
- case "font-style" : return xnHtmlNode.style.fontStyle;
- case "text-decoration" : return xnHtmlNode.style.textDecoration;
- case "color" : return xnHtmlNode.style.color;
- case "text-align" : return xnHtmlNode.style.textAlign;
- case "vertical-align" : return xnHtmlNode.style.verticalAlign;
- case "word-wrap" : return xnHtmlNode.style.wordWrap;
- case "line-spacing" : return xnHtmlNode.style.lineSpacing;
- case "letter-spacing" : return xnHtmlNode.style.letterSpacing;
- case "padding" : return xnHtmlNode.style.padding;
- case "padding-left" : return xnHtmlNode.style.paddingLeft;
- case "padding-top" : return xnHtmlNode.style.paddingTop;
- case "padding-right" : return xnHtmlNode.style.paddingRight;
- case "padding-bottom" : return xnHtmlNode.style.paddingBottom;
- case "background-color" : return xnHtmlNode.style.backgroundColor;
- case "background-image" : return xnHtmlNode.style.backgroundImage;
- case "background-repeat" : return xnHtmlNode.style.backgroundRepeat;
- case "background-position" :
- {
- var strBackgroundPosition = xnHtmlNode.style.backgroundPosition;
- if ("left center" == strBackgroundPosition)
- {
- strBackgroundPosition = "center left";
- }
- else if ("right center" == strBackgroundPosition)
- {
- strBackgroundPosition = "center right";
- }
- return strBackgroundPosition;
- }
- case "border-color" : return xnHtmlNode.style.borderColor;
- case "border-left-color" : return xnHtmlNode.style.borderLeftColor;
- case "border-top-color" : return xnHtmlNode.style.borderTopColor;
- case "border-right-color" : return xnHtmlNode.style.borderRightColor;
- case "border-bottom-color" : return xnHtmlNode.style.borderBottomColor;
- case "border-width" : return xnHtmlNode.style.borderWidth;
- case "border-left-width" : return xnHtmlNode.style.borderLeftWidth;
- case "border-top-width" : return xnHtmlNode.style.borderTopWidth;
- case "border-right-width" : return xnHtmlNode.style.borderRightWidth;
- case "border-bottom-width" : return xnHtmlNode.style.borderBottomWidth;
- case "border-style" : return xnHtmlNode.style.borderStyle;
- case "border-left-style" : return xnHtmlNode.style.borderLeftStyle;
- case "border-top-style" : return xnHtmlNode.style.borderTopStyle;
- case "border-right-style" : return xnHtmlNode.style.borderRightStyle;
- case "border-bottom-style" : return xnHtmlNode.style.borderBottomStyle;
- case "margin" : return xnHtmlNode.style.margin;
- case "margin-left" : return xnHtmlNode.style.marginLeft;
- case "margin-top" : return xnHtmlNode.style.marginTop;
- case "margin-right" : return xnHtmlNode.style.marginRight;
- case "margin-bottom" : return xnHtmlNode.style.marginBottom;
- case "opacity" : return xnHtmlNode.style.opacity * 100; // Designer에서 입력한 값으로 변환후 return
- case "overflow" : return xnHtmlNode.style.oveflow;
- case "clip" : return;
- case "gradient" : return;
- case "cursor" : return xnHtmlNode.style.cursor;
- case "focus-rect" : return;
- case "unloadmark" : return;
- }
- }
- return null;
- };
- /**
- * Xml Node style 를 설정한다
- *
- * Node.setStyle(Node, "Style이름", "값")
- */
- HtmlLib.setStyle = function (xnHtmlNode, strStyleName, strStyleValue)
- {
- try
- {
- if (null != xnHtmlNode && null != strStyleName && 0 < strStyleName.length && null != strStyleValue)
- {
- switch (strStyleName)
- {
- case "left" : xnHtmlNode.style.left = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue; break;
- case "right" :
- {
- if (-1 != strStyleValue.indexOf("%"))
- {
- strStyleValue = (100 - parseFloat(strStyleValue)) + "%";
- xnHtmlNode.style.right = strStyleValue;
- break;
- }
- xnHtmlNode.style.right = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue; break;
- }
- case "top" : xnHtmlNode.style.top = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue; break;
- case "bottom" :
- {
- if (-1 != strStyleValue.indexOf("%"))
- {
- strStyleValue = (100 - parseFloat(strStyleValue)) + "%";
- xnHtmlNode.style.bottom = strStyleValue;
- break;
- }
- xnHtmlNode.style.bottom = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue; break;
- }
- case "width" :
- {
- strStyleValue = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue;
- xnHtmlNode.style.width = strStyleValue;
- if (-1 == strStyleValue.indexOf("%") && isFinite(parseInt(strStyleValue)))
- {
- var nBlockWidth = xnHtmlNode.offsetWidth - parseInt(strStyleValue);
- if (0 < nBlockWidth)
- {
- xnHtmlNode.style.width = (parseInt(strStyleValue) - nBlockWidth) + "px";
- }
- nBlockWidth = null; //메모리 환원
- }
- break;
- }
- case "height" :
- {
- if (strStyleValue.toString().substring(0,1) == "-")
- {
- strStyleValue = "0";
- }
- strStyleValue = isFinite(strStyleValue) ? strStyleValue + "px" : strStyleValue;
- xnHtmlNode.style.height = strStyleValue;
- if (-1 == strStyleValue.indexOf("%") && isFinite(parseInt(strStyleValue)))
- {
- var nBlockHeight = xnHtmlNode.offsetHeight - parseInt(strStyleValue);
- if (0 < nBlockHeight)
- {
- xnHtmlNode.style.height = (parseInt(strStyleValue) - nBlockHeight) + "px";
- }
- nBlockHeight = null; //메모리 환원
- }
- break;
- }
- case "font-family" : xnHtmlNode.style.fontFamily = strStyleValue; break;
- case "font-size" :
- {
- strStyleValue = isFinite(strStyleValue) ? strStyleValue + "pt" : strStyleValue;
- xnHtmlNode.style.fontSize = strStyleValue;
- break;
- }
- case "font-weight" : xnHtmlNode.style.fontWeight = strStyleValue; break;
- case "font-style" : xnHtmlNode.style.fontStyle = strStyleValue; break;
- case "text-decoration" : xnHtmlNode.style.textDecoration = strStyleValue; break;
- case "color" :
- {
- strStyleValue = "" == strStyleValue ? "#000000" : strStyleValue;
- xnHtmlNode.style.color = strStyleValue; break;
- }
- case "text-align" : xnHtmlNode.style.textAlign = strStyleValue; break;
- case "vertical-align" : xnHtmlNode.style.verticalAlign = strStyleValue; break;
- case "word-wrap" : xnHtmlNode.style.wordWrap = strStyleValue; break;
- case "line-spacing" : xnHtmlNode.style.lineSpacing = strStyleValue; break;
- case "line-height" : xnHtmlNode.style.lineHeight = strStyleValue; break;
- case "letter-spacing" : xnHtmlNode.style.letterSpacing = strStyleValue; break;
- case "padding" : xnHtmlNode.style.padding = strStyleValue; break;
- case "padding-left" : xnHtmlNode.style.paddingLeft = strStyleValue; break;
- case "padding-top" : xnHtmlNode.style.paddingTop = strStyleValue; break;
- case "padding-right" : xnHtmlNode.style.paddingRight = strStyleValue; break;
- case "padding-bottom" : xnHtmlNode.style.paddingBottom = strStyleValue; break;
- case "background-color" : xnHtmlNode.style.backgroundColor = strStyleValue; break;
- case "background-image" :
- {
- if (strStyleValue.trim().substring(0,4) != "url(")
- {
- strStyleValue = "url(" + strStyleValue + ")";
- }
- xnHtmlNode.style.backgroundImage = strStyleValue; break;
- }
- case "background-repeat" : xnHtmlNode.style.backgroundRepeat = strStyleValue; break;
- case "background-position" :
- {
- if ("" != strStyleValue)
- {
- var strBackgroundPositionX = "";
- if (-1 != strStyleValue.indexOf("left"))
- {
- strBackgroundPositionX = "left";
- }
- else if (-1 != strStyleValue.indexOf("right"))
- {
- strBackgroundPositionX = "right";
- }
-
- var strBackgroundPositionY = "";
- if (-1 != strStyleValue.indexOf("top"))
- {
- strBackgroundPositionY = "top";
- }
- else if (-1 != strStyleValue.indexOf("bottom"))
- {
- strBackgroundPositionY = "bottom";
- }
-
- if (-1 != strStyleValue.indexOf("center"))
- {
- if ("center" == strStyleValue)
- {
- if ("" == strBackgroundPositionX)
- {
- strBackgroundPositionX = "center";
- }
- if ("" == strBackgroundPositionY)
- {
- strBackgroundPositionY = "center";
- }
- }
- }
- if ("" != strBackgroundPositionX && "" != strBackgroundPositionY)
- {
- strStyleValue = strBackgroundPositionX + " " + strBackgroundPositionY;
- }
- else if ("" != strBackgroundPositionX && "" == strBackgroundPositionY)
- {
- strStyleValue = strBackgroundPositionX;
- }
- else if ("" == strBackgroundPositionX && "" != strBackgroundPositionY)
- {
- strStyleValue = strBackgroundPositionY;
- }
- else if ("" == strBackgroundPositionX && "" == strBackgroundPositionY)
- {
- strStyleValue = "left center";
- }
- }
- xnHtmlNode.style.backgroundPosition = strStyleValue; break;
- }
- case "border-color" : xnHtmlNode.style.borderColor = strStyleValue; break;
- case "border-left-color" : xnHtmlNode.style.borderLeftColor = strStyleValue; break;
- case "border-top-color" : xnHtmlNode.style.borderTopColor = strStyleValue; break;
- case "border-right-color" : xnHtmlNode.style.borderRightColor = strStyleValue; break;
- case "border-bottom-color" : xnHtmlNode.style.borderBottomColor = strStyleValue; break;
- case "border-width" : xnHtmlNode.style.borderWidth = strStyleValue; break;
- case "border-left-width" : xnHtmlNode.style.borderLeftWidth = strStyleValue; break;
- case "border-top-width" : xnHtmlNode.style.borderTopWidth = strStyleValue; break;
- case "border-right-width" : xnHtmlNode.style.borderRightWidth = strStyleValue; break;
- case "border-bottom-width" : xnHtmlNode.style.borderBottomWidth = strStyleValue; break;
- case "border-style" : xnHtmlNode.style.borderStyle = strStyleValue; break;
- case "border-left-style" : xnHtmlNode.style.borderLeftStyle = strStyleValue; break;
- case "border-top-style" : xnHtmlNode.style.borderTopStyle = strStyleValue; break;
- case "border-right-style" : xnHtmlNode.style.borderRightStyle = strStyleValue; break;
- case "border-bottom-style" : xnHtmlNode.style.borderBottomStyle = strStyleValue; break;
- case "margin" : xnHtmlNode.style.margin = strStyleValue; break;
- case "margin-left" : xnHtmlNode.style.marginLeft = strStyleValue; break;
- case "margin-top" : xnHtmlNode.style.marginTop = strStyleValue; break;
- case "margin-right" : xnHtmlNode.style.marginRight = strStyleValue; break;
- case "margin-bottom" : xnHtmlNode.style.marginBottom = strStyleValue; break;
- case "opacity" :
- {
- if (is_ie)
- {
- xnHtmlNode.style.filter = "alpha(opacity=" + strStyleValue + ")";
- }
- else
- {
- if (1 < strStyleValue)
- {
- var fOpacity = parseFloat(strStyleValue)/100;
- strStyleValue = fOpacity;
- }
- xnHtmlNode.style.opacity = strStyleValue;
- }
- break;
- }
- case "overflow" : xnHtmlNode.style.overflow = strStyleValue; break;
- case "clip" : break;
- case "gradient" : break;
- case "cursor" :
- {
- if ("arrow" == strStyleValue)
- {
- strStyleValue = "default";
- }
- else if ("drag-move" == strStyleValue)
- {
- strStyleValue = "pointer";
- }
- else if ("h-resize" == strStyleValue)
- {
- strStyleValue = "col-resize";
- }
- else if ("v-resize" == strStyleValue)
- {
- strStyleValue = "row-resize";
- }
- else if ("no" == strStyleValue)
- {
- strStyleValue = "no-drop";
- }
- else if ("hand" == strStyleValue)
- {
- if (is_ie) strStyleValue = "hand";
- else strStyleValue = "pointer";
- }
- else
- {
- strStyleValue = "default";
- }
-
- xnHtmlNode.style.cursor = strStyleValue; break;
- }
- case "focus-rect" : break;
- case "unloadmark" : break;
- }
- }
- }
- catch (exception)
- {
- // alert(exception.message);
- }
- };
- HtmlLib.setStyleFront = function (xnHtmlNode, strStyleName, strStyleValue)
- {
- if (xnHtmlNode)
- {
- if ("margin" == strStyleName)
- {
- var strLeft = xnHtmlNode.style.marginLeft;
- var strTop = xnHtmlNode.style.marginTop;
- var strRight = xnHtmlNode.style.marginRight;
- var strBottom = xnHtmlNode.style.marginBottom;
-
- HtmlLib.setStyle(xnHtmlNode, strStyleName, strStyleValue);
-
- if ("" != strLeft)
- {
- xnHtmlNode.style.marginLeft = strLeft;
- }
- if ("" != strTop)
- {
- xnHtmlNode.style.marginTop = strTop;
- }
- if ("" != strRight)
- {
- xnHtmlNode.style.marginRight = strRight;
- }
- if ("" != strBottom)
- {
- xnHtmlNode.style.marginBottom = strBottom;
- }
- }
- else if ("border-width" == strStyleName)
- {
- var strLeftWidth = xnHtmlNode.style.borderLeftWidth;
- var strTopWidth = xnHtmlNode.style.borderTopWidth;
- var strRightWidth = xnHtmlNode.style.borderRightWidth;
- var strBottomWidth = xnHtmlNode.style.borderBottomWidth;
-
- HtmlLib.setStyle(xnHtmlNode, strStyleName, strStyleValue);
-
- if ("" != strLeftWidth)
- {
- xnHtmlNode.style.borderLeftWidth = strLeftWidth;
- }
- if ("" != strTopWidth)
- {
- xnHtmlNode.style.borderTopWidth = strTopWidth;
- }
- if ("" != strRightWidth)
- {
- xnHtmlNode.style.borderRightWidth = strRightWidth;
- }
- if ("" != strBottomWidth)
- {
- xnHtmlNode.style.borderBottomWidth = strBottomWidth;
- }
- }
- else if ("border-style" == strStyleName)
- {
- var strLeftStyle = xnHtmlNode.style.borderLeftStyle;
- var strTopStyle = xnHtmlNode.style.borderTopStyle;
- var strRightStyle = xnHtmlNode.style.borderRightStyle;
- var strBottomStyle = xnHtmlNode.style.borderBottomStyle;
-
- HtmlLib.setStyle(xnHtmlNode, strStyleName, strStyleValue);
-
- if ("" != strLeftStyle)
- {
- xnHtmlNode.style.borderLeftStyle = strLeftStyle;
- }
- if ("" != strTopStyle)
- {
- xnHtmlNode.style.borderTopStyle = strTopStyle;
- }
- if ("" != strRightStyle)
- {
- xnHtmlNode.style.borderRightStyle = strRightStyle;
- }
- if ("" != strBottomStyle)
- {
- xnHtmlNode.style.borderBottomStyle = strBottomStyle;
- }
- }
- else if ("border-color" == strStyleName)
- {
- var strLeftColor = xnHtmlNode.style.borderLeftColor;
- var strTopColor = xnHtmlNode.style.borderTopColor;
- var strRightColor = xnHtmlNode.style.borderRightColor;
- var strBottomColor = xnHtmlNode.style.borderBottomColor;
-
- HtmlLib.setStyle(xnHtmlNode, strStyleName, strStyleValue);
-
- if ("" != strLeftColor)
- {
- xnHtmlNode.style.borderLeftColor = strLeftColor;
- }
- if ("" != strTopColor)
- {
- xnHtmlNode.style.borderTopColor = strTopColor;
- }
- if ("" != strRightColor)
- {
- xnHtmlNode.style.borderRightColor = strRightColor;
- }
- if ("" != strBottomColor)
- {
- xnHtmlNode.style.borderBottomColor = strBottomColor;
- }
- }
- else if ("padding" == strStyleName)
- {
- var strLeft = xnHtmlNode.style.paddingLeft;
- var strTop = xnHtmlNode.style.paddingTop;
- var strRight = xnHtmlNode.style.paddingRight;
- var strBottom = xnHtmlNode.style.paddingBottom;
-
- HtmlLib.setStyle(xnHtmlNode, strStyleName, strStyleValue);
-
- if ("" != strLeft)
- {
- xnHtmlNode.style.paddingLeft = strLeft;
- }
- if ("" != strTop)
- {
- xnHtmlNode.style.paddingTop = strTop;
- }
- if ("" != strRight)
- {
- xnHtmlNode.style.paddingRight = strRight;
- }
- if ("" != strBottom)
- {
- xnHtmlNode.style.paddingBottom = strBottom;
- }
- }
- }
- };
|