1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408 |
- // Form Control State
- FCS_NORMAL = 0x00000000;
- FCS_FOCUS = 0x00000001; // focus
- FCS_SELECT = 0x00000002; // select
- FCS_HOVER = 0x00000004; // hover
- FCS_DOWN = 0x00000008; // down
- FCS_DISABLE = 0x00000010; // disable
- FCS_ACTIVE = 0x00000020; // active
- // Binding Type
- BT_NONE = 0;
- BT_SINGLE = 1;
- BT_NODESET = 2;
- XFormsControl.prototype = new XFormsElement;
- function XFormsControl (strParentId, strAlert, strHelp, strHint, strAccesskey, strClass,
- bDisabled, strId, nNavindex, strStyle, strTag, strVisibility, strUserDefineAttrib)
- {
- if (!strId)
- {
- return;
- }
- XFormsElement.call(this, strParentId, strId, strTag);
- /**
- * Attribute
- */
- this.attribute["alert"] = strAlert;
- this.attribute["help"] = strHelp;
- this.attribute["hint"] = strHint;
- this.attribute["accesskey"] = strAccesskey;
- this.attribute["class"] = strClass;
- this.attribute["disabled"] = String(bDisabled);
- this.attribute["id"] = strId;
- this.attribute["navindex"] = String(nNavindex);
- this.attribute["tag"] = strTag;
- this.attribute["visibility"] = strVisibility;
-
- /**
- * Property
- */
- this.disabled = bDisabled;
- this.hint = strHint;
- this.navIndex = nNavindex;
- this.visible = ("visible" == strVisibility) ? true : false;
-
- /**
- * html Element
- */
- this.m_heControl;
-
- /**
- * Style
- */
- this.m_strStyle = strStyle;
-
- /**
- * User Define Attribute
- */
- this.m_strUserDefineAttrib = strUserDefineAttrib;
-
- /**
- * Event State 관련
- */
- this.m_bDown = false;
- this.m_bDragStart = false;
- this.m_bLButtonDown = false;
- this.m_dwState = 0;
-
- /**
- * 컨트롤이 가져야 할 index 멤버변수
- */
- this.m_TabIndex;
- /**
- * 컨트롤 안에 존재하는 새부적인 컨트롤일 경우 true (ex> combo.input , combo.button)
- */
- this.m_bDependentCtl = false;
- /**
- * 도큐먼트에 컨트롤을 추가한다.
- */
- if ("xforms:col" != this.attribute["tag"])
- {
- XFormsDocument.appendControl(strId, this);
- }
-
- /**
- * 탭인덱스를 추가한다.
- */
- model.addTabIndex(nNavindex, this);
- };
- XFormsControl.prototype.init = function ()
- {
- this.m_heControl = document.getElementById("HE_" + this.id);
- var bIsControl = null != this.m_heControl ? true : false;
- this.setStyleToAttribute();
- this.setUserDefineAttribute();
-
- if (!bIsControl)
- {//물리적인 tag가 존재하지 않을 때 부모의 style을 상속받는다.
- // this.setNotObjToChildStyle();
- }
- else if (bIsControl && this.m_bDependentCtl)
- {//물리적인 tag가 존재하지만 컨트롤의 문서상에서 style을 변경할수 없는 자식들의 style을 넣어준다.
- //ex)combo.input , combo.buttom
- // this.setChildStyle();
- }
- if (null != g_objStyleSheet)
- {
- g_objStyleSheet.applyCSS(this);
- }
- if (bIsControl)
- {
- if (!this.m_bDependentCtl)
- {//앞에서 적용하였기 때문에 생략한다.
- // this.setChildStyle();
- }
- this.applyDefaultStyle();
- // this.adjustDIVSize();
-
- this.m_heControl.title = this.hint;
-
- if (1 == this.navIndex)
- {
- window.setTimeout("window.setFocus('" + this.id + "');", 0);
- }
-
- if(!this.visible)
- {
- this.m_heControl.style.visibility = "hidden";
- }
- }
- this.disabled = false;
- };
- XFormsControl.prototype.setStyleToAttribute = function ()
- {
- if (null != this.m_strStyle && "" != this.m_strStyle)
- {
- this.m_strStyle = this.m_strStyle.trim();
- if (";" == this.m_strStyle.charAt(this.m_strStyle.length - 1))
- {
- this.m_strStyle = this.m_strStyle.substring(0, this.m_strStyle.length - 1);
- }
-
- var arStyle = this.m_strStyle.split(";");
- for (var i=0; i<arStyle.length; i++)
- {
- if (null != arStyle[i] && "" != arStyle[i])
- {
- var arStyleUnit = arStyle[i].split(":");
- this.attribute[arStyleUnit[0].trim()] = arStyleUnit[1].trim();
- }
- }
- }
- };
- XFormsControl.prototype.setUserDefineAttribute = function ()
- {
- if (null != this.m_strUserDefineAttrib && "" != this.m_strUserDefineAttrib)
- {
- this.m_strUserDefineAttrib = this.m_strUserDefineAttrib.trim();
- if (";" == this.m_strUserDefineAttrib.charAt(this.m_strUserDefineAttrib.length - 1))
- {
- this.m_strUserDefineAttrib = this.m_strUserDefineAttrib.substring(0, this.m_strUserDefineAttrib.length - 1);
- }
-
- var arAttrib = this.m_strUserDefineAttrib.split(";");
- for (var i=0; i<arAttrib.length; i++)
- {
- if (null != arAttrib[i] && "" != arAttrib[i])
- {
- var arAttribUnit = arAttrib[i].split(":");
- this.attribute[arAttribUnit[0].trim()] = arAttribUnit[1].trim();
- }
- }
- }
- };
- XFormsControl.prototype.isIndepandent = function ()
- {
- return true;
- };
- XFormsControl.prototype.getAbility = function ()
- {
- return EA_CONTROL;
- };
- XFormsControl.prototype.isEnable = function ()
- {
- var objControl = this;
-
- while (null != objControl && (EA_CONTROL_BASE & objControl.getAbility()))
- {
- if (objControl.getState(FCS_DISABLE))
- {
- return false;
- }
-
- objControl = objControl.parent;
- }
-
- return true;
- };
- XFormsControl.prototype.setRefElement = function (objElementBase)
- {
- XFormsElement.prototype.setRefElement.call(this, objElementBase);
-
- this.m_heControl = objElementBase.getHtmlElement();
- };
- XFormsControl.prototype.getClass = function ()
- {
- return this.attribute["class"];
- };
- XFormsControl.prototype.getHtmlElement = function ()
- {
- return this.m_heControl;
- };
- XFormsControl.prototype.setHtmlElement = function (heElement)
- {
- this.m_heControl = heElement;
- };
- XFormsControl.prototype.refresh = function ()
- {
- if ("true" == this.attribute["disabled"])
- {
- this.setDisabled(true);
- }
- };
- /**
- * 컨트롤의 IE 이외의 브라우저에서 DIV border를 밖에 그리는 문제때문에 border 사이즈와 width, height를 조절한다.
- * DIV로 싸여있는 컨트롤은 이 함수를 init()에서 호출하자.
- * @return
- */
- XFormsControl.prototype.adjustDIVSize = function ()
- {
- if (!is_ie && this.m_heControl && this.m_heControl.tagName.toLowerCase() == "div")
- {
- var strWidth = this.attribute["width"];
- if (strWidth && strWidth.lastIndexOf("%") < 0)
- {
- var nWidth = parseInt(this.attribute["width"].replace("px",""));
- var nDifference = this.m_heControl.offsetWidth - this.m_heControl.clientWidth;
- this.m_heControl.style.width = (nWidth - nDifference) + "px";
- }
- var strHeight = this.attribute["height"];
- if (strHeight && strHeight.lastIndexOf("%") < 0)
- {
- var nHeight = parseInt(this.attribute["height"].replace("px",""));
- var nDifference = this.m_heControl.offsetHeight - this.m_heControl.clientHeight;
- this.m_heControl.style.height = (nHeight - nDifference) + "px";
- }
- }
- };
- XFormsControl.prototype.getBindingType = function ()
- {
- return BT_NONE;
- };
- XFormsControl.prototype.setDisabled = function (bDisabled, bParentDis)
- {
- if (null == bParentDis && this.disabled == bDisabled)
- {
- return;
- }
- if (null == bParentDis)
- {
- this.m_bThisDisabled = bDisabled;
- }
- if (null == bParentDis && !bDisabled)
- {
- this.m_bThisDisabled = null;
- }
- if (this.m_bThisDisabled && bParentDis && !bDisabled)
- {
- return;
- }
- this.disabled = bDisabled;
- // Attribute 변경
- this.attribute["disabled"] = String(bDisabled);
- // HTML 적용
- if (null != this.m_heControl)
- {
- this.m_heControl.disabled = bDisabled;
- }
- // 상태 변경
- this.setState(FCS_DISABLE, bDisabled);
- this.m_strPDisabled = bDisabled ? this.id : null;
- for (var i=0; i<this.children.length; i++)
- {
- var objChild = this.children.item(i);
- var strElementName = objChild.elementName;
- if (objChild instanceof XFormsControl)
- {
- if ( -1 != objChild.id.indexOf("fixed-cell"))
- {
- continue;
- }
- objChild.setDisabled(bDisabled , true);
- }
- }
- };
- XFormsControl.prototype.setHint = function (strHint)
- {
- // Attribute 변경
- this.attribute["hint"] = strHint;
- // Property 변경
- this.hint = strHint;
- // HTML 적용
- this.m_heControl.title = strHint;
- };
- XFormsControl.prototype.setNavIndex = function (nNavindex)
- {
- if (this.navIndex == nNavindex)
- {
- return;
- }
- else
- {
- model.replaceTabIndex(this.m_TabIndex, nNavindex, this);
- // Property 변경
- this.navIndex = nNavindex;
- // Attribute 변경
- this.attribute["navindex"] = String(nNavindex);
- }
- };
- XFormsControl.prototype.setVisible = function (bVisible)
- {
- // Property 적용
- this.visible = bVisible;
- if (bVisible)
- {
- // Attribute 적용
- this.attribute["visibility"] = "visible";
- // HTML 적용
- this.m_heControl.style.visibility = "visible";
- }
- else
- {
- // Attribute 적용
- this.attribute["visibility"] = "hidden";
- // HTML 적용
- this.m_heControl.style.visibility = "hidden";
- }
- };
- XFormsControl.prototype.refreshCurrentModel = function (strObj)
- {
- if (__useBinding)
- {
- var bAutoRefresh = (null == strObj || -1 != strObj.indexOf("/")) ? true: false;
- if (null == bAutoRefresh)
- {
- bAutoRefresh = true;
- }
- if(bAutoRefresh)
- {
- model.dispatch("xforms-recalculate");
- // TODO xforms-revalidate 미구현
- model.dispatch("xforms-refresh");
- }
- else
- {
- model.refresh();
- }
- }
- else
- {
- var strRef = strObj;
- if (null != strRef && !strRef.isEmpty())
- {
- if (null != REF_ATTRIBUTE[strRef])
- {
- for (strHtKey in REF_ATTRIBUTE[strRef])
- {
- REF_ATTRIBUTE[strRef][strHtKey].refresh();
- }
- return;
- }
- this.refresh();
- }
- else
- {
- this.refresh();
- }
- }
- };
- XFormsControl.prototype.setPosition = function (rectControl)
- {
- this.m_heControl.style.top = rectControl.getY() + "px";
- this.m_heControl.style.left = rectControl.getX() + "px";
- this.m_heControl.style.width = rectControl.getWidth() + "px";
- this.m_heControl.style.height = rectControl.getHeight() + "px";
- };
- XFormsControl.prototype.resizeControl = function ()
- {
- if (this.attribute["height"])
- {
- HtmlLib.setStyle(this.m_heControl, "height", this.attribute["height"]);
- }
- if (this.attribute["width"])
- {
- HtmlLib.setStyle(this.m_heControl, "width", this.attribute["width"]);
- }
- };
- XFormsControl.prototype.clientToControl = function (ptClient)
- {
- // ptClient.m_nX +=
- };
- XFormsControl.prototype.focus = function ()
- {
- try
- {//컨트롤의 상태가 disabled 일때 사용불가능
- this.m_heControl.focus();
- }
- catch(e)
- {
- }
- };
- /**
- * Attribute 값을 변경시키고 Attribute 값 변화에 맞는 동작을 수행한다.
- * @param strAttribute
- * @param strValue
- * @return
- */
- XFormsControl.prototype.setAttribute = function (strAttribute, strValue)
- {
- XFormsElement.prototype.setAttribute.call(this, strAttribute, strValue);
- switch (strAttribute)
- {
- case "alert" :
- {
- this.attribute["alert"] = strValue;
- break;
- }
-
- case "help" :
- {
- this.attribute["help"] = strValue;
- break;
- }
- case "hint" :
- {
- this.attribute["hint"] = strValue;
- this.setHint(strValue);
- break;
- }
- case "accesskey" :
- {
- this.attribute["accesskey"] = strValue;
- this.m_heControl.accessKey = strValue;
- break;
- }
- case "class" :
- {
- this.attribute["class"] = strValue;
- this.init();
- break;
- }
- case "disabled" :
- {
- if ("true" == strValue)
- {
- this.setDisabled (true);
- }
- else if ("false" == strValue)
- {
- this.setDisabled (false);
- }
- break;
- }
- case "navindex" :
- {
- this.setNavIndex(parseInt(strValue));
- break;
- }
-
- case "visibility" :
- {
- if ("visible" == strValue)
- {
- this.visible = true;
- this.attribute["visibility"] = strValue;
- this.m_heControl.style.visibility = "visible";
- }
- else if ("hidden" == strValue)
- {
- this.visible = false;
- this.attribute["visibility"] = strValue;
- this.m_heControl.style.visibility = "hidden";
- }
- break;
- }
- }
- };
- XFormsControl.prototype.onFocus = function (event)
- {
- if (!this.getState(FCS_ACTIVE))
- {
- this.setState(FCS_ACTIVE, true, event);
- this.dispatch("onactivate");
- }
-
- if (event.target == this.getId())
- {
- this.setState(FCS_FOCUS, true, event);
-
- if (null != this.m_heControl)
- {
- if (this.isFocusValid())
- {
- this.focus();
- }
- }
- }
- };
- XFormsControl.prototype.onBlur = function (event)
- {
- if (this.getState(FCS_ACTIVE))
- {
- this.setState(FCS_ACTIVE, false, event);
- this.dispatch("ondeactivate");
- }
- if (event.target == this.getId())
- {
- this.setState(FCS_FOCUS, false, event);
- }
- event.focus = "";
- };
- XFormsControl.prototype.onClick = function (event)
- {
- if (null == window.m_nDelayTime)
- {
- window.m_nDelayTime = window.setTimeout("var objCtrl = document.controls.m_htCollection['"+ this.id +"'];" +
- "if(null != objCtrl)" +
- "{" +
- "objCtrl.dispatch(\"ondelayclick\");" +
- "}",500);
- }
- };
- XFormsControl.prototype.onDelayClick = function (event)
- {
- window.clearTimeout(window.m_nDelayTime);
- window.m_nDelayTime = null;
- };
- XFormsControl.prototype.onCursor = function (event)
- {
- };
- XFormsControl.prototype.onDblClick = function (event)
- {
- window.clearTimeout(window.m_nDelayTime);
- window.m_nDelayTime = null;
- if (TFEvent.BUTTON_LEFT == event.button)
- {
- this.setState(FCS_DOWN, true, event);
- m_bDown = 0;
- }
- };
- XFormsControl.prototype.onKeyDown = function (event)
- {
- if (event.target == this.getId())
- {
- if (!event.ctrlKey && TFEvent.TAB == event.keyCode)
- {
- if (!event.shiftKey)
- {
- if (event.defaultAction != "cancle")
- {
- this.dispatch("onnext");
- }
- event.defaultAction = "cancle";
- }
- else
- {
- this.dispatch("onprevious");
- event.defaultAction = "cancle";
- }
- }
- else if (TFEvent.F1 == event.keyCode)
- {
- this.dispatch("xforms-help");
- }
- }
- };
- XFormsControl.prototype.onKeyUp = function (event)
- {
-
- };
- XFormsControl.prototype.onKeyPress = function (event)
- {
-
- };
- XFormsControl.prototype.onMouseDown = function (event)
- {
- if (is_ie)
- {
- var arOmitFormtags=["input", "textarea"];
- arOmitFormtags=arOmitFormtags.join("|");
- if (arOmitFormtags.indexOf(m_event.m_browserEvent.srcElement.tagName.toLowerCase())==-1)
- {
- body.m_heControl.onselectstart = new Function("return false");
- }
- else
- {
- body.m_heControl.onselectstart = new Function("return true");
- }
- }
- //combo control의 스크롤이 존재할 때 이벤트 처리
- //TODO 경북대병원 (is_smartphone 부분을 주석처리하고 줌 오류부분 파악불가)
- if(!is_smartphone)
- {
- var heElementName = is_firefox ? event.m_browserEvent.target : event.m_browserEvent.srcElement;
- if ("combo" == heElementName.getAttribute("U_D_C_S"))
- {
- heElementName = null;
- return;
- }
- }
- if (event.target == this.getId())
- {
- if (TFEvent.BUTTON_LEFT == event.button)
- {
- this.setState(FCS_DOWN, true, event);
- this.m_bDown = true;
- }
- window.setFocus(this.getId(), event);
- }
- this.m_bDragStart = false;
- };
- XFormsControl.prototype.onMouseEnter = function (event)
- {
- };
- XFormsControl.prototype.onMouseUp = function (event)
- {
- if (window.bDragDrop)
- {
- window.bDragDrop = false;
- var objControl = null;
- for (var i=0; i< document.controls.length; i++)
- {
- objControl = document.controls.item(i);
- if (TAG_LIST[objControl.getAttribute("tag")])
- {
- objControl.setAttribute("cursor", objControl.getAttribute("cursor"));
- }
- }
- this.dispatch("ondrop");
- }
- if (TFEvent.BUTTON_LEFT == event.button)
- {
- var bDown = (event.down == this.getId()) && this.m_bDown;
-
- if (this.getState(FCS_DOWN) && this.m_bDown)
- {
- this.setState(FCS_DOWN, false, event);
- this.m_bDown = false;
- }
-
- if (event.target == this.getId() && bDown)
- {
- this.dispatch("onclick");
- }
- }
- };
- XFormsControl.prototype.onMouseMove = function (event)
- {
- if (!event.capture.isEmpty())
- {
- return;
- }
-
- if (null != this.m_heControl)
- {
- if (event.down && window.bDragDrop)
- {//drap 상태
- if (TAG_LIST[this.getAttribute("tag")])
- {
- this.m_heControl.style.cursor = "pointer";
- }
- }
- }
- // TODO Viewer들의 hover 상태를 비운다. onChangedHover();
-
- if (event.target == this.getId())
- {
- // 이전 over가 자신이 아니면
- if (event.hover != this.getId())
- {
- // 이전 over는 mouseout
- if (!event.hover.isEmpty())
- {
- this.dispatch("onmouseenter");
- var objOldOver = document.allElement.item(event.hover);
- if (null != objOldOver)
- {
- objOldOver = objOldOver.getElement();
- objOldOver.dispatch("onmouseout");
- }
- }
-
- this.dispatch("onmouseover");
-
- // TODO IFrame 대응
- }
- }
- };
- XFormsControl.prototype.onMouseOut = function (event)
- {
- if (event.target == this.getId() && this.getState(FCS_HOVER))
- {
- this.setState(FCS_HOVER, false, event);
- }
- };
- XFormsControl.prototype.onMouseOver = function (event)
- {
- if (event.target == this.getId())
- {
- if (window.bDragDrop)
- {
- this.dispatch("ondragover");
- }
- this.dispatch("oncursor");
- if (!this.getState(FCS_HOVER))
- {
- this.setState(FCS_HOVER, true, event);
- }
- }
- };
- XFormsControl.prototype.onNext = function (event)
- {
- if (event.target == this.getId())
- {
- var arTabIndex = model.getTabIndex();
- var nIndex = arTabIndex.find(this);
- if (0 > nIndex)
- {
- if (null != this.parent)
- {
- nIndex = arTabIndex.find(this.parent);
- }
- }
-
- if (-1 <= nIndex)
- {
- var objNext;
- if (nIndex + 1 < arTabIndex.length)
- {
- objNext = arTabIndex[nIndex + 1];
- }
- else
- {
- objNext = arTabIndex[0];
- }
-
- if (null != objNext && (objNext.id != event.target))
- {
- window.setFocus(objNext.id);
- }
- else
- {
- window.setFocus("body");
- }
- }
-
- // 실제 브라우저 이벤트를 막는다.
- if (event.m_browserEvent.cancelable === undefined)
- {
- event.m_browserEvent.returnValue = false;
- }
- else
- {
- if (event.m_browserEvent.cancelable)
- {
- event.m_browserEvent.preventDefault ();
- }
- }
-
- this.dispatch("xforms-next");
- }
- };
- XFormsControl.prototype.onPrevious = function (event)
- {
- if (event.target == this.getId())
- {
- var arTabIndex = model.getTabIndex();
- var nIndex = arTabIndex.find(this);
-
- if (0 > nIndex)
- {
- if (null != this.parent)
- {
- nIndex = arTabIndex.find(this.parent);
- }
- }
-
- var objPrev;
- if (0 <= nIndex - 1)
- {
- objPrev = arTabIndex[nIndex - 1];
- }
- else if (0 <= arTabIndex.length - 1)
- {
- objPrev = arTabIndex[arTabIndex.length - 1];
- }
-
- if (null != objPrev && (objPrev.id != event.target))
- {
- window.setFocus(objPrev.id);
- }
- else
- {
- window.setFocus("body");
- }
-
- // 실제 브라우저 이벤트를 막는다.
- if (event.m_browserEvent.cancelable === undefined)
- {
- event.m_browserEvent.returnValue = false;
- }
- else
- {
- if (event.m_browserEvent.cancelable)
- {
- event.m_browserEvent.preventDefault ();
- }
- }
-
- this.dispatch("xforms-previous");
- }
- };
- XFormsControl.prototype.onScroll = function (event)
- {
- };
- XFormsControl.prototype.onScrollDown = function (event)
- {
- };
- XFormsControl.prototype.onScrollUp = function (event)
- {
- };
- XFormsControl.prototype.onMouseWheel = function (event)
- {
- };
- XFormsControl.prototype.onInvalid = function (event)
- {
- };
- XFormsControl.prototype.onOptional = function (event)
- {
- };
- XFormsControl.prototype.onReadonly = function (event)
- {
- };
- XFormsControl.prototype.onReadWrite = function (event)
- {
- };
- XFormsControl.prototype.onRequired = function (event)
- {
- };
- XFormsControl.prototype.onvalid = function (event)
- {
- };
- XFormsControl.prototype.onDragStart = function (event)
- {
- if ("false" != this.getAttribute("dragmode"))
- {
- event.drag = this.getId();
-
- if (event.target == event.currentTarget)
- {
-
- }
- }
- };
- XFormsControl.prototype.onDragEnter = function (event)
- {
- };
- XFormsControl.prototype.onDragOver = function (event)
- {
- };
- XFormsControl.prototype.onDragLeave = function (event)
- {
- };
- XFormsControl.prototype.onDrop = function (event)
- {
- };
- XFormsControl.prototype.setState = function (nState, bSet, event, bRedraw, bCallChange)
- {
- if (bSet)
- {
- switch(nState)
- {
- case FCS_HOVER : event.hover = this.getId(); this.setAttribute("hover", true); break;
- case FCS_DOWN : event.down = this.getId(); this.setAttribute("down", true); break;
- case FCS_FOCUS : event.focus = this.getId(); this.setAttribute("focus", true); break;
- case FCS_SELECT : this.attribute["select"] = "true"; break;
- case FCS_DISABLE : this.attribute["disable"] = "true"; break;
- }
- this.m_dwState |= nState;
- }
- else
- {
- switch(nState)
- {
- case FCS_HOVER : event.hover = ""; this.setAttribute("hover", false); break;
- case FCS_DOWN : event.down = ""; this.setAttribute("down", false); break;
- case FCS_FOCUS : event.focus = ""; this.setAttribute("focus", false); break;
- case FCS_SELECT : this.attribute["select"] = "false"; break;
- case FCS_DISABLE : this.attribute["disable"] = "false"; break;
- }
- this.m_dwState &= ~nState;
- }
-
- this.resetStyle(nState, bSet);
-
- if (bCallChange)
- {
- this.onStateChange(nState, bSet);
- }
- };
- XFormsControl.prototype.resetStyle = function (nState, bSet)
- {
- var htStyle = null;
- if (FCS_NORMAL == nState)
- {
- htStyle = this.attribute;
- }
- else
- {
- if (nState & FCS_DISABLE)
- {
- if (nState & FCS_SELECT)
- {
- htStyle = this.m_htSelectStyle;
- }
- if (nState & FCS_DISABLE)
- {
- htStyle = this.m_htDisableStyle;
- }
- }
- else
- {
- if (nState & FCS_HOVER)
- {
- htStyle = this.m_htHoverStyle;
- }
- if (nState & FCS_SELECT)
- {
- htStyle = this.m_htSelectStyle;
- }
- if (nState & FCS_FOCUS)
- {
- htStyle = this.m_htFocusStyle;
- }
- if (nState & FCS_DOWN)
- {
- htStyle = this.m_htDownStyle;
- }
- }
- }
-
- if (null != htStyle)
- {
- for (var strKey in htStyle)
- {
- var strValue = htStyle[strKey];
-
- if (!bSet)
- {
- strValue = this.attribute[strKey];
- }
-
- if (STYLE_LIST[strKey])
- {
- HtmlLib.setStyle(this.m_heControl, strKey, strValue);
- }
- }
- }
- else
- {
- if (null != this.m_heControl)
- {
- if (nState & FCS_DISABLE)
- {
- var nConStatus = this.getEditControls();
- if (1 == nConStatus)
- {
- if (!bSet)
- {
- this.m_heControl.style.backgroundColor = null != this.attribute["background-color"] ?this.attribute["background-color"] : "#ffffff";
- }
- else
- {
- this.m_heControl.style.backgroundColor = null != this.attribute["disable.background-color"] ? this.attribute["disable.background-color"] : "#EBEBE4";
- }
- }
- else if (2 == nConStatus)
- {
- if (!bSet)
- {
- this.m_heControl.style.color = null != this.attribute["color"] ?this.attribute["color"] : "#000000";
- }
- else
- {
- this.m_heControl.style.color = null != this.attribute["disable.background-color"] ? this.attribute["disable.background-color"] : "#EBEBE4";
- }
- }
- }
- }
- }
- };
- XFormsControl.prototype.getState = function (nState)
- {
- return this.m_dwState & nState;
- };
- XFormsControl.prototype.isFocusValid = function (nState)
- {
- var heParent = this.m_heControl;
-
- while (null != heParent && "HE_body" != heParent.id)
- {
- if ("hidden" == heParent.style.visibility || "none" == heParent.style.display || true == heParent.disabled)
- {
- return false;
- }
- if (is_firefox)
- {
- heParent = heParent.parentNode;
- }
- else
- {
- heParent = heParent.parentElement;
- }
- }
- return true;
- };
- XFormsControl.prototype.getEditControls = function ()
- {
- // CON_TPYE_EDIT = 1;
- //CON_TPYE_VIEW = 2;
- //CON_TPYE_BUTTON = 3;
- var strElementName = this.elementName;
- if ("xforms:input" == strElementName || "xforms:comboinput" == strElementName ||
- "xforms:output" == strElementName || "xforms:secret" == strElementName ||
- "xforms:textarea" == strElementName)
- {
- strElementName = null;
- return CON_TPYE_EDIT;
- }
- else if ("xforms:select1" == strElementName || "minimal" == this.attribute["appearance"])
- {
- strElementName = null;
- return CON_TPYE_EDIT;
- }
- else if ("xforms:button" == strElementName)
- {
- strElementName = null;
- return CON_TPYE_BUTTON;
- }
- else
- {
- strElementName = null;
- return CON_TPYE_VIEW;
- }
- };
- XFormsControl.prototype.defaultAction = function (strEventName, event)
- {
- if("onaccesskey" == strEventName)
- {
- this.dispatch("DOMActivate");
- this.dispatch("xforms-activate");
- }
-
- if (!this.isEnable())
- {
- return;
- }
-
- switch(strEventName)
- {
- case "onmouseactivate" : this.onMouseActivate(event); break;
- case "onmousemove" : this.onMouseMove(event); break;
- case "onmousedown" : this.onMouseDown(event); break;
- case "onmouseenter" : this.onMouseEnter(event); break;
- case "onmouseup" : this.onMouseUp(event); break;
- case "oncursor" : this.onCursor(event); break;
- case "onmouseover" : this.onMouseOver(event); break;
- case "onmouseout" : this.onMouseOut(event); break;
- case "onclick" : this.onClick(event); break;
- case "ondelayclick" : this.onDelayClick(event); break;
- case "ondblclick" : this.onDblClick(event); break;
- case "onfocus" : this.onFocus(event); break;
- case "onblur" : this.onBlur(event); break;
- case "onkeypress" : this.onKeyPress(event); break;
- case "onkeydown" : this.onKeyDown(event); break;
- case "onkeyup" : this.onKeyUp(event); break;
- case "onscrolldown" : this.onScrollDown(event); break;
- case "onscrollup" : this.onScrollUp(event); break;
- case "onscrollpagedown" : this.onScrollPageDown(event); break;
- case "onscrollpageup" : this.onScrollPageUp(event); break;
- case "onscrollpos" : this.onScrollPos(event); break;
- case "onscrolltrack" : this.onScrollTrack(event); break;
- case "onscrolltrackdown": this.onScrollTrackDown(event);break;
- case "onscrolltrackup" : this.onScrollTrackUp(event); break;
- case "onscroll" : this.onScroll(event); break;
- case "onmousewheel" : this.onMouseWheel(event); break;
- case "ontimer" : this.onTimer(event); break;
- case "onnext" : this.onNext(event); break;
- case "onprevious" : this.onPrevious(event); break;
- case "xforms-invalid" : this.onInvalid(event); break;
- case "xforms-optional" : this.onOptional(event); break;
- case "xforms-readonly" : this.onReadonly(event); break;
- case "xforms-readwrite" : this.onReadWrite(event); break;
- case "xforms-required" : this.onRequired(event); break;
- case "xforms-valid" : this.onvalid(event); break;
- case "xforms-enabled" : this.onEnabled(event); break;
- case "xforms-disabled" : this.onDisabled(event); break;
-
- case "ondragenter" : this.onDragEnter(event); break;
- case "ondragleave" : this.onDragLeave(event); break;
- case "ondrop" : this.onDrop(event); break;
- case "ondragover" : this.onDragOver(event); break;
- case "ondragstart" : this.onDragStart(event); break;
-
- case "onscrollmax" : this.onScrollMax(event); break;
- case "onscrollmin" : this.onScrollMin(event); break;
- }
- };
- XFormsControl.prototype.getClientLeft = function (bCalcScroll)
- {
- var nClientLeft = 0;
- var heOffsetParent = this.m_heControl;
- while (null != heOffsetParent)
- {
- nClientLeft += heOffsetParent.offsetLeft;
- if (heOffsetParent != this.m_heControl )
- {
- nClientLeft += heOffsetParent.clientLeft;
- }
- if (bCalcScroll && heOffsetParent != document.body)
- {
- nClientLeft -= (is_android ? 0 : heOffsetParent.scrollLeft);
- }
-
- heOffsetParent = heOffsetParent.offsetParent;
- }
- return nClientLeft;
- };
- XFormsControl.prototype.getClientTop = function (bCalcScroll)
- {
- var nClientTop = 0;
- var heOffsetParent = this.m_heControl;
- while (null != heOffsetParent)
- {
- nClientTop += heOffsetParent.offsetTop;
-
- if (heOffsetParent != this.m_heControl)
- {
- nClientTop += heOffsetParent.clientTop;
- }
- if (bCalcScroll&& heOffsetParent != document.body)
- {
- nClientTop -= (is_android ? 0 : heOffsetParent.scrollTop);
- }
- heOffsetParent = heOffsetParent.offsetParent;
- }
- return nClientTop;
- };
- XFormsControl.prototype.preTranslateEvent = function (event)
- {
- var nScrolledTargetX = event.targetX;
- var nScrolledTargetY = event.targetY;
- var heOffsetParent = null;
- var clAllItem = document.allElement;
- if (null != clAllItem.item(event.target))
- {
- //컨트롤의 존재 유무를 제어한다.
- heOffsetParent = clAllItem.item(event.target).m_heControl;
- }
-
- var strParentId = null != heOffsetParent ? heOffsetParent.getAttribute("id") : null;
- if (strParentId)
- {
- strParentId = strParentId.replace("HE_", "");
- }
-
- while (null != heOffsetParent && strParentId != event.currentTarget)
- {
- nScrolledTargetX += heOffsetParent.offsetLeft;
- nScrolledTargetY += heOffsetParent.offsetTop;
-
- if (strParentId != event.target)
- {
- nScrolledTargetX = nScrolledTargetX + heOffsetParent.clientLeft - heOffsetParent.scrollLeft;
- nScrolledTargetY = nScrolledTargetY + heOffsetParent.clientLeft - heOffsetParent.scrollTop;
- }
-
- heOffsetParent = heOffsetParent.offsetParent;
- if (heOffsetParent)
- {
- strParentId = heOffsetParent.getAttribute("id");
- if (strParentId)
- {
- strParentId = strParentId.replace("HE_", "");
- }
- }
- }
-
- if (null != heOffsetParent && event.target != event.currentTarget)
- {
- nScrolledTargetX -= heOffsetParent.scrollLeft;
- nScrolledTargetY -= heOffsetParent.scrollTop;
- }
-
- event.x = nScrolledTargetX;
- event.y = nScrolledTargetY;
- };
- /**
- * jquery Effects hide()
- */
- XFormsControl.prototype.hide = function ()
- {
- var arArg = arguments;
- switch (arArg.length)
- {
- case 1:
- {
- $(this.m_heControl).hide(arArg[0]);
- break;
- }
- case 2:
- {
- $(this.m_heControl).hide(arArg[0] ,arArg[1]);
- break;
- }
- case 3:
- {
- $(this.m_heControl).hide(arArg[0], arArg[1], arArg[2]);
- break;
- }
- default:
- {
- $(this.m_heControl).hide();
- break;
- }
- }
- };
- /**
- * jquery Effects show()
- */
- XFormsControl.prototype.show = function ()
- {
- var arArg = arguments;
- switch (arArg.length)
- {
- case 1:
- {
- $(this.m_heControl).show(arArg[0]);
- break;
- }
- case 2:
- {
- $(this.m_heControl).show(arArg[0] ,arArg[1]);
- break;
- }
- case 3:
- {
- $(this.m_heControl).show(arArg[0], arArg[1], arArg[2]);
- break;
- }
- default:
- {
- $(this.m_heControl).show();
- break;
- }
- }
- };
- /**
- * jquery Effects animate()
- */
- XFormsControl.prototype.animate = function ()
- {
- var arArg = arguments;
- switch (arArg.length)
- {
- case 1:
- {
- $(this.m_heControl).animate(arArg[0]);
- break;
- }
- case 2:
- {
- $(this.m_heControl).animate(arArg[0] ,arArg[1]);
- break;
- }
- case 3:
- {
- $(this.m_heControl).animate(arArg[0], arArg[1], arArg[2]);
- break;
- }
- case 4:
- {
- $(this.m_heControl).animate(arArg[0], arArg[1], arArg[2], arArg[3]);
- break;
- }
- default:
- {
- $(this.m_heControl).animate();
- break;
- }
- }
- };
- XFormsControl.createAttribute = function (xnHtmlNode, clAttribute)
- {
- for (var strKey in clAttribute.m_htCollection)
- {
- if (strKey == "id")
- {
- xnHtmlNode.setAttribute("id", "HE_" + clAttribute.item("id"));
- }
- else if (strKey == "disabled")
- {
- continue;
- }
- else if (strKey == "clsid")
- {
- xnHtmlNode.setAttribute("CLASSID", "clsid:" + clAttribute.item("clsid"));
- }
- else
- {
- if (STYLE_LIST[strKey])
- {
- HtmlLib.setStyle(xnHtmlNode, strKey, clAttribute.item(strKey));
- }
- else
- {
- xnHtmlNode.setAttribute(strKey, clAttribute.item(strKey));
- }
- }
- }
- xnHtmlNode.style.position = "absolute";
-
- xnHtmlNode = XFormsElement.createAttribute(xnHtmlNode, clAttribute);
- return xnHtmlNode;
- };
|