123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- XFormsIViewer.prototype = new XFormsControl;
- function XFormsIViewer (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind,
- strClass, bDisabled, strId, nNavindex, strRef, strSrc, strStyle, strTag, strVisibility, strUserDefineAttrib)
- {
- if (!strId)
- {
- return;
- }
-
- XFormsBindableControl.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strBind,
- strClass, bDisabled, strId, nNavindex, strRef, strStyle, strTag, strVisibility, strUserDefineAttrib);
-
- /**
- * Attribute
- */
- this.attribute["src"] = strSrc;
-
- /**
- * Property
- */
- this.selected;
- this.src = strSrc;
- // 자식화면 제어를 위해 필요한 Property
- this.body;
- this.document;
- this.window;
- };
- XFormsIViewer.prototype.init = function ()
- {
- XFormsControl.prototype.init.call(this);
- this.status = true;
- this.setSrc(this.src);
- this.resizeControl();
-
- var strId = this.id;
- if (this.m_heControl.attachEvent)
- {
- this.m_heControl.attachEvent("onload", function() {XFormsIViewer.setIviewerDoc(strId);});
- }
- else
- {
- this.m_heControl.addEventListener("load", function() {XFormsIViewer.setIviewerDoc(strId);}, false);
- }
- };
- XFormsIViewer.prototype.applyDefaultStyle = function ()
- {
- XFormsControl.prototype.applyDefaultStyle.call(this);
-
- if (!this.attribute["border-style"] && !this.attribute["border-width"])
- {
- this.m_heControl.style.borderWidth = "";
- }
- };
- XFormsIViewer.prototype.setAttribute = function (strAttribute, strValue)
- {
- switch (strAttribute) // 우겸 스타일 객체 수정한 뒤 작업해야 함..
- {
- case "src":
- {
- this.setSrc(strValue);
- break;
- }
- case "visibility" :
- {
- if ("visible" == strValue)
- {
- this.visible = true;
- this.attribute["visibility"] = strValue;
- this.m_heControl.style.visibility = "visible";
- this.m_heControl.style.display = "block";
- }
- else if ("hidden" == strValue)
- {
- this.visible = false;
- this.attribute["visibility"] = strValue;
- this.m_heControl.style.visibility = "hidden";
- this.m_heControl.style.display = "none";
- }
- break;
- }
- default:
- {
- XFormsControl.prototype.setAttribute.call(this, strAttribute, strValue);
- break;
- }
- }
- };
- XFormsIViewer.prototype.setSrc = function (strSrc)
- {
- this.src = strSrc;
- this.attribute["src"] = strSrc;
- // 확장자를 .xrw에서 .html로 변환
- this.m_heControl.src = strSrc.changeExtension("xrw", "html");
-
-
- };
- XFormsIViewer.prototype.setVisible = function (bVisible)
- {
- // Property 적용
- this.visible = bVisible;
- if (bVisible)
- {
- // Attribute 적용
- this.attribute["visibility"] = "visible";
- // HTML 적용
- this.m_heControl.style.visibility = "visible";
- this.m_heControl.style.display = "block";
- }
- else
- {
- // Attribute 적용
- this.attribute["visibility"] = "hidden";
- // HTML 적용
- this.m_heControl.style.visibility = "hidden";
- this.m_heControl.style.display = "none";
- }
- };
- XFormsIViewer.create = function (strParentId, clAttribute, strStyle)
- {
- // 메인노드 생성
- var xnIViewer = XFormsIViewer.createMainNode(clAttribute);
- var xnParent = document.getElementById("HE_"+strParentId);
- xnParent.appendChild(xnIViewer);
-
- // 하위노드 생성
- xnIViewer = XFormsIViewer.createSubNodes(xnIViewer, clAttribute);
- // object 생성
- return XFormsIViewer.createObject(strParentId, xnIViewer, clAttribute, strStyle);
- };
- XFormsIViewer.createMainNode = function (clAttribute)
- {
- var xnIViewer = document.createElement("iframe");
- xnIViewer = XFormsIViewer.createAttribute(xnIViewer, clAttribute);
- xnIViewer.frameBorder = "0";
- return xnIViewer;
- };
- XFormsIViewer.createSubNodes = function (xnIViewer, clAttribute)
- {
- return xnIViewer;
- };
- XFormsIViewer.createObject = function (strParentId, xnIViewer, clAttribute, strStyle)
- {
- // src 확장자 html로 바뀐거 다시 xrw로 바꿔치기
- if (clAttribute.exists("src"))
- {
- var strFileName = clAttribute.item("src");
- var nPosition = strFileName.lastIndexOf('.');
-
- if (nPosition > 0 && nPosition < strFileName.length && strFileName.substring(nPosition + 1) == "html")
- {
- strFileName = strFileName.substring(0, nPosition);
- strFileName += ".xrw";
- }
- clAttribute.add("src", strFileName);
- }
- var bDisabled = false;
- var strId = "";
- var strSrc = "";
- var strVisibility = "visible";
- var strUserDefineAttrib = "";
-
- for (var i=0; i<clAttribute.count(); i++)
- {
- var strAttributeName = clAttribute.keys()[i];
- switch (strAttributeName)
- {
- case "disabled" :
- {
- if ("true" == clAttribute.item(strAttributeName))
- {
- bDisabled = true;
- }
- break;
- }
- case "id" :
- {
- strId = clAttribute.item(strAttributeName);
- break;
- }
- case "src" :
- {
- strSrc = clAttribute.item(strAttributeName);
- break;
- }
- case "visibility" :
- {
- strVisibility = clAttribute.item(strAttributeName);
- break;
- }
-
- default :
- {
- if (!STYLE_LIST[strAttributeName])
- {
- strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
- }
- break;
- }
- }
- }
- var objIViewer = new XFormsIViewer (strParentId, "", "", "", "", "", "", bDisabled, strId, -1, "", strSrc, strStyle, "xforms:iviewer", strVisibility, strUserDefineAttrib);
- return objIViewer;
- };
- XFormsIViewer.createAttribute = function (xnHtmlNode, clAttribute)
- {
- // src 확장자 xrw에서 html로 바꿔치기
- if (clAttribute.exists("src"))
- {
- var strFileName = clAttribute.item("src");
- var nPosition = strFileName.lastIndexOf('.');
-
- if (nPosition > 0 && nPosition < strFileName.length && strFileName.substring(nPosition + 1) == "xrw")
- {
- strFileName = strFileName.substring(0, nPosition);
- strFileName += ".html";
- }
- clAttribute.add("src", strFileName);
- }
-
- xnHtmlNode = XFormsControl.createAttribute(xnHtmlNode, clAttribute);
- return xnHtmlNode;
- };
- XFormsIViewer.setIviewerDoc = function (strId)
- {
- var objIviewer = document.controls.item(strId);
- objIviewer.body = objIviewer.m_heControl.contentWindow.body;
- objIviewer.document = objIviewer.m_heControl.contentWindow.document;
- objIviewer.model = objIviewer.m_heControl.contentWindow.model;
- objIviewer.window = objIviewer.m_heControl.contentWindow;
- objIviewer.window.type = "iviewer";
- };
|